lib/assets/jzip/rich/cms/editor.js in rich_cms-1.0.0 vs lib/assets/jzip/rich/cms/editor.js in rich_cms-2.0.0
- old
+ new
@@ -1,34 +1,36 @@
Rich.Cms.Editor = (function() {
- var edit_panel = "#rich_cms_bar .panel .edit",
- content_class = "rich_cms_content",
- mark_class = "marked",
- editable_content = {},
- content_items = "";
+ var content_class = "rich_cms_content", mark_class = "marked", edit_panel = "#rich_cms_panel",
+ editable_content = {}, content_items = "";
var register = function(hash) {
$.extend(editable_content, hash);
content_items = $.keys(editable_content).join(",");
};
- var editHandler = function(event) {
- edit($(this));
- event.preventDefault();
- };
-
var bind = function() {
- $("#rich_cms_bar .menu a.mark" ).bind("click", mark );
- $(edit_panel + " a.close" ).bind("click", function() { $(edit_panel).hide(); });
- $("." + content_class + "." + mark_class).live("click", editHandler );
+ $("#rich_cms_panel .edit a.close").bind("click", function(event) {
+ event.preventDefault();
+ RaccoonTip.close();
+ });
+
+ RaccoonTip.register("." + content_class + "." + mark_class, "#rich_cms_panel", {beforeShow: edit, afterHide : function(content) { content.hide(); }});
+ bindSeatHolders();
+
+ $.registerAjaxFormHandler({
+ "rich_cms_content": afterUpdate
+ });
};
var bindSeatHolders = function() {
- $(content_items + "." + mark_class + ".sh_hint").bind("focus", editHandler);
+ RaccoonTip.register("." + content_class + "." + mark_class + ".sh_hint", "#rich_cms_panel", {event: "focus", beforeShow: edit, afterHide : function(content) { content.hide(); }});
};
var mark = function(event) {
+ event.preventDefault();
+
$(content_items).addClass(content_class).toggleClass(mark_class);
var markedContentItems = $(content_items + "." + mark_class);
if (markedContentItems.length) {
$.each(markedContentItems, function() {
@@ -40,26 +42,24 @@
bindSeatHolders();
} else {
$(content_items + ".block").removeClass("block");
$(edit_panel).hide();
}
-
- event.preventDefault();
};
- var edit = function(content_item) {
- var label = $("#rich_cms_bar .edit label");
- var inputs = $("#rich_cms_bar .edit form fieldset.inputs");
+ var edit = function() {
+ var content_item = $(this);
+ var label = $("#rich_cms_panel .edit form fieldset.inputs label");
+ var inputs = $("#rich_cms_panel .edit form fieldset.inputs");
+
+ var text = content_item.is("textarea") || content_item.hasClass("block");
+ var attrs = content_item.get(0).attributes;
- var text = content_item.is("textarea") || content_item.hasClass("block");
- var attrs = content_item.get(0).attributes;
-
- var match = $.grep($.makeArray(editable_content), function(hash) {
- return content_item.is($.keys(hash)[0]);
- })[0];
- var selector = $.keys(match)[0];
- var specs = $.values(match)[0];
+ var selector = $.grep($.keys(editable_content), function(s) {
+ return content_item.is(s);
+ })[0];
+ var specs = editable_content[selector];
label.html($.map(specs.keys, function(key) { return content_item.attr(key); }).join(", "));
inputs.find(":input").remove();
inputs.append("<input name='content_item[__selector__]' type='hidden' value='" + selector + "'/>");
@@ -107,12 +107,10 @@
};
return {
init: function() {
bind();
- $.registerAjaxFormHandler({
- "rich_cms_content": afterUpdate
- });
},
- register: register
+ register: register,
+ mark: mark
};
}());