// Generated by CoffeeScript 1.4.0
(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() {
      this.dom = $$("<div>\n</div>");
      return this.childContainer = this.dom;
    };

    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 this.dom = $$("<span class=\"control label " + this.properties.style + "\">" + 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() {
      var _this = this;
      this.dom = $("<div class=\"control tooltip " + this.properties.style + "\">\n    <div class=\"container\" title=\"\"></div>\n</div>");
      this.dom.find('.container').tooltip({
        content: function() {
          return "<div class=\"control tooltip body\">\n    <div>\n        " + _this.properties.text + "\n    </div>\n    <div>\n    </div>\n</div>";
        },
        position: {
          my: "left-15 bottom",
          at: "center top"
        }
      });
      return this.childContainer = this.dom.find('.container');
    };

    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 this.dom = $$("<div class=\"control icon style-" + 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,
        _this = this;
      icon = _make_icon(this.properties.icon);
      this.dom = $("<a href=\"#\" class=\"control button style-" + this.properties.style + "\">" + icon + " " + this.properties.text + "</a>");
      return this.dom.click(function(e) {
        if (!_this.properties.warning || confirm(_this.properties.warning)) {
          if (_this.event('click')) {
            return _this.cancel(e);
          }
        }
      });
    };

    return button;

  })(window.Control);

  window.Controls.list = (function(_super) {

    __extends(list, _super);

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

    list.prototype.createDom = function() {
      this.dom = $$("<div class=\"control container list\">\n</div>");
      return this.childContainer = this.dom;
    };

    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() {
      var _this = this;
      this.dom = $("<div class=\"control container listitem\">\n</div>");
      this.childContainer = this.dom;
      return this.dom.click(function(e) {
        if (_this.event('click')) {
          return _this.cancel(e);
        }
      });
    };

    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);
      this.dom = $$("<div class=\"control progressbar " + this.properties.style + "\" style=\"width: " + w + "\">\n    <div class=\"fill\">\n        <div class=\"tip\"></div>\n    </div>\n</div>");
      this.setProgress(this.properties.value);
      return this.childContainer = this.dom;
    };

    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);
