From ac02995bac96d622386a091bad06994f6cb0214b Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 15 Dec 2012 13:49:12 -0500 Subject: [PATCH 1/4] updated .gitignore --- .gitignore | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index d72e7481..5a1b8996 100644 --- a/.gitignore +++ b/.gitignore @@ -7,11 +7,11 @@ config/database.yml # Ignore bundler config -/.bundle +.bundle # Ignore the default SQLite database. -/db/*.sqlite3 +db/*.sqlite3 # Ignore all logfiles and tempfiles. -/log/*.log -/tmp +log/*.log +tmp From dfdc1bfd9466885058f35aedec6967305ab417ae Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 15 Dec 2012 14:08:00 -0500 Subject: [PATCH 2/4] removed config/database.yml --- config/database.yml | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 config/database.yml diff --git a/config/database.yml b/config/database.yml deleted file mode 100644 index 6705ca8f..00000000 --- a/config/database.yml +++ /dev/null @@ -1,21 +0,0 @@ -development: - min_messages: WARNING - adapter: postgresql - host: 127.0.0.1 - port: 5432 - encoding: unicode - database: metamap002_development - pool: 5 - username: postgres - password: "3112" - -production: - min_messages: WARNING - adapter: postgresql - host: ec2-107-21-107-194.compute-1.amazonaws.com - port: 5432 - encoding: unicode - database: ddcrn2lgphjk9k - pool: 5 - username: qqpckkahytovwv - password: "njeP6cMA8EjM9ukHk9s3ReOdy7" From d6803007c37e982876ea59446589c49ffb75b8f6 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 15 Dec 2012 14:24:21 -0500 Subject: [PATCH 3/4] pulled the on click handler event code out into a function at the bottom of graphsettings.js. I also created a function in preparation for handling double click on the canvas --- app/assets/javascripts/Jit/graphsettings.js | 73 ++++++++++++--------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index cf0ee059..99baab02 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -81,39 +81,13 @@ function graphSettings(type) { }, //Add also a click handler to nodes onClick: function (node) { - if (!node) return; - //set final styles - Mconsole.graph.eachNode(function (n) { - if (n.id != node.id) delete n.selected; - n.setData('dim', 25, 'end'); - n.eachAdjacency(function (adj) { - adj.setDataset('end', { - lineWidth: 0.5, - color: '#222222' - }); - adj.setData('showDesc', false, 'current'); - }); - }); - if (!node.selected) { - node.selected = true; - node.setData('dim', 35, 'end'); - node.eachAdjacency(function (adj) { - adj.setDataset('end', { - lineWidth: 3, - color: '#FFF' - }); - adj.setData('showDesc', true, 'current'); - }); + //clicking on a node, or clicking on blank part of canvas? + if (node) { + selectNodeOnClickHandler(node); } else { - delete node.selected; - } - //trigger animation to final styles - Mconsole.fx.animate({ - modes: ['node-property:dim', - 'edge-property:lineWidth:color'], - duration: 500 - }); - } + createNodeOnClickHandler(); + }//if + }//onClick }, //Number of iterations for the FD algorithm iterations: 200, @@ -417,4 +391,39 @@ var nodeSettings = { } } +function selectNodeOnClickHandler(node) { + //set final styles + Mconsole.graph.eachNode(function (n) { + if (n.id != node.id) delete n.selected; + n.setData('dim', 25, 'end'); + n.eachAdjacency(function (adj) { + adj.setDataset('end', { + lineWidth: 0.5, + color: '#222222' + }); + adj.setData('showDesc', false, 'current'); + }); + }); + if (!node.selected) { + node.selected = true; + node.setData('dim', 35, 'end'); + node.eachAdjacency(function (adj) { + adj.setDataset('end', { + lineWidth: 3, + color: '#FFF' + }); + adj.setData('showDesc', true, 'current'); + }); + } else { + delete node.selected; + } + //trigger animation to final styles + Mconsole.fx.animate({ + modes: ['node-property:dim', + 'edge-property:lineWidth:color'], + duration: 500 + }); +}//selectNodeOnClickHandler +function createNodeOnClickHandler() { +}//createNodeOnClickHandler From ca6c8118703a33a87eab098711224a93bb0f76a3 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 15 Dec 2012 14:47:04 -0500 Subject: [PATCH 4/4] pop up node creation on double click implemented. The x and y of the click are available to the function but are as yet unused --- app/assets/javascripts/Jit/graphsettings.js | 25 +++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index 99baab02..0248841a 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -80,12 +80,12 @@ function graphSettings(type) { this.onDragMove(node, eventInfo, e); }, //Add also a click handler to nodes - onClick: function (node) { + onClick: function (node, eventInfo, e) { //clicking on a node, or clicking on blank part of canvas? if (node) { selectNodeOnClickHandler(node); } else { - createNodeOnClickHandler(); + canvasDoubleClickHandler(e); }//if }//onClick }, @@ -425,5 +425,22 @@ function selectNodeOnClickHandler(node) { }); }//selectNodeOnClickHandler -function createNodeOnClickHandler() { -}//createNodeOnClickHandler +//for the canvasDoubleClickHandler function +var canvasDoubleClickHandlerObject = new Object(); +canvasDoubleClickHandlerObject.stored_timestamp = 0; + +function canvasDoubleClickHandler(e) { + var TOLERANCE = 1000; //1 second + + //grab the location and timestamp of the click + var stored_timestamp = canvasDoubleClickHandlerObject.stored_timestamp; + var now = Date.now(); //not compatible with IE8 FYI + + if (now - stored_timestamp < TOLERANCE) { + //pop up node creation :) + $('#new_item').fadeIn('fast'); + //NOTE: we have e.x, e.y so use them!! + } else { + canvasDoubleClickHandlerObject.stored_timestamp = now; + } +}//canvasDoubleClickHandler