From a33ec972abf1cadbae2a6a04f759617c82f2a95e Mon Sep 17 00:00:00 2001 From: Dharmraj Jhala Date: Thu, 1 Jun 2017 17:36:13 +0200 Subject: [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). --- addons/web_editor/static/src/js/snippets.editor.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'addons/web_editor/static/src/js/snippets.editor.js') diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js index 42f2103f95f..59f523126d9 100644 --- a/addons/web_editor/static/src/js/snippets.editor.js +++ b/addons/web_editor/static/src/js/snippets.editor.js @@ -1010,7 +1010,9 @@ data.Editor = Class.extend({ this.$target.after($clone); this.buildingBlock.call_for_all_snippets($clone, function (editor, $snippet) { for (var i in editor.styles) { - editor.styles[i].on_clone($snippet); + editor.styles[i].on_clone($snippet, { + isCurrent: ($snippet.is($clone)), + }); } }); return false; -- cgit v1.2.3