From c1728b9ecb7aa19b507de908fb3f4b1f538649fd Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Sat, 22 Nov 2014 16:47:09 -0500 Subject: [PATCH] fixed mouse mappings --- app/assets/javascripts/src/JIT.js | 6 +-- app/assets/javascripts/src/Metamaps.JIT.js | 57 +++++++++------------- 2 files changed, 27 insertions(+), 36 deletions(-) diff --git a/app/assets/javascripts/src/JIT.js b/app/assets/javascripts/src/JIT.js index 498183ef..633e68dd 100644 --- a/app/assets/javascripts/src/JIT.js +++ b/app/assets/javascripts/src/JIT.js @@ -2495,7 +2495,7 @@ Extras.Classes.Navigation = new Class({ //START METAMAPS CODE var rightClick = e.button == 2 || (navigator.platform.indexOf("Mac") != -1 && e.ctrlKey); // TODO make sure this works across browsers - if (!Metamaps.Mouse.boxStartCoordinates && ((e.button == 0 && e.shiftKey) || (e.button == 0 && e.ctrlKey) || (rightClick && e.ctrlKey))) { + if (!Metamaps.Mouse.boxStartCoordinates && ((e.button == 0 && e.shiftKey) || (e.button == 0 && e.ctrlKey) || rightClick)) { Metamaps.Mouse.boxStartCoordinates = eventInfo.getPos(); //console.log('mouse down'); } @@ -2525,13 +2525,13 @@ Extras.Classes.Navigation = new Class({ // START METAMAPS CODE var rightClick = e.button == 2 || (navigator.platform.indexOf("Mac") != -1 && e.ctrlKey); - if (!Metamaps.Mouse.boxStartCoordinates && ((e.button == 0 && e.shiftKey) || (e.button == 0 && e.ctrlKey) || (rightClick && e.ctrlKey))) { + if (!Metamaps.Mouse.boxStartCoordinates && ((e.button == 0 && e.shiftKey) || (e.button == 0 && e.ctrlKey) || rightClick)) { Metamaps.Visualize.mGraph.busy = true; Metamaps.boxStartCoordinates = eventInfo.getPos(); //console.log('mouse move'); return; } - if (Metamaps.Mouse.boxStartCoordinates && ((e.button == 0 && e.shiftKey) || (e.button == 0 && e.ctrlKey) || (rightClick && e.ctrlKey))) { + if (Metamaps.Mouse.boxStartCoordinates && ((e.button == 0 && e.shiftKey) || (e.button == 0 && e.ctrlKey) || rightClick)) { Metamaps.Visualize.mGraph.busy = true; Metamaps.JIT.drawSelectBox(eventInfo,e); //console.log('mouse move'); diff --git a/app/assets/javascripts/src/Metamaps.JIT.js b/app/assets/javascripts/src/Metamaps.JIT.js index 370a5f91..4b44a9fd 100644 --- a/app/assets/javascripts/src/Metamaps.JIT.js +++ b/app/assets/javascripts/src/Metamaps.JIT.js @@ -374,14 +374,14 @@ Metamaps.JIT = { $('.rightclickmenu').remove(); if (Metamaps.Mouse.boxStartCoordinates) { - if(e.ctrlKey && e.shiftKey){ + if(e.ctrlKey){ Metamaps.Visualize.mGraph.busy = false; Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos(); Metamaps.JIT.zoomToBox(e); //console.log('called zoom to box'); return; } - else if (e.ctrlKey || e.shiftKey) { + else if (e.shiftKey) { Metamaps.Visualize.mGraph.busy = false; Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos(); Metamaps.JIT.selectWithBox(e); @@ -410,10 +410,10 @@ Metamaps.JIT = { // remove the rightclickmenu $('.rightclickmenu').remove(); - if (Metamaps.Mouse.boxStartCoordinates && e.ctrlKey) { + if (Metamaps.Mouse.boxStartCoordinates) { Metamaps.Visualize.mGraph.busy = false; Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos(); - Metamaps.JIT.zoomToBox(e); + Metamaps.JIT.selectWithBox(e); return; } @@ -1097,7 +1097,7 @@ Metamaps.JIT = { eX = Metamaps.Mouse.boxEndCoordinates.x, eY = Metamaps.Mouse.boxEndCoordinates.y; - if(!(e.shiftKey) && !(e.ctrlKey)){ + if(!e.shiftKey){ Metamaps.Control.deselectAllNodes(); Metamaps.Control.deselectAllEdges(); } @@ -1108,7 +1108,7 @@ Metamaps.JIT = { y = n.pos.y; if ((sX < x && x < eX && sY < y && y < eY) || (sX > x && x > eX && sY > y && y > eY) || (sX > x && x > eX && sY < y && y < eY) || (sX < x && x < eX && sY > y && y > eY)) { - if(e.ctrlKey){ + if(e.shiftKey){ if(n.selected){ Metamaps.Control.deselectNode(n); } @@ -1211,7 +1211,7 @@ Metamaps.JIT = { var node2id = synapse.get('edge').nodeTo.id; var edge = Metamaps.Visualize.mGraph.graph.getAdjacence(node1id, node2id); if(selectTest){ - if(e.ctrlKey){ + if(e.shiftKey){ if(Metamaps.Selected.Edges.indexOf(synapse.get('edge')) != -1 ){ Metamaps.Control.deselectEdge(synapse.get('edge')); } @@ -1273,23 +1273,19 @@ Metamaps.JIT = { // wait a certain length of time, then check again, then run this code setTimeout(function () { if (!Metamaps.JIT.nodeWasDoubleClicked()) { - if (!e.shiftKey && !e.ctrlKey) { + + var nodeAlreadySelected = node.selected; + + if (!e.shiftKey) { Metamaps.Control.deselectAllNodes(); Metamaps.Control.deselectAllEdges(); + } + + if (nodeAlreadySelected) { + Metamaps.Control.deselectNode(node); + } else { Metamaps.Control.selectNode(node,e); } - else if(e.shiftKey && e.ctrlKey){ - //no result - } - else if(e.ctrlKey){ - if (node.selected) { - Metamaps.Control.deselectNode(node); - } else { - Metamaps.Control.selectNode(node,e); - } - }else if(e.shiftKey){ - Metamaps.Control.selectNode(node,e); - } //trigger animation to final styles Metamaps.Visualize.mGraph.fx.animate({ @@ -1531,22 +1527,17 @@ Metamaps.JIT = { // wait a certain length of time, then check again, then run this code setTimeout(function () { if (!Metamaps.JIT.nodeWasDoubleClicked()) { - if (!e.shiftKey && !e.ctrlKey) { + + var edgeAlreadySelected = Metamaps.Selected.Edges.indexOf(adj) !== -1; + + if (!e.shiftKey) { Metamaps.Control.deselectAllNodes(); Metamaps.Control.deselectAllEdges(); - Metamaps.Control.selectEdge(adj); } - else if (e.shiftKey && e.ctrlKey){ - //no result - } - else if (e.ctrlKey){ - if (Metamaps.Selected.Edges.indexOf(adj) !== -1) { - Metamaps.Control.deselectEdge(adj); - } else { - Metamaps.Control.selectEdge(adj); - } - } - else if (e.shiftKey){ + + if (edgeAlreadySelected) { + Metamaps.Control.deselectEdge(adj); + } else { Metamaps.Control.selectEdge(adj); }