{I" class:ETI"BundledAsset;FI"logical_path;TI"type_station/lib/models.js;FI" pathname;TI"H/workspace/app/assets/javascripts/type_station/lib/models.js.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+ÜçsWI" length;Tim I" digest;TI"%a5ef248d1c8076487ed30eda9727eb17;FI" source;TI"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); ;TI"required_assets_digest;TI"%5b08d1bd883f6ced4686153b307cd3c7;FI" _version;TI"%64e62ddc273c2f5847f30d698ca14b67;F