all files / button-group/ button-group.js

97.3% Statements 36/37
92% Branches 23/25
100% Functions 2/2
97.22% Lines 35/36
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   11× 11× 11× 11× 11× 11× 11×   11× 11× 11× 11× 11× 11× 32× 32× 32× 31× 20×     11× 11× 11×       11×   11×     11×   31×   31×     11×      
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-buttons"], function (require, exports, ej2_base_1, ej2_buttons_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    function createButtonGroup(selector, options, createElement) {
        if (options === void 0) { options = {}; }
        var child;
        var btnElem;
        var nextChild;
        var btnModel;
        Eif (ej2_base_1.isNullOrUndefined(createElement)) {
            createElement = ej2_base_1.createElement;
        }
        var wrapper = document.querySelector(selector);
        ej2_base_1.addClass([wrapper], ['e-btn-group', 'e-css']);
        wrapper.setAttribute('role', 'group');
        var childs = wrapper.children;
        options.buttons = options.buttons || [];
        for (var i = 0, j = 0; j < childs.length; i++, j++) {
            child = childs[j];
            btnModel = options.buttons[i];
            if (btnModel !== null) {
                if (child.tagName === 'BUTTON') {
                    btnElem = child;
                }
                else {
                    btnElem = createElement('label');
                    nextChild = childs[j + 1];
                    if (nextChild) {
                        wrapper.insertBefore(btnElem, nextChild);
                    }
                    else {
                        wrapper.appendChild(btnElem);
                    }
                    if (child.id) {
                        btnElem.setAttribute('for', child.id);
                    }
                    Iif (btnModel && btnModel.disabled) {
                        child.disabled = true;
                    }
                    j++;
                }
                if (options.cssClass && btnModel && !btnModel.cssClass) {
                    btnModel.cssClass = options.cssClass;
                }
                new ej2_buttons_1.Button(btnModel || {}, btnElem);
            }
        }
        return wrapper;
    }
    exports.createButtonGroup = createButtonGroup;
});