diff options
Diffstat (limited to 'addons/web_editor')
| -rw-r--r-- | addons/web_editor/static/src/js/snippets.editor.js | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js index ef033dc07f3..cd03cb70f6a 100644 --- a/addons/web_editor/static/src/js/snippets.editor.js +++ b/addons/web_editor/static/src/js/snippets.editor.js @@ -620,7 +620,7 @@ var BuildingBlock = Widget.extend({ animation.start(true, $target); self.call_for_all_snippets($target, function (editor, $snippet) { - editor.drop_and_build_snippet(); + _.defer(function () { editor.drop_and_build_snippet(); }); }); self.create_snippet_editor($target); self.cover_target($target.data('overlay'), $target); @@ -640,12 +640,10 @@ var BuildingBlock = Widget.extend({ var self = this; $snippet.add(globalSelector.all($snippet)).each(function () { var $snippet = $(this); - setTimeout(function () { - self.create_snippet_editor($snippet); - if ($snippet.data("snippet-editor")) { - callback.call(self, $snippet.data("snippet-editor"), $snippet); - } - }); + self.create_snippet_editor($snippet); + if ($snippet.data("snippet-editor")) { + callback.call(self, $snippet.data("snippet-editor"), $snippet); + } }); }, @@ -918,17 +916,25 @@ var Editor = Class.extend({ }, _drag_and_drop_stop: function () { var self = this; - var $dropzone = this.$target.prev(); - var prev = $dropzone.length && $dropzone[0].previousSibling; + + $(".oe_drop_zone").droppable('destroy').remove(); + + var prev = this.$target.first()[0].previousSibling; var next = this.$target.last()[0].nextSibling; var $parent = this.$target.parent(); - $(".oe_drop_clone").after(this.$target); + var $clone = $(".oe_drop_clone"); + if (prev === $clone[0]) { + prev = $clone[0].previousSibling; + } else if (next === $clone[0]) { + next = $clone[0].nextSibling; + } + $clone.after(this.$target); this.$overlay.removeClass("hidden"); $("body").removeClass('move-important'); - $('.oe_drop_zone').droppable('destroy').remove(); - $(".oe_drop_clone, .oe_drop_to_remove").remove(); + $clone.remove(); + $(".oe_drop_to_remove").remove(); if (this.dropped) { this.buildingBlock.parent.rte.historyRecordUndo(this.$target); |
