fixed mouse mappings

This commit is contained in:
Connor Turland 2014-11-22 16:47:09 -05:00
parent 2de697bcca
commit c1728b9ecb
2 changed files with 27 additions and 36 deletions

View file

@ -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');

View file

@ -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();
Metamaps.Control.selectNode(node,e);
}
else if(e.shiftKey && e.ctrlKey){
//no result
}
else if(e.ctrlKey){
if (node.selected) {
if (nodeAlreadySelected) {
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,24 +1527,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 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) {
if (edgeAlreadySelected) {
Metamaps.Control.deselectEdge(adj);
} else {
Metamaps.Control.selectEdge(adj);
}
}
else if (e.shiftKey){
Metamaps.Control.selectEdge(adj);
}
Metamaps.Visualize.mGraph.plot();
}