{I"
class:ETI"ProcessedAsset; FI"logical_path; TI"rubber_ring/editor.js; FI"
pathname; TI"\/Users/zigomir/development/rubber_ring/app/assets/javascripts/rubber_ring/editor.coffee; FI"content_type; TI"application/javascript; TI"
mtime; Tl+U£ŸQI"length; Ti‘I"digest; TI"%aabd4989a624d0d992b94de68068f7eb; FI"source; TI"‘(function() {
$(function() {
var $alert, $editable_content, config, duplicates, getCaretCharacterOffsetWithin, le, pm, te, util;
config = {
action_btns: {
reset_btn: '',
reset_img: ''
}
};
$editable_content = $("[contenteditable]");
$alert = $(".alert-saved div");
util = new Util();
duplicates = util.find_duplicated_keys($('[data-cms]'));
if (duplicates.length > 0) {
alert("Correct key duplicates: '" + duplicates + "'");
}
pm = new PersistenceManager(config.action_btns, $alert);
te = new TemplateEditor(pm, util);
te.init();
te.init_sortable();
le = new LinkEditor($editable_content);
le.init();
$("[contenteditable]").append(config.action_btns.reset_btn);
$("img[data-cms]").after(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;
});
$editable_content.change(function(e) {
var $content;
$content = $(e.currentTarget);
return pm.save($content);
});
$editable_content.not(".multi-line").keydown(function(e) {
if (e.keyCode === 13) {
return e.preventDefault();
}
});
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 $("[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;
}
});
});
}).call(this);
; TI"dependency_digest; TI"%8c57b327919a4aed59e52662dc679871; FI"required_paths; T[I"\/Users/zigomir/development/rubber_ring/app/assets/javascripts/rubber_ring/editor.coffee; FI"dependency_paths; T[{I" path; TI"\/Users/zigomir/development/rubber_ring/app/assets/javascripts/rubber_ring/editor.coffee; FI"
mtime; TI"2013-05-24T19:28:53+02:00; TI"digest; TI"%275c0a22f7ecf896049cd2df65d26e19; FI"
_version; TI"%1e2632a10b8c877576b37720d5bf8883; F