// Generated by CoffeeScript 1.7.1
(function() {
  var __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

  window._make_icon = function(icon) {
    if (icon) {
      return "<i class=\"icon-" + icon + "\"></i>";
    } else {
      return "";
    }
  };

  window.Controls["default"] = (function(_super) {
    __extends(_default, _super);

    function _default() {
      return _default.__super__.constructor.apply(this, arguments);
    }

    _default.prototype.createDom = function() {
      return "<div >\n    <children>\n</div>";
    };

    return _default;

  })(window.Control);

  window.Controls.label = (function(_super) {
    __extends(label, _super);

    function label() {
      return label.__super__.constructor.apply(this, arguments);
    }

    label.prototype.createDom = function() {
      return "<span class=\"control label " + (this.s(this.properties.style)) + "\">" + (this.s(this.properties.text)) + "</span>";
    };

    return label;

  })(window.Control);

  window.Controls.tooltip = (function(_super) {
    __extends(tooltip, _super);

    function tooltip() {
      return tooltip.__super__.constructor.apply(this, arguments);
    }

    tooltip.prototype.createDom = function() {
      return "<div class=\"control tooltip " + (this.s(this.properties.style)) + "\">\n    <div class=\"container\" title=\"\">\n        <children>\n    </div>\n</div>";
    };

    tooltip.prototype.setupDom = function(dom) {
      tooltip.__super__.setupDom.call(this, dom);
      return jQuery(this.dom).children('.container').tooltip({
        content: (function(_this) {
          return function() {
            return "<div class=\"control tooltip body\">\n    <div>\n        " + (_this.s(_this.properties.text)) + "\n    </div>\n    <div>\n    </div>\n</div>";
          };
        })(this),
        position: {
          my: "left-15 bottom",
          at: "center top"
        }
      });
    };

    return tooltip;

  })(window.Control);

  window.Controls.icon = (function(_super) {
    __extends(icon, _super);

    function icon() {
      return icon.__super__.constructor.apply(this, arguments);
    }

    icon.prototype.createDom = function() {
      var icon;
      icon = _make_icon(this.properties.icon);
      return "<div class=\"control icon style-" + (this.s(this.properties.style)) + "\">" + icon + "</div>";
    };

    return icon;

  })(window.Control);

  window.Controls.button = (function(_super) {
    __extends(button, _super);

    function button() {
      return button.__super__.constructor.apply(this, arguments);
    }

    button.prototype.createDom = function() {
      var icon;
      icon = _make_icon(this.properties.icon);
      return "<a href=\"#\" class=\"control button style-" + (this.s(this.properties.style)) + "\">" + icon + " " + (this.s(this.properties.text)) + "</a>";
    };

    button.prototype.setupDom = function(dom) {
      button.__super__.setupDom.call(this, dom);
      this.dom.addEventListener('click', (function(_this) {
        return function(e) {
          if (!_this.properties.warning || confirm(_this.properties.warning)) {
            if (_this.event('click')) {
              return _this.cancel(e);
            }
          }
        };
      })(this));
      return this;
    };

    return button;

  })(window.Control);

  window.Controls.togglebutton = (function(_super) {
    __extends(togglebutton, _super);

    function togglebutton() {
      return togglebutton.__super__.constructor.apply(this, arguments);
    }

    togglebutton.prototype.createDom = function() {
      var icon;
      icon = _make_icon(this.properties.icon);
      return "<a href=\"#\" class=\"control button style-" + (this.s(this.properties.style)) + " " + (this.properties.pressed ? 'pressed' : '') + "\">" + icon + " " + (this.s(this.properties.text)) + "</a>";
    };

    togglebutton.prototype.setupDom = function(dom) {
      togglebutton.__super__.setupDom.call(this, dom);
      return $(this.dom).click((function(_this) {
        return function(e) {
          if (_this.event('click')) {
            return _this.cancel(e);
          }
        };
      })(this));
    };

    return togglebutton;

  })(window.Control);

  window.Controls.list = (function(_super) {
    __extends(list, _super);

    function list() {
      return list.__super__.constructor.apply(this, arguments);
    }

    list.prototype.createDom = function() {
      return "<div class=\"control container list __child-container\">\n    <children>\n</div>";
    };

    return list;

  })(window.Control);

  window.Controls.listitem = (function(_super) {
    __extends(listitem, _super);

    function listitem() {
      return listitem.__super__.constructor.apply(this, arguments);
    }

    listitem.prototype.createDom = function() {
      return "<div class=\"control container listitem __child-container\">\n    <children>\n</div>";
    };

    listitem.prototype.setupDom = function(dom) {
      listitem.__super__.setupDom.call(this, dom);
      $(this.dom).click((function(_this) {
        return function(e) {
          if (_this.event('click')) {
            return _this.cancel(e);
          }
        };
      })(this));
      return this;
    };

    return listitem;

  })(window.Control);

  window.Controls.progressbar = (function(_super) {
    __extends(progressbar, _super);

    function progressbar() {
      return progressbar.__super__.constructor.apply(this, arguments);
    }

    progressbar.prototype.createDom = function() {
      var w;
      w = this._int_to_px(this.properties.width);
      return "<div class=\"control progressbar " + (this.s(this.properties.style)) + "\" style=\"width: " + w + "\">\n    <div class=\"fill\">\n        <div class=\"tip\"></div>\n    </div>\n</div>";
    };

    progressbar.prototype.setupDom = function(dom) {
      progressbar.__super__.setupDom.call(this, dom);
      return this.setProgress(this.properties.value);
    };

    progressbar.prototype.setProgress = function(p) {
      var pw;
      pw = this._int_to_px(Math.round(this.properties.width * p));
      return $(this.dom).find('.fill').css({
        width: pw
      });
    };

    return progressbar;

  })(window.Control);

}).call(this);
