{"version":3,"file":"primeng-megamenu.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":[],"mappings":";;;;;;MAuFa,QAAQ;IAwBjB,YAAmB,EAAc,EAAS,QAAmB,EAAS,EAAqB;QAAxE,OAAE,GAAF,EAAE,CAAY;QAAS,aAAQ,GAAR,QAAQ,CAAW;QAAS,OAAE,GAAF,EAAE,CAAmB;QAhBlF,gBAAW,GAAW,YAAY,CAAC;QAEnC,eAAU,GAAY,IAAI,CAAC;QAE3B,eAAU,GAAW,CAAC,CAAC;KAY+D;IAE/F,kBAAkB;Q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