'use strict';

var baseComponent = require('../base-component.js');

class Button extends baseComponent.BaseComponent {
  // #region fields
  icon;
  click;
  component;
  // #endregion
  // #region constructors
  constructor(element, options) {
    super(element, options);
    this.options.icon = element.dataset.icon;
    this.options.fillMode = element.dataset.fillMode;
    this.component = new kendo.ui.Button(element, this.options);
    this._initCommand();
  }
  // #endregion
  // #region methods
  _initCommand() {
    if (!this.options.command) {
      return;
    }
    const command = this.options.command;
    this.component.setOptions({
      click: (event) => {
        event.preventDefault();
        command.exec();
      }
    });
    $(command).on("enabledChanged", (event, newState) => {
      this.component.enable(newState);
    });
  }
  // #endregion
}

exports.Button = Button;
