"use strict"; 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; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var common_1 = require("@angular/common"); var domhandler_1 = require("../dom/domhandler"); var router_1 = require("@angular/router"); var MenubarSub = /** @class */ (function () { function MenubarSub(renderer, cd) { this.renderer = renderer; this.cd = cd; this.autoZIndex = true; this.baseZIndex = 0; this.menuHoverActive = false; } MenubarSub.prototype.onItemMenuClick = function (event, item, menuitem) { if (!this.autoDisplay) { if (menuitem.disabled) { return; } this.activeItem = this.activeMenu ? (this.activeMenu.isEqualNode(item) ? null : item) : item; var nextElement = item.children[0].nextElementSibling; if (nextElement) { var sublist = nextElement.children[0]; if (this.autoZIndex) { sublist.style.zIndex = String(this.baseZIndex + (++domhandler_1.DomHandler.zindex)); } if (this.root) { sublist.style.top = domhandler_1.DomHandler.getOuterHeight(item.children[0]) + 'px'; sublist.style.left = '0px'; } else { sublist.style.top = '0px'; sublist.style.left = domhandler_1.DomHandler.getOuterWidth(item.children[0]) + 'px'; } } this.menuClick = true; this.menuHoverActive = this.activeMenu ? (!this.activeMenu.isEqualNode(item)) : true; this.activeMenu = this.activeMenu ? (this.activeMenu.isEqualNode(item) ? null : item) : item; this.bindEventListener(); } }; MenubarSub.prototype.bindEventListener = function () { var _this = this; if (!this.documentClickListener) { this.documentClickListener = this.renderer.listen('document', 'click', function (event) { if (!_this.menuClick) { _this.activeItem = null; _this.menuHoverActive = false; } _this.menuClick = false; }); } }; MenubarSub.prototype.onItemMouseEnter = function (event, item, menuitem) { if (this.autoDisplay || (!this.autoDisplay && this.root && this.menuHoverActive)) { if (menuitem.disabled) { return; } if (this.hideTimeout) { clearTimeout(this.hideTimeout); this.hideTimeout = null; } this.activeItem = this.activeItem ? (this.activeItem.isEqualNode(item) && this.autoDisplay ? null : item) : item; var nextElement = item.children[0].nextElementSibling; if (nextElement) { var sublist = nextElement.children[0]; sublist.style.zIndex = String(++domhandler_1.DomHandler.zindex); if (this.root) { sublist.style.top = domhandler_1.DomHandler.getOuterHeight(item.children[0]) + 'px'; sublist.style.left = '0px'; } else { sublist.style.top = '0px'; sublist.style.left = domhandler_1.DomHandler.getOuterWidth(item.children[0]) + 'px'; } } this.activeMenu = this.activeMenu ? (this.activeMenu.isEqualNode(item) && this.autoDisplay ? null : item) : item; } }; MenubarSub.prototype.onItemMouseLeave = function (event) { var _this = this; if (this.autoDisplay) { this.hideTimeout = setTimeout(function () { _this.activeItem = null; _this.cd.markForCheck(); }, 250); } }; MenubarSub.prototype.itemClick = function (event, item) { if (item.disabled) { event.preventDefault(); return; } if (!item.url) { event.preventDefault(); } if (item.command) { item.command({ originalEvent: event, item: item }); } this.activeItem = null; }; MenubarSub.prototype.listClick = function (event) { if (this.autoDisplay) { this.activeItem = null; } }; MenubarSub.prototype.ngOnDestroy = function () { if (this.documentClickListener) { this.documentClickListener(); this.documentClickListener = null; } }; __decorate([ core_1.Input(), __metadata("design:type", Object) ], MenubarSub.prototype, "item", void 0); __decorate([ core_1.Input(), __metadata("design:type", Boolean) ], MenubarSub.prototype, "root", void 0); __decorate([ core_1.Input(), __metadata("design:type", Boolean) ], MenubarSub.prototype, "autoDisplay", void 0); __decorate([ core_1.Input(), __metadata("design:type", Boolean) ], MenubarSub.prototype, "autoZIndex", void 0); __decorate([ core_1.Input(), __metadata("design:type", Number) ], MenubarSub.prototype, "baseZIndex", void 0); MenubarSub = __decorate([ core_1.Component({ selector: 'p-menubarSub', template: "\n