import { Component, ChangeDetectionStrategy, ViewEncapsulation, ElementRef, Renderer2, ChangeDetectorRef, Input, ContentChildren, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { PrimeTemplate } from 'primeng/api'; import { RouterModule } from '@angular/router'; import { RippleModule } from 'primeng/ripple'; class MegaMenu { constructor(el, renderer, cd) { this.el = el; this.renderer = renderer; this.cd = cd; this.orientation = 'horizontal'; this.autoZIndex = true; this.baseZIndex = 0; } ngAfterContentInit() { this.templates.forEach((item) => { switch (item.getType()) { case 'start': this.startTemplate = item.template; break; case 'end': this.endTemplate = item.template; break; } }); } onCategoryMouseEnter(event, menuitem) { if (menuitem.disabled) { event.preventDefault(); return; } if (this.activeItem) { this.activeItem = menuitem; } } onCategoryClick(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(); } } } itemClick(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; } getColumnClass(menuitem) { let length = menuitem.items ? menuitem.items.length : 0; let 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; } bindDocumentClickListener() { if (!this.documentClickListener) { this.documentClickListener = (event) => { if (this.el && !this.el.nativeElement.contains(event.target)) { this.activeItem = null; this.unbindDocumentClickListener(); this.cd.markForCheck(); } }; document.addEventListener('click', this.documentClickListener); } } unbindDocumentClickListener() { if (this.documentClickListener) { document.removeEventListener('click', this.documentClickListener); this.documentClickListener = null; } } } MegaMenu.decorators = [ { type: Component, args: [{ selector: 'p-megaMenu', template: `
`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, styles: [".p-megamenu-root-list{list-style:none;margin:0;padding:0}.p-megamenu-root-list>.p-menuitem{position:relative}.p-megamenu .p-menuitem-link{-ms-flex-align:center;align-items:center;cursor:pointer;display:-ms-flexbox;display:flex;overflow:hidden;position:relative;text-decoration:none}.p-megamenu .p-menuitem-text{line-height:1}.p-megamenu-panel{display:none;position:absolute;width:auto;z-index:1}.p-megamenu-root-list>.p-menuitem-active>.p-megamenu-panel{display:block}.p-megamenu-submenu{list-style:none;margin:0;padding:0}.p-megamenu-horizontal .p-megamenu-root-list{-ms-flex-align:center;-ms-flex-wrap:wrap;align-items:center;display:-ms-flexbox;display:flex;flex-wrap:wrap}.p-megamenu-vertical .p-megamenu-root-list{-ms-flex-direction:column;flex-direction:column}.p-megamenu-vertical .p-megamenu-root-list>.p-menuitem-active>.p-megamenu-panel{left:100%;top:0}.p-megamenu-vertical .p-megamenu-root-list>.p-menuitem>.p-menuitem-link>.p-submenu-icon{margin-left:auto}.p-megamenu-grid{display:-ms-flexbox;display:flex}.p-megamenu-col-2,.p-megamenu-col-3,.p-megamenu-col-4,.p-megamenu-col-6,.p-megamenu-col-12{-ms-flex:0 0 auto;flex:0 0 auto;padding:.5rem}.p-megamenu-col-2{width:16.6667%}.p-megamenu-col-3{width:25%}.p-megamenu-col-4{width:33.3333%}.p-megamenu-col-6{width:50%}.p-megamenu-col-12{width:100%}"] },] } ]; MegaMenu.ctorParameters = () => [ { type: ElementRef }, { type: Renderer2 }, { type: ChangeDetectorRef } ]; MegaMenu.propDecorators = { model: [{ type: Input }], style: [{ type: Input }], styleClass: [{ type: Input }], orientation: [{ type: Input }], autoZIndex: [{ type: Input }], baseZIndex: [{ type: Input }], templates: [{ type: ContentChildren, args: [PrimeTemplate,] }] }; class MegaMenuModule { } MegaMenuModule.decorators = [ { type: NgModule, args: [{ imports: [CommonModule, RouterModule, RippleModule], exports: [MegaMenu, RouterModule], declarations: [MegaMenu] },] } ]; /** * Generated bundle index. Do not edit. */ export { MegaMenu, MegaMenuModule }; //# sourceMappingURL=primeng-megamenu.js.map