From d7814798036008aac9299cff4226a53ef1329846 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 9 Mar 2013 18:15:54 -0500 Subject: [PATCH 01/14] Gemfile.lock change --- Gemfile.lock | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index cc33f0b6..ed4f0c01 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -60,6 +60,7 @@ GEM railties (>= 3.1.0, < 5.0) thor (~> 0.14) json (1.7.6) + libv8 (3.11.8.13) mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) @@ -94,8 +95,10 @@ GEM rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) rake (10.0.3) + rb-readline (0.4.2) rdoc (3.12) json (~> 1.4) + ref (1.0.2) sass (3.2.1) sass-rails (3.2.5) railties (~> 3.2.0) @@ -106,6 +109,9 @@ GEM multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) + therubyracer (0.11.4) + libv8 (~> 3.11.8.12) + ref thor (0.16.0) tilt (1.3.3) treetop (1.4.12) @@ -133,5 +139,7 @@ DEPENDENCIES pg rails (= 3.2.11) rails3-jquery-autocomplete + rb-readline sass-rails (~> 3.2.3) + therubyracer uglifier (>= 1.0.3) From fa789dff2e4401518253b341c7a969497936d4c1 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Mon, 11 Mar 2013 21:54:38 -0400 Subject: [PATCH 02/14] Drag around all selected nodes, not just one - implements #79 --- .../Jit/graphsettings-event-handlers.js | 39 +++++++++---------- .../javascripts/Jit/graphsettings-model.js | 3 +- app/assets/javascripts/Jit/graphsettings.js | 1 + .../Jit/select-edit-delete-nodes-and-edges.js | 23 +++++++++++ 4 files changed, 44 insertions(+), 22 deletions(-) diff --git a/app/assets/javascripts/Jit/graphsettings-event-handlers.js b/app/assets/javascripts/Jit/graphsettings-event-handlers.js index 72e1fc8a..5c5659f3 100644 --- a/app/assets/javascripts/Jit/graphsettings-event-handlers.js +++ b/app/assets/javascripts/Jit/graphsettings-event-handlers.js @@ -73,24 +73,6 @@ function nodeWasDoubleClicked() { } }//nodeWasDoubleClicked; -function selectNode(node) { - node.selected = true; - node.setData('dim', 30, 'current'); - node.setData('onCanvas',true); - node.eachAdjacency(function (adj) { - selectEdge(adj); - }); -} - -function deselectNode(node) { - delete node.selected; - node.setData('onCanvas', false); - node.eachAdjacency(function(adj) { - deselectEdge(adj); - }); - node.setData('dim', 25, 'current'); -} - function selectNodeOnClickHandler(node, e) { if (Mconsole.busy) return; @@ -157,10 +139,25 @@ function onDragMoveTopicHandler(node, eventInfo, e) { var pos = eventInfo.getPos(); // if it's a left click, move the node if (e.button == 0 && !e.altKey && (e.buttons == 0 || e.buttons == 1 || e.buttons == undefined)) { + var len = MetamapsModel.selectedNodes.length; + + //first define offset for each node + var xOffset = new Array(); + var yOffset = new Array(); + for (var i = 0; i < len; i += 1) { + n = MetamapsModel.selectedNodes[i]; + xOffset[i] = n.getData('xloc') - node.getData('xloc'); + yOffset[i] = n.getData('yloc') - node.getData('yloc'); + } + + for (var i = 0; i < len; i += 1) { + n = MetamapsModel.selectedNodes[i]; + n.pos.setc(pos.x + xOffset[i], pos.y + yOffset[i]); + n.setData('xloc', pos.x + xOffset[i]); + n.setData('yloc', pos.y + yOffset[i]); + } + dragged = node.id; - node.pos.setc(pos.x, pos.y); - node.data.$xloc = pos.x; - node.data.$yloc = pos.y; Mconsole.plot(); } // if it's a right click or holding down alt, start synapse creation ->third option is for firefox diff --git a/app/assets/javascripts/Jit/graphsettings-model.js b/app/assets/javascripts/Jit/graphsettings-model.js index 61ba0981..d9cd00c1 100644 --- a/app/assets/javascripts/Jit/graphsettings-model.js +++ b/app/assets/javascripts/Jit/graphsettings-model.js @@ -9,8 +9,9 @@ var MetamapsModel = new Object(); MetamapsModel.embed = false; -//array of all selected edges +//array of all selected edges, same for nodes MetamapsModel.selectedEdges = new Array(); +MetamapsModel.selectedNodes = new Array(); //is any showcard open right now? which one? MetamapsModel.showcardInUse = null; diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index 4d8eef7c..c69e52d8 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -480,6 +480,7 @@ function onDragEndTopicHandler(node, eventInfo, e, allowRealtime) { tempNode2 = null; tempInit = false; } else if (dragged != 0 && goRealtime) { + //TODO: dragged is invalid if multiple nodes were dragged saveLayout(dragged); } }//onDragEndTopicHandler diff --git a/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js b/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js index 47a845c8..dbd5c4ee 100644 --- a/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js +++ b/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js @@ -287,6 +287,29 @@ function deleteSelectedEdges() { MetamapsModel.selectedEdges = new Array(); } +function selectNode(node) { + node.selected = true; + node.setData('dim', 30, 'current'); + node.setData('onCanvas',true); + node.eachAdjacency(function (adj) { + selectEdge(adj); + }); + MetamapsModel.selectedNodes.push(node); +} + +function deselectNode(node) { + delete node.selected; + node.setData('onCanvas', false); + node.eachAdjacency(function(adj) { + deselectEdge(adj); + }); + node.setData('dim', 25, 'current'); + + //remove the node + MetamapsModel.selectedNodes.splice( + MetamapsModel.selectedNodes.indexOf(node), 1); +} + function selectEdge(edge) { var showDesc = edge.getData("showDesc"); if (! showDesc) { From 0a1b5d51d873851a9bf79b823e71b0f1f08e464c Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Mon, 11 Mar 2013 22:24:17 -0400 Subject: [PATCH 03/14] Revert "Drag around all selected nodes, not just one - implements #79" This reverts commit fa789dff2e4401518253b341c7a969497936d4c1. --- .../Jit/graphsettings-event-handlers.js | 39 ++++++++++--------- .../javascripts/Jit/graphsettings-model.js | 3 +- app/assets/javascripts/Jit/graphsettings.js | 1 - .../Jit/select-edit-delete-nodes-and-edges.js | 23 ----------- 4 files changed, 22 insertions(+), 44 deletions(-) diff --git a/app/assets/javascripts/Jit/graphsettings-event-handlers.js b/app/assets/javascripts/Jit/graphsettings-event-handlers.js index 5c5659f3..72e1fc8a 100644 --- a/app/assets/javascripts/Jit/graphsettings-event-handlers.js +++ b/app/assets/javascripts/Jit/graphsettings-event-handlers.js @@ -73,6 +73,24 @@ function nodeWasDoubleClicked() { } }//nodeWasDoubleClicked; +function selectNode(node) { + node.selected = true; + node.setData('dim', 30, 'current'); + node.setData('onCanvas',true); + node.eachAdjacency(function (adj) { + selectEdge(adj); + }); +} + +function deselectNode(node) { + delete node.selected; + node.setData('onCanvas', false); + node.eachAdjacency(function(adj) { + deselectEdge(adj); + }); + node.setData('dim', 25, 'current'); +} + function selectNodeOnClickHandler(node, e) { if (Mconsole.busy) return; @@ -139,25 +157,10 @@ function onDragMoveTopicHandler(node, eventInfo, e) { var pos = eventInfo.getPos(); // if it's a left click, move the node if (e.button == 0 && !e.altKey && (e.buttons == 0 || e.buttons == 1 || e.buttons == undefined)) { - var len = MetamapsModel.selectedNodes.length; - - //first define offset for each node - var xOffset = new Array(); - var yOffset = new Array(); - for (var i = 0; i < len; i += 1) { - n = MetamapsModel.selectedNodes[i]; - xOffset[i] = n.getData('xloc') - node.getData('xloc'); - yOffset[i] = n.getData('yloc') - node.getData('yloc'); - } - - for (var i = 0; i < len; i += 1) { - n = MetamapsModel.selectedNodes[i]; - n.pos.setc(pos.x + xOffset[i], pos.y + yOffset[i]); - n.setData('xloc', pos.x + xOffset[i]); - n.setData('yloc', pos.y + yOffset[i]); - } - dragged = node.id; + node.pos.setc(pos.x, pos.y); + node.data.$xloc = pos.x; + node.data.$yloc = pos.y; Mconsole.plot(); } // if it's a right click or holding down alt, start synapse creation ->third option is for firefox diff --git a/app/assets/javascripts/Jit/graphsettings-model.js b/app/assets/javascripts/Jit/graphsettings-model.js index d9cd00c1..61ba0981 100644 --- a/app/assets/javascripts/Jit/graphsettings-model.js +++ b/app/assets/javascripts/Jit/graphsettings-model.js @@ -9,9 +9,8 @@ var MetamapsModel = new Object(); MetamapsModel.embed = false; -//array of all selected edges, same for nodes +//array of all selected edges MetamapsModel.selectedEdges = new Array(); -MetamapsModel.selectedNodes = new Array(); //is any showcard open right now? which one? MetamapsModel.showcardInUse = null; diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index c69e52d8..4d8eef7c 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -480,7 +480,6 @@ function onDragEndTopicHandler(node, eventInfo, e, allowRealtime) { tempNode2 = null; tempInit = false; } else if (dragged != 0 && goRealtime) { - //TODO: dragged is invalid if multiple nodes were dragged saveLayout(dragged); } }//onDragEndTopicHandler diff --git a/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js b/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js index dbd5c4ee..47a845c8 100644 --- a/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js +++ b/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js @@ -287,29 +287,6 @@ function deleteSelectedEdges() { MetamapsModel.selectedEdges = new Array(); } -function selectNode(node) { - node.selected = true; - node.setData('dim', 30, 'current'); - node.setData('onCanvas',true); - node.eachAdjacency(function (adj) { - selectEdge(adj); - }); - MetamapsModel.selectedNodes.push(node); -} - -function deselectNode(node) { - delete node.selected; - node.setData('onCanvas', false); - node.eachAdjacency(function(adj) { - deselectEdge(adj); - }); - node.setData('dim', 25, 'current'); - - //remove the node - MetamapsModel.selectedNodes.splice( - MetamapsModel.selectedNodes.indexOf(node), 1); -} - function selectEdge(edge) { var showDesc = edge.getData("showDesc"); if (! showDesc) { From 88a230dccfef0bce1c514044040401ba42405a5a Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Mon, 11 Mar 2013 22:25:22 -0400 Subject: [PATCH 04/14] Revert "Revert "Drag around all selected nodes, not just one - implements #79"" This reverts commit 0a1b5d51d873851a9bf79b823e71b0f1f08e464c. --- .../Jit/graphsettings-event-handlers.js | 39 +++++++++---------- .../javascripts/Jit/graphsettings-model.js | 3 +- app/assets/javascripts/Jit/graphsettings.js | 1 + .../Jit/select-edit-delete-nodes-and-edges.js | 23 +++++++++++ 4 files changed, 44 insertions(+), 22 deletions(-) diff --git a/app/assets/javascripts/Jit/graphsettings-event-handlers.js b/app/assets/javascripts/Jit/graphsettings-event-handlers.js index 72e1fc8a..5c5659f3 100644 --- a/app/assets/javascripts/Jit/graphsettings-event-handlers.js +++ b/app/assets/javascripts/Jit/graphsettings-event-handlers.js @@ -73,24 +73,6 @@ function nodeWasDoubleClicked() { } }//nodeWasDoubleClicked; -function selectNode(node) { - node.selected = true; - node.setData('dim', 30, 'current'); - node.setData('onCanvas',true); - node.eachAdjacency(function (adj) { - selectEdge(adj); - }); -} - -function deselectNode(node) { - delete node.selected; - node.setData('onCanvas', false); - node.eachAdjacency(function(adj) { - deselectEdge(adj); - }); - node.setData('dim', 25, 'current'); -} - function selectNodeOnClickHandler(node, e) { if (Mconsole.busy) return; @@ -157,10 +139,25 @@ function onDragMoveTopicHandler(node, eventInfo, e) { var pos = eventInfo.getPos(); // if it's a left click, move the node if (e.button == 0 && !e.altKey && (e.buttons == 0 || e.buttons == 1 || e.buttons == undefined)) { + var len = MetamapsModel.selectedNodes.length; + + //first define offset for each node + var xOffset = new Array(); + var yOffset = new Array(); + for (var i = 0; i < len; i += 1) { + n = MetamapsModel.selectedNodes[i]; + xOffset[i] = n.getData('xloc') - node.getData('xloc'); + yOffset[i] = n.getData('yloc') - node.getData('yloc'); + } + + for (var i = 0; i < len; i += 1) { + n = MetamapsModel.selectedNodes[i]; + n.pos.setc(pos.x + xOffset[i], pos.y + yOffset[i]); + n.setData('xloc', pos.x + xOffset[i]); + n.setData('yloc', pos.y + yOffset[i]); + } + dragged = node.id; - node.pos.setc(pos.x, pos.y); - node.data.$xloc = pos.x; - node.data.$yloc = pos.y; Mconsole.plot(); } // if it's a right click or holding down alt, start synapse creation ->third option is for firefox diff --git a/app/assets/javascripts/Jit/graphsettings-model.js b/app/assets/javascripts/Jit/graphsettings-model.js index 61ba0981..d9cd00c1 100644 --- a/app/assets/javascripts/Jit/graphsettings-model.js +++ b/app/assets/javascripts/Jit/graphsettings-model.js @@ -9,8 +9,9 @@ var MetamapsModel = new Object(); MetamapsModel.embed = false; -//array of all selected edges +//array of all selected edges, same for nodes MetamapsModel.selectedEdges = new Array(); +MetamapsModel.selectedNodes = new Array(); //is any showcard open right now? which one? MetamapsModel.showcardInUse = null; diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index 4d8eef7c..c69e52d8 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -480,6 +480,7 @@ function onDragEndTopicHandler(node, eventInfo, e, allowRealtime) { tempNode2 = null; tempInit = false; } else if (dragged != 0 && goRealtime) { + //TODO: dragged is invalid if multiple nodes were dragged saveLayout(dragged); } }//onDragEndTopicHandler diff --git a/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js b/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js index 47a845c8..dbd5c4ee 100644 --- a/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js +++ b/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js @@ -287,6 +287,29 @@ function deleteSelectedEdges() { MetamapsModel.selectedEdges = new Array(); } +function selectNode(node) { + node.selected = true; + node.setData('dim', 30, 'current'); + node.setData('onCanvas',true); + node.eachAdjacency(function (adj) { + selectEdge(adj); + }); + MetamapsModel.selectedNodes.push(node); +} + +function deselectNode(node) { + delete node.selected; + node.setData('onCanvas', false); + node.eachAdjacency(function(adj) { + deselectEdge(adj); + }); + node.setData('dim', 25, 'current'); + + //remove the node + MetamapsModel.selectedNodes.splice( + MetamapsModel.selectedNodes.indexOf(node), 1); +} + function selectEdge(edge) { var showDesc = edge.getData("showDesc"); if (! showDesc) { From e54c4e24edd04259d23e2ceac7b114478357a935 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Mon, 11 Mar 2013 22:50:17 -0400 Subject: [PATCH 05/14] fixed problems with multiple node selection dragging (#79) --- .../Jit/graphsettings-event-handlers.js | 65 ++++++++++++++----- .../Jit/select-edit-delete-nodes-and-edges.js | 2 + 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/Jit/graphsettings-event-handlers.js b/app/assets/javascripts/Jit/graphsettings-event-handlers.js index 5c5659f3..bab19427 100644 --- a/app/assets/javascripts/Jit/graphsettings-event-handlers.js +++ b/app/assets/javascripts/Jit/graphsettings-event-handlers.js @@ -132,6 +132,28 @@ function canvasDoubleClickHandler(canvasLoc,e) { } }//canvasDoubleClickHandler +function handleSelectionBeforeDragging(node, e) { + // four cases: + // 1 nothing is selected, so pretend you aren't selecting + // 2 others are selected only and shift, so additionally select this one + // 3 others are selected only, no shift: drag only this one + // 4 this node and others were selected, so drag them (just return false) + //return value: deselect node again after? + if (MetamapsModel.selectedNodes.length == 0) { + selectNode(node); + return 'deselect'; + } + if (MetamapsModel.selectedNodes.indexOf(node) == -1) { + if (e.shiftKey) { + selectNode(node); + return 'nothing'; + } else { + return 'only-drag-this-one'; + } + } + return 'nothing'; //case 4? +} + function onDragMoveTopicHandler(node, eventInfo, e) { if (node && !node.nodeFrom) { $('#new_synapse').fadeOut('fast'); @@ -139,24 +161,35 @@ function onDragMoveTopicHandler(node, eventInfo, e) { var pos = eventInfo.getPos(); // if it's a left click, move the node if (e.button == 0 && !e.altKey && (e.buttons == 0 || e.buttons == 1 || e.buttons == undefined)) { - var len = MetamapsModel.selectedNodes.length; + //if the node dragged isn't already selected, select it + var whatToDo = handleSelectionBeforeDragging(node, e); + if (whatToDo == 'only-drag-this-one') { + node.pos.setc(pos.x, pos.y); + node.setData('xloc', pos.x); + node.setData('yloc', pos.y); + } else { + var len = MetamapsModel.selectedNodes.length; - //first define offset for each node - var xOffset = new Array(); - var yOffset = new Array(); - for (var i = 0; i < len; i += 1) { - n = MetamapsModel.selectedNodes[i]; - xOffset[i] = n.getData('xloc') - node.getData('xloc'); - yOffset[i] = n.getData('yloc') - node.getData('yloc'); + //first define offset for each node + var xOffset = new Array(); + var yOffset = new Array(); + for (var i = 0; i < len; i += 1) { + n = MetamapsModel.selectedNodes[i]; + xOffset[i] = n.getData('xloc') - node.getData('xloc'); + yOffset[i] = n.getData('yloc') - node.getData('yloc'); + }//for + + for (var i = 0; i < len; i += 1) { + n = MetamapsModel.selectedNodes[i]; + n.pos.setc(pos.x + xOffset[i], pos.y + yOffset[i]); + n.setData('xloc', pos.x + xOffset[i]); + n.setData('yloc', pos.y + yOffset[i]); + }//for + }//if + + if (whatToDo == 'deselect') { + deselectNode(node); } - - for (var i = 0; i < len; i += 1) { - n = MetamapsModel.selectedNodes[i]; - n.pos.setc(pos.x + xOffset[i], pos.y + yOffset[i]); - n.setData('xloc', pos.x + xOffset[i]); - n.setData('yloc', pos.y + yOffset[i]); - } - dragged = node.id; Mconsole.plot(); } diff --git a/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js b/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js index dbd5c4ee..5c6dc9d8 100644 --- a/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js +++ b/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js @@ -288,6 +288,7 @@ function deleteSelectedEdges() { } function selectNode(node) { + if (MetamapsModel.selectedNodes.indexOf(node) != -1) return; node.selected = true; node.setData('dim', 30, 'current'); node.setData('onCanvas',true); @@ -311,6 +312,7 @@ function deselectNode(node) { } function selectEdge(edge) { + if (MetamapsModel.selectedEdges.indexOf(edge) != -1) return; var showDesc = edge.getData("showDesc"); if (! showDesc) { edge.setData('showDesc', true, 'current'); From 610286cee76cdc6f5c7256f2a495ffd509d8c632 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Thu, 14 Mar 2013 20:53:01 -0400 Subject: [PATCH 06/14] changed onCanvas to whiteCircle and inCommons to greenCircle in node data. Also a few other minor/helpful tweaks --- app/assets/javascripts/Jit/find.js | 16 ++++++++-------- .../Jit/graphsettings-event-handlers.js | 5 +++-- app/assets/javascripts/Jit/graphsettings.js | 8 ++++---- .../javascripts/Jit/onCreateLabelHandler.js | 1 + .../Jit/select-edit-delete-nodes-and-edges.js | 15 ++++++++++----- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/Jit/find.js b/app/assets/javascripts/Jit/find.js index 476fa1c9..7378f36f 100644 --- a/app/assets/javascripts/Jit/find.js +++ b/app/assets/javascripts/Jit/find.js @@ -85,7 +85,7 @@ var findMappers = ['name', 'topic (by name)', 'map (by name)', 'synapse (by topi function hideAll(duration) { if (duration == null) duration = 500; Mconsole.graph.eachNode( function (n) { - if (!(n.getData('inCommons') || n.getData('onCanvas'))) { + if (!(n.getData('greenCircle') || n.getData('whiteCircle'))) { n.setData('alpha', 0.4, 'end'); n.eachAdjacency(function(adj) { adj.setData('alpha', 0.4, 'end'); @@ -120,26 +120,26 @@ function onCanvasSearch(searchQuery, mapID, mapperID) { nodeName = n.name.toLowerCase(); if (name != null) { if (nodeName.indexOf(searchQuery) !== -1 && searchQuery != "") { - n.setData('onCanvas', true); + n.setData('whiteCircle', true); } else { - n.setData('onCanvas', false); + n.setData('whiteCircle', false); } } else if (mapID != null) { if (n.getData('inmaps').indexOf(parseInt(mapID)) !== -1) { - n.setData('onCanvas', true); + n.setData('whiteCircle', true); } else { - n.setData('onCanvas', false); + n.setData('whiteCircle', false); } } else if (mapperID != null) { if (n.getData('userid').toString() == mapperID) { - n.setData('onCanvas', true); + n.setData('whiteCircle', true); } else { - n.setData('onCanvas', false); + n.setData('whiteCircle', false); } } Mconsole.plot(); @@ -175,7 +175,7 @@ function clearCanvasExceptRoot() { function clearFoundData() { Mconsole.graph.eachNode( function(n) { - if (n.getData('inCommons') === true) { + if (n.getData('greenCircle') === true) { Mconsole.graph.removeNode(n.id); Mconsole.labels.disposeLabel(n.id); } diff --git a/app/assets/javascripts/Jit/graphsettings-event-handlers.js b/app/assets/javascripts/Jit/graphsettings-event-handlers.js index bab19427..80136c18 100644 --- a/app/assets/javascripts/Jit/graphsettings-event-handlers.js +++ b/app/assets/javascripts/Jit/graphsettings-event-handlers.js @@ -33,12 +33,13 @@ function nodeDoubleClickHandler(node, e) { return; } - if (node.getData('inCommons') == false) { + //greenCircle being true denotes it's actually "in the commons" still + if (node.getData('greenCircle') == false) { return; } //this line adds it to the console if you close seek - node.setData('inCommons', false); + node.setData('greenCircle', false); //this is just aesthetic deselectNode(node); diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index c69e52d8..5b5646d8 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -235,12 +235,12 @@ var nodeSettings = { var pos = node.pos.getc(true), dim = node.getData('dim'), cat = node.getData('metacode'), - inCommons = node.getData('inCommons'), - onCanvas = node.getData('onCanvas'), + greenCircle = node.getData('greenCircle'), + whiteCircle = node.getData('whiteCircle'), ctx = canvas.getCtx(); // if the topic is from the Commons draw a green circle around it - if (inCommons) { + if (greenCircle) { ctx.beginPath(); ctx.arc(pos.x, pos.y, dim+3, 0, 2 * Math.PI, false); ctx.strokeStyle = '#67be5f'; // green @@ -248,7 +248,7 @@ var nodeSettings = { ctx.stroke(); } // if the topic is on the Canvas draw a white circle around it - if (onCanvas) { + if (whiteCircle) { ctx.beginPath(); ctx.arc(pos.x, pos.y, dim+3, 0, 2 * Math.PI, false); if (! MetamapsModel.embed) ctx.strokeStyle = 'white'; diff --git a/app/assets/javascripts/Jit/onCreateLabelHandler.js b/app/assets/javascripts/Jit/onCreateLabelHandler.js index 71f0d0de..51a41f93 100644 --- a/app/assets/javascripts/Jit/onCreateLabelHandler.js +++ b/app/assets/javascripts/Jit/onCreateLabelHandler.js @@ -323,6 +323,7 @@ function bindCallbacks(showCard, nameContainer, node) { $(showCard).find('.best_in_place_name').bind("ajax:success", function() { var name = $(this).html(); $(nameContainer).find('.label').html(name); + node.name = name; }); $(showCard).find('.best_in_place_desc').bind("ajax:success", function() { diff --git a/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js b/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js index 5c6dc9d8..fa5ee66c 100644 --- a/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js +++ b/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js @@ -291,7 +291,7 @@ function selectNode(node) { if (MetamapsModel.selectedNodes.indexOf(node) != -1) return; node.selected = true; node.setData('dim', 30, 'current'); - node.setData('onCanvas',true); + node.setData('whiteCircle',true); node.eachAdjacency(function (adj) { selectEdge(adj); }); @@ -300,7 +300,7 @@ function selectNode(node) { function deselectNode(node) { delete node.selected; - node.setData('onCanvas', false); + node.setData('whiteCircle', false); node.eachAdjacency(function(adj) { deselectEdge(adj); }); @@ -373,6 +373,8 @@ function hideNode(nodeid) { alert("You can't hide this topic, it is the root of your graph."); return; } + + deselectNode(node); node.setData('alpha', 0, 'end'); node.eachAdjacency(function(adj) { @@ -386,15 +388,18 @@ function hideNode(nodeid) { Mconsole.graph.removeNode(nodeid); Mconsole.labels.disposeLabel(nodeid); } + function hideSelectedNodes() { Mconsole.graph.eachNode( function (n) { - if (n.data.$onCanvas == true) { + if (n.getData('whiteCircle') == true) { hideNode(n.id); } }); } function removeNode(nodeid) { + var node = Mconsole.graph.getNode(nodeid); + deselectNode(node); if (mapperm) { $.ajax({ type: "POST", @@ -405,7 +410,7 @@ function removeNode(nodeid) { function removeSelectedNodes() { if (mapperm) { Mconsole.graph.eachNode( function (n) { - if (n.data.$onCanvas == true) { + if (n.getData('whiteCircle') == true) { removeNode(n.id); } }); @@ -424,7 +429,7 @@ function deleteNode(nodeid) { } function deleteSelectedNodes() { Mconsole.graph.eachNode( function (n) { - if (n.data.$onCanvas == true) { + if (n.getData('whiteCircle') == true) { deleteNode(n.id); } }); From 1c3aa6c97310bbc4b9ad39a3331f9692967ae6f2 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Thu, 14 Mar 2013 21:01:09 -0400 Subject: [PATCH 07/14] more onCanvas/inCommons => whiteCircle/greenCircle changes in views. Also changed a thing in main/search.js.erb about the "temp" node being undefined instead of null that may fix an issue or not --- app/views/main/search.js.erb | 15 +++++++-------- app/views/topics/create.js.erb | 8 ++++---- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/views/main/search.js.erb b/app/views/main/search.js.erb index 9cc2e6dd..2be2dcc4 100644 --- a/app/views/main/search.js.erb +++ b/app/views/main/search.js.erb @@ -19,8 +19,8 @@ var even = true; var temp = Mconsole.graph.getNode('<%= topic.id %>'); temp.setData('dim', 1, 'start'); temp.setData('dim', 25, 'end'); - temp.setData('inCommons',true); - temp.setData('onCanvas',false); + temp.setData('greenCircle',true); + temp.setData('whiteCircle',false); temp.setPos(new $jit.Complex(myX, myY), 'current'); temp.setPos(new $jit.Complex(myX, myY), 'start'); temp.setPos(new $jit.Complex(myX, myY), 'end'); @@ -28,17 +28,16 @@ var even = true; Mconsole.labels.plotLabel(Mconsole.canvas, temp, Mconsole.config); myX += 100; even = !even; - } - else { + } else { var temp = Mconsole.graph.getNode('<%= topic.id %>'); - if (temp == null || temp.getData('inCommons')) { + if (temp == undefined) { var newnode = <%= topic.self_as_json.html_safe %>; Mconsole.graph.addNode(newnode); var temp = Mconsole.graph.getNode('<%= topic.id %>'); temp.setData('dim', 1, 'start'); temp.setData('dim', 25, 'end'); - temp.setData('inCommons',true); - temp.setData('onCanvas',false); + temp.setData('greenCircle',true); + temp.setData('whiteCircle',false); if (myX > (w-100)) { myX = -w + 400; myY += 200; @@ -85,7 +84,7 @@ var even = true; username: '<%= synapse.user.name %>', permission: '<%= synapse.permission %>' }); - temp.data.$direction = d; + temp.setData('direction', d); Mconsole.fx.plotLine(temp, Mconsole.canvas); } <% end %> diff --git a/app/views/topics/create.js.erb b/app/views/topics/create.js.erb index a69c0a3c..19a1cee2 100644 --- a/app/views/topics/create.js.erb +++ b/app/views/topics/create.js.erb @@ -25,8 +25,8 @@ if (!$.isEmptyObject(Mconsole.graph.nodes)) { var temp = Mconsole.graph.getNode('<%= @topic.id %>'); temp.setData('dim', 1, 'start'); temp.setData('dim', 40, 'end'); - temp.setData('onCanvas', false); - temp.setData('inCommons', false); + temp.setData('whiteCircle', false); + temp.setData('greenCircle', false); if (gType == "centered") { var tempPos = new $jit.Complex(x, y); @@ -84,8 +84,8 @@ if (!$.isEmptyObject(Mconsole.graph.nodes)) { var temp = Mconsole.graph.getNode('<%= @topic.id %>'); temp.setData('dim', 1, 'start'); temp.setData('dim', 25, 'end'); - temp.setData('onCanvas', false); - temp.setData('inCommons', false); + temp.setData('whiteCircle', false); + temp.setData('greenCircle', false); if (gType == "arranged" || gType == "chaotic") { <% if not @mapping.nil? %> temp.setData('mappingid', <%= @mapping.id %>); From 86895836a0b851a9e3f9257b04f648a9ccef3981 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Thu, 14 Mar 2013 22:55:28 -0400 Subject: [PATCH 08/14] changed some disposeLabels to hideLabels - fix #156 --- app/assets/javascripts/Jit/find.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/Jit/find.js b/app/assets/javascripts/Jit/find.js index 7378f36f..f9381bfc 100644 --- a/app/assets/javascripts/Jit/find.js +++ b/app/assets/javascripts/Jit/find.js @@ -149,7 +149,9 @@ function onCanvasSearch(searchQuery, mapID, mapperID) { function clearCanvas() { Mconsole.graph.eachNode(function(n) { Mconsole.graph.removeNode(n.id); - Mconsole.labels.disposeLabel(n.id); + //TODO shouldn't we use disposeLabel? Yes, but it breaks things so it's + //hide for now + Mconsole.labels.hideLabel(n.id); }); Mconsole.plot(); } @@ -164,8 +166,7 @@ function clearCanvasExceptRoot() { ids.forEach(function(id, index) { if (id != root.id) { Mconsole.graph.removeNode(id); - //don't use disposeLabel or they'll never come back! - //maybe there's a better way that recreates the labels later?? + //TODO is hideLabel correct? Maybe it is... Mconsole.labels.hideLabel(id); $('#topic_' + id + '_label').hide(); } @@ -177,7 +178,9 @@ function clearFoundData() { Mconsole.graph.eachNode( function(n) { if (n.getData('greenCircle') === true) { Mconsole.graph.removeNode(n.id); - Mconsole.labels.disposeLabel(n.id); + //TODO is hideLabel correct? Maybe it is... + Mconsole.labels.hideLabel(n.id); + $('#topic_' + n.id + '_label').hide(); } }); Mconsole.plot(); From 0049ae88d1715f1b7fde2aa855ab1a1927ba2767 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 16 Mar 2013 12:51:56 -0400 Subject: [PATCH 09/14] hide synapse autocomplete after synapse creation - didn't we fix this already? --- app/views/synapses/create.js.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/synapses/create.js.erb b/app/views/synapses/create.js.erb index 0814e363..faf77cac 100644 --- a/app/views/synapses/create.js.erb +++ b/app/views/synapses/create.js.erb @@ -5,6 +5,7 @@ $('#new_synapse').fadeOut('fast'); $('#synapse_desc').attr('value',''); $('#synapse_desc').autocomplete('disable'); +$('#synapse_desc').fadeOut('fast'); $('#synapse_topic1id').attr('value','0'); $('#synapse_topic2id').attr('value','0'); From 6ed19db3ec52150e7fcc930aba89d207bb30ad4b Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 16 Mar 2013 12:56:26 -0400 Subject: [PATCH 10/14] undo the bug I introduced in the last commit; also change selectNodeOnClickHandler to selectNode to prevent a couple errors in topics/create.js.erb --- app/views/synapses/create.js.erb | 1 - app/views/topics/create.js.erb | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/synapses/create.js.erb b/app/views/synapses/create.js.erb index faf77cac..0814e363 100644 --- a/app/views/synapses/create.js.erb +++ b/app/views/synapses/create.js.erb @@ -5,7 +5,6 @@ $('#new_synapse').fadeOut('fast'); $('#synapse_desc').attr('value',''); $('#synapse_desc').autocomplete('disable'); -$('#synapse_desc').fadeOut('fast'); $('#synapse_topic1id').attr('value','0'); $('#synapse_topic2id').attr('value','0'); diff --git a/app/views/topics/create.js.erb b/app/views/topics/create.js.erb index 19a1cee2..18cb397d 100644 --- a/app/views/topics/create.js.erb +++ b/app/views/topics/create.js.erb @@ -72,7 +72,7 @@ if (!$.isEmptyObject(Mconsole.graph.nodes)) { modes: ['node-property:dim'], duration: 500, onComplete: function() { - selectNodeOnClickHandler(temp); + selectNode(temp); } }); @@ -101,7 +101,7 @@ if (!$.isEmptyObject(Mconsole.graph.nodes)) { modes: ['node-property:dim'], duration: 500, onComplete: function() { - selectNodeOnClickHandler(temp); + selectNode(temp); } }); } From f714212423012f45ec48e9394c3474e6a483e393 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 16 Mar 2013 13:30:54 -0400 Subject: [PATCH 11/14] implement synapse autocomplete controller function to make the results distinct. fixes #139 --- .../javascripts/Jit/graphsettings-event-handlers.js | 3 +++ app/controllers/synapses_controller.rb | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/Jit/graphsettings-event-handlers.js b/app/assets/javascripts/Jit/graphsettings-event-handlers.js index 80136c18..52f12e20 100644 --- a/app/assets/javascripts/Jit/graphsettings-event-handlers.js +++ b/app/assets/javascripts/Jit/graphsettings-event-handlers.js @@ -61,6 +61,9 @@ function nodeDoubleClickHandler(node, e) { }//doubleClickNodeHandler +/* + * Returns a boolean saying if the node was double clicked in our understanding of the word + */ function nodeWasDoubleClicked() { //grab the timestamp of the click var storedTime = MetamapsModel.lastNodeClick; diff --git a/app/controllers/synapses_controller.rb b/app/controllers/synapses_controller.rb index 4a4910ab..e1fe3f90 100644 --- a/app/controllers/synapses_controller.rb +++ b/app/controllers/synapses_controller.rb @@ -5,7 +5,17 @@ class SynapsesController < ApplicationController respond_to :html, :js, :json - autocomplete :synapse, :desc, :full => true + def autocomplete_synapse_desc + term = params[:term] + if term && !term.empty? + items = Synapse.select('DISTINCT "desc"'). + where('LOWER("desc") like ?', term.downcase + '%'). + limit(10).order('"desc"') + else + items = {} + end + render :json => json_for_autocomplete(items, :desc) + end # GET synapses # or GET users/:user_id/synapses From 1f7588f1ceb72851fe3680df5f86966fd8600689 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Sun, 17 Mar 2013 02:29:17 -0400 Subject: [PATCH 12/14] added ability to use touch to drag nodes, pan, and zoom. fixed label glitch for the most part --- Gemfile | 4 +- Gemfile.lock | 8 --- Gemfile~ | 46 +++++++++++++ .../Jit/graphsettings-event-handlers.js | 64 ++++++++++++++++++- app/assets/javascripts/Jit/graphsettings.js | 46 +++++++++++-- app/assets/javascripts/Jit/jit2.0.0.js | 3 + app/assets/javascripts/Jit/loadgraphs.js | 19 ++++++ .../javascripts/Jit/onCreateLabelHandler.js | 6 +- app/assets/javascripts/application.js | 18 +++++- 9 files changed, 192 insertions(+), 22 deletions(-) create mode 100644 Gemfile~ diff --git a/Gemfile b/Gemfile index cb1ac1c2..1f7c3bd8 100644 --- a/Gemfile +++ b/Gemfile @@ -13,8 +13,8 @@ gem 'formtastic' gem 'json' gem 'rails3-jquery-autocomplete' gem 'best_in_place' -gem 'therubyracer' #optional -gem 'rb-readline' +#gem 'therubyracer' #optional +#gem 'rb-readline' # Gems used only for assets and not required # in production environments by default. diff --git a/Gemfile.lock b/Gemfile.lock index ed4f0c01..cc33f0b6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -60,7 +60,6 @@ GEM railties (>= 3.1.0, < 5.0) thor (~> 0.14) json (1.7.6) - libv8 (3.11.8.13) mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) @@ -95,10 +94,8 @@ GEM rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) rake (10.0.3) - rb-readline (0.4.2) rdoc (3.12) json (~> 1.4) - ref (1.0.2) sass (3.2.1) sass-rails (3.2.5) railties (~> 3.2.0) @@ -109,9 +106,6 @@ GEM multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - therubyracer (0.11.4) - libv8 (~> 3.11.8.12) - ref thor (0.16.0) tilt (1.3.3) treetop (1.4.12) @@ -139,7 +133,5 @@ DEPENDENCIES pg rails (= 3.2.11) rails3-jquery-autocomplete - rb-readline sass-rails (~> 3.2.3) - therubyracer uglifier (>= 1.0.3) diff --git a/Gemfile~ b/Gemfile~ new file mode 100644 index 00000000..6b2f6e48 --- /dev/null +++ b/Gemfile~ @@ -0,0 +1,46 @@ +source 'https://rubygems.org' + +gem 'rails', '3.2.11' + +# Bundle edge Rails instead: +# gem 'rails', :git => 'git://github.com/rails/rails.git' + +gem 'pg' +gem 'authlogic' +gem 'cancan' +gem 'formula' +gem 'formtastic' +gem 'json' +gem 'rails3-jquery-autocomplete' +gem 'best_in_place' +#gem 'therubyracer' #optional +gem 'rb-readline' + +# Gems used only for assets and not required +# in production environments by default. +group :assets do + gem 'sass-rails', '~> 3.2.3' + gem 'coffee-rails', '~> 3.2.1' + + # See https://github.com/sstephenson/execjs#readme for more supported runtimes + # gem 'therubyracer' + + gem 'uglifier', '>= 1.0.3' +end + +gem 'jquery-rails', '2.1.2' + +# To use ActiveModel has_secure_password +# gem 'bcrypt-ruby', '~> 3.0.0' + +# To use Jbuilder templates for JSON + gem 'jbuilder' + +# Use unicorn as the web server +# gem 'unicorn' + +# Deploy with Capistrano +# gem 'capistrano' + +# To use debugger +# gem 'ruby-debug19', :require => 'ruby-debug' diff --git a/app/assets/javascripts/Jit/graphsettings-event-handlers.js b/app/assets/javascripts/Jit/graphsettings-event-handlers.js index 80136c18..2e40b82c 100644 --- a/app/assets/javascripts/Jit/graphsettings-event-handlers.js +++ b/app/assets/javascripts/Jit/graphsettings-event-handlers.js @@ -160,8 +160,8 @@ function onDragMoveTopicHandler(node, eventInfo, e) { $('#new_synapse').fadeOut('fast'); $('#new_topic').fadeOut('fast'); var pos = eventInfo.getPos(); - // if it's a left click, move the node - if (e.button == 0 && !e.altKey && (e.buttons == 0 || e.buttons == 1 || e.buttons == undefined)) { + // if it's a left click, or a touch, move the node + if ( e.touches || (e.button == 0 && !e.altKey && (e.buttons == 0 || e.buttons == 1 || e.buttons == undefined))) { //if the node dragged isn't already selected, select it var whatToDo = handleSelectionBeforeDragging(node, e); if (whatToDo == 'only-drag-this-one') { @@ -235,3 +235,63 @@ function onDragMoveTopicHandler(node, eventInfo, e) { } } } + +var lastDist = 0; + +function getDistance(p1, p2) { + return Math.sqrt(Math.pow((p2.x - p1.x), 2) + Math.pow((p2.y - p1.y), 2)); +} + +function touchPanZoomHandler(eventInfo, e) { + if (e.touches.length == 1) { + var thispos = touchPos, + currentPos = eventInfo.getPos(), + canvas = Mconsole.canvas, + ox = canvas.translateOffsetX, + oy = canvas.translateOffsetY, + sx = canvas.scaleOffsetX, + sy = canvas.scaleOffsetY; + currentPos.x *= sx; + currentPos.y *= sy; + currentPos.x += ox; + currentPos.y += oy; + //var x = currentPos.x - thispos.x, + // y = currentPos.y - thispos.y; + var x = currentPos.x - thispos.x, + y = currentPos.y - thispos.y; + touchPos = currentPos; + Mconsole.canvas.translate(x * 1/sx, y * 1/sy); + } + else if (e.touches.length == 2) { + var touch1 = e.touches[0]; + var touch2 = e.touches[1]; + + var dist = getDistance({ + x: touch1.clientX, + y: touch1.clientY + }, { + x: touch2.clientX, + y: touch2.clientY + }); + + if(!lastDist) { + lastDist = dist; + } + + var scale = dist / lastDist; + + console.log(scale); + + if (8 >= Mconsole.canvas.scaleOffsetX*scale && Mconsole.canvas.scaleOffsetX*scale >= 1) { + Mconsole.canvas.scale(scale, scale); + } + if (Mconsole.canvas.scaleOffsetX < 0.5) { + Mconsole.canvas.viz.labels.hideLabels(true); + } + else if (Mconsole.canvas.scaleOffsetX > 0.5) { + Mconsole.canvas.viz.labels.hideLabels(false); + } + lastDist = dist; + } + +} \ No newline at end of file diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index 5b5646d8..3ca32af5 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -58,7 +58,7 @@ function graphSettings(type, embed) { }, //Update node positions when dragged onDragMove: function (node, eventInfo, e) { - onDragMoveTopicHandler(node, eventInfo, e); + onDragMoveTopicHandler(node, eventInfo, e); }, onDragEnd: function(node, eventInfo, e) { onDragEndTopicHandler(node, eventInfo, e, false); @@ -67,16 +67,52 @@ function graphSettings(type, embed) { onDragCancelHandler(node, eventInfo, e, false); }, //Implement the same handler for touchscreens + onTouchStart: function (node, eventInfo, e) { + //$jit.util.event.stop(e); //stop default touchmove event + //Mconsole.events.onMouseDown(e, null, eventInfo); + Mconsole.events.touched = true; + touchPos = eventInfo.getPos(); + var canvas = Mconsole.canvas, + ox = canvas.translateOffsetX; + oy = canvas.translateOffsetY, + sx = canvas.scaleOffsetX, + sy = canvas.scaleOffsetY; + touchPos.x *= sx; + touchPos.y *= sy; + touchPos.x += ox; + touchPos.y += oy; + + touchDragNode = node; + }, + //Implement the same handler for touchscreens onTouchMove: function (node, eventInfo, e) { - $jit.util.event.stop(e); //stop default touchmove event - this.onDragMove(node, eventInfo, e); + if (touchDragNode) onDragMoveTopicHandler(touchDragNode, eventInfo, e); + else { + touchPanZoomHandler(eventInfo, e); + $('#topic_' + MetamapsModel.showcardInUse + '_label').hide(); + } + }, + //Implement the same handler for touchscreens + onTouchEnd: function (node, eventInfo, e) { + //clicking on a node, or clicking on blank part of canvas? + if (node.nodeFrom) { + selectEdgeOnClickHandler(node, e); + } else if (node && !node.nodeFrom) { + selectNodeOnClickHandler(node, e); + } else { + canvasDoubleClickHandler(eventInfo.getPos(), e); + }//if + }, + //Implement the same handler for touchscreens + onTouchCancel: function (node, eventInfo, e) { + }, //Add also a click handler to nodes onClick: function (node, eventInfo, e) { if (e.target.id != "infovis-canvas") return false; //topic and synapse editing cards - hideCards(); + if (!Mconsole.events.moved) hideCards(); //clicking on a node, or clicking on blank part of canvas? if (node.nodeFrom) { @@ -84,6 +120,8 @@ function graphSettings(type, embed) { } else if (node && !node.nodeFrom) { selectNodeOnClickHandler(node, e); } else { + //topic and synapse editing cards + if (!Mconsole.events.moved) hideCards(); canvasDoubleClickHandler(eventInfo.getPos(), e); }//if } diff --git a/app/assets/javascripts/Jit/jit2.0.0.js b/app/assets/javascripts/Jit/jit2.0.0.js index 7e15717b..0a5fdc9e 100644 --- a/app/assets/javascripts/Jit/jit2.0.0.js +++ b/app/assets/javascripts/Jit/jit2.0.0.js @@ -2591,6 +2591,7 @@ Extras.Classes.Navigation = new Class({ $.event.stop($.event.get(e, win)); var val = this.config.zooming / 1000, ans = 1 + scroll * val; + // START METAMAPS CODE if (ans > 1) { if (5 >= this.canvas.scaleOffsetX) { this.canvas.scale(ans, ans); @@ -2607,6 +2608,8 @@ Extras.Classes.Navigation = new Class({ else if (this.canvas.scaleOffsetX > 0.5) { this.canvas.viz.labels.hideLabels(false); } + // END METAMAPS CODE + // ORIGINAL CODE this.canvas.scale(ans, ans); }, onMouseDown: function(e, win, eventInfo) { diff --git a/app/assets/javascripts/Jit/loadgraphs.js b/app/assets/javascripts/Jit/loadgraphs.js index 2335a4ba..8a1c585b 100644 --- a/app/assets/javascripts/Jit/loadgraphs.js +++ b/app/assets/javascripts/Jit/loadgraphs.js @@ -118,6 +118,25 @@ function initialize(type, loadLater, embed){ else if ( type == "arranged" || type == "chaotic") { Mconsole.animate(chooseAnimate); } + + // prevent touch events on the canvas from default behaviour + $("#infovis-canvas").bind('touchstart', function(event) { + event.preventDefault(); + Mconsole.events.touched = true; + }); + + // prevent touch events on the canvas from default behaviour + $("#infovis-canvas").bind('touchmove', function(event) { + //touchPanZoomHandler(event); + }); + + // prevent touch events on the canvas from default behaviour + $("#infovis-canvas").bind('touchend touchcancel', function(event) { + lastDist = 0; + if (!Mconsole.events.touchMoved && !touchDragNode) hideCurrentCard(); + Mconsole.events.touched = Mconsole.events.touchMoved = false; + touchDragNode = false; + }); }); // end }// if not loadLater diff --git a/app/assets/javascripts/Jit/onCreateLabelHandler.js b/app/assets/javascripts/Jit/onCreateLabelHandler.js index 51a41f93..1b629588 100644 --- a/app/assets/javascripts/Jit/onCreateLabelHandler.js +++ b/app/assets/javascripts/Jit/onCreateLabelHandler.js @@ -290,15 +290,13 @@ function bindCallbacks(showCard, nameContainer, node) { // add some events to the label $(nameContainer).find('.label').click(function(e){ - $('.name').css('display','block'); - $('.name.topic_' + node.id).css('display','none'); + hideCurrentCard(); $('.showcard.topic_' + node.id).fadeIn('fast'); $('.showcard.topic_' + node.id).find('.scroll').mCustomScrollbar("update"); node.setData('dim', 1, 'current'); - - hideCurrentCard(); MetamapsModel.showcardInUse = node.id; Mconsole.plot(); + $('#topic_' + node.id + '_label').hide(); }); nameContainer.onmouseover = function(){ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 012cbcc2..86984539 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -21,7 +21,7 @@ // other options are 'graph' var viewMode = "list"; -var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null, gType, tempNode = null, tempInit = false, tempNode2 = null, metacodeIMGinit = false, findOpen = false, analyzeOpen = false, organizeOpen = false, goRealtime = false, mapid = null, mapperm = false; +var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null, gType, tempNode = null, tempInit = false, tempNode2 = null, metacodeIMGinit = false, findOpen = false, analyzeOpen = false, organizeOpen = false, goRealtime = false, mapid = null, mapperm = false, touchPos, touchDragNode; $(document).ready(function() { @@ -69,11 +69,25 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null, height: '0px' }, 300, function() { sliding1 = false; + menuIsOpen = false; }); } },800); } ); + + var menuIsOpen = false; + $("#mainTitle a").bind('touchend', function(evt) { + if (!menuIsOpen) { + menuIsOpen = true; + var listLength = $('.logo .menu li').length * 28; + $('.footer .menu').animate({ + height: listLength + 'px' + }, 300); + evt.preventDefault(); + evt.stopPropogation(); + } + }); addHoverForSettings(); @@ -99,7 +113,7 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null, saveLayoutAll(); }); -}); +}); // end document.ready function addHoverForSettings() { // controls the sliding hover of the settings for cards From 9187112754990800b00399f25f9fead60e39a104 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Sun, 17 Mar 2013 05:18:30 -0400 Subject: [PATCH 13/14] fixed labels all up. made it so only one showcard exists --- .../javascripts/Jit/graphsettings-model.js | 1 + app/assets/javascripts/Jit/graphsettings.js | 45 +++++----- .../javascripts/Jit/onCreateLabelHandler.js | 86 ++++++++++--------- app/assets/stylesheets/ForceDirected.css | 2 +- app/assets/stylesheets/base.css | 3 + app/views/main/console.html.erb | 1 + app/views/maps/show.html.erb | 1 + app/views/topics/show.html.erb | 1 + 8 files changed, 78 insertions(+), 62 deletions(-) diff --git a/app/assets/javascripts/Jit/graphsettings-model.js b/app/assets/javascripts/Jit/graphsettings-model.js index d9cd00c1..dbfecf4f 100644 --- a/app/assets/javascripts/Jit/graphsettings-model.js +++ b/app/assets/javascripts/Jit/graphsettings-model.js @@ -15,6 +15,7 @@ MetamapsModel.selectedNodes = new Array(); //is any showcard open right now? which one? MetamapsModel.showcardInUse = null; +MetamapsModel.widthOfLabel = null; //is the mouse hovering over an edge? which one? MetamapsModel.edgeHoveringOver = false; diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index 3ca32af5..b9002d79 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -89,19 +89,12 @@ function graphSettings(type, embed) { if (touchDragNode) onDragMoveTopicHandler(touchDragNode, eventInfo, e); else { touchPanZoomHandler(eventInfo, e); - $('#topic_' + MetamapsModel.showcardInUse + '_label').hide(); + Mconsole.labels.hideLabel(Mconsole.graph.getNode(MetamapsModel.showcardInUse)); } }, //Implement the same handler for touchscreens onTouchEnd: function (node, eventInfo, e) { - //clicking on a node, or clicking on blank part of canvas? - if (node.nodeFrom) { - selectEdgeOnClickHandler(node, e); - } else if (node && !node.nodeFrom) { - selectNodeOnClickHandler(node, e); - } else { - canvasDoubleClickHandler(eventInfo.getPos(), e); - }//if + }, //Implement the same handler for touchscreens onTouchCancel: function (node, eventInfo, e) { @@ -538,18 +531,28 @@ function onDragCancelHandler(node, eventInfo, e, centred) { } function onPlaceLabelHandler(domElement, node) { - var style = domElement.style; - var left = parseInt(style.left); - var top = parseInt(style.top); - var w = domElement.offsetWidth; - style.left = (left - w / 2 + 107) + 'px'; - style.top = (top-165) + 'px'; - style.display = ''; - var label = document.getElementById('topic_' + node.id + '_label'); - $(label).show(); - w = label.offsetWidth; - style = label.style; - style.left = (-(w / 2 + 106)) + 'px'; + var style = domElement.style; + var left = parseInt(style.left); + var top = parseInt(style.top); + var w = $('#topic_' + node.id + '_label').width(); + style.left = (left - w / 2) + 'px'; + style.top = (top+20) + 'px'; + style.display = ''; + + // now position the showcard + if (MetamapsModel.showcardInUse != null) { + top = $('#' + MetamapsModel.showcardInUse).css('top'); + left = parseInt($('#' + MetamapsModel.showcardInUse).css('left')); + if (0 != $('#topic_' + MetamapsModel.showcardInUse + '_label').width()) { + MetamapsModel.widthOfLabel = $('#topic_' + MetamapsModel.showcardInUse + '_label').width(); + } + w = MetamapsModel.widthOfLabel/2; + left = (left + w) + 'px'; + $('#showcard').css('top', top); + $('#showcard').css('left', left); + + Mconsole.labels.hideLabel(Mconsole.graph.getNode(MetamapsModel.showcardInUse)); + } } // thanks to http://stackoverflow.com/questions/4338963/ diff --git a/app/assets/javascripts/Jit/onCreateLabelHandler.js b/app/assets/javascripts/Jit/onCreateLabelHandler.js index 1b629588..e960bc7a 100644 --- a/app/assets/javascripts/Jit/onCreateLabelHandler.js +++ b/app/assets/javascripts/Jit/onCreateLabelHandler.js @@ -15,22 +15,6 @@ */ function onCreateLabelHandler(domElement, node) { - var html = generateShowcardHTML(); - html = replaceVariables(html, node); - - var showCard = document.createElement('div'); - showCard.className = 'showcard topic_' + node.id; - if (authorizeToEdit(node)) { - var perm = document.createElement('div'); - perm.className = 'permission canEdit'; - perm.innerHTML = html; - showCard.appendChild(perm); - } else { - showCard.innerHTML = html; - } - showCard.style.display = "none"; - domElement.appendChild(showCard); - // Create a 'name' button and add it to the main node label var nameContainer = document.createElement('span'), style = nameContainer.style; @@ -42,7 +26,7 @@ function onCreateLabelHandler(domElement, node) { style.fontSize = "0.9em"; style.color = "#222222"; - bindCallbacks(showCard, nameContainer, node); + bindNameContainerCallbacks(nameContainer, node); } function generateShowcardHTML() { @@ -273,39 +257,41 @@ function hideCard(node) { $(card).fadeOut('fast', function(){ node.setData('dim', 25, 'current'); - $('.name.topic_' + node.id).show(); + Mconsole.labels.hideLabel(Mconsole.graph.getNode(node.id), true) Mconsole.plot(); }); MetamapsModel.showcardInUse = null; } -function bindCallbacks(showCard, nameContainer, node) { - // add some events to the label - $(showCard).find('img.icon').click(function(){ - hideCard(node); - }); - - $(showCard).find('.scroll').mCustomScrollbar(); +function bindNameContainerCallbacks(nameContainer, node) { + nameContainer.onmouseover = function(){ + $('.name.topic_' + node.id + ' .nodeOptions').css('display','block'); + } + + nameContainer.onmouseout = function(){ + $('.name.topic_' + node.id + ' .nodeOptions').css('display','none'); + } + + var showCard = document.getElementById('showcard'); // add some events to the label $(nameContainer).find('.label').click(function(e){ hideCurrentCard(); - $('.showcard.topic_' + node.id).fadeIn('fast'); - $('.showcard.topic_' + node.id).find('.scroll').mCustomScrollbar("update"); - node.setData('dim', 1, 'current'); - MetamapsModel.showcardInUse = node.id; - Mconsole.plot(); - $('#topic_' + node.id + '_label').hide(); - }); - - nameContainer.onmouseover = function(){ - $('.name.topic_' + node.id + ' .nodeOptions').css('display','block'); - } - - nameContainer.onmouseout = function(){ - $('.name.topic_' + node.id + ' .nodeOptions').css('display','none'); - } + showCard.innerHTML = ''; + + var html = generateShowcardHTML(); + html = replaceVariables(html, node); + + showCard.className = 'showcard topic_' + node.id; + if (authorizeToEdit(node)) { + var perm = document.createElement('div'); + perm.className = 'permission canEdit'; + perm.innerHTML = html; + showCard.appendChild(perm); + } else { + showCard.innerHTML = html; + } //bind best_in_place ajax callbacks $(showCard).find('.best_in_place_metacode').bind("ajax:success", function() { @@ -377,4 +363,24 @@ function bindCallbacks(showCard, nameContainer, node) { else if (permission == "public") el.html("pu"); else if (permission == "private") el.html("pr"); }); + + var top = $('#' + node.id).css('top'); + var left = parseInt($('#' + node.id).css('left')); + var w = $('#topic_' + node.id + '_label').width(); + w = w/2; + left = (left + w) + 'px'; + $('#showcard').css('top', top); + $('#showcard').css('left', left); + + $('.showcard.topic_' + node.id).fadeIn('fast'); + $('.showcard.topic_' + node.id).find('.scroll').mCustomScrollbar(); + node.setData('dim', 1, 'current'); + MetamapsModel.showcardInUse = node.id; + Mconsole.plot(); + Mconsole.labels.hideLabel(Mconsole.graph.getNode(node.id)) + // add some events to the label + $(showCard).find('img.icon').click(function(){ + hideCard(node); + }); + }); } diff --git a/app/assets/stylesheets/ForceDirected.css b/app/assets/stylesheets/ForceDirected.css index 9c4662df..0e70f5da 100644 --- a/app/assets/stylesheets/ForceDirected.css +++ b/app/assets/stylesheets/ForceDirected.css @@ -4,6 +4,7 @@ .label { display:block; + white-space: nowrap; padding: 2px 4px; background:#ddd; opacity:0.8; @@ -13,5 +14,4 @@ span.name { cursor: pointer; position: absolute; - top: 185px; } diff --git a/app/assets/stylesheets/base.css b/app/assets/stylesheets/base.css index c9b3122d..a9bd8a59 100644 --- a/app/assets/stylesheets/base.css +++ b/app/assets/stylesheets/base.css @@ -7,6 +7,9 @@ } .showcard, #showcard { + position:absolute; + display:none; + margin-top: -181px; width:216px; height:320px; color:#FFF; diff --git a/app/views/main/console.html.erb b/app/views/main/console.html.erb index b992b2fd..93abd496 100644 --- a/app/views/main/console.html.erb +++ b/app/views/main/console.html.erb @@ -23,6 +23,7 @@
+
<% if authenticated? %> diff --git a/app/views/maps/show.html.erb b/app/views/maps/show.html.erb index e199d5eb..662664ec 100644 --- a/app/views/maps/show.html.erb +++ b/app/views/maps/show.html.erb @@ -42,6 +42,7 @@
+
diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index c48bcc46..552e2819 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -30,6 +30,7 @@
+
From c4bc2b36752c04d028f2a5975e9ccbd1f9432262 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Sun, 17 Mar 2013 05:19:43 -0400 Subject: [PATCH 14/14] reset the gemfile --- Gemfile | 4 ++-- Gemfile~ | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 1f7c3bd8..cb1ac1c2 100644 --- a/Gemfile +++ b/Gemfile @@ -13,8 +13,8 @@ gem 'formtastic' gem 'json' gem 'rails3-jquery-autocomplete' gem 'best_in_place' -#gem 'therubyracer' #optional -#gem 'rb-readline' +gem 'therubyracer' #optional +gem 'rb-readline' # Gems used only for assets and not required # in production environments by default. diff --git a/Gemfile~ b/Gemfile~ index 6b2f6e48..1f7c3bd8 100644 --- a/Gemfile~ +++ b/Gemfile~ @@ -14,7 +14,7 @@ gem 'json' gem 'rails3-jquery-autocomplete' gem 'best_in_place' #gem 'therubyracer' #optional -gem 'rb-readline' +#gem 'rb-readline' # Gems used only for assets and not required # in production environments by default.