test/dummy/tmp/cache/assets/development/sprockets/f270587a206c85bb7163b16529b5ff69 in rubber_ring-0.1.2 vs test/dummy/tmp/cache/assets/development/sprockets/f270587a206c85bb7163b16529b5ff69 in rubber_ring-1.0.0
- old
+ new
@@ -1,69 +1,115 @@
{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+TpjQI"length; TiêI"digest; TI"%42698a9a3d1a588f0817287b5402d93f; FI"source; TI"ê(function() {
- this.PersistenceManager = (function() {
- PersistenceManager.prototype.content = null;
+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); }; };
- PersistenceManager.prototype.save_path = null;
-
- PersistenceManager.prototype.remove_path = null;
-
- PersistenceManager.prototype.remove_image_path = null;
-
+ this.PersistenceManager = (function() {
PersistenceManager.prototype.post_object = {
page_controller: App.controller,
page_action: App.action,
- page_path: document.location.pathname
+ page_path: document.location.pathname,
+ page_locale: App.locale
};
- function PersistenceManager() {
- this.save_path = App.save_path;
- this.remove_path = App.remove_path;
- this.remove_image_path = App.remove_image_path;
+ 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, path, tag, value;
+ var key, value;
- tag = content.context.localName;
key = content.attr("data-cms");
- value = content.html().trim().replace(/[\r\n]/g, '');
- if (tag === 'img') {
- value = content.attr("src");
+ if (content.is('input')) {
+ value = content.val();
+ } else {
+ value = this.sanitize(content);
}
this.post_object.content = {};
this.post_object.content[key] = value;
- path = this.save_path;
- console.log("Sending CMS content to server...");
- console.log(this.post_object);
- return this.post_to_backend(path, this.post_object);
+ 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");
- console.log("Removing of key %s content", key);
- path = this.remove_path.replace(':key', key);
- this.post_object.key_to_remove = key;
+ path = App.remove_path.replace(':key', key);
return this.post_to_backend(path, this.post_object);
};
PersistenceManager.prototype.remove_image = function(src) {
- console.log("Removing image with src = %s", src);
this.post_object.src_to_remove = src;
- return this.post_to_backend(this.remove_image_path, this.post_object);
+ return this.post_to_backend(App.remove_attachment_path, this.post_object);
};
PersistenceManager.prototype.post_to_backend = function(path, post_object) {
- return $.post(path, post_object, function(data) {
- return console.log(data);
+ 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"%c392f84d89e4fb81c6a4d3afe5a3715d; FI"
_version; TI"%35f7b60363742cb867c4c7f8a36022b9; F
+; TI"required_assets_digest; TI"%a36a9c1ab05781b705383a5538974670; FI"
_version; TI"%2cf3622cbba861b85d33ffabfa420c13; F
\ No newline at end of file