From 550757a186f2738a12617aab404f52e120da0e8b Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sun, 15 Oct 2017 13:20:18 +0200 Subject: [PATCH] Bug: Prevent dragdrop on back node --- src/js/dial.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/js/dial.js b/src/js/dial.js index 4820b93..ef41db3 100644 --- a/src/js/dial.js +++ b/src/js/dial.js @@ -258,13 +258,25 @@ dial.initGrid = function(){ link.onmousedown = function(){ dial._selectedItem = this; }; function dragstart_handler(ev) { + if(!ev.target.Node){ + ev.preventDefault(); + return; + } var index = (dial.page - 1) * (app.settings.grid.rows * app.settings.grid.columns) + +(ev.target.parentElement.getAttribute('gridindex')); if(app.settings.grid.backNode && dial.path != '/') index -= dial.page; ev.dataTransfer.setData("text/plain", index); - } - function dragover_handler(ev) { + } + function dragover_handler(ev) { ev.preventDefault(); - ev.dataTransfer.dropEffect = "move" + if(app.settings.grid.backNode && dial.path != '/'){ + var gridIndex = 0; + if(ev.target.tagName == 'DIV') gridIndex = +(ev.target.parentElement.parentElement.getAttribute('gridindex')); + else gridIndex = +(ev.target.getAttribute('gridindex')); + if(gridIndex==0) ev.dataTransfer.dropEffect = "none"; + else ev.dataTransfer.dropEffect = "move"; + } else { + ev.dataTransfer.dropEffect = "move"; + } } function drop_handler(ev) { ev.preventDefault();