From 453758a9ffdc7048b4a6e1b01676ae1d3bc52342 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 29 Nov 2014 15:23:53 -0500 Subject: [PATCH 1/5] use lambda to store currentPage so explore/mine doesn't get rendered incorrectly in url as explore/ --- app/assets/javascripts/src/Metamaps.Views.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/src/Metamaps.Views.js b/app/assets/javascripts/src/Metamaps.Views.js index eab536ba..36fc0d2c 100644 --- a/app/assets/javascripts/src/Metamaps.Views.js +++ b/app/assets/javascripts/src/Metamaps.Views.js @@ -91,8 +91,14 @@ Metamaps.Views.init = function () { } Metamaps.Loading.hide(); - setTimeout(function(){ - var path = Metamaps.currentSection == "" ? "" : "/explore/" + Metamaps.currentPage; + + console.log("OK current page is " + Metamaps.currentPage); + console.log(Metamaps); + setTimeout((function(localCurrentPage){ return function(){ + console.log("YEAH current page is " + Metamaps.currentPage); + console.log("YEAH current page passed is " + localCurrentPage); + console.log(Metamaps); + var path = (Metamaps.currentSection == "") ? "" : "/explore/" + localCurrentPage; // alter url if for mapper profile page if (that.collection && that.collection.mapperId) { @@ -100,7 +106,7 @@ Metamaps.Views.init = function () { } Metamaps.Router.navigate(path); - }, 500); + }})(Metamaps.currentPage), 500); }, handleSuccess: function () { var that = this; @@ -133,4 +139,4 @@ Metamaps.Views.init = function () { Metamaps.Views.exploreMaps = new mapsWrapper(); }; -})(); \ No newline at end of file +})(); From 5f347bff6785fe49444c4b8534312c12a5c4093d Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 29 Nov 2014 15:24:34 -0500 Subject: [PATCH 2/5] remove console.logs whoops --- app/assets/javascripts/src/Metamaps.Views.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/assets/javascripts/src/Metamaps.Views.js b/app/assets/javascripts/src/Metamaps.Views.js index 36fc0d2c..b56a599f 100644 --- a/app/assets/javascripts/src/Metamaps.Views.js +++ b/app/assets/javascripts/src/Metamaps.Views.js @@ -92,12 +92,7 @@ Metamaps.Views.init = function () { Metamaps.Loading.hide(); - console.log("OK current page is " + Metamaps.currentPage); - console.log(Metamaps); setTimeout((function(localCurrentPage){ return function(){ - console.log("YEAH current page is " + Metamaps.currentPage); - console.log("YEAH current page passed is " + localCurrentPage); - console.log(Metamaps); var path = (Metamaps.currentSection == "") ? "" : "/explore/" + localCurrentPage; // alter url if for mapper profile page From fe3d2808621ffe79bb342fd1d6ac5ea6f5753cb9 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 29 Nov 2014 15:29:16 -0500 Subject: [PATCH 3/5] remove console.log from Connor --- app/assets/javascripts/src/Metamaps.Router.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/javascripts/src/Metamaps.Router.js b/app/assets/javascripts/src/Metamaps.Router.js index 5c5d6879..6d9e2012 100644 --- a/app/assets/javascripts/src/Metamaps.Router.js +++ b/app/assets/javascripts/src/Metamaps.Router.js @@ -225,7 +225,6 @@ if (href.attr === "") Metamaps.Router.home(); else { - console.log(segments); Metamaps.Router[segments[0]](segments[1], segments[2]); } } From 93227f0e2fd8eb70271a87edac51240cfc52d0b3 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Sat, 29 Nov 2014 15:36:03 -0500 Subject: [PATCH 4/5] fixed synapse selection and removal of multiple topics bugs --- app/assets/javascripts/src/Metamaps.JIT.js | 32 ++++++++++++---------- app/assets/javascripts/src/Metamaps.js | 30 +++++--------------- 2 files changed, 25 insertions(+), 37 deletions(-) diff --git a/app/assets/javascripts/src/Metamaps.JIT.js b/app/assets/javascripts/src/Metamaps.JIT.js index f27bbb02..ee6068bb 100644 --- a/app/assets/javascripts/src/Metamaps.JIT.js +++ b/app/assets/javascripts/src/Metamaps.JIT.js @@ -1129,11 +1129,18 @@ Metamaps.JIT = { sY = -1 * sY; eY = -1 * eY - Metamaps.Synapses.each(function(synapse) { - var fromNodeX = synapse.get('edge').nodeFrom.pos.x; - var fromNodeY = -1 * synapse.get('edge').nodeFrom.pos.y; - var toNodeX = synapse.get('edge').nodeTo.pos.x; - var toNodeY = -1 * synapse.get('edge').nodeTo.pos.y; + var edgesToToggle = []; + Metamaps.Synapses.each(function(synapse) { + var e = synapse.get('edge'); + if (edgesToToggle.indexOf(e) === -1) { + edgesToToggle.push(e); + } + }); + edgesToToggle.forEach(function(edge) { + var fromNodeX = edge.nodeFrom.pos.x; + var fromNodeY = -1 * edge.nodeFrom.pos.y; + var toNodeX = edge.nodeTo.pos.x; + var toNodeY = -1 * edge.nodeTo.pos.y; var maxX = fromNodeX; var maxY = fromNodeY; @@ -1209,21 +1216,18 @@ Metamaps.JIT = { //The test synapse was selected! - // make sure the edge hasn't been hidden from the page - var node1id = synapse.get('edge').nodeFrom.id; - var node2id = synapse.get('edge').nodeTo.id; - var edge = Metamaps.Visualize.mGraph.graph.getAdjacence(node1id, node2id); - if(selectTest){ + if(selectTest){ + // shiftKey = toggleSelect, otherwise if(e.shiftKey){ - if(Metamaps.Selected.Edges.indexOf(synapse.get('edge')) != -1 ){ - Metamaps.Control.deselectEdge(synapse.get('edge')); + if(Metamaps.Selected.Edges.indexOf(edge) != -1 ){ + Metamaps.Control.deselectEdge(edge); } else{ - if (edge) Metamaps.Control.selectEdge(synapse.get('edge')); + Metamaps.Control.selectEdge(edge); } } else{ - if (edge) Metamaps.Control.selectEdge(synapse.get('edge')); + Metamaps.Control.selectEdge(edge); } } }); diff --git a/app/assets/javascripts/src/Metamaps.js b/app/assets/javascripts/src/Metamaps.js index 5bce8987..e27d6423 100644 --- a/app/assets/javascripts/src/Metamaps.js +++ b/app/assets/javascripts/src/Metamaps.js @@ -2818,20 +2818,8 @@ Metamaps.Control = { } Metamaps.Control.deselectNode(node); - - node.setData('alpha', 0, 'end'); - node.eachAdjacency(function (adj) { - adj.setData('alpha', 0, 'end'); - }); - Metamaps.Visualize.mGraph.fx.animate({ - modes: ['node-property:alpha', - 'edge-property:alpha' - ], - duration: 500 - }); - setTimeout(function () { - Metamaps.Visualize.mGraph.graph.removeNode(nodeid); - }, 500); + Metamaps.Visualize.mGraph.graph.removeNode(nodeid); + Metamaps.Visualize.mGraph.plot(); Metamaps.Filter.checkMetacodes(); Metamaps.Filter.checkMappers(); }, @@ -2996,17 +2984,13 @@ Metamaps.Control = { hideEdge: function (edge) { var from = edge.nodeFrom.id; var to = edge.nodeTo.id; - edge.setData('alpha', 0, 'end'); Metamaps.Control.deselectEdge(edge); - Metamaps.Visualize.mGraph.fx.animate({ - modes: ['edge-property:alpha'], - duration: 500 - }); - setTimeout(function () { + if (Metamaps.Visualize.mGraph.graph.getAdjacence(from, to)) { Metamaps.Visualize.mGraph.graph.removeAdjacence(from, to); - }, 500); - Metamaps.Filter.checkSynapses(); - Metamaps.Filter.checkMappers(); + Metamaps.Visualize.mGraph.plot(); + Metamaps.Filter.checkSynapses(); + Metamaps.Filter.checkMappers(); + } }, updateSelectedPermissions: function (permission) { From 739eba71bb0ced9d6d97c1d2b00ec00fd8c0e161 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 29 Nov 2014 15:51:31 -0500 Subject: [PATCH 5/5] only one router setTimeout function at a time - make it erase old functions if new one --- app/assets/javascripts/src/Metamaps.Views.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/src/Metamaps.Views.js b/app/assets/javascripts/src/Metamaps.Views.js index b56a599f..00f1b7f6 100644 --- a/app/assets/javascripts/src/Metamaps.Views.js +++ b/app/assets/javascripts/src/Metamaps.Views.js @@ -9,7 +9,7 @@ Metamaps.Views.init = function () { template: Hogan.compile( $('#mapperCardTemplate').html() ), - tagName: "div", + tagNamea: "div", className: "mapper", @@ -92,7 +92,8 @@ Metamaps.Views.init = function () { Metamaps.Loading.hide(); - setTimeout((function(localCurrentPage){ return function(){ + clearTimeout(Metamaps.routerTimeoutFunctionIds); + Metamaps.routerTimeoutId = setTimeout((function(localCurrentPage){ return function(){ var path = (Metamaps.currentSection == "") ? "" : "/explore/" + localCurrentPage; // alter url if for mapper profile page