test/dummy/tmp/cache/assets/development/sprockets/65a5689d2de3f83bcc1531b0bd7918ce in polyblock-0.0.7 vs test/dummy/tmp/cache/assets/development/sprockets/65a5689d2de3f83bcc1531b0bd7918ce in polyblock-0.1.2

- old
+ new

@@ -1,8 +1,8 @@ {I" class:ETI"BundledAsset;FI"logical_path;TI"polyblock/polyblock.js;FI" pathname;TI"i/Applications/XAMPP/xamppfiles/htdocs/polyblock/app/assets/javascripts/polyblock/polyblock.js.coffee;FI"content_type;TI"application/javascript;TI" -mtime;Tl+Þ™›RI" length;Ti¦"I" digest;TI"%0434c1906ebe15a3deba628874b09ca3;FI" source;TI"¦"(function() { +mtime;Tl+$íµRI" length;TiÌ$I" digest;TI"%e1e59b64ca2cd2d984a4c8158e57cc3e;FI" source;TI"Ì$(function() { var unsavedChanges; CKEDITOR.disableAutoInline = true; unsavedChanges = false; @@ -12,258 +12,259 @@ return "Are you sure you want to leave this page? Your unsaved changes will not be stored!"; } }; $(function() { - var blockclones, blocks, changeChecker, changeText, convertFromTextarea, convertToTextarea, currentMode, editorModeOff, editorModeOn, indicator, initialBodyPadding, previousMode, revertChanges, saveChanges, showSavedChanges, showUnsavedChanges, startListening, stopListening, verbose; - blocks = $(".polyblock[contenteditable='true']"); - if (!blocks.length) { - return; - } - blockclones = {}; - blocks.each(function() { - var id; - id = $(this).attr('id'); - blockclones[id] = $(this).clone(); - return CKEDITOR.inline(id, { - on: { - focus: function(e) { - editorModeOn(); - return startListening(id); - }, - blur: function(e) { - return stopListening(); - }, - keyup: function(e) { - return alert("changed!"); - } + return $(document).ready(function() { + var blockclones, blocks, changeChecker, changeText, convertFromTextarea, convertToTextarea, currentMode, editorModeOff, editorModeOn, indicator, initialBodyPadding, previousMode, revertChanges, saveChanges, showSavedChanges, showUnsavedChanges, startListening, stopListening, verbose; + blocks = $(".polyblock[contenteditable='true']"); + if (!blocks.length) { + return; + } + blockclones = {}; + blocks.each(function() { + var id; + id = $(this).attr('id'); + blockclones[id] = $(this).clone(); + if (!_.contains(_.keys(CKEDITOR.instances), id)) { + return CKEDITOR.inline(id, { + on: { + focus: function(e) { + editorModeOn(); + return startListening(id); + }, + blur: function(e) { + return stopListening(); + } + } + }); } }); - }); - verbose = false; - changeChecker = null; - indicator = $('.pb-change-indicator'); - changeText = $('.pb-change-text'); - startListening = function(which) { - var buffer; - stopListening(); - if (verbose) { - console.log("I'm listening..."); - } - buffer = CKEDITOR.instances[which].getData(); - return changeChecker = setInterval(function() { - var reading; + verbose = true; + changeChecker = null; + indicator = $('.pb-change-indicator'); + changeText = $('.pb-change-text'); + startListening = function(which) { + var buffer; + stopListening(); if (verbose) { - console.log("Checking for changes..."); + console.log("I'm listening..."); } - reading = CKEDITOR.instances[which].getData(); - if (reading !== buffer && !unsavedChanges) { - return showUnsavedChanges(); - } else if (reading === buffer && unsavedChanges) { - return showSavedChanges(); + buffer = CKEDITOR.instances[which].getData(); + return changeChecker = setInterval(function() { + var reading; + if (verbose) { + console.log("Checking for changes..."); + } + reading = CKEDITOR.instances[which].getData(); + if (reading !== buffer && !unsavedChanges) { + return showUnsavedChanges(); + } else if (reading === buffer && unsavedChanges) { + return showSavedChanges(); + } + }, 1000); + }; + stopListening = function() { + if (changeChecker == null) { + return; } - }, 1000); - }; - stopListening = function() { - if (changeChecker == null) { - return; - } - if (verbose) { - console.log("I'm no longer listening."); - } - clearInterval(changeChecker); - return changeChecker = null; - }; - showUnsavedChanges = function() { - indicator.transition({ - rotate: "-30deg", - color: "red" - }); - changeText.html("You have unsaved changes.").transition({ - color: "red" - }); - return unsavedChanges = true; - }; - showSavedChanges = function() { - indicator.transition({ - rotate: "0deg", - color: "green" - }); - changeText.html("All changes saved.").transition({ - color: "green" - }); - return unsavedChanges = false; - }; - initialBodyPadding = $('body').css("padding-bottom"); - editorModeOn = function(pb) { - return $('#pb_bar').show("slide", { - direction: "down" - }, 250, function() { - $('body').css("padding-bottom", $("#pb_bar").height() + 20); - return typeof pb === "function" ? pb() : void 0; - }); - }; - editorModeOff = function(pb) { - return $('#pb_bar').hide("slide", { - direction: "down" - }, 250, function() { - $('body').css("padding-bottom", initialBodyPadding); - return typeof pb === "function" ? pb() : void 0; - }); - }; - saveChanges = function() { - var pbs; - showSavedChanges(); - pbs = _.object(_.map(blocks, function(b) { - return $(b).data("pbid"); - }), _.map(blocks, function(b) { - return $(b).html(); - })); - return $.post("/polyblock/update", { - pbs: pbs - }, function(data) { - return editorModeOff(function() { - return alertify.success("Your changes have been saved."); + if (verbose) { + console.log("I'm no longer listening."); + } + clearInterval(changeChecker); + return changeChecker = null; + }; + showUnsavedChanges = function() { + indicator.transition({ + rotate: "-30deg", + color: "red" }); - }); - }; - revertChanges = function(pb) { - if (!confirm("Are you sure you want to discard your changes?")) { - return; - } - return editorModeOff(function() { - blocks.each(function() { - return $(this).replaceWith(blockclones[$(this).attr("id")]); + changeText.html("You have unsaved changes.").transition({ + color: "red" }); - return alertify.success("Your changes have been discarded."); - }); - }; - currentMode = previousMode = "WYSIWYG"; - convertToTextarea = function(block, content, tab) { - var previous_textarea, replaceIt, tabchars, textarea, - _this = this; - if (content == null) { - content = null; - } - if (tab == null) { - tab = "\t"; - } - tabchars = tab.replace(/\\/, "").length; - previous_textarea = $("textarea[data-pbid=" + (block.attr("data-pbid")) + "]"); - if (content == null) { - content = previous_textarea.is("*") ? previous_textarea.val() : block.html(); - } - textarea = $('<textarea />').addClass("form-control").attr("data-pbid", block.attr("data-pbid")).val(content).css({ - "font-family": 'Monaco, Menlo, Consolas, "Courier New", monospace' - }).on("keydown", function(e) { - var end, keycode, start; - keycode = e.keyCode || e.which; - if (!(keycode === 9 || keycode === 8 || keycode === 46)) { + return unsavedChanges = true; + }; + showSavedChanges = function() { + indicator.transition({ + rotate: "0deg", + color: "green" + }); + changeText.html("All changes saved.").transition({ + color: "green" + }); + return unsavedChanges = false; + }; + initialBodyPadding = $('body').css("padding-bottom"); + editorModeOn = function(pb) { + return $('#pb_bar').show("slide", { + direction: "down" + }, 250, function() { + $('body').css("padding-bottom", $("#pb_bar").height() + 20); + return typeof pb === "function" ? pb() : void 0; + }); + }; + editorModeOff = function(pb) { + return $('#pb_bar').hide("slide", { + direction: "down" + }, 250, function() { + $('body').css("padding-bottom", initialBodyPadding); + return typeof pb === "function" ? pb() : void 0; + }); + }; + saveChanges = function() { + var pbs; + showSavedChanges(); + pbs = _.object(_.map(blocks, function(b) { + return $(b).data("pbid"); + }), _.map(blocks, function(b) { + return $(b).html(); + })); + return $.post("/polyblock/update", { + pbs: pbs + }, function(data) { + return editorModeOff(function() { + return alertify.success("Your changes have been saved."); + }); + }); + }; + revertChanges = function(pb) { + if (!confirm("Are you sure you want to discard your changes?")) { return; } - start = $(this).get(0).selectionStart; - end = $(this).get(0).selectionEnd; - if (keycode === 9) { - e.preventDefault(); - $(this).val("" + ($(this).val().substring(0, start)) + tab + ($(this).val().substring(end))); - return $(this).get(0).selectionStart = $(this).get(0).selectionEnd = start + tabchars; - } else if (keycode === 8) { - if (!(currentMode === "HAML" && $(this).val().substring(start - tabchars, start) === tab)) { + return editorModeOff(function() { + blocks.each(function() { + return $(this).replaceWith(blockclones[$(this).attr("id")]); + }); + return alertify.success("Your changes have been discarded."); + }); + }; + currentMode = previousMode = "WYSIWYG"; + convertToTextarea = function(block, content, tab) { + var previous_textarea, replaceIt, tabchars, textarea, + _this = this; + if (content == null) { + content = null; + } + if (tab == null) { + tab = "\t"; + } + tabchars = tab.replace(/\\/, "").length; + previous_textarea = $("textarea[data-pbid=" + (block.attr("data-pbid")) + "]"); + if (content == null) { + content = previous_textarea.is("*") ? previous_textarea.val() : block.html(); + } + textarea = $('<textarea />').addClass("form-control").attr("data-pbid", block.attr("data-pbid")).val(content).css({ + "font-family": 'Monaco, Menlo, Consolas, "Courier New", monospace' + }).on("keydown", function(e) { + var end, keycode, start; + keycode = e.keyCode || e.which; + if (!(keycode === 9 || keycode === 8 || keycode === 46)) { return; } - e.preventDefault(); - $(this).val("" + ($(this).val().substring(0, start - tabchars)) + ($(this).val().substring(end))); - return $(this).get(0).selectionStart = $(this).get(0).selectionEnd = start - tabchars; - } else if (keycode === 46) { - if (!(currentMode === "HAML" && $(this).val().substring(start, start + tabchars) === tab)) { - return; + start = $(this).get(0).selectionStart; + end = $(this).get(0).selectionEnd; + if (keycode === 9) { + e.preventDefault(); + $(this).val("" + ($(this).val().substring(0, start)) + tab + ($(this).val().substring(end))); + return $(this).get(0).selectionStart = $(this).get(0).selectionEnd = start + tabchars; + } else if (keycode === 8) { + if (!(currentMode === "HAML" && $(this).val().substring(start - tabchars, start) === tab)) { + return; + } + e.preventDefault(); + $(this).val("" + ($(this).val().substring(0, start - tabchars)) + ($(this).val().substring(end))); + return $(this).get(0).selectionStart = $(this).get(0).selectionEnd = start - tabchars; + } else if (keycode === 46) { + if (!(currentMode === "HAML" && $(this).val().substring(start, start + tabchars) === tab)) { + return; + } + e.preventDefault(); + $(this).val("" + ($(this).val().substring(0, start)) + ($(this).val().substring(end + tabchars))); + return $(this).get(0).selectionStart = $(this).get(0).selectionEnd = start; } - e.preventDefault(); - $(this).val("" + ($(this).val().substring(0, start)) + ($(this).val().substring(end + tabchars))); - return $(this).get(0).selectionStart = $(this).get(0).selectionEnd = start; - } - }); - replaceIt = function(html) { - if (!previous_textarea.is("*")) { - block.replaceWith(textarea); + }); + replaceIt = function(html) { + if (!previous_textarea.is("*")) { + block.replaceWith(textarea); + } else { + previous_textarea.replaceWith(textarea); + } + return textarea.autosize().focus(); + }; + if (previousMode !== "HAML") { + return replaceIt(content); } else { - previous_textarea.replaceWith(textarea); + return $.post("/convert_haml_to_html", { + haml: content + }, function(data) { + return replaceIt(data); + }); } - return textarea.autosize().focus(); }; - if (previousMode !== "HAML") { - return replaceIt(content); - } else { - return $.post("/convert_haml_to_html", { - haml: content - }, function(data) { - return replaceIt(data); - }); - } - }; - convertFromTextarea = function(block) { - var replaceIt, textarea, - _this = this; - textarea = $("textarea[data-pbid=" + (block.attr("data-pbid")) + "]"); - replaceIt = function(html) { - console.log("Replacing with html: " + html); - textarea.replaceWith(block); - return block.html(html); - }; - if (previousMode !== "HAML") { - return replaceIt(textarea.text()); - } else { - return $.post("/convert_haml_to_html", { - haml: textarea.val() - }, function(data) { - return replaceIt(data); - }); - } - }; - $('#pb_bar_format_buttons button').click(function(e) { - var changeModes, - _this = this; - e.preventDefault(); - if ($(this).hasClass("active")) { - return; - } - previousMode = currentMode; - currentMode = $(this).html(); - changeModes = function(block) { - var content, textarea; + convertFromTextarea = function(block) { + var replaceIt, textarea, + _this = this; textarea = $("textarea[data-pbid=" + (block.attr("data-pbid")) + "]"); - content = textarea.is("*") ? textarea.val() : block.html(); - switch (currentMode) { - case "WYSIWYG": - return convertFromTextarea(block); - case "HTML": - return convertToTextarea(block, html_beautify(content)); - case "HAML": - return $.post("/convert_html_to_haml", { - html: content - }, function(data) { - return convertToTextarea(block, data, " "); - }); - case "Markdown": - return convertToTextarea(block, html_beautify(content)); + replaceIt = function(html) { + console.log("Replacing with html: " + html); + textarea.replaceWith(block); + return block.html(html); + }; + if (previousMode !== "HAML") { + return replaceIt(textarea.text()); + } else { + return $.post("/convert_haml_to_html", { + haml: textarea.val() + }, function(data) { + return replaceIt(data); + }); } }; - if (previousMode === "WYSIWYG") { - blocks = $(".polyblock[contenteditable='true']"); - } - blocks.each(function() { - return changeModes($(this)); + $('#pb_bar_format_buttons button').click(function(e) { + var changeModes, + _this = this; + e.preventDefault(); + if ($(this).hasClass("active")) { + return; + } + previousMode = currentMode; + currentMode = $(this).html(); + changeModes = function(block) { + var content, textarea; + textarea = $("textarea[data-pbid=" + (block.attr("data-pbid")) + "]"); + content = textarea.is("*") ? textarea.val() : block.html(); + switch (currentMode) { + case "WYSIWYG": + return convertFromTextarea(block); + case "HTML": + return convertToTextarea(block, html_beautify(content)); + case "HAML": + return $.post("/convert_html_to_haml", { + html: content + }, function(data) { + return convertToTextarea(block, data, " "); + }); + case "Markdown": + return convertToTextarea(block, html_beautify(content)); + } + }; + if (previousMode === "WYSIWYG") { + blocks = $(".polyblock[contenteditable='true']"); + } + blocks.each(function() { + return changeModes($(this)); + }); + return $(this).siblings().removeClass("active").end().addClass("active"); }); - return $(this).siblings().removeClass("active").end().addClass("active"); + $('#pb_bar_revert').click(function(e) { + e.preventDefault(); + return revertChanges(); + }); + return $('#pb_bar_save').click(function(e) { + e.preventDefault(); + return saveChanges(); + }); }); - $('#pb_bar_revert').click(function(e) { - e.preventDefault(); - return revertChanges(); - }); - return $('#pb_bar_save').click(function(e) { - e.preventDefault(); - return saveChanges(); - }); }); }).call(this); -;TI"required_assets_digest;TI"%6ab94ad0760586efc649776fdc98664e;FI" _version;TI"%01dc9d4cb5b0ece13ed47cc1cabfeb41;F +;TI"required_assets_digest;TI"%0f4109cc79588cfd9528a1f314992f83;FI" _version;TI"%01dc9d4cb5b0ece13ed47cc1cabfeb41;F \ No newline at end of file