From 0697584108efa2db2f06b3405c5cf2746f21c33c Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Sat, 24 May 2014 20:15:31 +1000 Subject: [PATCH] Fixes bug where droppable colour sticks --- .../cms/assets/js/october.dragcomponents.js | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/modules/cms/assets/js/october.dragcomponents.js b/modules/cms/assets/js/october.dragcomponents.js index 3ce08936b..9a773c9b4 100644 --- a/modules/cms/assets/js/october.dragcomponents.js +++ b/modules/cms/assets/js/october.dragcomponents.js @@ -167,26 +167,18 @@ } function finishDrag() { - - // Dragged back to original position - if (collision($clone, $el)) { - // Do nothing - } // Dragged to the code editor - else if (collision($clone, $editorArea)) { - + if (collision($clone, $editorArea)) { // Add the component to the page $el.click() // Can only attach to page or layouts - if (!$componentList.length || !$editor) - return - - // Inject {% component %} tag - var alias = $('input[name="component_aliases[]"]', $el).val() - $editor.insert("{% component '" + alias + "' %}") + if ($componentList.length && $editor) { + // Inject {% component %} tag + var alias = $('input[name="component_aliases[]"]', $el).val() + $editor.insert("{% component '" + alias + "' %}") + } } - // Dragged to the component list else if (collision($clone, $componentList)) { // Add the component to the page @@ -197,6 +189,10 @@ $editor.removeAllListeners('mousemove') $editor.blur() } + + if ($componentList.length) { + $componentList.removeClass('droppable') + } } function collision($div1, $div2) {