{I" class:ETI"BundledAsset;FI"logical_path;TI"'rubber_ring/persistence_manager.js;FI" pathname;TI"\/home/vagrant/rubber_ring/app/assets/javascripts/rubber_ring/persistence_manager.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+^-ËQI" length;TibI" digest;TI"%7f211a439dbf930b71f42e2f1706af4c;FI" source;TI"b(function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; this.PersistenceManager = (function() { PersistenceManager.prototype.post_object = { page_controller: App.controller, page_action: App.action, page_path: document.location.pathname, page_locale: App.locale }; function PersistenceManager(action_btns, alert) { this.action_btns = action_btns; this.alert = alert; this.post_to_backend = __bind(this.post_to_backend, this); } 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; if (content.is("a")) { this.post_object.content["" + key + "_href"] = content.attr("href"); } return this.post_to_backend(App.save_path, this.post_object); }; PersistenceManager.prototype.save_template = function(templates) { this.post_object.content = templates; return this.post_to_backend(App.save_template_path, this.post_object); }; PersistenceManager.prototype.add_template = function(content) { this.post_object.content = content; return this.post_to_backend(App.add_template_path, this.post_object); }; PersistenceManager.prototype.remove_template = function(content) { this.post_object.content = content; return this.post_to_backend(App.remove_template_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(App.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").split('/').reverse()[0]; this.post_object.content["" + key + "_href"] = content.attr("href"); return this.post_to_backend(App.save_attachment_path, this.post_object); }; PersistenceManager.prototype.sanitize = function(content) { var key, regex, value, _ref; content = content.html().replace(/^[\s]+$/g, "").trim(); _ref = this.action_btns; for (key in _ref) { value = _ref[key]; regex = new RegExp(value, "g"); content = content.replace(regex, "").trim(); } return content; }; PersistenceManager.prototype.remove = function(content) { var key, path; key = content.attr("data-cms"); path = App.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(App.remove_attachment_path, this.post_object); }; PersistenceManager.prototype.post_to_backend = function(path, post_object) { var _this = this; return $.post(path, post_object, function() { _this.alert.addClass("animate"); return _this.alert.on("transitionend", function() { return _this.alert.removeClass("animate"); }); }); }; return PersistenceManager; })(); }).call(this); ;TI"required_assets_digest;TI"%a36a9c1ab05781b705383a5538974670;FI" _version;TI"%2cf3622cbba861b85d33ffabfa420c13;F