{"version":3,"sources":["../../src/app/components/megamenu/megamenu.ts"],"names":["MegaMenu","el","renderer","cd","this","orientation","autoZIndex","baseZIndex","prototype","ngAfterContentInit","_this","templates","forEach","item","getType","startTemplate","template","endTemplate","onCategoryMouseEnter","event","menuitem","disabled","preventDefault","activeItem","onCategoryClick","url","command","originalEvent","items","unbindDocumentClickListener","bindDocumentClickListener","itemClick","getColumnClass","columnClass","length","documentClickListener","nativeElement","contains","target","markForCheck","document","addEventListener","removeEventListener","Component","args","selector","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","ElementRef","Renderer2","ChangeDetectorRef","Input","ContentChildren","PrimeTemplate","NgModule","imports","CommonModule","RouterModule","RippleModule","exports","declarations"],"mappings":"olBA+GI,SAAAA,EAAmBC,EAAuBC,EAA4BC,GAAnDC,KAAAH,GAAAA,EAAuBG,KAAAF,SAAAA,EAA4BE,KAAAD,GAAAA,EAhB7DC,KAAAC,YAAsB,aAEtBD,KAAAE,YAAsB,EAEtBF,KAAAG,WAAqB,SAc9BP,EAAAQ,UAAAC,mBAAA,WAAA,IAAAC,EAAAN,KACIA,KAAKO,UAAUC,SAAQ,SAACC,GACpB,OAAOA,EAAKC,WACR,IAAK,QACDJ,EAAKK,cAAgBF,EAAKG,SAC9B,MAEA,IAAK,MACDN,EAAKO,YAAcJ,EAAKG,cAMxChB,EAAAQ,UAAAU,qBAAA,SAAqBC,EAAOC,GACpBA,EAASC,SACTF,EAAMG,iBAINlB,KAAKmB,aACLnB,KAAKmB,WAAaH,IAI1BpB,EAAAQ,UAAAgB,gBAAA,SAAgBL,EAAON,GACfA,EAAKQ,SACLF,EAAMG,kBAILT,EAAKY,KACNN,EAAMG,iBAGNT,EAAKa,SACLb,EAAKa,QAAQ,CACTC,cAAeR,EACfN,KAAMA,IAIVA,EAAKe,QACDxB,KAAKmB,YAAcnB,KAAKmB,aAAeV,GACvCT,KAAKmB,WAAa,KAClBnB,KAAKyB,gCAGLzB,KAAKmB,WAAaV,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AAaC,EAAAA,aAAaC,EAAAA,cACpCC,QAAS,CAAC/D,EAAS6D,EAAAA,cACnBG,aAAc,CAAChE","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 { }"]}