UNPKG

primeng

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primeng.svg)](https://badge.fury.io/js/primeng) [![Build Status](https://travis-ci.org/primefaces/primeng.

2 lines 10.3 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("primeng/dom"),require("@angular/router")):"function"==typeof define&&define.amd?define("primeng/contextmenu",["exports","@angular/core","@angular/common","primeng/dom","@angular/router"],t):t(((e=e||self).primeng=e.primeng||{},e.primeng.contextmenu={}),e.ng.core,e.ng.common,e.primeng.dom,e.ng.router)}(this,(function(e,t,i,n,o){"use strict";var r=this&&this.__decorate||function(e,t,i,n){var o,r=arguments.length,l=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(l=(r<3?o(l):r>3?o(t,i,l):o(t,i))||l);return r>3&&l&&Object.defineProperty(t,i,l),l},l=this&&this.__param||function(e,t){return function(i,n){t(i,n,e)}},s=function(){function e(e){this.contextMenu=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.onItemMouseEnter=function(e,t,i){if(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null),!i.disabled){this.activeItem=t;var o=t.children[0].nextElementSibling;if(o){var r=o.children[0];r.style.zIndex=++n.DomHandler.zindex,this.position(r,t)}}},e.prototype.itemClick=function(e,t){t.disabled?e.preventDefault():(t.command&&(t.command({originalEvent:e,item:t}),e.preventDefault()),t.items?e.preventDefault():this.contextMenu.hide())},e.prototype.listClick=function(e){this.activeItem=null},e.prototype.position=function(e,t){this.containerOffset=n.DomHandler.getOffset(t.parentElement);var i=n.DomHandler.getViewport(),o=e.offsetParent?e.offsetWidth:n.DomHandler.getHiddenElementOuterWidth(e),r=n.DomHandler.getOuterWidth(t.children[0]),l=n.DomHandler.getOuterHeight(t.children[0]),s=e.offsetHeight?e.offsetHeight:n.DomHandler.getHiddenElementOuterHeight(e);parseInt(this.containerOffset.top)+l+s>i.height-n.DomHandler.calculateScrollbarHeight()?e.style.bottom="0px":e.style.top="0px",parseInt(this.containerOffset.left)+r+o>i.width-n.DomHandler.calculateScrollbarWidth()?e.style.left=-o+"px":e.style.left=r+"px"},e.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[t.forwardRef((function(){return a}))]}]}]},r([t.Input()],e.prototype,"item",void 0),r([t.Input()],e.prototype,"root",void 0),r([t.Input()],e.prototype,"parentActive",null),e=r([t.Component({selector:"p-contextMenuSub",template:'\n <ul [ngClass]="{\'ui-widget-content ui-corner-all ui-submenu-list ui-shadow\':!root}" class="ui-menu-list">\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" #item [ngClass]="{\'ui-menuitem ui-corner-all\':true,\'ui-menuitem-active\':item==activeItem,\'ui-helper-hidden\': child.visible === false}"\n (mouseenter)="onItemMouseEnter($event,item,child)" role="none">\n <a *ngIf="!child.routerLink" [attr.href]="child.url" [attr.target]="child.target" [attr.title]="child.title" [attr.id]="child.id" [attr.tabindex]="child.tabindex ? child.tabindex : \'0\'" (click)="itemClick($event, child)"\n [ngClass]="{\'ui-menuitem-link ui-corner-all\':true,\'ui-state-disabled\':child.disabled}" [ngStyle]="child.style" [class]="child.styleClass"\n [attr.aria-haspopup]="item.items != null" [attr.aria-expanded]="item === activeItem">\n <span class="ui-submenu-icon pi pi-fw pi-caret-right" *ngIf="child.items"></span>\n <span class="ui-menuitem-icon" *ngIf="child.icon" [ngClass]="child.icon"></span>\n <span class="ui-menuitem-text">{{child.label}}</span>\n </a>\n <a *ngIf="child.routerLink" [routerLink]="child.routerLink" [queryParams]="child.queryParams" [routerLinkActive]="\'ui-menuitem-link-active\'" role="menuitem"\n [routerLinkActiveOptions]="child.routerLinkActiveOptions||{exact:false}" [attr.target]="child.target" [attr.title]="child.title" [attr.id]="child.id" [attr.tabindex]="child.tabindex ? child.tabindex : \'0\'"\n (click)="itemClick($event, child)" [ngClass]="{\'ui-menuitem-link ui-corner-all\':true,\'ui-state-disabled\':child.disabled}"\n [ngStyle]="child.style" [class]="child.styleClass"\n [fragment]="child.fragment" [queryParamsHandling]="child.queryParamsHandling" [preserveFragment]="child.preserveFragment" [skipLocationChange]="child.skipLocationChange" [replaceUrl]="child.replaceUrl" [state]="child.state">\n <span class="ui-submenu-icon pi pi-fw pi-caret-right" *ngIf="child.items"></span>\n <span class="ui-menuitem-icon" *ngIf="child.icon" [ngClass]="child.icon"></span>\n <span class="ui-menuitem-text">{{child.label}}</span>\n </a>\n <p-contextMenuSub class="ui-submenu" [parentActive]="item==activeItem" [item]="child" *ngIf="child.items"></p-contextMenuSub>\n </li>\n </ng-template>\n </ul>\n '}),l(0,t.Inject(t.forwardRef((function(){return a}))))],e)}(),a=function(){function e(e,i,n){this.el=e,this.renderer=i,this.zone=n,this.autoZIndex=!0,this.baseZIndex=0,this.triggerEvent="contextmenu",this.onShow=new t.EventEmitter,this.onHide=new t.EventEmitter}return e.prototype.ngAfterViewInit=function(){var e=this;this.global?this.triggerEventListener=this.renderer.listen("document",this.triggerEvent,(function(t){e.show(t),t.preventDefault()})):this.target&&(this.triggerEventListener=this.renderer.listen(this.target,this.triggerEvent,(function(t){e.show(t),t.preventDefault(),t.stopPropagation()}))),this.appendTo&&("body"===this.appendTo?document.body.appendChild(this.containerViewChild.nativeElement):n.DomHandler.appendChild(this.containerViewChild.nativeElement,this.appendTo))},e.prototype.show=function(e){this.position(e),this.moveOnTop(),this.containerViewChild.nativeElement.style.display="block",this.parentActive=!0,n.DomHandler.fadeIn(this.containerViewChild.nativeElement,250),this.bindGlobalListeners(),e&&e.preventDefault(),this.onShow.emit()},e.prototype.hide=function(){this.containerViewChild.nativeElement.style.display="none",this.parentActive=!1,this.unbindGlobalListeners(),this.onHide.emit()},e.prototype.moveOnTop=function(){this.autoZIndex&&(this.containerViewChild.nativeElement.style.zIndex=String(this.baseZIndex+ ++n.DomHandler.zindex))},e.prototype.toggle=function(e){this.containerViewChild.nativeElement.offsetParent?this.hide():this.show(e)},e.prototype.position=function(e){if(e){var t=e.pageX+1,i=e.pageY+1,o=this.containerViewChild.nativeElement.offsetParent?this.containerViewChild.nativeElement.offsetWidth:n.DomHandler.getHiddenElementOuterWidth(this.containerViewChild.nativeElement),r=this.containerViewChild.nativeElement.offsetParent?this.containerViewChild.nativeElement.offsetHeight:n.DomHandler.getHiddenElementOuterHeight(this.containerViewChild.nativeElement),l=n.DomHandler.getViewport();t+o-document.body.scrollLeft>l.width&&(t-=o),i+r-document.body.scrollTop>l.height&&(i-=r),t<document.body.scrollLeft&&(t=document.body.scrollLeft),i<document.body.scrollTop&&(i=document.body.scrollTop),this.containerViewChild.nativeElement.style.left=t+"px",this.containerViewChild.nativeElement.style.top=i+"px"}},e.prototype.bindGlobalListeners=function(){var e=this;this.documentClickListener||(this.documentClickListener=this.renderer.listen("document","click",(function(t){e.containerViewChild.nativeElement.offsetParent&&e.isOutsideClicked(t)&&2!==t.button&&e.hide()}))),this.zone.runOutsideAngular((function(){e.windowResizeListener||(e.windowResizeListener=e.onWindowResize.bind(e),window.addEventListener("resize",e.windowResizeListener))}))},e.prototype.unbindGlobalListeners=function(){this.documentClickListener&&(this.documentClickListener(),this.documentClickListener=null),this.windowResizeListener&&(window.removeEventListener("resize",this.windowResizeListener),this.windowResizeListener=null)},e.prototype.onWindowResize=function(e){this.containerViewChild.nativeElement.offsetParent&&this.hide()},e.prototype.isOutsideClicked=function(e){return!(this.containerViewChild.nativeElement.isSameNode(e.target)||this.containerViewChild.nativeElement.contains(e.target))},e.prototype.ngOnDestroy=function(){this.unbindGlobalListeners(),this.triggerEventListener&&this.triggerEventListener(),this.appendTo&&this.el.nativeElement.appendChild(this.containerViewChild.nativeElement)},e.ctorParameters=function(){return[{type:t.ElementRef},{type:t.Renderer2},{type:t.NgZone}]},r([t.Input()],e.prototype,"model",void 0),r([t.Input()],e.prototype,"global",void 0),r([t.Input()],e.prototype,"target",void 0),r([t.Input()],e.prototype,"style",void 0),r([t.Input()],e.prototype,"styleClass",void 0),r([t.Input()],e.prototype,"appendTo",void 0),r([t.Input()],e.prototype,"autoZIndex",void 0),r([t.Input()],e.prototype,"baseZIndex",void 0),r([t.Input()],e.prototype,"triggerEvent",void 0),r([t.Output()],e.prototype,"onShow",void 0),r([t.Output()],e.prototype,"onHide",void 0),r([t.ViewChild("container")],e.prototype,"containerViewChild",void 0),e=r([t.Component({selector:"p-contextMenu",template:'\n <div #container [ngClass]="\'ui-contextmenu ui-widget ui-widget-content ui-corner-all ui-shadow\'"\n [class]="styleClass" [ngStyle]="style">\n <p-contextMenuSub [item]="model" [parentActive]="parentActive" root="root"></p-contextMenuSub>\n </div>\n ',changeDetection:t.ChangeDetectionStrategy.Default})],e)}(),d=function(){function e(){}return e=r([t.NgModule({imports:[i.CommonModule,o.RouterModule],exports:[a,o.RouterModule],declarations:[a,s]})],e)}();e.ContextMenu=a,e.ContextMenuModule=d,e.ContextMenuSub=s,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=primeng-contextmenu.umd.min.js.map