| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- "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 domhandler_1 = require("../dom/domhandler");
- var common_1 = require("@angular/common");
- var ButtonDirective = /** @class */ (function () {
- function ButtonDirective(el) {
- this.el = el;
- this.iconPos = 'left';
- this.cornerStyleClass = 'ui-corner-all';
- }
- ButtonDirective.prototype.ngAfterViewInit = function () {
- domhandler_1.DomHandler.addMultipleClasses(this.el.nativeElement, this.getStyleClass());
- if (this.icon) {
- var iconElement = document.createElement("span");
- iconElement.setAttribute("aria-hidden", "true");
- var iconPosClass = (this.iconPos == 'right') ? 'ui-button-icon-right' : 'ui-button-icon-left';
- iconElement.className = iconPosClass + ' ui-clickable ' + this.icon;
- this.el.nativeElement.appendChild(iconElement);
- }
- var labelElement = document.createElement("span");
- labelElement.className = 'ui-button-text ui-clickable';
- labelElement.appendChild(document.createTextNode(this.label || 'ui-btn'));
- this.el.nativeElement.appendChild(labelElement);
- this.initialized = true;
- };
- ButtonDirective.prototype.getStyleClass = function () {
- var styleClass = 'ui-button ui-widget ui-state-default ' + this.cornerStyleClass;
- if (this.icon) {
- if (this.label != null && this.label != undefined) {
- if (this.iconPos == 'left')
- styleClass = styleClass + ' ui-button-text-icon-left';
- else
- styleClass = styleClass + ' ui-button-text-icon-right';
- }
- else {
- styleClass = styleClass + ' ui-button-icon-only';
- }
- }
- else {
- if (this.label) {
- styleClass = styleClass + ' ui-button-text-only';
- }
- else {
- styleClass = styleClass + ' ui-button-text-empty';
- }
- }
- return styleClass;
- };
- Object.defineProperty(ButtonDirective.prototype, "label", {
- get: function () {
- return this._label;
- },
- set: function (val) {
- this._label = val;
- if (this.initialized) {
- domhandler_1.DomHandler.findSingle(this.el.nativeElement, '.ui-button-text').textContent = this._label;
- if (!this.icon) {
- if (this._label) {
- domhandler_1.DomHandler.removeClass(this.el.nativeElement, 'ui-button-text-empty');
- domhandler_1.DomHandler.addClass(this.el.nativeElement, 'ui-button-text-only');
- }
- else {
- domhandler_1.DomHandler.addClass(this.el.nativeElement, 'ui-button-text-empty');
- domhandler_1.DomHandler.removeClass(this.el.nativeElement, 'ui-button-text-only');
- }
- }
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ButtonDirective.prototype, "icon", {
- get: function () {
- return this._icon;
- },
- set: function (val) {
- this._icon = val;
- if (this.initialized) {
- var iconPosClass = (this.iconPos == 'right') ? 'ui-button-icon-right' : 'ui-button-icon-left';
- domhandler_1.DomHandler.findSingle(this.el.nativeElement, '.ui-clickable').className =
- iconPosClass + ' ui-clickable ' + this.icon;
- }
- },
- enumerable: true,
- configurable: true
- });
- ButtonDirective.prototype.ngOnDestroy = function () {
- while (this.el.nativeElement.hasChildNodes()) {
- this.el.nativeElement.removeChild(this.el.nativeElement.lastChild);
- }
- this.initialized = false;
- };
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], ButtonDirective.prototype, "iconPos", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], ButtonDirective.prototype, "cornerStyleClass", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String),
- __metadata("design:paramtypes", [String])
- ], ButtonDirective.prototype, "label", null);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String),
- __metadata("design:paramtypes", [String])
- ], ButtonDirective.prototype, "icon", null);
- ButtonDirective = __decorate([
- core_1.Directive({
- selector: '[pButton]'
- }),
- __metadata("design:paramtypes", [core_1.ElementRef])
- ], ButtonDirective);
- return ButtonDirective;
- }());
- exports.ButtonDirective = ButtonDirective;
- var Button = /** @class */ (function () {
- function Button() {
- this.iconPos = 'left';
- this.onClick = new core_1.EventEmitter();
- this.onFocus = new core_1.EventEmitter();
- this.onBlur = new core_1.EventEmitter();
- }
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Button.prototype, "type", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Button.prototype, "iconPos", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Button.prototype, "icon", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Button.prototype, "label", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Button.prototype, "disabled", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], Button.prototype, "style", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Button.prototype, "styleClass", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], Button.prototype, "onClick", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], Button.prototype, "onFocus", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], Button.prototype, "onBlur", void 0);
- Button = __decorate([
- core_1.Component({
- selector: 'p-button',
- template: "\n <button [attr.type]=\"type\" [class]=\"styleClass\" [ngStyle]=\"style\" [disabled]=\"disabled\"\n [ngClass]=\"{'ui-button ui-widget ui-state-default ui-corner-all':true,\n 'ui-button-icon-only': (icon && !label),\n 'ui-button-text-icon-left': (icon && label && iconPos === 'left'),\n 'ui-button-text-icon-right': (icon && label && iconPos === 'right'),\n 'ui-button-text-only': (!icon && label),\n 'ui-button-text-empty': (!icon && !label),\n 'ui-state-disabled': disabled}\"\n (click)=\"onClick.emit($event)\" (focus)=\"onFocus.emit($event)\" (blur)=\"onBlur.emit($event)\">\n <ng-content></ng-content>\n <span [ngClass]=\"{'ui-clickable': true,\n 'ui-button-icon-left': (iconPos === 'left'), \n 'ui-button-icon-right': (iconPos === 'right')}\"\n [class]=\"icon\" *ngIf=\"icon\"></span>\n <span class=\"ui-button-text ui-clickable\">{{label||'ui-btn'}}</span>\n </button>\n "
- })
- ], Button);
- return Button;
- }());
- exports.Button = Button;
- var ButtonModule = /** @class */ (function () {
- function ButtonModule() {
- }
- ButtonModule = __decorate([
- core_1.NgModule({
- imports: [common_1.CommonModule],
- exports: [ButtonDirective, Button],
- declarations: [ButtonDirective, Button]
- })
- ], ButtonModule);
- return ButtonModule;
- }());
- exports.ButtonModule = ButtonModule;
- //# sourceMappingURL=button.js.map
|