summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/snippets.options.js2
-rw-r--r--addons/web_editor/static/src/js/widgets.js22
2 files changed, 12 insertions, 12 deletions
diff --git a/addons/web_editor/static/src/js/snippets.options.js b/addons/web_editor/static/src/js/snippets.options.js
index 6d4800cd0db..4d533cadd00 100644
--- a/addons/web_editor/static/src/js/snippets.options.js
+++ b/addons/web_editor/static/src/js/snippets.options.js
@@ -609,7 +609,7 @@ odoo.define('web_editor.snippets.options', function (require) {
var _editor = new widget.MediaDialog(null, {}, null, $image[0]).open();
_editor.$('[href="#editor-media-video"], [href="#editor-media-icon"]').addClass('hidden');
- _editor.on('saved', this, function () {
+ _editor.on('save', this, function () {
var value = $image.attr("src");
this.background(type, value, $li);
this.$target.addClass("oe_custom_bg");
diff --git a/addons/web_editor/static/src/js/widgets.js b/addons/web_editor/static/src/js/widgets.js
index 00a693d40f2..7a3ab09dd76 100644
--- a/addons/web_editor/static/src/js/widgets.js
+++ b/addons/web_editor/static/src/js/widgets.js
@@ -34,11 +34,11 @@ Dialog = Dialog.extend({
self.$('input:first').focus();
});
this.on("closed", this, function () {
- this.trigger(this.destroyAction);
+ this.trigger(this.destroyAction, this.final_data || null);
});
},
save: function () {
- this.destroyAction = "saved";
+ this.destroyAction = "save";
this.close();
},
});
@@ -164,8 +164,8 @@ var MediaDialog = Dialog.extend({
},
save: function () {
if (this.options.select_images) {
- this.trigger("saved", this.active.save());
- this.close();
+ this.final_data = this.active.save();
+ this._super.apply(this, arguments);
return;
}
if(this.rte) {
@@ -198,8 +198,8 @@ var MediaDialog = Dialog.extend({
}
var media = this.active.media;
- $(document.body).trigger("media-saved", [media, self.old_media]);
- self.trigger("saved", [media, self.old_media]);
+ this.final_data = [media, self.old_media];
+ $(document.body).trigger("media-saved", this.final_data);
// Update editor bar after image edition (in case the image change to icon or other)
_.defer(function () {
@@ -312,10 +312,8 @@ var ImageDialog = Widget.extend({
},
save: function () {
if (this.options.select_images) {
- this.parent.trigger("save", this.images);
return this.images;
}
- this.parent.trigger("save", this.media);
var img = this.images[0];
if (!img) {
@@ -668,7 +666,6 @@ var fontIconsDialog = Widget.extend({
*/
save: function () {
var self = this;
- this.parent.trigger("save", this.media);
var style = this.media.attributes.style ? this.media.attributes.style.value : '';
var classes = (this.media.className||"").split(/\s+/);
var custom_classes = /^fa(-[1-5]x|spin|rotate-(9|18|27)0|flip-(horizont|vertic)al|fw|border)?$/;
@@ -684,6 +681,8 @@ var fontIconsDialog = Widget.extend({
style = style.replace(/\s*width:[^;]+/, '');
}
$(this.media).attr("class", _.compact(final_classes).join(' ')).attr("style", style);
+
+ return this.media;
},
/**
* return the data font object (with base, parser and icons) or null
@@ -907,7 +906,6 @@ var VideoDialog = Widget.extend({
return false;
},
save: function () {
- this.parent.trigger("save", this.media);
var video_id = this.$("#video_id").val();
if (!video_id) {
this.$("button.btn-primary").click();
@@ -921,6 +919,8 @@ var VideoDialog = Widget.extend({
'</div>');
$(this.media).replaceWith($iframe);
this.media = $iframe[0];
+
+ return this.media;
},
clear: function () {
if (this.media.dataset.src) {
@@ -1095,7 +1095,7 @@ var LinkDialog = Dialog.extend({
if (classes.replace(/(^|[ ])(btn-default|btn-success|btn-primary|btn-info|btn-warning|btn-danger)([ ]|$)/gi, ' ')) {
self.data.style = {'background-color': '', 'color': ''};
}
- self.trigger("save", self.data);
+ self.final_data = self.data;
}).then(_super);
},
bind_data: function () {