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 diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index cf0ee059..0248841a 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -80,40 +80,14 @@ function graphSettings(type) { this.onDragMove(node, eventInfo, e); }, //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'); - }); + onClick: function (node, eventInfo, e) { + //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 - }); - } + canvasDoubleClickHandler(e); + }//if + }//onClick }, //Number of iterations for the FD algorithm iterations: 200, @@ -417,4 +391,56 @@ 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 +//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 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"