all files / common/ common.js

90.74% Statements 98/108
86.67% Branches 78/90
93.75% Functions 15/16
90.1% Lines 91/101
18 statements, 7 functions, 29 branches Ignored     
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              56× 56× 62× 62× 27×     56×   12× 12× 12× 12× 12×     12× 78× 10× 10× 10× 10×       10×       12× 12× 12× 11× 11×     20× 20× 14×     12×           20× 20×     19×   31× 31×               31×     31× 31×     31×     31× 31× 31× 31×       31×   31×   31× 67×       67×       248×                                
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/* istanbul ignore next */ 
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
define(["require", "exports", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    function getModel(props, model) {
        var obj = ej2_base_1.extend({}, props);
        for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {
            var prop = _a[_i];
            if ((model).indexOf(prop) < 0) {
                ej2_base_1.deleteObject(obj, prop);
            }
        }
        return obj;
    }
    exports.getModel = getModel;
    function upDownKeyHandler(ul, keyCode) {
        var defaultIdx = keyCode === 40 ? 0 : ul.childElementCount - 1;
        var liIdx = defaultIdx;
        var li;
        var selectedLi = ul.querySelector('.e-selected');
        Iif (selectedLi) {
            selectedLi.classList.remove('e-selected');
        }
        for (var i = 0, len = ul.children.length; i < len; i++) {
            if (ul.children[i].classList.contains('e-focused')) {
                li = ul.children[i];
                liIdx = i;
                li.classList.remove('e-focused');
                if (keyCode === 40) {
                    liIdx++;
                }
                else {
                    liIdx--;
                }
                if (liIdx === (keyCode === 40 ? ul.childElementCount : -1)) {
                    liIdx = defaultIdx;
                }
            }
        }
        li = ul.children[liIdx];
        liIdx = isValidLI(ul, li, liIdx, keyCode);
        if (liIdx !== -1) {
            ej2_base_1.addClass([ul.children[liIdx]], 'e-focused');
            ul.children[liIdx].focus();
        }
    }
    exports.upDownKeyHandler = upDownKeyHandler;
    function isValidLI(ul, li, index, keyCode, count) {
        if (count === void 0) { count = 0; }
        if (li.classList.contains('e-separator') || li.classList.contains('e-disabled')) {
            if (index === (keyCode === 40 ? ul.childElementCount - 1 : 0)) {
                index = keyCode === 40 ? 0 : ul.childElementCount - 1;
            }
            else {
                if (keyCode === 40) {
                    index++;
                }
                else {
                    index--;
                }
            }
        }
        li = ul.children[index];
        if (li.classList.contains('e-separator') || li.classList.contains('e-disabled')) {
            count++;
            if (count === ul.childElementCount) {
                return index = -1;
            }
            index = isValidLI(ul, li, index, keyCode, count);
        }
        return index;
    }
    function setBlankIconStyle(popup, blankIcon) {
        var blankIconList = [].slice.call(popup.getElementsByClassName('e-blank-icon'));
        Iif (blankIcon) {
            var menuItem = [].slice.call(popup.getElementsByClassName('e-item'));
            menuItem.forEach(function (li) {
                if (li.style.paddingLeft || li.style.paddingRight) {
                    li.removeAttribute('style');
                }
            });
        }
        Iif (!blankIconList.length) {
            return;
        }
        var iconLi = popup.querySelector('.e-item:not(.e-blank-icon):not(.e-separator)');
        Iif (ej2_base_1.isNullOrUndefined(iconLi)) {
            return;
        }
        Iif (iconLi.classList.contains('e-url')) {
            iconLi = iconLi.querySelector('.e-menu-url');
        }
        var icon = iconLi.querySelector('.e-menu-icon');
        var cssProp;
        var enableRtl = popup.classList.contains('e-rtl');
        Iif (enableRtl) {
            cssProp = { padding: 'paddingRight', margin: 'marginLeft' };
        }
        else {
            cssProp = { padding: 'paddingLeft', margin: 'marginRight' };
        }
        var size = parseInt(getComputedStyle(icon).fontSize, 10) + parseInt((enableRtl ? getComputedStyle(icon)[cssProp.margin] : getComputedStyle(icon)[cssProp.margin]), 10)
            + parseInt(getComputedStyle(iconLi).paddingLeft, 10) + "px";
        blankIconList.forEach(function (li) {
            Iif (li.classList.contains('e-url')) {
                li.querySelector('.e-menu-url').style[cssProp.padding] = size;
            }
            else {
                li.style[cssProp.padding] = size;
            }
        });
    }
    exports.setBlankIconStyle = setBlankIconStyle;
    var Item = (function (_super) {
        __extends(Item, _super);
        function Item() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        __decorate([
            ej2_base_1.Property('')
        ], Item.prototype, "iconCss", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], Item.prototype, "id", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], Item.prototype, "separator", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], Item.prototype, "text", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], Item.prototype, "url", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], Item.prototype, "disabled", void 0);
        return Item;
    }(ej2_base_1.ChildProperty));
    exports.Item = Item;
});