summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/website.editor.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/website/static/src/js/website.editor.js')
-rw-r--r--addons/website/static/src/js/website.editor.js34
1 files changed, 31 insertions, 3 deletions
diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js
index c50ad392887..b5caac71d74 100644
--- a/addons/website/static/src/js/website.editor.js
+++ b/addons/website/static/src/js/website.editor.js
@@ -104,6 +104,7 @@
left: $el.width() / 2 + image_left - $btn.outerWidth() / 2,
});
}).on('mouseleave', 'img', function (e) {
+ if (!previousSelection) { return; }
var $previous = $(previousSelection.$);
var $button = $previous.next('button');
$button.css('visibility', 'hidden');
@@ -1370,6 +1371,11 @@
// a/@href, ...)
_(mutations).chain()
.filter(function (m) {
+ // ignore any change related to mundane image-edit-button
+ if (m.target && m.target.className
+ && m.target.className.indexOf('image-edit-button') !== -1) {
+ return false;
+ }
switch(m.type) {
case 'attributes': // ignore .cke_focus being added or removed
// if attribute is not a class, can't be .cke_focus change
@@ -1383,8 +1389,11 @@
// ignore mutation if the *only* change is .cke_focus
return change.length !== 1 || change[0] === 'cke_focus';
case 'childList':
- // <br type="_moz"> appears when focusing RTE in FF, ignore
- return m.addedNodes.length !== 1 || m.addedNodes[0].nodeName !== 'BR';
+ // Remove ignorable nodes from addedNodes or removedNodes,
+ // if either set remains non-empty it's considered to be an
+ // impactful change. Otherwise it's ignored.
+ return !!remove_mundane_nodes(m.addedNodes).length ||
+ !!remove_mundane_nodes(m.removedNodes).length;
default:
return true;
}
@@ -1394,11 +1403,30 @@
while (node && !$(node).hasClass('oe_editable')) {
node = node.parentNode;
}
- $(m.target).trigger('node_changed');
return node;
})
.compact()
.uniq()
.each(function (node) { $(node).trigger('content_changed'); })
});
+ function remove_mundane_nodes(nodes) {
+ if (!nodes || !nodes.length) { return []; }
+
+ var output = [];
+ for(var i=0; i<nodes.length; ++i) {
+ var node = nodes[i];
+ if (node.nodeName === 'BR' && node.getAttribute('type') === '_moz') {
+ // <br type="_moz"> appears when focusing RTE in FF, ignore
+ continue;
+ }
+ if (node.className.indexOf('image-edit-button') !== -1) {
+ // [Edit] button added and removed on image hover, don't count
+ // as making parent node dirty
+ continue;
+ }
+
+ output.push(node);
+ }
+ return output;
+ }
})();