I"m (function() { var extend = 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; }, hasProp = {}.hasOwnProperty; this.TypeStation.Store = (function() { function Store(id) { this.id = id != null ? id : null; this.STORE = {}; } Store.prototype.get = function(key) { return this.STORE[key]; }; Store.prototype.set = function(key, value) { return this.STORE[key] = value; }; Store.prototype.each = function(callback) { var key, ref, results, value; ref = this.STORE; results = []; for (key in ref) { value = ref[key]; results.push(typeof callback === "function" ? callback(key, value) : void 0); } return results; }; return Store; })(); this.TypeStation.Model = (function(superClass) { extend(Model, superClass); function Model(id) { this.id = id != null ? id : null; Model.__super__.constructor.apply(this, arguments); this.DIRTY = {}; } Model.prototype.set = function(key, value) { Model.__super__.set.call(this, key, value); return this.DIRTY[key] = 1; }; Model.prototype.changedKeys = function() { return Object.keys(this.DIRTY); }; Model.prototype.isChanged = function() { return this.changedKeys().length > 0; }; Model.prototype._reset = function() { this.STORE = {}; return this.DIRTY = {}; }; Model.prototype.save = function(callback) { var data, key, ref, self, value; if (callback == null) { callback = function() {}; } self = this; data = []; ref = this.STORE; for (key in ref) { value = ref[key]; data.push(value); } return $.ajax({ type: "PATCH", url: self.id, dataType: 'json', contentType: 'application/json', data: JSON.stringify({ contents: data }), success: function(data) { self._reset(); return callback(data); }, error: function(jqxhr, status, err) { return vex.dialog.alert({ message: (window.titleize(status)) + ": " + jqxhr.responseJSON.message, buttons: [ $.extend({}, vex.dialog.buttons.YES, { text: 'Close' }) ] }); } }); }; return Model; })(this.TypeStation.Store); }).call(this); :ET