{"version":3,"sources":["../../src/app/components/menubar/menubar.ts"],"names":["MenubarSub","el","renderer","cd","this","autoZIndex","baseZIndex","leafClick","EventEmitter","menuHoverActive","Object","defineProperty","prototype","_parentActive","value","root","activeItem","onItemClick","event","item","disabled","preventDefault","url","routerLink","command","originalEvent","items","unbindDocumentClickListener","bindDocumentClickListener","onLeafClick","onItemMouseEnter","mobileActive","autoDisplay","emit","_this","documentClickListener","nativeElement","contains","target","markForCheck","document","addEventListener","removeEventListener","ngOnDestroy","Component","args","selector","template","encapsulation","ViewEncapsulation","None","ElementRef","Renderer2","ChangeDetectorRef","Input","Output","Menubar","ngAfterContentInit","templates","forEach","getType","startTemplate","endTemplate","toggle","DomHandler","findSingle","style","zIndex","String","generateZIndex","bindOutsideClickListener","outsideClickListener","rootmenu","menubutton","unbindOutsideClickListener","changeDetection","ChangeDetectionStrategy","OnPush","ContentChildren","PrimeTemplate","ViewChild","NgModule","imports","CommonModule","RouterModule","RippleModule","exports","declarations"],"mappings":"uoBA6EI,SAAAA,EAAmBC,EAAuBC,EAA6BC,GAApDC,KAAAH,GAAAA,EAAuBG,KAAAF,SAAAA,EAA6BE,KAAAD,GAAAA,EA/B9DC,KAAAC,YAAsB,EAEtBD,KAAAE,WAAqB,EAmBpBF,KAAAG,UAA+B,IAAIC,EAAAA,aAM7CJ,KAAAK,iBAA2B,SAnB3BC,OAAAC,eAAaX,EAAAY,UAAA,eAAY,KAAzB,WAEI,OAAOR,KAAKS,mBAEhB,SAAiBC,GACRV,KAAKW,OACNX,KAAKS,cAAgBC,EAEhBA,IACDV,KAAKY,WAAa,wCAgB9BhB,EAAAY,UAAAK,YAAA,SAAYC,EAAOC,GACXA,EAAKC,SACLF,EAAMG,kBAILF,EAAKG,KAAQH,EAAKI,YACnBL,EAAMG,iBAGNF,EAAKK,SACLL,EAAKK,QAAQ,CACTC,cAAeP,EACfC,KAAMA,IAIVA,EAAKO,QACDtB,KAAKY,YAAcG,IAASf,KAAKY,YACjCZ,KAAKY,W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,++BA7LPC,EAAAA,kBAAmBC,EAAAA,iBAAqBC,EAAAA,oDAkMjEC,EAAAA,qBAEAA,EAAAA,0BAEAA,EAAAA,0BAEAA,EAAAA,0BAEAA,EAAAA,2BAEAA,EAAAA,yBAEAwB,EAAAA,gBAAejC,KAAA,CAACkC,EAAAA,mCAEhBC,EAAAA,UAASnC,KAAA,CAAC,gCAEVmC,EAAAA,UAASnC,KAAA,CAAC,qBAqEf,iCALCoC,EAAAA,SAAQpC,KAAA,CAAC,CACNqC,QAAS,CAACC,EAAAA,aAAaC,EAAAA,aAAaC,EAAAA,cACpCC,QAAS,CAAC9B,EAAQ4B,EAAAA,cAClBG,aAAc,CAAC/B,EAAQxD","sourcesContent":["import { NgModule, Component, ElementRef, Input, Renderer2, OnDestroy,ChangeDetectorRef, ChangeDetectionStrategy, ViewEncapsulation, AfterContentInit, ContentChildren, QueryList, TemplateRef, ViewChild, Output, EventEmitter } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { DomHandler } from 'primeng/dom';\nimport { MenuItem, PrimeTemplate } from 'primeng/api';\nimport { RouterModule } from '@angular/router';\nimport { RippleModule } from 'primeng/ripple'; \n\n@Component({\n selector: 'p-menubarSub',\n template: `\n \n `,\n encapsulation: ViewEncapsulation.None\n})\nexport class MenubarSub implements OnDestroy {\n\n @Input() item: MenuItem;\n\n @Input() root: boolean;\n\n @Input() autoZIndex: boolean = true;\n\n @Input() baseZIndex: number = 0;\n\n @Input() mobileActive: boolean;\n\n @Input() autoDisplay: boolean;\n\n @Input() get parentActive():boolean \n {\n return this._parentActive;\n }\n set parentActive(value) {\n if (!this.root) {\n this._parentActive = value;\n\n if (!value)\n this.activeItem = null;\n }\n }\n\n @Output() leafClick: EventEmitter = new EventEmitter();\n\n _parentActive: boolean;\n\n documentClickListener: any;\n\n menuHoverActive: boolean = false;\n\n activeItem: any;\n\n constructor(public el: ElementRef, public renderer: Renderer2, private cd: ChangeDetectorRef) { }\n\n onItemClick(event, item) {\n if (item.disabled) {\n event.preventDefault();\n return;\n }\n\n if (!item.url && !item.routerLink) {\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 && item === this.activeItem) {\n this.activeItem = null;\n this.unbindDocumentClickListener();\n }\n else {\n this.activeItem = item;\n if (this.root) {\n this.bindDocumentClickListener();\n }\n }\n }\n\n if (!item.items) {\n this.onLeafClick();\n }\n }\n\n onItemMouseEnter(event, item) {\n if (item.disabled || this.mobileActive) {\n event.preventDefault();\n return;\n }\n\n if (this.root) {\n if (this.activeItem || this.autoDisplay) {\n this.activeItem = item;\n this.bindDocumentClickListener();\n }\n }\n else {\n this.activeItem = item;\n this.bindDocumentClickListener();\n }\n }\n\n onLeafClick() {\n this.activeItem = null;\n if (this.root) {\n this.unbindDocumentClickListener();\n }\n\n this.leafClick.emit();\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.cd.markForCheck();\n this.unbindDocumentClickListener();\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 ngOnDestroy() {\n this.unbindDocumentClickListener();\n }\n}\n\n@Component({\n selector: 'p-menubar',\n template: `\n
\n
\n \n
\n \n \n \n \n
\n \n
\n \n
\n \n
\n
\n
\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./menubar.css']\n})\nexport class Menubar implements AfterContentInit, OnDestroy {\n\n @Input() model: MenuItem[];\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() autoZIndex: boolean = true;\n\n @Input() baseZIndex: number = 0;\n\n @Input() autoDisplay: boolean;\n\n @ContentChildren(PrimeTemplate) templates: QueryList;\n\n @ViewChild('menubutton') menubutton: ElementRef;\n\n @ViewChild('rootmenu') rootmenu: MenubarSub;\n\n startTemplate: TemplateRef;\n\n endTemplate: TemplateRef;\n\n mobileActive: boolean;\n\n outsideClickListener: any;\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 toggle(event) {\n this.mobileActive = !this.mobileActive;\n let rootmenu = DomHandler.findSingle(this.el.nativeElement,\".p-menubar-root-list\")\n rootmenu.style.zIndex = String(DomHandler.generateZIndex());\n this.bindOutsideClickListener();\n event.preventDefault();\n }\n\n bindOutsideClickListener() {\n if (!this.outsideClickListener) {\n this.outsideClickListener = (event) => {\n if (this.mobileActive && this.rootmenu.el.nativeElement !== event.target && !this.rootmenu.el.nativeElement.contains(event.target)\n && this.menubutton.nativeElement !== event.target && !this.menubutton.nativeElement.contains(event.target)) {\n this.mobileActive = false;\n this.cd.markForCheck();\n }\n };\n document.addEventListener('click', this.outsideClickListener);\n }\n }\n\n onLeafClick() {\n this.mobileActive = false;\n this.unbindOutsideClickListener();\n }\n\n unbindOutsideClickListener() {\n if (this.outsideClickListener) {\n document.removeEventListener('click', this.outsideClickListener);\n this.outsideClickListener = null;\n }\n }\n\n ngOnDestroy() {\n this.unbindOutsideClickListener();\n }\n}\n\n@NgModule({\n imports: [CommonModule,RouterModule,RippleModule],\n exports: [Menubar,RouterModule],\n declarations: [Menubar,MenubarSub]\n})\nexport class MenubarModule { }\n"]}