test/dummy/tmp/cache/assets/development/sprockets/1f634c9d68d6c31855bf84ecb8e9d3a1 in rubber_ring-0.1.2 vs test/dummy/tmp/cache/assets/development/sprockets/1f634c9d68d6c31855bf84ecb8e9d3a1 in rubber_ring-1.0.0

- old
+ new

@@ -1,68 +1,110 @@ {I" class:ETI"ProcessedAsset;FI"logical_path;TI"rubber_ring/editor.js;FI" pathname;TI"O/home/vagrant/rubber_ring/app/assets/javascripts/rubber_ring/editor.coffee;FI"content_type;TI"application/javascript;TI" -mtime;Tl+çQjQI" length;TiýI" digest;TI"%793df7795cd0865eed6786bbb47f3e1c;FI" source;TI"ý(function() { +mtime;Tl+^-ËQI" length;TiJI" digest;TI"%d8ba7d7b1b1f89c4b5a2b992fbe22ef7;FI" source;TI"J(function() { $(function() { - var $contentEditable, $duplicables, generate_new_group_key, pm; + var duplicates, getCaretCharacterOffsetWithin, le, pm, te, util; - pm = new PersistenceManager(); - $contentEditable = $("[contenteditable]"); - $duplicables = $(".duplicable"); - $("body").on("focus", "[contenteditable]", function() { - var $this; + util = new Util(); + duplicates = util.find_duplicated_keys($('[data-cms]')); + if (duplicates.length > 0) { + alert("Correct key duplicates: '" + duplicates + "'"); + } + pm = new PersistenceManager(App.config.action_btns, $(".alert-saved div")); + te = new TemplateEditor(pm, util); + te.init(); + te.init_sortable(); + le = new LinkEditor($("[contenteditable]")); + le.init(); + App.init = function() { + $("[contenteditable]").append(App.config.action_btns.reset_btn); + $("img[data-cms]").after(App.config.action_btns.reset_img); + $("body").on("click", ".reset-content", function(e) { + var $content_to_reset; - $this = $(this); - $this.data("before", $this.html()); - return $this; - }).on("blur", "[contenteditable]", function() { - var $this; + $content_to_reset = $(e.currentTarget).parent(); + if (window.confirm("Really want reset content?")) { + return pm.remove($content_to_reset).then(function() { + return window.location.reload(true); + }); + } + }); + $("body").on("click", ".reset-image", function(e) { + var $image_to_reset; - $this = $(this); - if ($this.data("before") !== $this.html()) { + $image_to_reset = $(e.currentTarget).prev(); + if (window.confirm("Really want reset image?")) { + return pm.remove($image_to_reset).then(function() { + return window.location.reload(true); + }); + } + }); + $(".rubber_ring_attachment").click(function(e) { + return e.preventDefault(); + }); + $("body").on("focus", "[contenteditable]", function() { + var $this; + + $this = $(this); $this.data("before", $this.html()); - $this.trigger("change"); - } - return $this; - }); - $contentEditable.change(function(e) { - var $content; + return $this; + }).on("blur", "[contenteditable]", function() { + var $this; - $content = $(e.currentTarget); - return pm.save($content); - }); - $contentEditable.not(".multi-line").keydown(function(e) { - if (e.keyCode === 13) { - return e.preventDefault(); - } - }); - $duplicables.on("dblclick", function(e) { - var $clone, $editField, new_key; + $this = $(this); + if ($this.data("before") !== $this.html()) { + $this.data("before", $this.html()); + $this.trigger("change"); + } + return $this; + }); + $("[contenteditable]").change(function(e) { + var $content; - $editField = $(e.currentTarget); - pm.save($editField); - $clone = $editField.clone(true).appendTo($editField.parent()); - new_key = generate_new_group_key($clone); - $clone.attr("data-cms", new_key); - return pm.save($clone); - }); - generate_new_group_key = function(element) { - var temp_key; + $content = $(e.currentTarget); + return pm.save($content); + }); + $("[contenteditable]").not(".multi-line").keydown(function(e) { + if (e.keyCode === 13) { + return e.preventDefault(); + } + }); + return $("[contenteditable].multi-line").keydown(function(e) { + var end, lineBreak; - temp_key = element.data("cms").split("_").reverse(); - temp_key[0] = $(".duplicable").length - 1; - return temp_key.reverse().join("_"); + if (e.which === 13) { + lineBreak = "<br />"; + end = $(this).text().length === getCaretCharacterOffsetWithin(this); + if (end) { + this.insertAdjacentHTML("beforeend", lineBreak); + } else { + document.execCommand("insertHTML", false, lineBreak); + } + return false; + } + }); }; - return $duplicables.on("mouseup", function(e) { - var $removingField; + getCaretCharacterOffsetWithin = function(element) { + var caretOffset, preCaretRange, preCaretTextRange, range, textRange; - if (e.which === 2) { - e.preventDefault(); - $removingField = $(e.currentTarget); - pm.remove($removingField); - return $removingField.remove(); + caretOffset = 0; + if (typeof window.getSelection !== "undefined") { + range = window.getSelection().getRangeAt(0); + preCaretRange = range.cloneRange(); + preCaretRange.selectNodeContents(element); + preCaretRange.setEnd(range.endContainer, range.endOffset); + caretOffset = preCaretRange.toString().length; + } else if (typeof document.selection !== "undefined" && document.selection.type !== "Control") { + textRange = document.selection.createRange(); + preCaretTextRange = document.body.createTextRange(); + preCaretTextRange.moveToElementText(element); + preCaretTextRange.setEndPoint("EndToEnd", textRange); + caretOffset = preCaretTextRange.text.length; } - }); + return caretOffset; + }; + return App.init(); }); }).call(this); -;TI"dependency_digest;TI"%64144ab0c16a14e69159038a14d6cbfa;FI"required_paths;T[I"O/home/vagrant/rubber_ring/app/assets/javascripts/rubber_ring/editor.coffee;FI"dependency_paths;T[{I" path;TI"O/home/vagrant/rubber_ring/app/assets/javascripts/rubber_ring/editor.coffee;FI" -mtime;TI"2013-04-14T08:51:19+02:00;TI" digest;TI"%a255366cb634c7ebb865c05ceca763bb;FI" _version;TI"%35f7b60363742cb867c4c7f8a36022b9;F +;TI"dependency_digest;TI"%995b005b04ac0ed508817a81f4f87bf3;FI"required_paths;T[I"O/home/vagrant/rubber_ring/app/assets/javascripts/rubber_ring/editor.coffee;FI"dependency_paths;T[{I" path;TI"O/home/vagrant/rubber_ring/app/assets/javascripts/rubber_ring/editor.coffee;FI" +mtime;TI"2013-06-26T20:05:18+02:00;TI" digest;TI"%76f14d355d8cf039a56c6b5784c52151;FI" _version;TI"%2cf3622cbba861b85d33ffabfa420c13;F \ No newline at end of file