Fixes bug where droppable colour sticks

This commit is contained in:
Sam Georges 2014-05-24 20:15:31 +10:00
parent da7515e230
commit 0697584108
1 changed files with 10 additions and 14 deletions

View File

@ -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) {