// 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.Controls.codearea = (function(_super) {
    __extends(codearea, _super);

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

    codearea.prototype.createDom = function() {
      return "<div class=\"control control-inset codearea\"> \n</div>";
    };

    codearea.prototype.setupDom = function(dom) {
      codearea.__super__.setupDom.call(this, dom);
      this.cm = CodeMirror(this.dom, {
        value: this.properties.value,
        mode: this.properties.mode,
        lineNumbers: true,
        matchBrackets: true
      });
      $(this.dom).children().css({
        width: this._int_to_px(this.properties.width)
      });
      $(this.dom).find('.CodeMirror-scroll').css({
        height: this._int_to_px(this.properties.height)
      });
      return setTimeout(this.cm.refresh, 1);
    };

    codearea.prototype.onBroadcast = function(msg) {
      if (msg === 'visible') {
        return setTimeout(this.cm.refresh, 1);
      }
    };

    codearea.prototype.detectUpdates = function() {
      var r, value;
      r = {};
      value = this.cm.getValue();
      if (value !== this.properties.value) {
        r.value = value;
      }
      return r;
    };

    return codearea;

  })(window.Control);

}).call(this);
