summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2016-03-25 09:36:46 +0100
committerNicolas Lempereur <nle@odoo.com>2016-03-25 11:39:57 +0100
commit85eda0c55f8fc8623c7eb1e09bdd2b3fd709eafd (patch)
tree194709552310f3d17b1bbf15261278dbaef0244c
parent62792a8ff644254048ed3304f11be8dcd52ef692 (diff)
[FIX] web_editor: two editor and image bar buttons
Some image functionalities of the inline summernote would only take the first of multiple editor into account when selecting the targeted image of an image button action (image size, image padding, ...). This commit select the appropriate editor given the current editable. closes #11474 opw-668861
-rw-r--r--addons/web_editor/static/src/js/rte.summernote.js17
1 files changed, 9 insertions, 8 deletions
diff --git a/addons/web_editor/static/src/js/rte.summernote.js b/addons/web_editor/static/src/js/rte.summernote.js
index 094d13340dc..65c9df7fce7 100644
--- a/addons/web_editor/static/src/js/rte.summernote.js
+++ b/addons/web_editor/static/src/js/rte.summernote.js
@@ -295,11 +295,12 @@ eventHandler.modules.handle.update = function ($handle, oStyle, isAirMode) {
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/* hack for image and link editor */
-function getImgTarget () {
- return $(".note-control-selection").data('target');
+function getImgTarget ($editable) {
+ var $handle = $editable ? dom.makeLayoutInfo($editable).handle() : undefined;
+ return $(".note-control-selection", $handle).data('target');
}
eventHandler.modules.editor.padding = function ($editable, sValue) {
- var $target = $(getImgTarget());
+ var $target = $(getImgTarget($editable));
var paddings = "small medium large xl".split(/\s+/);
$editable.data('NoteHistory').recordUndo();
if (sValue.length) {
@@ -309,16 +310,16 @@ eventHandler.modules.editor.padding = function ($editable, sValue) {
$target.removeClass("padding-" + paddings.join(" padding-"));
};
eventHandler.modules.editor.resize = function ($editable, sValue) {
- var $target = $(getImgTarget());
+ var $target = $(getImgTarget($editable));
$editable.data('NoteHistory').recordUndo();
var width = ($target.attr('style') || '').match(/(^|;|\s)width:\s*([0-9]+)%/);
if (width) {
width = width[2]/100;
}
- $(getImgTarget()).css('width', width != sValue ? (sValue * 100) + '%' : '');
+ $target.css('width', width != sValue ? (sValue * 100) + '%' : '');
};
eventHandler.modules.editor.resizefa = function ($editable, sValue) {
- var $target = $(getImgTarget());
+ var $target = $(getImgTarget($editable));
$editable.data('NoteHistory').recordUndo();
$target.attr('class', $target.attr('class').replace(/\s*fa-[0-9]+x/g, ''));
if (+sValue > 1) {
@@ -326,7 +327,7 @@ eventHandler.modules.editor.resizefa = function ($editable, sValue) {
}
};
eventHandler.modules.editor.floatMe = function ($editable, sValue) {
- var $target = $(getImgTarget());
+ var $target = $(getImgTarget($editable));
$editable.data('NoteHistory').recordUndo();
switch (sValue) {
case 'center': $target.toggleClass('center-block').removeClass('pull-right pull-left'); break;
@@ -335,7 +336,7 @@ eventHandler.modules.editor.floatMe = function ($editable, sValue) {
}
};
eventHandler.modules.editor.imageShape = function ($editable, sValue) {
- var $target = $(getImgTarget());
+ var $target = $(getImgTarget($editable));
$editable.data('NoteHistory').recordUndo();
$target.toggleClass(sValue);
};