{"version":3,"file":"primeng-megamenu.umd.js","sources":["../../src/app/components/megamenu/megamenu.ts","../../src/app/components/megamenu/primeng-megamenu.ts"],"sourcesContent":["import {NgModule,Component,ElementRef,Input,Renderer2,ChangeDetectionStrategy, ViewEncapsulation, ChangeDetectorRef, AfterContentInit, ContentChildren, QueryList, TemplateRef} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {MegaMenuItem,MenuItem, PrimeTemplate} from 'primeng/api';\nimport {RouterModule} from '@angular/router';\nimport {RippleModule} from 'primeng/ripple'; \n\n@Component({\n selector: 'p-megaMenu',\n template: `\n
\n
\n \n
\n \n
\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./megamenu.css']\n})\nexport class MegaMenu implements AfterContentInit {\n\n @Input() model: MegaMenuItem[];\n\n @Input() style: any;\n\n @Input() styleClass: string;\n \n @Input() orientation: string = 'horizontal';\n\n @Input() autoZIndex: boolean = true;\n\n @Input() baseZIndex: number = 0;\n\n @ContentChildren(PrimeTemplate) templates: QueryList;\n \n activeItem: any;\n\n documentClickListener: any;\n\n startTemplate: TemplateRef;\n\n endTemplate: TemplateRef;\n \n constructor(public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef) {}\n \n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch(item.getType()) {\n case 'start':\n this.startTemplate = item.template;\n break;\n\n case 'end':\n this.endTemplate = item.template;\n break;\n }\n });\n }\n\n onCategoryMouseEnter(event, menuitem: MegaMenuItem) {\n if (menuitem.disabled) {\n event.preventDefault();\n return;\n }\n\n if (this.activeItem) {\n this.activeItem = menuitem;\n }\n }\n\n onCategoryClick(event, item: MenuItem | MegaMenuItem) {\n if (item.disabled) {\n event.preventDefault();\n return;\n }\n\n if (!item.url) {\n event.preventDefault();\n }\n\n if (item.command) {\n item.command({\n originalEvent: event,\n item: item\n });\n }\n\n if (item.items) {\n if (this.activeItem && this.activeItem === item) {\n this.activeItem = null;\n this.unbindDocumentClickListener();\n }\n else {\n this.activeItem = item;\n this.bindDocumentClickListener();\n }\n }\n }\n \n itemClick(event, item: MenuItem | MegaMenuItem) {\n if (item.disabled) {\n event.preventDefault();\n return;\n }\n \n if (!item.url) {\n event.preventDefault();\n }\n \n if (item.command) {\n item.command({\n originalEvent: event,\n item: item\n });\n }\n \n this.activeItem = null;\n }\n \n getColumnClass(menuitem: MegaMenuItem) {\n let length = menuitem.items ? menuitem.items.length: 0;\n let columnClass;\n switch(length) {\n case 2:\n columnClass= 'p-megamenu-col-6';\n break;\n \n case 3:\n columnClass= 'p-megamenu-col-4';\n break;\n \n case 4:\n columnClass= 'p-megamenu-col-3';\n break;\n \n case 6:\n columnClass= 'p-megamenu-col-2';\n break;\n \n default:\n columnClass= 'p-megamenu-col-12';\n break;\n }\n \n return columnClass;\n }\n\n bindDocumentClickListener() {\n if (!this.documentClickListener) {\n this.documentClickListener = (event) => {\n if (this.el && !this.el.nativeElement.contains(event.target)) {\n this.activeItem = null;\n this.unbindDocumentClickListener();\n this.cd.markForCheck();\n }\n };\n\n document.addEventListener('click', this.documentClickListener);\n }\n }\n\n unbindDocumentClickListener() {\n if (this.documentClickListener) {\n document.removeEventListener('click', this.documentClickListener);\n this.documentClickListener = null;\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule,RouterModule,RippleModule],\n exports: [MegaMenu,RouterModule],\n declarations: [MegaMenu]\n})\nexport class MegaMenuModule { }","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["Component","ChangeDetectionStrategy","ViewEncapsulation","ElementRef","Renderer2","ChangeDetectorRef","Input","ContentChildren","PrimeTemplate","NgModule","CommonModule","RouterModule","RippleModule"],"mappings":";;;;;;;QA+GI,kBAAmB,EAAc,EAAS,QAAmB,EAAS,EAAqB;YAAxE,OAAE,GAAF,EAAE,CAAY;YAAS,aAAQ,GAAR,QAAQ,CAAW;YAAS,OAAE,GAAF,EAAE,CAAmB;YAhBlF,gBAAW,GAAW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