UNPKG

10.6 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/animations"),require("@angular/common"),require("primeng/dom"),require("@angular/router")):"function"==typeof define&&define.amd?define("primeng/tieredmenu",["exports","@angular/core","@angular/animations","@angular/common","primeng/dom","@angular/router"],t):t(((e=e||self).primeng=e.primeng||{},e.primeng.tieredmenu={}),e.ng.core,e.ng.animations,e.ng.common,e.primeng.dom,e.ng.router)}(this,(function(e,t,i,n,o,r){"use strict";var s=this&&this.__decorate||function(e,t,i,n){var o,r=arguments.length,s=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(r<3?o(s):r>3?o(t,i,s):o(t,i))||s);return r>3&&s&&Object.defineProperty(t,i,s),s},a=this&&this.__param||function(e,t){return function(i,n){t(i,n,e)}},l=function(){function e(e,t,i){this.cf=t,this.renderer=i,this.autoZIndex=!0,this.baseZIndex=0,this.tieredMenu=e}return Object.defineProperty(e.prototype,"parentActive",{get:function(){return this._parentActive},set:function(e){this._parentActive=e,e||(this.activeItem=null)},enumerable:!0,configurable:!0}),e.prototype.ngAfterViewInit=function(){this.root&&!this.tieredMenu.popup&&this.bindDocumentClickListener()},e.prototype.onItemMouseEnter=function(e,t,i){if(this.tieredMenu.popup||!this.root||this.activeItem){if(i.disabled)return;this.activeItem=t;var n=t.children[0].nextElementSibling;if(n){var r=n.children[0];this.autoZIndex&&(r.style.zIndex=String(this.baseZIndex+ ++o.DomHandler.zindex)),r.style.zIndex=String(++o.DomHandler.zindex),r.style.top="0px",r.style.left=o.DomHandler.getOuterWidth(t.children[0])+"px"}}},e.prototype.itemClick=function(e,t,i){if(i.disabled)return e.preventDefault(),!0;if(i.url||e.preventDefault(),i.command&&i.command({originalEvent:e,item:i}),this.root&&!this.activeItem&&!this.tieredMenu.popup){this.activeItem=t;var n=t.children[0].nextElementSibling;if(n){var r=n.children[0];this.autoZIndex&&(r.style.zIndex=String(this.baseZIndex+ ++o.DomHandler.zindex)),r.style.zIndex=String(++o.DomHandler.zindex),r.style.top="0px",r.style.left=o.DomHandler.getOuterWidth(t.children[0])+"px",this.rootItemClick=!0}}!i.items&&this.tieredMenu.popup&&this.tieredMenu.hide()},e.prototype.listClick=function(e){this.rootItemClick||(this.activeItem=null)},e.prototype.bindDocumentClickListener=function(){var e=this;this.documentClickListener||(this.documentClickListener=this.renderer.listen("document","click",(function(){e.rootItemClick||(e.parentActive=!1,e.activeItem=null),e.rootItemClick=!1})))},e.prototype.unbindDocumentClickListener=function(){this.documentClickListener&&(this.documentClickListener(),this.documentClickListener=null)},e.prototype.ngOnDestroy=function(){this.root&&!this.tieredMenu.popup&&this.unbindDocumentClickListener()},e.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[t.forwardRef((function(){return u}))]}]},{type:t.ChangeDetectorRef},{type:t.Renderer2}]},s([t.Input()],e.prototype,"item",void 0),s([t.Input()],e.prototype,"root",void 0),s([t.Input()],e.prototype,"autoZIndex",void 0),s([t.Input()],e.prototype,"baseZIndex",void 0),s([t.Input()],e.prototype,"parentActive",null),e=s([t.Component({selector:"p-tieredMenuSub",template:'\n <ul [ngClass]="{\'ui-widget-content ui-corner-all ui-shadow ui-submenu-list\': !root}" (click)="listClick($event)" role="menubar">\n <ng-template ngFor let-child [ngForOf]="(root ? item : item.items)">\n <li *ngIf="child.separator" class="ui-menu-separator ui-widget-content" [ngClass]="{\'ui-helper-hidden\': child.visible === false}" role="separator">\n <li *ngIf="!child.separator" #listItem [ngClass]="{\'ui-menuitem ui-widget ui-corner-all\':true,\'ui-menuitem-active\':listItem==activeItem,\'ui-helper-hidden\': child.visible === false}"\n [class]="child.styleClass" [ngStyle]="child.style" role="none"\n (mouseenter)="onItemMouseEnter($event, listItem, child)">\n <a *ngIf="!child.routerLink" [attr.href]="child.url" class="ui-menuitem-link ui-corner-all" [attr.target]="child.target" [attr.tabindex]="child.tabindex ? child.tabindex : \'0\'" [attr.title]="child.title" [attr.id]="child.id" \n [ngClass]="{\'ui-state-disabled\':child.disabled}" (click)="itemClick($event, listItem, child)" role="menuitem" [attr.aria-haspopup]="item.items != null" [attr.aria-expanded]="item === activeItem">\n <span class="ui-menuitem-icon" *ngIf="child.icon" [ngClass]="child.icon"></span>\n <span class="ui-menuitem-text">{{child.label}}</span>\n <span class="ui-submenu-icon pi pi-fw pi-caret-right" *ngIf="child.items"></span>\n </a>\n <a *ngIf="child.routerLink" [routerLink]="child.routerLink" role="menuitem" [queryParams]="child.queryParams" [routerLinkActive]="\'ui-menuitem-link-active\'" role="menuitem" [attr.tabindex]="child.tabindex ? child.tabindex : \'0\'"\n [routerLinkActiveOptions]="child.routerLinkActiveOptions||{exact:false}"\n class="ui-menuitem-link ui-corner-all" [attr.target]="child.target" [attr.title]="child.title" [attr.id]="child.id"\n [ngClass]="{\'ui-state-disabled\':child.disabled}" (click)="itemClick($event, listItem, child)"\n [fragment]="child.fragment" [queryParamsHandling]="child.queryParamsHandling" [preserveFragment]="child.preserveFragment" [skipLocationChange]="child.skipLocationChange" [replaceUrl]="child.replaceUrl" [state]="child.state">\n <span class="ui-menuitem-icon" *ngIf="child.icon" [ngClass]="child.icon"></span>\n <span class="ui-menuitem-text">{{child.label}}</span>\n <span class="ui-submenu-icon pi pi-fw pi-caret-right" *ngIf="child.items"></span>\n </a>\n <p-tieredMenuSub class="ui-submenu" [item]="child" *ngIf="child.items" [baseZIndex]="baseZIndex" [parentActive]="listItem==activeItem" [autoZIndex]="autoZIndex"></p-tieredMenuSub>\n </li>\n </ng-template>\n </ul>\n '}),a(0,t.Inject(t.forwardRef((function(){return u}))))],e)}(),u=function(){function e(e,t){this.el=e,this.renderer=t,this.autoZIndex=!0,this.baseZIndex=0,this.showTransitionOptions="225ms ease-out",this.hideTransitionOptions="195ms ease-in"}return e.prototype.toggle=function(e){this.visible?this.hide():this.show(e),this.preventDocumentDefault=!0},e.prototype.show=function(e){this.target=e.currentTarget,this.visible=!0,this.parentActive=!0,this.preventDocumentDefault=!0},e.prototype.onOverlayAnimationStart=function(e){switch(e.toState){case"visible":this.popup&&(this.container=e.element,this.moveOnTop(),this.appendOverlay(),o.DomHandler.absolutePosition(this.container,this.target),this.bindDocumentClickListener(),this.bindDocumentResizeListener());break;case"void":this.onOverlayHide()}},e.prototype.appendOverlay=function(){this.appendTo&&("body"===this.appendTo?document.body.appendChild(this.container):o.DomHandler.appendChild(this.container,this.appendTo))},e.prototype.restoreOverlayAppend=function(){this.container&&this.appendTo&&this.el.nativeElement.appendChild(this.container)},e.prototype.moveOnTop=function(){this.autoZIndex&&(this.container.style.zIndex=String(this.baseZIndex+ ++o.DomHandler.zindex))},e.prototype.hide=function(){this.visible=!1,this.parentActive=!1},e.prototype.onWindowResize=function(){this.hide()},e.prototype.bindDocumentClickListener=function(){var e=this;this.documentClickListener||(this.documentClickListener=this.renderer.listen("document","click",(function(){!e.preventDocumentDefault&&e.popup&&e.hide(),e.preventDocumentDefault=!1})))},e.prototype.unbindDocumentClickListener=function(){this.documentClickListener&&(this.documentClickListener(),this.documentClickListener=null)},e.prototype.bindDocumentResizeListener=function(){this.documentResizeListener=this.onWindowResize.bind(this),window.addEventListener("resize",this.documentResizeListener)},e.prototype.unbindDocumentResizeListener=function(){this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)},e.prototype.onOverlayHide=function(){this.unbindDocumentClickListener(),this.unbindDocumentResizeListener(),this.preventDocumentDefault=!1,this.target=null},e.prototype.ngOnDestroy=function(){this.popup&&(this.restoreOverlayAppend(),this.onOverlayHide())},e.ctorParameters=function(){return[{type:t.ElementRef},{type:t.Renderer2}]},s([t.Input()],e.prototype,"model",void 0),s([t.Input()],e.prototype,"popup",void 0),s([t.Input()],e.prototype,"style",void 0),s([t.Input()],e.prototype,"styleClass",void 0),s([t.Input()],e.prototype,"appendTo",void 0),s([t.Input()],e.prototype,"autoZIndex",void 0),s([t.Input()],e.prototype,"baseZIndex",void 0),s([t.Input()],e.prototype,"showTransitionOptions",void 0),s([t.Input()],e.prototype,"hideTransitionOptions",void 0),e=s([t.Component({selector:"p-tieredMenu",template:'\n <div [ngClass]="{\'ui-tieredmenu ui-widget ui-widget-content ui-corner-all\':true, \'ui-tieredmenu-dynamic ui-shadow\':popup}" [class]="styleClass" [ngStyle]="style"\n [@overlayAnimation]="{value: \'visible\', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}" [@.disabled]="popup !== true" (@overlayAnimation.start)="onOverlayAnimationStart($event)" *ngIf="!popup || visible">\n <p-tieredMenuSub [item]="model" root="root" [parentActive]="parentActive" [baseZIndex]="baseZIndex" [autoZIndex]="autoZIndex"></p-tieredMenuSub>\n </div>\n ',animations:[i.trigger("overlayAnimation",[i.state("void",i.style({transform:"translateY(5%)",opacity:0})),i.state("visible",i.style({transform:"translateY(0)",opacity:1})),i.transition("void => visible",i.animate("{{showTransitionParams}}")),i.transition("visible => void",i.animate("{{hideTransitionParams}}"))])],changeDetection:t.ChangeDetectionStrategy.Default})],e)}(),d=function(){function e(){}return e=s([t.NgModule({imports:[n.CommonModule,r.RouterModule],exports:[u,r.RouterModule],declarations:[u,l]})],e)}();e.TieredMenu=u,e.TieredMenuModule=d,e.TieredMenuSub=l,Object.defineProperty(e,"__esModule",{value:!0})}));
2//# sourceMappingURL=primeng-tieredmenu.umd.min.js.map
\No newline at end of file