summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2016-09-14 11:58:45 +0200
committerChristophe Simonis <chs@odoo.com>2016-09-14 11:58:45 +0200
commit19b4f5efe4ee69f0fcd73ebe80f6347b30681354 (patch)
treef8c7cf10fcf11bb03512b0e31358c53325fc381d /addons/web_editor/static/src/js
parent4e7981f7ac65d464b49a874b55cc293122559d23 (diff)
parentfa7430c157a095d2a779245cefa704e63f2ffde1 (diff)
[MERGE] forward port branch saas-10 up to fa7430c
Diffstat (limited to 'addons/web_editor/static/src/js')
-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 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);