"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 MegaMenu = /** @class */ (function () { function MegaMenu(el, renderer) { this.el = el; this.renderer = renderer; this.orientation = 'horizontal'; this.autoZIndex = true; this.baseZIndex = 0; } MegaMenu.prototype.onItemMouseEnter = function (event, item, menuitem) { if (menuitem.disabled) { return; } if (this.hideTimeout) { clearTimeout(this.hideTimeout); this.hideTimeout = null; } this.activeItem = item; if (menuitem.items) { var submenu = item.children[0].nextElementSibling; if (submenu) { if (this.autoZIndex) { submenu.style.zIndex = String(this.baseZIndex + (++domhandler_1.DomHandler.zindex)); } if (this.orientation === 'horizontal') { submenu.style.top = domhandler_1.DomHandler.getOuterHeight(item.children[0]) + 'px'; submenu.style.left = '0px'; } else if (this.orientation === 'vertical') { submenu.style.top = '0px'; submenu.style.left = domhandler_1.DomHandler.getOuterWidth(item.children[0]) + 'px'; } } } }; MegaMenu.prototype.onItemMouseLeave = function (event, link) { var _this = this; this.hideTimeout = setTimeout(function () { _this.activeItem = null; }, 1000); }; MegaMenu.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; }; MegaMenu.prototype.getColumnClass = function (menuitem) { var length = menuitem.items ? menuitem.items.length : 0; var columnClass; switch (length) { case 2: columnClass = 'ui-g-6'; break; case 3: columnClass = 'ui-g-4'; break; case 4: columnClass = 'ui-g-3'; break; case 6: columnClass = 'ui-g-2'; break; default: columnClass = 'ui-g-12'; break; } return columnClass; }; __decorate([ core_1.Input(), __metadata("design:type", Array) ], MegaMenu.prototype, "model", void 0); __decorate([ core_1.Input(), __metadata("design:type", Object) ], MegaMenu.prototype, "style", void 0); __decorate([ core_1.Input(), __metadata("design:type", String) ], MegaMenu.prototype, "styleClass", void 0); __decorate([ core_1.Input(), __metadata("design:type", String) ], MegaMenu.prototype, "orientation", void 0); __decorate([ core_1.Input(), __metadata("design:type", Boolean) ], MegaMenu.prototype, "autoZIndex", void 0); __decorate([ core_1.Input(), __metadata("design:type", Number) ], MegaMenu.prototype, "baseZIndex", void 0); MegaMenu = __decorate([ core_1.Component({ selector: 'p-megaMenu', template: "\n
\n \n
\n " }), __metadata("design:paramtypes", [core_1.ElementRef, core_1.Renderer2]) ], MegaMenu); return MegaMenu; }()); exports.MegaMenu = MegaMenu; var MegaMenuModule = /** @class */ (function () { function MegaMenuModule() { } MegaMenuModule = __decorate([ core_1.NgModule({ imports: [common_1.CommonModule, router_1.RouterModule], exports: [MegaMenu, router_1.RouterModule], declarations: [MegaMenu] }) ], MegaMenuModule); return MegaMenuModule; }()); exports.MegaMenuModule = MegaMenuModule; //# sourceMappingURL=megamenu.js.map