{"version":3,"file":"primeng-menubar.umd.js","sources":["../../src/app/components/menubar/menubar.ts","../../src/app/components/menubar/primeng-menubar.ts"],"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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["EventEmitter","Component","ViewEncapsulation","ElementRef","Renderer2","ChangeDetectorRef","Input","Output","DomHandler","ChangeDetectionStrategy","ContentChildren","PrimeTemplate","ViewChild","NgModule","CommonModule","RouterModule","RippleModule"],"mappings":";;;;;;;QA6EI,oBAAmB,EAAc,EAAS,QAAmB,EAAU,EAAqB;YAAzE,OAAE,GAAF,EAAE,CAAY;YAAS,aAAQ,GAAR,QAAQ,CAAW;YAAU,OAAE,GAAF,EAAE,CAAmB;YA/BnF,eAAU,GAAY,IAAI,CAAC;YAE3B,eAAU,GAAW,CAAC,CAAC;YAmBtB,cAAS,GAAsB,IAAIA,iBAAY,EAAE,CAAC;YAM5D,oBAAe,GAAY,KAAK,CAAC;SAIgE;QAvBjG,sBAAa,oCAAY;iBAAzB;gBAEI,OAAO,IAAI,CAAC,aAAa,CAAC;aAC7B;iB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