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

    __extends(codearea, _super);

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

    codearea.prototype.createDom = function() {
      this.dom = $("<div class=\"control control-inset codearea\"> \n</div>");
      this.cm = CodeMirror(this.dom[0], {
        value: this.properties.value,
        mode: this.properties.mode,
        lineNumbers: true,
        matchBrackets: true
      });
      this.dom.find('>*').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);
