define(["require", "exports", "../ScreenSizeDetection", "./toolbar.service", "../Utils"], function (require, exports, ScreenSizeDetection_1, toolbar_service_1, Utils_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ToolbarController = /** @class */ (function () {
        function ToolbarController($element) {
            this.$element = $element;
            this.backdropClass = 'sidenav-active';
            this.toolbarService = toolbar_service_1.ToolbarService;
            this.listItems = this.$element[0].querySelectorAll('ul li');
            this.mainElement = document.getElementById('maincontent');
            this.eventName = (Utils_1.Utils.isTouchDevice()) ? 'touchstart' : 'click';
            this.subscribeScreensize();
        }
        ToolbarController.prototype.subscribeScreensize = function () {
            var _this = this;
            ScreenSizeDetection_1.default.get().subscribe(function (screensize) {
                if (screensize === 'xs' || screensize === 'sm') {
                    _this.start();
                }
                else {
                    _this.destroy();
                }
            });
        };
        ToolbarController.prototype.start = function () {
            for (var index = 0; index < this.listItems.length; index++) {
                var element = this.listItems[index];
                element.addEventListener(this.eventName, this.toggleMenu);
            }
        };
        ToolbarController.prototype.destroy = function () {
            for (var index = 0; index < this.listItems.length; index++) {
                var element = this.listItems[index];
                element.removeEventListener(this.eventName, this.toggleMenu);
            }
        };
        ToolbarController.prototype.toggleMenu = function (e) {
            e.stopPropagation();
            e.currentTarget.classList.toggle('active');
            this.mainElement.classList.toggle(this.backdropClass);
        };
        ToolbarController.prototype.toggleSidenav = function () {
            this.toolbarService.sidenavActive = !this.toolbarService.sidenavActive;
            Utils_1.Utils.toggleNoScrollBodyState();
        };
        return ToolbarController;
    }());
    exports.ToolbarController = ToolbarController;
});
//# sourceMappingURL=toolbar.controller.js.map