(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('primeng/api'), require('@angular/router'), require('primeng/ripple')) : typeof define === 'function' && define.amd ? define('primeng/megamenu', ['exports', '@angular/core', '@angular/common', 'primeng/api', '@angular/router', 'primeng/ripple'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.primeng = global.primeng || {}, global.primeng.megamenu = {}), global.ng.core, global.ng.common, global.primeng.api, global.ng.router, global.primeng.ripple)); }(this, (function (exports, core, common, api, router, ripple) { 'use strict'; var MegaMenu = /** @class */ (function () { function MegaMenu(el, renderer, cd) { this.el = el; this.renderer = renderer; this.cd = cd; this.orientation = 'horizontal'; this.autoZIndex = true; this.baseZIndex = 0; } MegaMenu.prototype.ngAfterContentInit = function () { var _this = this; this.templates.forEach(function (item) { switch (item.getType()) { case 'start': _this.startTemplate = item.template; break; case 'end': _this.endTemplate = item.template; break; } }); }; MegaMenu.prototype.onCategoryMouseEnter = function (event, menuitem) { if (menuitem.disabled) { event.preventDefault(); return; } if (this.activeItem) { this.activeItem = menuitem; } }; MegaMenu.prototype.onCategoryClick = function (event, item) { if (item.disabled) { event.preventDefault(); return; } if (!item.url) { event.preventDefault(); } if (item.command) { item.command({ originalEvent: event, item: item }); } if (item.items) { if (this.activeItem && this.activeItem === item) { this.activeItem = null; this.unbindDocumentClickListener(); } else { this.activeItem = item; this.bindDocumentClickListener(); } } }; 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 = 'p-megamenu-col-6'; break; case 3: columnClass = 'p-megamenu-col-4'; break; case 4: columnClass = 'p-megamenu-col-3'; break; case 6: columnClass = 'p-megamenu-col-2'; break; default: columnClass = 'p-megamenu-col-12'; break; } return columnClass; }; MegaMenu.prototype.bindDocumentClickListener = function () { var _this = this; if (!this.documentClickListener) { this.documentClickListener = function (event) { if (_this.el && !_this.el.nativeElement.contains(event.target)) { _this.activeItem = null; _this.unbindDocumentClickListener(); _this.cd.markForCheck(); } }; document.addEventListener('click', this.documentClickListener); } }; MegaMenu.prototype.unbindDocumentClickListener = function () { if (this.documentClickListener) { document.removeEventListener('click', this.documentClickListener); this.documentClickListener = null; } }; return MegaMenu; }()); MegaMenu.decorators = [ { type: core.Component, args: [{ selector: 'p-megaMenu', template: "\n