text: "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 Button = (function () {
      function Button(el, domHandler) {
          this.el = el;
          this.domHandler = domHandler;
          this.iconPos = 'left';
          this.cornerStyleClass = 'ui-corner-all';
      }
      Button.prototype.ngAfterViewInit = function () {
          this.domHandler.addMultipleClasses(this.el.nativeElement, this.getStyleClass());
          if (this.icon) {
              var iconElement = document.createElement("span");
              var iconPosClass = (this.iconPos == 'right') ? 'ui-button-icon-right' : 'ui-button-icon-left';
              iconElement.className = iconPosClass + ' ui-clickable fa fa-fw ' + 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;
      };
      Button.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 {
              styleClass = styleClass + ' ui-button-text-only';
          }
          return styleClass;
      };
      Object.defineProperty(Button.prototype, "label", {
          get: function () {
              return this._label;
          },
          set: function (val) {
              this._label = val;
              if (this.initialized) {
                  this.domHandler.findSingle(this.el.nativeElement, '.ui-button-text').textContent = this._label;
              }
          },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(Button.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';
                  this.domHandler.findSingle(this.el.nativeElement, '.fa').className = iconPosClass + ' ui-clifa fa-fw ' + this.icon;
              }
          },
          enumerable: true,
          configurable: true
      });
      Button.prototype.ngOnDestroy = function () {
          while (this.el.nativeElement.hasChildNodes()) {
              this.el.nativeElement.removeChild(this.el.nativeElement.lastChild);
          }
          this.initialized = false;
      };
      return Button;
  }());
  __decorate([
      core_1.Input(),
      __metadata("design:type", String)
  ], Button.prototype, "iconPos", void 0);
  __decorate([
      core_1.Input(),
      __metadata("design:type", String)
  ], Button.prototype, "cornerStyleClass", void 0);
  __decorate([
      core_1.Input(),
      __metadata("design:type", String),
      __metadata("design:paramtypes", [String])
  ], Button.prototype, "label", null);
  __decorate([
      core_1.Input(),
      __metadata("design:type", String),
      __metadata("design:paramtypes", [String])
  ], Button.prototype, "icon", null);
  Button = __decorate([
      core_1.Directive({
          selector: '[pButton]',
          providers: [domhandler_1.DomHandler]
      }),
      __metadata("design:paramtypes", [core_1.ElementRef, domhandler_1.DomHandler])
  ], Button);
  exports.Button = Button;
  var ButtonModule = (function () {
      function ButtonModule() {
      }
      return ButtonModule;
  }());
  ButtonModule = __decorate([
      core_1.NgModule({
          imports: [common_1.CommonModule],
          exports: [Button],
          declarations: [Button]
      })
  ], ButtonModule);
  exports.ButtonModule = ButtonModule;
  //# sourceMappingURL=button.js.map