summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/website.snippets.editor.js
diff options
context:
space:
mode:
authorDharmraj Jhala <dja@openerp.com>2017-06-01 17:36:13 +0200
committerqsm-odoo <qsm@odoo.com>2017-06-02 10:26:24 +0200
commita33ec972abf1cadbae2a6a04f759617c82f2a95e (patch)
tree431c12fab5809348fb426ac0914cd460287cdad8 /addons/website/static/src/js/website.snippets.editor.js
parent29ac4004cfd7b197982e7412f08cb1b5178e7d89 (diff)
[FIX] web_editor, website: allow to detect indirect clones
When cloning a snippet section thanks to the editor, the associated snippet options' `on_clone` methods are called. Now these methods receive a new argument `options`. The option this commit introduces is the `isCurrent` one. It allows the method to know if the snippet section it is associated to is the one that was cloned or if it is a child of the one that was cloned. This is useful to solve a known bug when cloning elements which have bootstrap columns: - When one column is cloned we want it to lose its col-*-offset-* classes so that the offset is not duplicated (only the column). - When a container with column children is cloned we do not want these column' offsets to be removed (we want the whole cloned container to be the same).
Diffstat (limited to 'addons/website/static/src/js/website.snippets.editor.js')
-rw-r--r--addons/website/static/src/js/website.snippets.editor.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js
index 083ed195905..8c872928be4 100644
--- a/addons/website/static/src/js/website.snippets.editor.js
+++ b/addons/website/static/src/js/website.snippets.editor.js
@@ -265,9 +265,13 @@ options.registry["margin-x"] = options.registry.marginAndResize.extend({
return this.grid;
},
- on_clone: function ($clone) {
- var _class = $clone.attr("class").replace(/\s*(col-lg-offset-|col-md-offset-)([0-9-]+)/g, '');
- $clone.attr("class", _class);
+ on_clone: function ($clone, options) {
+ // Below condition is added to remove offset of target element only
+ // and not its children to avoid design alteration of a container / block.
+ if (options.isCurrent) {
+ var _class = $clone.attr("class").replace(/\s*(col-lg-offset-|col-md-offset-)([0-9-]+)/g, '');
+ $clone.attr("class", _class);
+ }
return false;
},
on_resize: function (compass, beginClass, current) {