{I" class:ETI"ProcessedAsset;FI"logical_path;TI"'rubber_ring/persistence_manager.js;FI" pathname;TI"h/home/vagrant/development/rubber_ring/app/assets/javascripts/rubber_ring/persistence_manager.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+v …QI" length;Tix I" digest;TI"%9b05927d8597cf2c34514f88de08b7b4;FI" source;TI"x (function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; this.PersistenceManager = (function() { PersistenceManager.prototype.save_path = null; PersistenceManager.prototype.remove_path = null; PersistenceManager.prototype.save_image_path = null; PersistenceManager.prototype.save_attachment_path = null; PersistenceManager.prototype.remove_attachment_path = null; PersistenceManager.prototype.$alert = null; PersistenceManager.prototype.post_object = { page_controller: App.controller, page_action: App.action, page_path: document.location.pathname }; function PersistenceManager(action_btns) { var _this = this; this.action_btns = action_btns; this.post_to_backend = __bind(this.post_to_backend, this); this.save_path = App.save_path; this.save_image_path = App.save_image_path; this.save_attachment_path = App.save_attachment_path; this.remove_path = App.remove_path; this.remove_attachment_path = App.remove_attachment_path; this.$alert = $(".alert-saved div"); this.$alert.bind('transitionend webkitTransitionEnd', function() { return _this.$alert.removeClass("show"); }); } PersistenceManager.prototype.save = function(content) { var key, value; key = content.attr("data-cms"); if (content.is('input')) { value = content.val(); } else { value = this.sanitize(content); } this.post_object.content = {}; this.post_object.content[key] = value; return this.post_to_backend(this.save_path, this.post_object); }; PersistenceManager.prototype.save_image = function(content) { var key; key = content.attr("data-cms"); this.post_object.content = {}; this.post_object.content[key] = content.attr("src"); this.post_object.width = content.attr("width"); this.post_object.height = content.attr("height"); return this.post_to_backend(this.save_image_path, this.post_object); }; PersistenceManager.prototype.save_attachment = function(content) { var key; key = content.attr("data-cms"); this.post_object.content = {}; this.post_object.content[key] = content.attr("href"); return this.post_to_backend(this.save_attachment_path, this.post_object); }; PersistenceManager.prototype.sanitize = function(content) { var key, value, _ref; content = content.html().trim().replace(/^[ \t\r\n]+/g, ''); _ref = this.action_btns; for (key in _ref) { value = _ref[key]; content = content.replace(value, '').trim(); } return content; }; PersistenceManager.prototype.remove = function(content) { var key, path; key = content.attr("data-cms"); path = this.remove_path.replace(':key', key); return this.post_to_backend(path, this.post_object); }; PersistenceManager.prototype.remove_image = function(src) { this.post_object.src_to_remove = src; return this.post_to_backend(this.remove_attachment_path, this.post_object); }; PersistenceManager.prototype.post_to_backend = function(path, post_object) { var _this = this; return $.post(path, post_object, function() { return _this.$alert.addClass("show"); }); }; return PersistenceManager; })(); }).call(this); ;TI"dependency_digest;TI"%50c6d363439f26e26a84360c0e4a63ea;FI"required_paths;T[I"h/home/vagrant/development/rubber_ring/app/assets/javascripts/rubber_ring/persistence_manager.coffee;FI"dependency_paths;T[{I" path;TI"h/home/vagrant/development/rubber_ring/app/assets/javascripts/rubber_ring/persistence_manager.coffee;FI" mtime;TI"2013-05-04T15:21:58+02:00;TI" digest;TI"%af57f097f179a0a66f7010edd7a63237;FI" _version;TI"%1e2632a10b8c877576b37720d5bf8883;F