From ff9ae691d55846bd282fa49b7b46d940f4ed0d55 Mon Sep 17 00:00:00 2001 From: "chm@openerp.com" <> Date: Wed, 23 Apr 2014 11:59:01 +0200 Subject: [PATCH] [FIX] website: snippet editor: speed up save view (construct only option with clean_for_save method); fix carousel arrow bzr revid: chm@openerp.com-20140423095901-q945d4593uet41xy --- .../static/src/js/website.snippets.editor.js | 48 +++++++------------ 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js index bae014029e1..0177e8b8b64 100644 --- a/addons/website/static/src/js/website.snippets.editor.js +++ b/addons/website/static/src/js/website.snippets.editor.js @@ -130,6 +130,7 @@ */ + var dummy = function () {}; var website = openerp.website; website.add_template_file('/website/static/src/xml/website.snippets.xml'); @@ -161,7 +162,6 @@ return this._super.apply(this, arguments); }, save: function () { - website.snippet.clean_for_save = true; this.snippets.clean_for_save(); this._super(); }, @@ -362,15 +362,21 @@ }, clean_for_save: function () { var self = this; - $(website.snippet.globalSelector).each(function () { - var $snippet = $(this); - self.make_active($snippet); - self.make_active(false); - var editor = $snippet.data("snippet-editor"); - if (editor) { - editor.clean_for_save(); + + $("*[contentEditable], *[attributeEditable]") + .removeAttr('contentEditable') + .removeAttr('attributeEditable'); + + var options = website.snippet.options; + var template = website.snippet.templateOptions; + for (var k in options) { + if (template[k] && options[k].prototype.clean_for_save !== dummy) { + var $snippet = this.dom_filter(template[k].selector); + $snippet.each(function () { + new options[k](self, null, $(this), k).clean_for_save(); + }); } - }); + } }, make_active: function ($snippet) { if ($snippet && this.$active_snipped_id && this.$active_snipped_id.get(0) === $snippet.get(0)) { @@ -854,8 +860,7 @@ } }, - clean_for_save: function () { - } + clean_for_save: dummy }); website.snippet.options.background = website.snippet.Option.extend({ @@ -943,8 +948,7 @@ this.id = this.unique_id(); this.$target.attr("id", this.id); this.$target.find("[data-slide]").attr("data-cke-saved-href", "#" + this.id); - this.$target.find("[data-slide-to]").attr("data-target", "#" + this.id); - + this.$target.find("[data-target]").attr("data-target", "#" + this.id); this.rebind_event(); }, on_clone: function ($clone) { @@ -964,7 +968,7 @@ }, clean_for_save: function () { this._super(); - this.$target.find(".item").removeClass("next prev left right"); + $(".carousel").find(".item").removeClass("next prev left right active"); if(!this.$target.find(".item.active").length) { this.$target.find(".item:first").addClass("active"); } @@ -1519,9 +1523,6 @@ }); }, onFocus : function () { - // don't open media editor before clean for save - if (website.snippet.clean_for_save) return; - var self = this; if (this.$target.parent().data("oe-field") === "image") { this.$overlay.addClass("hidden"); @@ -1761,19 +1762,6 @@ } this.$overlay.removeClass('oe_active'); }, - - /* clean_for_save - * function called just before save vue - */ - clean_for_save: function () { - for (var i in this.styles){ - this.styles[i].clean_for_save(); - } - this.$target.removeAttr('contentEditable') - .find('*').removeAttr('contentEditable'); - this.$target.removeAttr('attributeEditable') - .find('*').removeAttr('attributeEditable'); - }, }); })();