all files / modules/ ribbon-contextualtab.js

100% Statements 51/51
95.45% Branches 21/22
100% Functions 9/9
100% Lines 51/51
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   12×   8338×                                                    
define(["require", "exports", "../base/constant", "@syncfusion/ej2-base"], function (require, exports, constants, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var RibbonContextualTab = (function () {
        function RibbonContextualTab(parent) {
            this.parent = parent;
        }
        RibbonContextualTab.prototype.getModuleName = function () {
            return 'ribbonContextualTab';
        };
        RibbonContextualTab.prototype.destroy = function () {
            this.parent = null;
        };
        RibbonContextualTab.prototype.addContextualTabs = function () {
            var isSelected = false;
            for (var n = 0; n < this.parent.contextualTabs.length; n++) {
                for (var i = 0; i < this.parent.contextualTabs[parseInt(n.toString(), 10)].tabs.length; i++) {
                    this.parent.addTab(this.parent.contextualTabs[parseInt(n.toString(), 10)].tabs[parseInt(i.toString(), 10)]);
                    var index = this.parent.tabs.length - 1;
                    var tabEle = this.parent.tabObj.element;
                    var toolbarEle = tabEle.querySelectorAll('.e-toolbar-item')[parseInt(index.toString(), 10)];
                    toolbarEle.classList.add(constants.RIBBON_CONTEXTUAL_TAB);
                    toolbarEle.classList.add('e-hidden');
                    if (this.parent.contextualTabs[parseInt(n.toString(), 10)].visible) {
                        this.parent.showTab(this.parent.contextualTabs[parseInt(n.toString(), 10)].tabs[parseInt(i.toString(), 10)].id, true);
                        if (this.parent.contextualTabs[parseInt(n.toString(), 10)].isSelected && !isSelected) {
                            this.parent.selectTab(this.parent.contextualTabs[parseInt(n.toString(), 10)].tabs[0].id);
                            isSelected = true;
                        }
                    }
                }
            }
        };
        RibbonContextualTab.prototype.updateContextualTabs = function (newProp, contextualTab) {
            if (!(ej2_base_1.isNullOrUndefined(newProp.visible))) {
                for (var i = 0; i < contextualTab.tabs.length; i++) {
                    if (newProp.visible) {
                        this.parent.showTab(contextualTab.tabs[parseInt(i.toString(), 10)].id, true);
                    }
                    else {
                        this.parent.hideTab(contextualTab.tabs[parseInt(i.toString(), 10)].id, true);
                    }
                }
            }
            if (!(ej2_base_1.isNullOrUndefined(newProp.isSelected))) {
                if (newProp.isSelected && contextualTab.visible) {
                    this.parent.selectTab(contextualTab.tabs[0].id);
                }
                else {
                    var tabEle = this.parent.tabObj.element;
                    for (var i = 0; i < this.parent.tabs.length; i++) {
                        var toolbarEle = tabEle.querySelectorAll('.e-toolbar-item')[parseInt(i.toString(), 10)];
                        Eif (!(toolbarEle.classList.contains('e-hidden') || toolbarEle.classList.contains('e-disable'))) {
                            this.parent.selectTab(this.parent.tabs[parseInt(i.toString(), 10)].id);
                            break;
                        }
                    }
                }
            }
            if (newProp.tabs) {
                var _loop_1 = function (key) {
                    var index = parseInt(key, 10);
                    var tab = this_1.parent.tabs.filter(function (e) {
                        return e.id === contextualTab.tabs[parseInt(index.toString(), 10)].id;
                    })[0];
                    this_1.parent.updateTab(tab);
                };
                var this_1 = this;
                for (var _i = 0, _a = Object.keys(newProp.tabs); _i < _a.length; _i++) {
                    var key = _a[_i];
                    _loop_1(key);
                }
            }
        };
        return RibbonContextualTab;
    }());
    exports.RibbonContextualTab = RibbonContextualTab;
});