all files / items/ ribbon-combobox.js

96.08% Statements 98/102
87.5% Branches 49/56
100% Functions 21/21
96.04% Lines 97/101
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 1871×   1× 1× 1× 711×   1× 8683×   1× 371×   1× 193× 193×     193× 193× 193× 193×       193×                                                           6× 6× 2×   4× 4× 4× 1×     6×             6× 2×                 1× 120× 120× 120× 1×         1×   120× 120× 120× 120× 8× 8× 6×   2× 2× 2×       8×       120× 120× 6× 6× 3×   6× 5× 4×         1× 37× 37× 37× 1× 1× 1×     37× 37× 37× 78× 37× 37× 2× 1×       1× 7× 7×   1× 1×   1× 2× 2× 1×   1×   1× 4× 4× 1×   3×   1× 6× 6× 1×   5× 5× 5× 1×   4× 2×   4× 4× 4×   1×   1×    
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-dropdowns", "../base/index"], function (require, exports, ej2_base_1, ej2_dropdowns_1, index_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var RibbonComboBox = (function () {
        function RibbonComboBox(parent) {
            this.parent = parent;
        }
        RibbonComboBox.prototype.getModuleName = function () {
            return 'ribbonComboBox';
        };
        RibbonComboBox.prototype.destroy = function () {
            this.parent = null;
        };
        RibbonComboBox.prototype.createComboBox = function (item, itemEle) {
            var _this = this;
            var inputEle = this.parent.createElement('input', {
                id: item.id
            });
            itemEle.appendChild(inputEle);
            var comboBoxSettings = item.comboBoxSettings;
            Eif (comboBoxSettings.htmlAttributes) {
                Iif (comboBoxSettings.htmlAttributes.id) {
                    delete comboBoxSettings.htmlAttributes.id;
                }
            }
            new ej2_dropdowns_1.ComboBox({
                locale: this.parent.locale,
                enableRtl: this.parent.enableRtl,
                enablePersistence: this.parent.enablePersistence,
                allowCustom: false,
                floatLabelType: 'Never',
                ignoreAccent: true,
                ignoreCase: true,
                allowFiltering: comboBoxSettings.allowFiltering,
                autofill: comboBoxSettings.autofill,
                cssClass: (index_1.RIBBON_CONTROL + index_1.SPACE + (comboBoxSettings.cssClass ? comboBoxSettings.cssClass : '')).trim(),
                dataSource: comboBoxSettings.dataSource,
                enabled: !item.disabled,
                fields: comboBoxSettings.fields,
                filterType: comboBoxSettings.filterType,
                footerTemplate: comboBoxSettings.footerTemplate,
                groupTemplate: comboBoxSettings.groupTemplate,
                headerTemplate: comboBoxSettings.headerTemplate,
                index: comboBoxSettings.index,
                itemTemplate: comboBoxSettings.itemTemplate,
                noRecordsTemplate: comboBoxSettings.noRecordsTemplate,
                placeholder: comboBoxSettings.placeholder,
                popupHeight: comboBoxSettings.popupHeight,
                popupWidth: comboBoxSettings.popupWidth,
                showClearButton: comboBoxSettings.showClearButton,
                sortOrder: comboBoxSettings.sortOrder,
                text: comboBoxSettings.text,
                value: comboBoxSettings.value,
                width: comboBoxSettings.width,
                beforeOpen: function (e) {
                    requestAnimationFrame(function () {
                        if (!_this.parent) {
                            return;
                        }
                        var target = _this.parent.getAppendToElement();
                        var popupEle = document.getElementById(inputEle.id + '_popup');
                        if (popupEle && !target.contains(popupEle)) {
                            target.appendChild(popupEle);
                        }
                    });
                    Iif (comboBoxSettings.beforeOpen) {
                        comboBoxSettings.beforeOpen.call(_this, e);
                    }
                },
                open: comboBoxSettings.open,
                htmlAttributes: comboBoxSettings.htmlAttributes,
                close: function (e) {
                    if (comboBoxSettings.close) {
                        comboBoxSettings.close.call(_this, e);
                    }
                },
                filtering: comboBoxSettings.filtering,
                change: comboBoxSettings.change,
                select: comboBoxSettings.select,
                created: comboBoxSettings.created
            }, inputEle);
        };
        RibbonComboBox.prototype.addOverFlowEvents = function (item, itemEle, overflowButton) {
            var _this = this;
            var comboBoxSettings = item.comboBoxSettings;
            if (comboBoxSettings.label && this.parent.activeLayout === 'Simplified') {
                var label = this.parent.createElement('div', {
                    className: 'e-ribbon-combobox-label',
                    id: item.id + '_label',
                    innerHTML: comboBoxSettings.label
                });
                itemEle.insertBefore(label, itemEle.firstChild);
            }
            var inputEle = itemEle.querySelector('#' + item.id);
            inputEle.setAttribute('data-control', item.type.toString());
            var comboBoxObj = ej2_base_1.getComponent(inputEle, ej2_dropdowns_1.ComboBox);
            comboBoxObj.beforeOpen = function (e) {
                requestAnimationFrame(function () {
                    if (!_this.parent) {
                        return;
                    }
                    var target = _this.parent.getAppendToElement();
                    var popupEle = document.getElementById(item.id + '_popup');
                    Iif (popupEle && !target.contains(popupEle)) {
                        target.appendChild(popupEle);
                    }
                });
                Iif (item.comboBoxSettings.beforeOpen) {
                    item.comboBoxSettings.beforeOpen.call(_this, e);
                }
            };
            comboBoxObj.setProperties({ cssClass: comboBoxObj.cssClass + index_1.SPACE + index_1.RIBBON_POPUP_CONTROL });
            comboBoxObj.close = function (e) {
                var target = e.event ? e.event.target : null;
                if (item.comboBoxSettings.close) {
                    item.comboBoxSettings.close.call(_this, e);
                }
                if (target && !target.closest('.e-ribbon-group-overflow-ddb')) {
                    if (overflowButton.element.classList.contains('e-active')) {
                        overflowButton.toggle();
                    }
                }
            };
        };
        RibbonComboBox.prototype.removeOverFlowEvents = function (item, itemEle) {
            var _this = this;
            var comboBoxSettings = item.comboBoxSettings;
            if (comboBoxSettings.label) {
                var label = itemEle.querySelector('#' + item.id + '_label');
                Eif (label) {
                    label.remove();
                }
            }
            var inputEle = itemEle.querySelector('#' + item.id);
            var comboBoxObj = ej2_base_1.getComponent(inputEle, ej2_dropdowns_1.ComboBox);
            var cssClass = comboBoxObj.cssClass.split(index_1.SPACE);
            cssClass = cssClass.filter(function (value) { return value !== index_1.RIBBON_POPUP_CONTROL; });
            comboBoxObj.setProperties({ cssClass: cssClass.join(index_1.SPACE) });
            comboBoxObj.close = function (e) {
                if (item.comboBoxSettings.close) {
                    item.comboBoxSettings.close.call(_this, e);
                }
            };
        };
        RibbonComboBox.prototype.getComboBoxObj = function (controlId) {
            var inputEle = index_1.getItemElement(this.parent, controlId);
            return inputEle ? ej2_base_1.getComponent(inputEle, ej2_dropdowns_1.ComboBox) : null;
        };
        RibbonComboBox.prototype.filter = function (controlId, dataSource, query, fields) {
            this.getComboBoxObj(controlId).filter(dataSource, query, fields);
        };
        RibbonComboBox.prototype.hidePopup = function (controlId) {
            var comboBoxObj = this.getComboBoxObj(controlId);
            if (!comboBoxObj) {
                return;
            }
            comboBoxObj.hidePopup();
        };
        RibbonComboBox.prototype.showPopup = function (controlId) {
            var comboBoxObj = this.getComboBoxObj(controlId);
            if (!comboBoxObj) {
                return;
            }
            comboBoxObj.showPopup();
        };
        RibbonComboBox.prototype.updateComboBox = function (prop, id) {
            var itemProp = index_1.getItem(this.parent.tabs, id);
            if (!itemProp) {
                return;
            }
            ej2_base_1.merge(itemProp.item.comboBoxSettings, prop);
            var inputEle = index_1.getItemElement(this.parent, id, itemProp);
            if (!inputEle) {
                return;
            }
            if (prop.cssClass) {
                prop.cssClass = (index_1.RIBBON_CONTROL + index_1.SPACE + prop.cssClass).trim();
            }
            delete prop.close;
            var comboBoxObj = ej2_base_1.getComponent(inputEle, ej2_dropdowns_1.ComboBox);
            comboBoxObj.setProperties(prop);
        };
        return RibbonComboBox;
    }());
    exports.RibbonComboBox = RibbonComboBox;
});