summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/snippets.editor.js
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2016-09-12 17:02:04 +0200
committerqsm-odoo <qsm@odoo.com>2016-09-13 13:18:17 +0200
commit965d5a42fda26c256ac96b5ee9556956b0e5a22d (patch)
tree07f04ab747b175d63a64a87c2c9d2dc09c050abf /addons/web_editor/static/src/js/snippets.editor.js
parent5e9ebcfb01f3250833a543154d072d6c785c9330 (diff)
[FIX] web_editor: allow to drop a snippet where its movement began
Before this commit, if we dragged a snippet and dropped it where we began the drag, the snippet was removed.
Diffstat (limited to 'addons/web_editor/static/src/js/snippets.editor.js')
-rw-r--r--addons/web_editor/static/src/js/snippets.editor.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js
index 043163802dc..a76ee437210 100644
--- a/addons/web_editor/static/src/js/snippets.editor.js
+++ b/addons/web_editor/static/src/js/snippets.editor.js
@@ -959,17 +959,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);