From 3f032f3f9737c50a113331c12edc9b39a6e30d14 Mon Sep 17 00:00:00 2001 From: "chm@openerp.com" <> Date: Mon, 5 May 2014 17:07:22 +0200 Subject: [PATCH] [FIX] website editor: background image bzr revid: chm@openerp.com-20140505150722-gwewelvu3uv6joen --- .../website/static/src/js/website.editor.js | 1 + .../static/src/js/website.snippets.editor.js | 23 +++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 2119d05f650..d7b7843de00 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -1056,6 +1056,7 @@ this.trigger("saved"); }, cancel: function () { + this.trigger("cancel"); }, close: function () { this.$el.modal('hide'); diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js index bae014029e1..51e8bc3b991 100644 --- a/addons/website/static/src/js/website.snippets.editor.js +++ b/addons/website/static/src/js/website.snippets.editor.js @@ -362,7 +362,7 @@ }, clean_for_save: function () { var self = this; - $(website.snippet.globalSelector).each(function () { + this.dom_filter(website.snippet.globalSelector).each(function () { var $snippet = $(this); self.make_active($snippet); self.make_active(false); @@ -875,20 +875,29 @@ this._super(np); if (np.$next) { if (np.$next.hasClass("oe_custom_bg")) { - var editor = new website.editor.ImageDialog(); - editor.on('start', self, function (o) {o.url = np.$prev && np.$prev.data("src") || np.$next && np.$next.data("src") || "";}); - editor.on('save', self, function (o) { - self._set_bg(o.url); - np.$next.data("src", o.url); + var $image = $(''); + $image.attr("src", np.$prev ? np.$prev.data("src") : ''); + $image.appendTo(self.$target); + + self.element = new CKEDITOR.dom.element($image[0]); + var editor = new website.editor.MediaDialog(self, self.element); + editor.appendTo(document.body); + editor.$('[href="#editor-media-video"], [href="#editor-media-icon"]').addClass('hidden'); + + $image.on('saved', self, function (o) { + var src = $image.attr("src"); + self._set_bg(src); + np.$next.data("src", src); self.$target.trigger("snippet-style-change", [self, np]); + $image.remove(); }); editor.on('cancel', self, function () { if (!np.$prev || np.$prev.data("src") === "") { self.$target.removeClass(np.$next.data("value")); self.$target.trigger("snippet-style-change", [self, np]); } + $image.remove(); }); - editor.appendTo($('body')); } else { this._set_bg(np.$next.data("src")); }