var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = Object.prototype.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; }; Annotator.Editor = (function(_super) { __extends(Editor, _super); Editor.prototype.events = { "form submit": "submit", ".annotator-save click": "submit", ".annotator-cancel click": "hide", ".annotator-cancel mouseover": "onCancelButtonMouseover", "textarea keydown": "processKeypress" }; Editor.prototype.classes = { hide: 'annotator-hide', focus: 'annotator-focus' }; Editor.prototype.html = "
\n
\n \n \n
\n
"; Editor.prototype.options = {}; function Editor(options) { this.onCancelButtonMouseover = __bind(this.onCancelButtonMouseover, this); this.processKeypress = __bind(this.processKeypress, this); this.submit = __bind(this.submit, this); this.load = __bind(this.load, this); this.hide = __bind(this.hide, this); this.show = __bind(this.show, this); Editor.__super__.constructor.call(this, $(this.html)[0], options); this.fields = []; this.annotation = {}; } Editor.prototype.show = function(event) { util.preventEventDefault(event); this.element.removeClass(this.classes.hide); this.element.find('.annotator-save').addClass(this.classes.focus); this.checkOrientation(); this.element.find(":input:first").focus(); this.setupDraggables(); return this.publish('show'); }; Editor.prototype.hide = function(event) { util.preventEventDefault(event); this.element.addClass(this.classes.hide); return this.publish('hide'); }; Editor.prototype.load = function(annotation) { var field, _i, _len, _ref; this.annotation = annotation; this.publish('load', [this.annotation]); _ref = this.fields; for (_i = 0, _len = _ref.length; _i < _len; _i++) { field = _ref[_i]; field.load(field.element, this.annotation); } return this.show(); }; Editor.prototype.submit = function(event) { var field, _i, _len, _ref; util.preventEventDefault(event); _ref = this.fields; for (_i = 0, _len = _ref.length; _i < _len; _i++) { field = _ref[_i]; field.submit(field.element, this.annotation); } this.publish('save', [this.annotation]); return this.hide(); }; Editor.prototype.addField = function(options) { var element, field, input; field = $.extend({ id: 'annotator-field-' + util.uuid(), type: 'input', label: '', load: function() {}, submit: function() {} }, options); input = null; element = $('
  • '); field.element = element[0]; switch (field.type) { case 'textarea': input = $('