all files / sidebar/ sidebar.js

98.17% Statements 430/438
93.16% Branches 354/380
100% Functions 48/48
98.14% Lines 423/431
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 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679              201× 201× 201×   205×   205× 205× 205×   205× 205× 205× 205× 46×   205× 95× 95×     110×   205× 205× 205× 205× 205× 37×     207×   205× 205× 205×   205×           206×     202× 202×     206× 42×   164×   160× 160×     302× 57×   245× 244×       302×   631×   216×   216× 216× 215×   216× 216× 89×   216× 216× 216× 216× 46×   216×   216× 79×   137× 119×     216× 98×     118×             312× 312×   310×     107× 107×             107× 55× 55×   52×     52× 52× 52× 52× 52× 52× 43× 43×   52× 52× 52×   52× 52×   52×       13× 13× 13×         11× 10×           262× 262×             262× 262× 262× 262× 97×   165×   165× 165× 165× 165× 165× 165× 165× 165× 20×   165× 165×       218× 216×           56× 37×   19×   56× 32×     362×   361×       789×           83×   112×                                   57×     57×   14×     13×           206× 204× 204×           205× 205×   260× 260× 260× 259×   260× 259×     30× 30× 30× 30× 30×                     11× 11× 11× 11×   11×                                               425× 425× 425× 425× 423× 423× 190×     425× 425× 425× 425×   136× 136× 72×   136×   57× 57× 34×   57×   36× 36×     36×   196× 196× 25×     20×       171× 171× 157×     196×     260× 260× 10×   260× 260× 260× 260× 260× 260× 260× 260×     256×     260× 260× 260× 259× 259×   260×                                                                                                    
/* 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", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1, ej2_base_2, ej2_base_3) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var CONTROL = 'e-control';
    var ROOT = 'e-sidebar';
    var DOCKER = 'e-dock';
    var CLOSE = 'e-close';
    var OPEN = 'e-open';
    var TRASITION = 'e-transition';
    var DEFAULTBACKDROP = 'e-sidebar-overlay';
    var RTL = 'e-rtl';
    var RIGHT = 'e-right';
    var LEFT = 'e-left';
    var OVER = 'e-over';
    var PUSH = 'e-push';
    var SLIDE = 'e-slide';
    var VISIBILITY = 'e-visibility';
    var DISPLAY = 'e-sidebar-display';
    var MAINCONTENTANIMATION = 'e-content-animation';
    var DISABLEANIMATION = 'e-disable-animation';
    var CONTEXT = 'e-sidebar-context';
    var SIDEBARABSOLUTE = 'e-sidebar-absolute';
    var Sidebar = (function (_super) {
        __extends(Sidebar, _super);
        function Sidebar(options, element) {
            var _this = _super.call(this, options, element) || this;
            _this.documentClickContext = _this.documentclickHandler.bind(_this);
            return _this;
        }
        Sidebar.prototype.preRender = function () {
            this.setWidth();
        };
        Sidebar.prototype.render = function () {
            this.initialize();
            this.wireEvents();
            this.renderComplete();
        };
        Sidebar.prototype.initialize = function () {
            this.setTarget();
            this.addClass();
            this.setZindex();
            if (this.enableDock) {
                this.setDock();
            }
            if (this.isOpen) {
                this.show();
                this.firstRender = true;
            }
            else {
                this.setMediaQuery();
            }
            this.checkType(true);
            this.setType(this.type);
            this.setCloseOnDocumentClick();
            this.setEnableRTL();
            if (ej2_base_1.Browser.isDevice) {
                this.windowWidth = window.innerWidth;
            }
        };
        Sidebar.prototype.setEnableRTL = function () {
            (this.enableRtl ? ej2_base_3.addClass : ej2_base_3.removeClass)([this.element], RTL);
        };
        Sidebar.prototype.setTarget = function () {
            this.targetEle = this.element.nextElementSibling;
            this.sidebarEleCopy = this.element.cloneNode(true);
            if (typeof (this.target) === 'string') {
                this.setProperties({ target: document.querySelector(this.target) }, true);
            }
            if (this.target) {
                this.target.insertBefore(this.element, this.target.children[0]);
                ej2_base_3.addClass([this.element], SIDEBARABSOLUTE);
                ej2_base_3.addClass([this.target], CONTEXT);
                this.targetEle = this.getTargetElement();
            }
        };
        Sidebar.prototype.getTargetElement = function () {
            var siblingElement = this.element.nextElementSibling;
            while (!ej2_base_2.isNullOrUndefined(siblingElement)) {
                if (!siblingElement.classList.contains(ROOT)) {
                    break;
                }
                siblingElement = siblingElement.nextElementSibling;
            }
            return siblingElement;
        };
        Sidebar.prototype.setCloseOnDocumentClick = function () {
            if (this.closeOnDocumentClick) {
                document.addEventListener('mousedown', this.documentClickContext);
                document.addEventListener('touchstart', this.documentClickContext);
            }
            else {
                document.removeEventListener('mousedown', this.documentClickContext);
                document.removeEventListener('touchstart', this.documentClickContext);
            }
        };
        Sidebar.prototype.setWidth = function () {
            if (this.enableDock && this.position === 'Left') {
                ej2_base_3.setStyleAttribute(this.element, { 'width': this.setDimension(this.dockSize) });
            }
            else if (this.enableDock && this.position === 'Right') {
                ej2_base_3.setStyleAttribute(this.element, { 'width': this.setDimension(this.dockSize) });
            }
            else Eif (!this.enableDock) {
                ej2_base_3.setStyleAttribute(this.element, { 'width': this.setDimension(this.width) });
            }
        };
        Sidebar.prototype.setDimension = function (width) {
            if (typeof width === 'number') {
                width = ej2_base_1.formatUnit(width);
            }
            else if (typeof width === 'string') {
                width = (width.match(/px|%|em/)) ? width : ej2_base_1.formatUnit(width);
            }
            else {
                width = '100%';
            }
            return width;
        };
        Sidebar.prototype.setZindex = function () {
            ej2_base_3.setStyleAttribute(this.element, { 'z-index': '' + this.zIndex });
        };
        Sidebar.prototype.addClass = function () {
            if (this.element.tagName === 'EJS-SIDEBAR') {
                ej2_base_3.addClass([this.element], DISPLAY);
            }
            var classELement = document.querySelector('.e-main-content');
            if (!ej2_base_1.isNullOrUndefined(classELement || this.targetEle)) {
                ej2_base_3.addClass([classELement || this.targetEle], [MAINCONTENTANIMATION]);
            }
            this.tabIndex = this.element.hasAttribute('tabindex') ? this.element.getAttribute('tabindex') : null;
            if (!this.enableDock && this.type !== 'Auto') {
                ej2_base_3.addClass([this.element], [VISIBILITY]);
            }
            ej2_base_3.removeClass([this.element], [OPEN, CLOSE, RIGHT, LEFT, SLIDE, PUSH, OVER]);
            this.element.classList.add(ROOT);
            ej2_base_3.addClass([this.element], (this.position === 'Right') ? RIGHT : LEFT);
            if (this.enableDock) {
                ej2_base_3.addClass([this.element], DOCKER);
            }
            if (!ej2_base_1.isNullOrUndefined(this.tabIndex)) {
                this.element.setAttribute('tabindex', this.tabIndex);
            }
            if (this.type === 'Auto' && !ej2_base_1.Browser.isDevice) {
                this.show();
            }
            else if (!this.isOpen) {
                ej2_base_3.addClass([this.element], [CLOSE, DISABLEANIMATION]);
            }
        };
        Sidebar.prototype.checkType = function (val) {
            if (!(this.type === 'Push' || this.type === 'Over' || this.type === 'Slide')) {
                this.type = 'Auto';
            }
            else {
                if (!this.element.classList.contains(CLOSE) && !val) {
                    this.hide();
                }
            }
        };
        Sidebar.prototype.transitionEnd = function (e) {
            this.setDock();
            Iif (!ej2_base_1.isNullOrUndefined(e) && !this.firstRender) {
                this.triggerChange();
            }
            this.firstRender = false;
            ej2_base_1.EventHandler.remove(this.element, 'transitionend', this.transitionEnd);
        };
        Sidebar.prototype.destroyBackDrop = function () {
            var sibling = document.querySelector('.e-main-content') || this.targetEle;
            if (this.target && this.showBackdrop && sibling && !ej2_base_1.isNullOrUndefined(this.defaultBackdropDiv)) {
                ej2_base_3.removeClass([this.defaultBackdropDiv], DEFAULTBACKDROP);
            }
            else if (this.showBackdrop && this.modal) {
                this.modal.style.display = 'none';
                this.modal.outerHTML = '';
                this.modal = null;
            }
        };
        Sidebar.prototype.hide = function (e) {
            var _this = this;
            var closeArguments = {
                model: this,
                element: this.element,
                cancel: false,
                isInteracted: !ej2_base_1.isNullOrUndefined(e),
                event: (e || null)
            };
            this.trigger('close', closeArguments, function (observedcloseArgs) {
                Eif (!observedcloseArgs.cancel) {
                    if (_this.element.classList.contains(CLOSE)) {
                        return;
                    }
                    Iif (_this.element.classList.contains(OPEN) && !_this.animate) {
                        _this.triggerChange();
                    }
                    ej2_base_3.addClass([_this.element], CLOSE);
                    ej2_base_3.removeClass([_this.element], OPEN);
                    ej2_base_3.setStyleAttribute(_this.element, { 'width': ej2_base_1.formatUnit(_this.enableDock ? _this.dockSize : _this.width) });
                    _this.setType(_this.type);
                    var sibling = document.querySelector('.e-main-content') || _this.targetEle;
                    if (!_this.enableDock && sibling) {
                        sibling.style.transform = 'translateX(' + 0 + 'px)';
                        sibling.style[_this.position === 'Left' ? 'marginLeft' : 'marginRight'] = '0px';
                    }
                    _this.destroyBackDrop();
                    _this.setAnimation();
                    if (_this.type === 'Slide') {
                        document.body.classList.remove('e-sidebar-overflow');
                    }
                    _this.setProperties({ isOpen: false }, true);
                    if (_this.enableDock) {
                        setTimeout(function () { return _this.setTimeOut(); }, 50);
                    }
                    ej2_base_1.EventHandler.add(_this.element, 'transitionend', _this.transitionEnd, _this);
                }
            });
        };
        Sidebar.prototype.setTimeOut = function () {
            var sibling = document.querySelector('.e-main-content') || this.targetEle;
            var elementWidth = this.element.getBoundingClientRect().width;
            if (this.element.classList.contains(OPEN) && sibling && !(this.type === 'Over' && this.enableDock)) {
                if (this.position === 'Left') {
                    sibling.style.marginLeft = this.setDimension(this.width === 'auto' ? elementWidth : this.width);
                }
                else {
                    sibling.style.marginRight = this.setDimension(this.width === 'auto' ? elementWidth : this.width);
                }
            }
            else if (this.element.classList.contains(CLOSE) && sibling) {
                if (this.position === 'Left') {
                    sibling.style.marginLeft = this.setDimension(this.dockSize === 'auto' ? elementWidth : this.dockSize);
                }
                else {
                    sibling.style.marginRight = this.setDimension(this.dockSize === 'auto' ? elementWidth : this.dockSize);
                }
            }
        };
        Sidebar.prototype.show = function (e) {
            var _this = this;
            var openArguments = {
                model: this,
                element: this.element,
                cancel: false,
                isInteracted: !ej2_base_1.isNullOrUndefined(e),
                event: (e || null)
            };
            this.trigger('open', openArguments, function (observedopenArgs) {
                Eif (!observedopenArgs.cancel) {
                    ej2_base_3.removeClass([_this.element], [VISIBILITY, DISABLEANIMATION]);
                    if (_this.element.classList.contains(OPEN)) {
                        return;
                    }
                    if (_this.element.classList.contains(CLOSE) && !_this.animate) {
                        _this.triggerChange();
                    }
                    ej2_base_3.addClass([_this.element], [OPEN, TRASITION]);
                    ej2_base_3.setStyleAttribute(_this.element, { 'transform': '' });
                    ej2_base_3.removeClass([_this.element], CLOSE);
                    ej2_base_3.setStyleAttribute(_this.element, { 'width': ej2_base_1.formatUnit(_this.width) });
                    _this.setType(_this.type);
                    _this.createBackDrop();
                    _this.setAnimation();
                    if (_this.type === 'Slide') {
                        document.body.classList.add('e-sidebar-overflow');
                    }
                    _this.setProperties({ isOpen: true }, true);
                    ej2_base_1.EventHandler.add(_this.element, 'transitionend', _this.transitionEnd, _this);
                }
            });
        };
        Sidebar.prototype.setAnimation = function () {
            if (this.animate) {
                ej2_base_3.removeClass([this.element], DISABLEANIMATION);
            }
            else {
                ej2_base_3.addClass([this.element], DISABLEANIMATION);
            }
        };
        Sidebar.prototype.triggerChange = function () {
            var changeArguments = { name: 'change', element: this.element };
            this.trigger('change', changeArguments);
        };
        Sidebar.prototype.setDock = function () {
            if (this.enableDock && this.position === 'Left' && !this.getState()) {
                ej2_base_3.setStyleAttribute(this.element, { 'transform': 'translateX(' + -100 + '%) translateX(' + this.setDimension(this.dockSize) + ')' });
            }
            else if (this.enableDock && this.position === 'Right' && !this.getState()) {
                ej2_base_3.setStyleAttribute(this.element, { 'transform': 'translateX(' + 100 + '%) translateX(' + '-' + this.setDimension(this.dockSize) + ')' });
            }
            if (this.element.classList.contains(CLOSE) && this.enableDock) {
                ej2_base_3.setStyleAttribute(this.element, { 'width': this.setDimension(this.dockSize) });
            }
        };
        Sidebar.prototype.createBackDrop = function () {
            if (this.target && this.showBackdrop && this.getState()) {
                var targetString = this.target;
                var sibling = document.querySelector('.e-main-content') || this.targetEle;
                this.defaultBackdropDiv = this.createElement('div');
                ej2_base_3.addClass([this.defaultBackdropDiv], DEFAULTBACKDROP);
                ej2_base_3.setStyleAttribute(this.defaultBackdropDiv, { height: targetString.style.height });
                sibling.appendChild(this.defaultBackdropDiv);
            }
            else if (this.showBackdrop && !this.modal && this.getState()) {
                this.modal = this.createElement('div');
                this.modal.className = DEFAULTBACKDROP;
                this.modal.style.display = 'block';
                document.body.appendChild(this.modal);
            }
        };
        Sidebar.prototype.getPersistData = function () {
            return this.addOnPersist(['type', 'position', 'isOpen']);
        };
        Sidebar.prototype.getModuleName = function () {
            return 'sidebar';
        };
        Sidebar.prototype.toggle = function () {
            if (this.element.classList.contains(OPEN)) {
                this.hide();
            }
            else {
                this.show();
            }
        };
        Sidebar.prototype.getState = function () {
            return this.element.classList.contains(OPEN) ? true : false;
        };
        Sidebar.prototype.setMediaQuery = function () {
            if (this.mediaQuery) {
                var media = false;
                if (typeof (this.mediaQuery) === 'string') {
                    media = window.matchMedia(this.mediaQuery).matches;
                }
                else {
                    media = (this.mediaQuery).matches;
                }
                if (media && this.windowWidth !== window.innerWidth) {
                    this.show();
                }
                else Iif (this.getState() && this.windowWidth !== window.innerWidth) {
                    this.hide();
                }
            }
        };
        Sidebar.prototype.resize = function () {
            Iif (!ej2_base_1.isNullOrUndefined(this.width) && this.width !== 'auto' && typeof this.width === 'string' && !this.width.includes('px')) {
                this.setType(this.type);
            }
            Eif (this.type === 'Auto') {
                Eif (ej2_base_1.Browser.isDevice) {
                    ej2_base_3.addClass([this.element], OVER);
                }
                else {
                    ej2_base_3.addClass([this.element], PUSH);
                }
            }
            this.setMediaQuery();
            Eif (ej2_base_1.Browser.isDevice) {
                this.windowWidth = window.innerWidth;
            }
        };
        Sidebar.prototype.documentclickHandler = function (e) {
            Iif (ej2_base_1.closest(e.target, '.' + CONTROL + '' + '.' + ROOT)) {
                return;
            }
            this.hide(e);
        };
        Sidebar.prototype.enableGestureHandler = function (args) {
            if (!this.isOpen && this.position === 'Left' && args.swipeDirection === 'Right' &&
                (args.startX <= 20 && args.distanceX >= 50 && args.velocity >= 0.5)) {
                this.show();
            }
            else if (this.isOpen && this.position === 'Left' && args.swipeDirection === 'Left') {
                this.hide(args.originalEvent);
            }
            else if (this.isOpen && this.position === 'Right' && args.swipeDirection === 'Right') {
                this.hide(args.originalEvent);
            }
            else if (!this.isOpen && this.position === 'Right' && args.swipeDirection === 'Left'
                && (window.innerWidth - args.startX <= 20 && args.distanceX >= 50 && args.velocity >= 0.5)) {
                this.show();
            }
        };
        Sidebar.prototype.setEnableGestures = function () {
            if (this.enableGestures) {
                this.mainContentEle = new ej2_base_3.Touch(document.body, { swipe: this.enableGestureHandler.bind(this) });
                this.sidebarEle = new ej2_base_3.Touch(this.element, { swipe: this.enableGestureHandler.bind(this) });
            }
            else {
                if (this.mainContentEle && this.sidebarEle) {
                    this.mainContentEle.destroy();
                    this.sidebarEle.destroy();
                }
            }
        };
        Sidebar.prototype.wireEvents = function () {
            this.setEnableGestures();
            ej2_base_1.EventHandler.add(window, 'resize', this.resize, this);
        };
        Sidebar.prototype.unWireEvents = function () {
            ej2_base_1.EventHandler.remove(window, 'resize', this.resize);
            ej2_base_1.EventHandler.remove(document, 'mousedown touchstart', this.documentclickHandler);
            if (this.mainContentEle) {
                this.mainContentEle.destroy();
            }
            if (this.sidebarEle) {
                this.sidebarEle.destroy();
            }
        };
        Sidebar.prototype.onPropertyChanged = function (newProp, oldProp) {
            var sibling = document.querySelector('.e-main-content') || this.targetEle;
            var isRendered = this.isServerRendered;
            for (var _i = 0, _a = Object.keys(newProp); _i < _a.length; _i++) {
                var prop = _a[_i];
                switch (prop) {
                    case 'isOpen':
                        Iif (this.isOpen) {
                            this.show();
                        }
                        else {
                            this.hide();
                        }
                        break;
                    case 'width':
                        this.setWidth();
                        Iif (!this.getState()) {
                            this.setDock();
                        }
                        break;
                    case 'animate':
                        this.setAnimation();
                        break;
                    case 'type':
                        this.checkType(false);
                        ej2_base_3.removeClass([this.element], [VISIBILITY]);
                        this.addClass();
                        ej2_base_3.addClass([this.element], this.type === 'Auto' ? (ej2_base_1.Browser.isDevice ? ['e-over'] :
                            ['e-push']) : ['e-' + this.type.toLowerCase()]);
                        break;
                    case 'position':
                        this.element.style.transform = '';
                        this.setDock();
                        Eif (sibling) {
                            sibling.style[this.position === 'Left' ? 'marginRight' : 'marginLeft'] = '0px';
                        }
                        if (this.position === 'Right') {
                            ej2_base_3.removeClass([this.element], LEFT);
                            ej2_base_3.addClass([this.element], RIGHT);
                        }
                        else {
                            ej2_base_3.removeClass([this.element], RIGHT);
                            ej2_base_3.addClass([this.element], LEFT);
                        }
                        this.setType(this.type);
                        break;
                    case 'showBackdrop':
                        if (this.showBackdrop) {
                            this.createBackDrop();
                        }
                        else {
                            Eif (this.modal) {
                                this.modal.style.display = 'none';
                                this.modal.outerHTML = '';
                                this.modal = null;
                            }
                        }
                        break;
                    case 'target':
                        if (typeof (this.target) === 'string') {
                            this.setProperties({ target: document.querySelector(this.target) }, true);
                        }
                        if (ej2_base_1.isNullOrUndefined(this.target)) {
                            ej2_base_3.removeClass([this.element], SIDEBARABSOLUTE);
                            ej2_base_3.removeClass([oldProp.target], CONTEXT);
                            ej2_base_3.setStyleAttribute(sibling, { 'margin-left': 0, 'margin-right': 0 });
                            document.body.insertAdjacentElement('afterbegin', this.element);
                        }
                        this.isServerRendered = false;
                        _super.prototype.refresh.call(this);
                        this.isServerRendered = isRendered;
                        break;
                    case 'closeOnDocumentClick':
                        this.setCloseOnDocumentClick();
                        break;
                    case 'enableDock':
                        Eif (!this.getState()) {
                            this.setDock();
                        }
                        break;
                    case 'zIndex':
                        this.setZindex();
                        break;
                    case 'mediaQuery':
                        this.setMediaQuery();
                        break;
                    case 'enableGestures':
                        this.setEnableGestures();
                        break;
                    case 'enableRtl':
                        this.setEnableRTL();
                        break;
                }
            }
        };
        Sidebar.prototype.setType = function (type) {
            var elementWidth = this.element.getBoundingClientRect().width;
            this.setZindex();
            var sibling = document.querySelector('.e-main-content') || this.targetEle;
            if (sibling) {
                sibling.style.transform = 'translateX(' + 0 + 'px)';
                if (!ej2_base_1.Browser.isDevice && this.type !== 'Auto' && !(this.type === 'Over' && this.enableDock)) {
                    sibling.style[this.position === 'Left' ? 'marginLeft' : 'marginRight'] = '0px';
                }
            }
            var margin = this.position === 'Left' ? elementWidth + 'px' : elementWidth + 'px';
            var eleWidth = this.position === 'Left' ? elementWidth : -(elementWidth);
            ej2_base_3.removeClass([this.element], [PUSH, OVER, SLIDE]);
            switch (type) {
                case 'Push':
                    ej2_base_3.addClass([this.element], [PUSH]);
                    if (sibling && (this.enableDock || this.element.classList.contains(OPEN))) {
                        sibling.style[this.position === 'Left' ? 'marginLeft' : 'marginRight'] = margin;
                    }
                    break;
                case 'Slide':
                    ej2_base_3.addClass([this.element], [SLIDE]);
                    if (sibling && (this.enableDock || this.element.classList.contains(OPEN))) {
                        sibling.style.transform = 'translateX(' + eleWidth + 'px)';
                    }
                    break;
                case 'Over':
                    ej2_base_3.addClass([this.element], [OVER]);
                    if (this.enableDock && (this.element.classList.contains(CLOSE) || this.isOpen)) {
                        Eif (sibling) {
                            sibling.style[this.position === 'Left' ? 'marginLeft' : 'marginRight'] = this.setDimension(this.dockSize);
                        }
                    }
                    break;
                case 'Auto':
                    ej2_base_3.addClass([this.element], [TRASITION]);
                    if (ej2_base_1.Browser.isDevice) {
                        if (sibling && (this.enableDock) && !this.getState()) {
                            sibling.style[this.position === 'Left' ? 'marginLeft' : 'marginRight'] = margin;
                            ej2_base_3.addClass([this.element], PUSH);
                        }
                        else {
                            ej2_base_3.addClass([this.element], OVER);
                        }
                    }
                    else {
                        ej2_base_3.addClass([this.element], PUSH);
                        if (sibling && (this.enableDock || this.element.classList.contains(OPEN))) {
                            sibling.style[this.position === 'Left' ? 'marginLeft' : 'marginRight'] = margin;
                        }
                    }
                    this.createBackDrop();
            }
        };
        Sidebar.prototype.destroy = function () {
            _super.prototype.destroy.call(this);
            if (this.target) {
                ej2_base_3.removeClass([this.target], CONTEXT);
            }
            this.destroyBackDrop();
            Eif (this.element) {
                ej2_base_3.removeClass([this.element], [OPEN, CLOSE, PUSH, SLIDE, OVER, LEFT, RIGHT, TRASITION, DISABLEANIMATION]);
                ej2_base_3.removeClass([this.element], SIDEBARABSOLUTE);
                this.element.style.width = '';
                this.element.style.zIndex = '';
                this.element.style.transform = '';
                if (!ej2_base_1.isNullOrUndefined(this.sidebarEleCopy.getAttribute('tabindex'))) {
                    this.element.setAttribute('tabindex', this.tabIndex);
                }
                else {
                    this.element.removeAttribute('tabindex');
                }
            }
            this.windowWidth = null;
            var sibling = document.querySelector('.e-main-content') || this.targetEle;
            if (!ej2_base_1.isNullOrUndefined(sibling)) {
                sibling.style.margin = '';
                sibling.style.transform = '';
            }
            this.unWireEvents();
        };
        __decorate([
            ej2_base_2.Property('auto')
        ], Sidebar.prototype, "dockSize", void 0);
        __decorate([
            ej2_base_2.Property(null)
        ], Sidebar.prototype, "mediaQuery", void 0);
        __decorate([
            ej2_base_2.Property(false)
        ], Sidebar.prototype, "enableDock", void 0);
        __decorate([
            ej2_base_2.Property('en-US')
        ], Sidebar.prototype, "locale", void 0);
        __decorate([
            ej2_base_2.Property(false)
        ], Sidebar.prototype, "enablePersistence", void 0);
        __decorate([
            ej2_base_2.Property(true)
        ], Sidebar.prototype, "enableGestures", void 0);
        __decorate([
            ej2_base_2.Property(false)
        ], Sidebar.prototype, "isOpen", void 0);
        __decorate([
            ej2_base_2.Property(false)
        ], Sidebar.prototype, "enableRtl", void 0);
        __decorate([
            ej2_base_2.Property(true)
        ], Sidebar.prototype, "animate", void 0);
        __decorate([
            ej2_base_2.Property('auto')
        ], Sidebar.prototype, "height", void 0);
        __decorate([
            ej2_base_2.Property(false)
        ], Sidebar.prototype, "closeOnDocumentClick", void 0);
        __decorate([
            ej2_base_2.Property('Left')
        ], Sidebar.prototype, "position", void 0);
        __decorate([
            ej2_base_2.Property(null)
        ], Sidebar.prototype, "target", void 0);
        __decorate([
            ej2_base_2.Property(false)
        ], Sidebar.prototype, "showBackdrop", void 0);
        __decorate([
            ej2_base_2.Property('Auto')
        ], Sidebar.prototype, "type", void 0);
        __decorate([
            ej2_base_2.Property('auto')
        ], Sidebar.prototype, "width", void 0);
        __decorate([
            ej2_base_2.Property(1000)
        ], Sidebar.prototype, "zIndex", void 0);
        __decorate([
            ej2_base_1.Event()
        ], Sidebar.prototype, "created", void 0);
        __decorate([
            ej2_base_1.Event()
        ], Sidebar.prototype, "close", void 0);
        __decorate([
            ej2_base_1.Event()
        ], Sidebar.prototype, "open", void 0);
        __decorate([
            ej2_base_1.Event()
        ], Sidebar.prototype, "change", void 0);
        __decorate([
            ej2_base_1.Event()
        ], Sidebar.prototype, "destroyed", void 0);
        Sidebar = __decorate([
            ej2_base_2.NotifyPropertyChanges
        ], Sidebar);
        return Sidebar;
    }(ej2_base_1.Component));
    exports.Sidebar = Sidebar;
});