summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/snippets.editor.js30
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 020c93cdc17..66789ef635e 100644
--- a/addons/web_editor/static/src/js/snippets.editor.js
+++ b/addons/web_editor/static/src/js/snippets.editor.js
@@ -596,7 +596,7 @@ data.Class = 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);
@@ -616,12 +616,10 @@ data.Class = Widget.extend({
var self = this;
$snippet.add(data.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 @@ data.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.getParent().rte.historyRecordUndo(this.$target);