all files / appbar/ appbar.js

99.25% Statements 132/133
98.75% Branches 79/80
94.74% Functions 18/19
99.21% Lines 126/127
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 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 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208  1× 1× 1× 1× 1× 1×   1× 1× 1× 1×       1× 1× 1× 1× 1×   1×   1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 30×   1× 30× 30× 30× 30×   1× 150×   1×     1×   1× 30× 30× 9×   30× 2×   30× 2×   30× 2×   30× 2×   30× 30× 30× 2×     1× 34× 34× 34×   5× 5× 5×   4× 1×     3×   4×   3× 1×   3× 1×   3×   4× 1×     3×   4×   6× 4× 3× 3× 3× 3× 2×     1×       4×   6×   6× 6× 6×   4× 1×     3×   4×       1× 6× 6× 6× 6× 3×     3×       1× 35× 2×   33× 2×     1× 36×   28× 28×   2× 2×   2× 2×   2× 2×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×   1×    
/* 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", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1, ej2_base_2) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var CLS_APPBAR = 'e-appbar';
    var CLS_HORIZONTAL_BOTTOM = 'e-horizontal-bottom';
    var CLS_STICKY = 'e-sticky';
    var CLS_PROMINENT = 'e-prominent';
    var CLS_DENSE = 'e-dense';
    var CLS_RTL = 'e-rtl';
    var CLS_LIGHT = 'e-light';
    var CLS_DARK = 'e-dark';
    var CLS_PRIMARY = 'e-primary';
    var CLS_INHERIT = 'e-inherit';
    var AppBar = (function (_super) {
        __extends(AppBar, _super);
        function AppBar(options, element) {
            return _super.call(this, options, element) || this;
        }
        AppBar.prototype.destroy = function () {
            _super.prototype.destroy.call(this);
            this.element.classList.remove(CLS_APPBAR);
            this.element.removeAttribute('style');
            this.element.removeAttribute('role');
        };
        AppBar.prototype.getModuleName = function () {
            return 'appbar';
        };
        AppBar.prototype.getPersistData = function () {
            return this.addOnPersist([]);
        };
        AppBar.prototype.preRender = function () {
        };
        AppBar.prototype.render = function () {
            this.element.classList.add(CLS_APPBAR);
            if (this.element.tagName !== 'HEADER') {
                this.element.setAttribute('role', 'banner');
            }
            if (this.cssClass) {
                ej2_base_2.addClass([this.element], this.cssClass.split(' '));
            }
            if (this.position === 'Bottom') {
                this.element.classList.add(CLS_HORIZONTAL_BOTTOM);
            }
            if (this.isSticky) {
                this.element.classList.add(CLS_STICKY);
            }
            if (this.enableRtl) {
                this.element.classList.add(CLS_RTL);
            }
            this.setHeightMode();
            this.setColorMode();
            if (!ej2_base_2.isNullOrUndefined(this.htmlAttributes)) {
                this.setHtmlAttributes(this.htmlAttributes, this.element);
            }
        };
        AppBar.prototype.onPropertyChanged = function (newProp, oldProp) {
            for (var _i = 0, _a = Object.keys(newProp); _i < _a.length; _i++) {
                var prop = _a[_i];
                switch (prop) {
                    case 'mode':
                        ej2_base_2.removeClass([this.element], [CLS_DENSE, CLS_PROMINENT]);
                        this.setHeightMode();
                        break;
                    case 'position':
                        if (this.position === 'Bottom') {
                            ej2_base_2.addClass([this.element], CLS_HORIZONTAL_BOTTOM);
                        }
                        else {
                            ej2_base_2.removeClass([this.element], CLS_HORIZONTAL_BOTTOM);
                        }
                        break;
                    case 'cssClass':
                        if (oldProp.cssClass) {
                            ej2_base_2.removeClass([this.element], oldProp.cssClass.split(' '));
                        }
                        if (newProp.cssClass) {
                            ej2_base_2.addClass([this.element], newProp.cssClass.split(' '));
                        }
                        break;
                    case 'isSticky':
                        if (this.isSticky) {
                            ej2_base_2.addClass([this.element], CLS_STICKY);
                        }
                        else {
                            ej2_base_2.removeClass([this.element], CLS_STICKY);
                        }
                        break;
                    case 'htmlAttributes':
                        if (!ej2_base_2.isNullOrUndefined(this.htmlAttributes)) {
                            if (!ej2_base_2.isNullOrUndefined(oldProp.htmlAttributes)) {
                                var keys = Object.keys(oldProp.htmlAttributes);
                                for (var _b = 0, keys_1 = keys; _b < keys_1.length; _b++) {
                                    var key = keys_1[_b];
                                    if (key === 'class') {
                                        ej2_base_2.removeClass([this.element], oldProp.htmlAttributes["" + key]);
                                    }
                                    else {
                                        this.element.removeAttribute(key);
                                    }
                                }
                            }
                            this.setHtmlAttributes(newProp.htmlAttributes, this.element);
                        }
                        break;
                    case 'colorMode':
                        ej2_base_2.removeClass([this.element], [CLS_DARK, CLS_PRIMARY, CLS_INHERIT, CLS_LIGHT]);
                        this.setColorMode();
                        break;
                    case 'enableRtl':
                        if (this.enableRtl) {
                            ej2_base_2.addClass([this.element], CLS_RTL);
                        }
                        else {
                            ej2_base_2.removeClass([this.element], CLS_RTL);
                        }
                        break;
                }
            }
        };
        AppBar.prototype.setHtmlAttributes = function (attribute, element) {
            var keys = Object.keys(attribute);
            for (var _i = 0, keys_2 = keys; _i < keys_2.length; _i++) {
                var key = keys_2[_i];
                if (key === 'class') {
                    ej2_base_2.addClass([element], attribute["" + key]);
                }
                else {
                    element.setAttribute(key, attribute["" + key]);
                }
            }
        };
        AppBar.prototype.setHeightMode = function () {
            if (this.mode === 'Prominent') {
                this.element.classList.add(CLS_PROMINENT);
            }
            else if (this.mode === 'Dense') {
                this.element.classList.add(CLS_DENSE);
            }
        };
        AppBar.prototype.setColorMode = function () {
            switch (this.colorMode) {
                case 'Light':
                    this.element.classList.add(CLS_LIGHT);
                    break;
                case 'Dark':
                    this.element.classList.add(CLS_DARK);
                    break;
                case 'Primary':
                    this.element.classList.add(CLS_PRIMARY);
                    break;
                case 'Inherit':
                    this.element.classList.add(CLS_INHERIT);
                    break;
            }
        };
        __decorate([
            ej2_base_1.Property('Regular')
        ], AppBar.prototype, "mode", void 0);
        __decorate([
            ej2_base_1.Property('Top')
        ], AppBar.prototype, "position", void 0);
        __decorate([
            ej2_base_1.Property()
        ], AppBar.prototype, "cssClass", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], AppBar.prototype, "isSticky", void 0);
        __decorate([
            ej2_base_1.Property()
        ], AppBar.prototype, "htmlAttributes", void 0);
        __decorate([
            ej2_base_1.Property('Light')
        ], AppBar.prototype, "colorMode", void 0);
        __decorate([
            ej2_base_1.Event()
        ], AppBar.prototype, "created", void 0);
        __decorate([
            ej2_base_1.Event()
        ], AppBar.prototype, "destroyed", void 0);
        AppBar = __decorate([
            ej2_base_1.NotifyPropertyChanges
        ], AppBar);
        return AppBar;
    }(ej2_base_1.Component));
    exports.AppBar = AppBar;
});