| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- "use strict";
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
- return c > 3 && r && Object.defineProperty(target, key, r), r;
- };
- var __metadata = (this && this.__metadata) || function (k, v) {
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var core_1 = require("@angular/core");
- var animations_1 = require("@angular/animations");
- var common_1 = require("@angular/common");
- var domhandler_1 = require("../dom/domhandler");
- var button_1 = require("../button/button");
- var router_1 = require("@angular/router");
- var router_2 = require("@angular/router");
- var SplitButton = /** @class */ (function () {
- function SplitButton(el, renderer, router, cd) {
- this.el = el;
- this.renderer = renderer;
- this.router = router;
- this.cd = cd;
- this.iconPos = 'left';
- this.onClick = new core_1.EventEmitter();
- this.onDropdownClick = new core_1.EventEmitter();
- this.showTransitionOptions = '225ms ease-out';
- this.hideTransitionOptions = '195ms ease-in';
- this.overlayVisible = false;
- }
- SplitButton.prototype.onDefaultButtonClick = function (event) {
- this.onClick.emit(event);
- };
- SplitButton.prototype.itemClick = function (event, item) {
- if (item.disabled) {
- event.preventDefault();
- return;
- }
- if (!item.url) {
- event.preventDefault();
- }
- if (item.command) {
- item.command({
- originalEvent: event,
- item: item
- });
- }
- this.overlayVisible = false;
- };
- SplitButton.prototype.show = function () {
- this.overlayVisible = !this.overlayVisible;
- };
- SplitButton.prototype.onOverlayAnimationStart = function (event) {
- switch (event.toState) {
- case 'visible':
- this.overlay = event.element;
- this.appendOverlay();
- this.overlay.style.zIndex = String(++domhandler_1.DomHandler.zindex);
- this.alignOverlay();
- this.bindDocumentClickListener();
- this.bindDocumentResizeListener();
- break;
- case 'void':
- this.onOverlayHide();
- break;
- }
- };
- SplitButton.prototype.onDropdownButtonClick = function (event) {
- this.onDropdownClick.emit(event);
- this.dropdownClick = true;
- this.show();
- };
- SplitButton.prototype.alignOverlay = function () {
- if (this.appendTo)
- domhandler_1.DomHandler.absolutePosition(this.overlay, this.containerViewChild.nativeElement);
- else
- domhandler_1.DomHandler.relativePosition(this.overlay, this.containerViewChild.nativeElement);
- };
- SplitButton.prototype.appendOverlay = function () {
- if (this.appendTo) {
- if (this.appendTo === 'body')
- document.body.appendChild(this.overlay);
- else
- domhandler_1.DomHandler.appendChild(this.overlay, this.appendTo);
- this.overlay.style.minWidth = domhandler_1.DomHandler.getWidth(this.el.nativeElement.children[0]) + 'px';
- }
- };
- SplitButton.prototype.restoreOverlayAppend = function () {
- if (this.overlay && this.appendTo) {
- this.el.nativeElement.appendChild(this.overlay);
- }
- };
- SplitButton.prototype.bindDocumentClickListener = function () {
- var _this = this;
- if (!this.documentClickListener) {
- this.documentClickListener = this.renderer.listen('document', 'click', function () {
- if (_this.dropdownClick) {
- _this.dropdownClick = false;
- }
- else {
- _this.overlayVisible = false;
- _this.unbindDocumentClickListener();
- _this.cd.markForCheck();
- }
- });
- }
- };
- SplitButton.prototype.unbindDocumentClickListener = function () {
- if (this.documentClickListener) {
- this.documentClickListener();
- this.documentClickListener = null;
- }
- };
- SplitButton.prototype.bindDocumentResizeListener = function () {
- this.documentResizeListener = this.onWindowResize.bind(this);
- window.addEventListener('resize', this.documentResizeListener);
- };
- SplitButton.prototype.unbindDocumentResizeListener = function () {
- if (this.documentResizeListener) {
- window.removeEventListener('resize', this.documentResizeListener);
- this.documentResizeListener = null;
- }
- };
- SplitButton.prototype.onWindowResize = function () {
- this.overlayVisible = false;
- };
- SplitButton.prototype.onOverlayHide = function () {
- this.unbindDocumentClickListener();
- this.unbindDocumentResizeListener();
- this.overlay = null;
- };
- SplitButton.prototype.ngOnDestroy = function () {
- this.restoreOverlayAppend();
- this.onOverlayHide();
- };
- __decorate([
- core_1.Input(),
- __metadata("design:type", Array)
- ], SplitButton.prototype, "model", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], SplitButton.prototype, "icon", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], SplitButton.prototype, "iconPos", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], SplitButton.prototype, "label", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], SplitButton.prototype, "onClick", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], SplitButton.prototype, "onDropdownClick", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], SplitButton.prototype, "style", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], SplitButton.prototype, "styleClass", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], SplitButton.prototype, "menuStyle", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], SplitButton.prototype, "menuStyleClass", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], SplitButton.prototype, "disabled", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Number)
- ], SplitButton.prototype, "tabindex", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], SplitButton.prototype, "appendTo", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], SplitButton.prototype, "dir", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], SplitButton.prototype, "showTransitionOptions", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], SplitButton.prototype, "hideTransitionOptions", void 0);
- __decorate([
- core_1.ViewChild('container', { static: false }),
- __metadata("design:type", core_1.ElementRef)
- ], SplitButton.prototype, "containerViewChild", void 0);
- __decorate([
- core_1.ViewChild('defaultbtn', { static: false }),
- __metadata("design:type", core_1.ElementRef)
- ], SplitButton.prototype, "buttonViewChild", void 0);
- SplitButton = __decorate([
- core_1.Component({
- selector: 'p-splitButton',
- template: "\n <div #container [ngClass]=\"{'ui-splitbutton ui-buttonset ui-widget':true,'ui-state-disabled':disabled}\" [ngStyle]=\"style\" [class]=\"styleClass\">\n <button #defaultbtn type=\"button\" pButton [icon]=\"icon\" [iconPos]=\"iconPos\" [label]=\"label\" [cornerStyleClass]=\"dir === 'rtl' ? 'ui-corner-right': 'ui-corner-left'\" (click)=\"onDefaultButtonClick($event)\" [disabled]=\"disabled\" [attr.tabindex]=\"tabindex\">\n </button><button type=\"button\" pButton class=\"ui-splitbutton-menubutton\" icon=\"pi pi-chevron-down\" [cornerStyleClass]=\"dir === 'rtl' ? 'ui-corner-left': 'ui-corner-right'\" (click)=\"onDropdownButtonClick($event)\" [disabled]=\"disabled\"></button>\n <div #overlay [ngClass]=\"'ui-menu ui-menu-dynamic ui-widget ui-widget-content ui-corner-all ui-helper-clearfix ui-shadow'\" *ngIf=\"overlayVisible\"\n [ngStyle]=\"menuStyle\" [class]=\"menuStyleClass\"\n [@overlayAnimation]=\"{value: 'visible', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}\" (@overlayAnimation.start)=\"onOverlayAnimationStart($event)\">\n <ul class=\"ui-menu-list ui-helper-reset\">\n <ng-template ngFor let-item [ngForOf]=\"model\">\n <li class=\"ui-menuitem ui-widget ui-corner-all\" role=\"menuitem\" *ngIf=\"item.visible !== false\">\n <a *ngIf=\"!item.routerLink\" [attr.href]=\"item.url\" class=\"ui-menuitem-link ui-corner-all\" [attr.target]=\"item.target\"\n [ngClass]=\"{'ui-state-disabled':item.disabled}\" (click)=\"itemClick($event, item)\">\n <span [ngClass]=\"'ui-menuitem-icon'\" [class]=\"item.icon\" *ngIf=\"item.icon\"></span>\n <span class=\"ui-menuitem-text\">{{item.label}}</span>\n </a>\n <a *ngIf=\"item.routerLink\" [routerLink]=\"item.routerLink\" [queryParams]=\"item.queryParams\"\n class=\"ui-menuitem-link ui-corner-all\" [attr.target]=\"item.target\" [ngClass]=\"{'ui-state-disabled':item.disabled}\" (click)=\"itemClick($event, item)\">\n <span [ngClass]=\"'ui-menuitem-icon'\" [class]=\"item.icon\" *ngIf=\"item.icon\"></span>\n <span class=\"ui-menuitem-text\">{{item.label}}</span>\n </a>\n </li>\n </ng-template>\n </ul>\n </div>\n </div>\n ",
- animations: [
- animations_1.trigger('overlayAnimation', [
- animations_1.state('void', animations_1.style({
- transform: 'translateY(5%)',
- opacity: 0
- })),
- animations_1.state('visible', animations_1.style({
- transform: 'translateY(0)',
- opacity: 1
- })),
- animations_1.transition('void => visible', animations_1.animate('{{showTransitionParams}}')),
- animations_1.transition('visible => void', animations_1.animate('{{hideTransitionParams}}'))
- ])
- ]
- }),
- __metadata("design:paramtypes", [core_1.ElementRef, core_1.Renderer2, router_1.Router, core_1.ChangeDetectorRef])
- ], SplitButton);
- return SplitButton;
- }());
- exports.SplitButton = SplitButton;
- var SplitButtonModule = /** @class */ (function () {
- function SplitButtonModule() {
- }
- SplitButtonModule = __decorate([
- core_1.NgModule({
- imports: [common_1.CommonModule, button_1.ButtonModule, router_2.RouterModule],
- exports: [SplitButton, button_1.ButtonModule, router_2.RouterModule],
- declarations: [SplitButton]
- })
- ], SplitButtonModule);
- return SplitButtonModule;
- }());
- exports.SplitButtonModule = SplitButtonModule;
- //# sourceMappingURL=splitbutton.js.map
|