{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+^-ËQI" length;TiJI" digest;TI"%d8ba7d7b1b1f89c4b5a2b992fbe22ef7;FI" source;TI"J(function() { $(function() { var duplicates, getCaretCharacterOffsetWithin, le, pm, te, util; 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; $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; $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()); return $this; }).on("blur", "[contenteditable]", function() { var $this; $this = $(this); if ($this.data("before") !== $this.html()) { $this.data("before", $this.html()); $this.trigger("change"); } return $this; }); $("[contenteditable]").change(function(e) { var $content; $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; if (e.which === 13) { lineBreak = "
"; end = $(this).text().length === getCaretCharacterOffsetWithin(this); if (end) { this.insertAdjacentHTML("beforeend", lineBreak); } else { document.execCommand("insertHTML", false, lineBreak); } return false; } }); }; getCaretCharacterOffsetWithin = function(element) { var caretOffset, preCaretRange, preCaretTextRange, range, textRange; 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"%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