From 1491c2089575102cecf94b06a7bd2ee22fd38572 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Fri, 29 Mar 2013 02:38:13 -0400 Subject: [PATCH] shift+click for box selecting topics --- Gemfile | 4 +-- Gemfile.lock | 2 -- Gemfile~ | 2 +- app/assets/javascripts/Jit/graphsettings.js | 25 +++++++------------ app/assets/javascripts/Jit/jit2.0.0.js | 27 ++++++++++++++++----- app/assets/javascripts/application.js | 2 +- app/assets/stylesheets/ForceDirected.css | 6 +++++ app/assets/stylesheets/application.css | 9 +++++++ 8 files changed, 49 insertions(+), 28 deletions(-) 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 a85dcd9a..cc33f0b6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -94,7 +94,6 @@ GEM rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) rake (10.0.3) - rb-readline (0.4.1) rdoc (3.12) json (~> 1.4) sass (3.2.1) @@ -134,6 +133,5 @@ DEPENDENCIES pg rails (= 3.2.11) rails3-jquery-autocomplete - rb-readline sass-rails (~> 3.2.3) uglifier (>= 1.0.3) diff --git a/Gemfile~ b/Gemfile~ index 6b2f6e48..cb1ac1c2 100644 --- a/Gemfile~ +++ b/Gemfile~ @@ -13,7 +13,7 @@ gem 'formtastic' gem 'json' gem 'rails3-jquery-autocomplete' gem 'best_in_place' -#gem 'therubyracer' #optional +gem 'therubyracer' #optional gem 'rb-readline' # Gems used only for assets and not required diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index d7a4b2d1..b8e23b3f 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -102,6 +102,13 @@ function graphSettings(type, embed) { }, //Add also a click handler to nodes onClick: function (node, eventInfo, e) { + if (MetamapsModel.boxStartCoordinates) { + Mconsole.busy = false; + MetamapsModel.boxEndCoordinates = eventInfo.getPos(); + selectNodesWithBox(); + return; + } + if (e.target.id != "infovis-canvas") return false; //topic and synapse editing cards @@ -111,7 +118,7 @@ function graphSettings(type, embed) { deselectAllEdges(); } - //clicking on a node, or clicking on blank part of canvas? + //clicking on a edge, node, or clicking on blank part of canvas? if (node.nodeFrom) { selectEdgeOnClickHandler(node, e); } else if (node && !node.nodeFrom) { @@ -432,6 +439,7 @@ var nodeSettings = { } function drawSelectBox(eventInfo, e) { + Mconsole.plot(); var ctx=Mconsole.canvas.getCtx(); var startX = MetamapsModel.boxStartCoordinates.x, @@ -475,21 +483,6 @@ function selectNodesWithBox() { function onMouseMoveHandler(node, eventInfo, e) { if (Mconsole.busy) return; - - if (!MetamapsModel.boxStartCoordinates && e.shiftKey) { - MetamapsModel.boxStartCoordinates = eventInfo.getPos(); - return; - } - if (MetamapsModel.boxStartCoordinates && e.shiftKey) { - drawSelectBox(eventInfo,e); - return; - } - if (MetamapsModel.boxStartCoordinates && !e.shiftKey) { - MetamapsModel.boxEndCoordinates = eventInfo.getPos(); - Mconsole.plot(); - selectNodesWithBox(); - return; - } var node = eventInfo.getNode(); var edge = eventInfo.getEdge(); diff --git a/app/assets/javascripts/Jit/jit2.0.0.js b/app/assets/javascripts/Jit/jit2.0.0.js index 0a5fdc9e..c62970ed 100644 --- a/app/assets/javascripts/Jit/jit2.0.0.js +++ b/app/assets/javascripts/Jit/jit2.0.0.js @@ -2616,6 +2616,11 @@ Extras.Classes.Navigation = new Class({ if(!this.config.panning) return; if(this.config.panning == 'avoid nodes' && eventInfo.getNode()) return; this.pressed = true; + //START METAMAPS CODE + if (!MetamapsModel.boxStartCoordinates && e.shiftKey) { + MetamapsModel.boxStartCoordinates = eventInfo.getPos(); + } + // END METAMAPS CODE this.pos = eventInfo.getPos(); var canvas = this.canvas, ox = canvas.translateOffsetX, @@ -2632,12 +2637,22 @@ Extras.Classes.Navigation = new Class({ if(!this.config.panning) return; if(!this.pressed) return; if(this.config.panning == 'avoid nodes' && eventInfo.getNode()) return; - // START METAMAPS CODE - if (e.target.id != 'infovis-canvas') { - this.pressed = false; - return; - } - // END METAMAPS CODE + // START METAMAPS CODE + if (!MetamapsModel.boxStartCoordinates && e.shiftKey) { + Mconsole.busy = true; + MetamapsModel.boxStartCoordinates = eventInfo.getPos(); + return; + } + if (MetamapsModel.boxStartCoordinates && e.shiftKey) { + Mconsole.busy = true; + drawSelectBox(eventInfo,e); + return; + } + if (e.target.id != 'infovis-canvas') { + this.pressed = false; + return; + } + // END METAMAPS CODE var thispos = this.pos, currentPos = eventInfo.getPos(), canvas = this.canvas, diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 47bba8d2..35ef4a3a 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, touchPos, touchDragNode; +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, mouseIsDown = false; $(document).ready(function() { diff --git a/app/assets/stylesheets/ForceDirected.css b/app/assets/stylesheets/ForceDirected.css index 0e70f5da..d0fd0f50 100644 --- a/app/assets/stylesheets/ForceDirected.css +++ b/app/assets/stylesheets/ForceDirected.css @@ -14,4 +14,10 @@ span.name { cursor: pointer; position: absolute; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 9065e7cd..8bbb6f6f 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -245,6 +245,15 @@ input[type="submit"] { /*overflow:hidden; */ } +#infovis-canvas { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + /* --- top options --*/ .headertop { display:block;