fixed right click on topic menu, fixed synapse color when opening for synapse card, removed mCustomScrollbar

This commit is contained in:
Connor Turland 2014-10-04 00:15:47 -04:00
parent fae7f9996d
commit d30417f958
10 changed files with 48 additions and 108 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -424,7 +424,6 @@ Metamaps.GlobalUI.Search = {
padding: '7px 10px 3px 10px', padding: '7px 10px 3px 10px',
width: '380px' width: '380px'
}); });
$('.sidebarSearchField').focus();
self.changing = false; self.changing = false;
self.isOpen = true; self.isOpen = true;
}); });
@ -451,11 +450,6 @@ Metamaps.GlobalUI.Search = {
}); });
} }
}, closeAfter); }, closeAfter);
/*if (self.locked) {
$('.sidebarSearchField').typeahead('setQuery', '');
$('.sidebarSearchField').blur();
}*/
}, },
startTypeahead: function () { startTypeahead: function () {
var self = Metamaps.GlobalUI.Search; var self = Metamaps.GlobalUI.Search;

View file

@ -568,7 +568,12 @@ Metamaps.JIT = {
levelDistance: 200 levelDistance: 200
}, },
onMouseEnter: function (edge) { onMouseEnter: function (edge) {
if (edge.getData('alpha') === 0) return; // don't do anything if the edge is filtered var filtered = edge.getData('alpha') === 0;
// don't do anything if the edge is filtered
// or if the canvas is animating
if (filtered || Metamaps.Visualize.mGraph.busy) return;
$('canvas').css('cursor', 'pointer'); $('canvas').css('cursor', 'pointer');
var edgeIsSelected = Metamaps.Selected.Edges.indexOf(edge); var edgeIsSelected = Metamaps.Selected.Edges.indexOf(edge);
//following if statement only executes if the edge being hovered over is not selected //following if statement only executes if the edge being hovered over is not selected
@ -1089,17 +1094,22 @@ Metamaps.JIT = {
} }
//The test synapse was selected! //The test synapse was selected!
// make sure the edge hasn't been hidden temporarily
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){
if(e.ctrlKey){ if(e.ctrlKey){
if(Metamaps.Selected.Edges.indexOf(synapse.get('edge')) != -1 ){ if(Metamaps.Selected.Edges.indexOf(synapse.get('edge')) != -1 ){
Metamaps.Control.deselectEdge(synapse.get('edge')); Metamaps.Control.deselectEdge(synapse.get('edge'));
} }
else{ else{
Metamaps.Control.selectEdge(synapse.get('edge')); if (edge) Metamaps.Control.selectEdge(synapse.get('edge'));
} }
} }
else{ else{
Metamaps.Control.selectEdge(synapse.get('edge')); if (edge) Metamaps.Control.selectEdge(synapse.get('edge'));
} }
} }
}); });
@ -1227,7 +1237,7 @@ Metamaps.JIT = {
top: e.clientY top: e.clientY
}); });
//add the menu to the page //add the menu to the page
$('#infovis-canvaswidget').append(rightclickmenu); $('#wrapper').append(rightclickmenu);
// attach events to clicks on the list items // attach events to clicks on the list items
@ -1264,7 +1274,7 @@ Metamaps.JIT = {
// when in radial, center on the topic you picked // when in radial, center on the topic you picked
$('.rc-center').click(function () { $('.rc-center').click(function () {
$('.rightclickmenu').remove(); $('.rightclickmenu').remove();
centerOn(node.id); Metamaps.Topic.centerOn(node.id);
}); });
// open the entity in a new tab // open the entity in a new tab
@ -1282,7 +1292,7 @@ Metamaps.JIT = {
}); });
// change the metacode of all the selected nodes that you have edit permission for // change the metacode of all the selected nodes that you have edit permission for
$('.rc-metacode li').click(function () { $('.rc-metacode li li').click(function () {
$('.rightclickmenu').remove(); $('.rightclickmenu').remove();
// //
Metamaps.Control.updateSelectedMetacodes($(this).attr('data-id')); Metamaps.Control.updateSelectedMetacodes($(this).attr('data-id'));

View file

@ -27,7 +27,7 @@ Metamaps.Settings = {
background: '#344A58', background: '#344A58',
synapses: { synapses: {
normal: '#888888', normal: '#888888',
hover: '#222222', hover: '#888888',
selected: '#FFFFFF' selected: '#FFFFFF'
}, },
topics: { topics: {
@ -61,6 +61,12 @@ Metamaps.Mouse = {
}; };
Metamaps.Selected = { Metamaps.Selected = {
reset: function () {
var self = Metamaps.Selected;
self.Nodes = [];
self.edges = [];
},
Nodes: [], Nodes: [],
Edges: [] Edges: []
}; };
@ -1323,6 +1329,7 @@ Metamaps.Visualize = {
self.mGraph.loadJSON(Metamaps.JIT.vizData, rootIndex); self.mGraph.loadJSON(Metamaps.JIT.vizData, rootIndex);
//compute positions and plot. //compute positions and plot.
self.computePositions(); self.computePositions();
self.mGraph.busy = true;
if (self.type == "RGraph") { if (self.type == "RGraph") {
self.mGraph.fx.animate(Metamaps.JIT.RGraph.animate); self.mGraph.fx.animate(Metamaps.JIT.RGraph.animate);
} else if (self.type == "ForceDirected") { } else if (self.type == "ForceDirected") {
@ -1494,7 +1501,7 @@ Metamaps.Realtime = {
}); });
$('body').click(self.close); $('body').click(self.close);
self.socket = io.connect('http://gentle-savannah-1303.herokuapp.com'); self.socket = io.connect('http://localhost:5001');
self.startActiveMap(); self.startActiveMap();
}, },
toggleBox: function (event) { toggleBox: function (event) {
@ -2222,7 +2229,7 @@ Metamaps.Control = {
} }
Metamaps.Visualize.mGraph.plot(); Metamaps.Visualize.mGraph.plot();
}, },
deselectEdge: function (edge, quick) { deselectEdge: function (edge) {
edge.setData('showDesc', false, 'current'); edge.setData('showDesc', false, 'current');
edge.setDataset('current', { edge.setDataset('current', {
@ -2233,8 +2240,7 @@ Metamaps.Control = {
if (Metamaps.Mouse.edgeHoveringOver == edge) { if (Metamaps.Mouse.edgeHoveringOver == edge) {
edge.setDataset('current', { edge.setDataset('current', {
showDesc: true, showDesc: true,
lineWidth: 4, lineWidth: 4
color: Metamaps.Settings.colors.synapses.hover
}); });
} }
@ -2295,6 +2301,7 @@ Metamaps.Control = {
var from = edge.nodeFrom.id; var from = edge.nodeFrom.id;
var to = edge.nodeTo.id; var to = edge.nodeTo.id;
edge.setData('alpha', 0, 'end'); edge.setData('alpha', 0, 'end');
Metamaps.Control.deselectEdge(edge);
Metamaps.Visualize.mGraph.fx.animate({ Metamaps.Visualize.mGraph.fx.animate({
modes: ['edge-property:alpha'], modes: ['edge-property:alpha'],
duration: 500 duration: 500
@ -2924,6 +2931,9 @@ Metamaps.Topic = {
// update filters // update filters
Metamaps.Filter.reset(); Metamaps.Filter.reset();
// reset selected arrays
Metamaps.Selected.reset();
// these three update the actual filter box with the right list items // these three update the actual filter box with the right list items
Metamaps.Filter.checkMetacodes(); Metamaps.Filter.checkMetacodes();
Metamaps.Filter.checkSynapses(); Metamaps.Filter.checkSynapses();
@ -2942,6 +2952,18 @@ Metamaps.Topic = {
Metamaps.SynapseCard.hideCard(); Metamaps.SynapseCard.hideCard();
} }
}, },
centerOn: function (nodeid) {
if (!Metamaps.Visualize.mGraph.busy) {
var node = Metamaps.Visualize.mGraph.graph.getNode(nodeid);
Metamaps.Visualize.mGraph.onClick(node.id, {
hideLabels: false,
duration: 1000,
onComplete: function () {
}
});
}
},
/* /*
* *
* *
@ -3163,9 +3185,8 @@ Metamaps.Synapse = {
Metamaps.Visualize.mGraph.graph.addAdjacence(node1, node2, newedge.data); Metamaps.Visualize.mGraph.graph.addAdjacence(node1, node2, newedge.data);
edgeOnViz = Metamaps.Visualize.mGraph.graph.getAdjacence(node1.id, node2.id); edgeOnViz = Metamaps.Visualize.mGraph.graph.getAdjacence(node1.id, node2.id);
synapse.set('edge', edgeOnViz); synapse.set('edge', edgeOnViz);
synapse.updateEdge(); // links the topic and the mapping to the node synapse.updateEdge(); // links the synapse and the mapping to the edge
Metamaps.Visualize.mGraph.fx.plotLine(edgeOnViz, Metamaps.Visualize.mGraph.canvas);
Metamaps.Control.selectEdge(edgeOnViz); Metamaps.Control.selectEdge(edgeOnViz);
var mappingSuccessCallback = function (mappingModel, response) { var mappingSuccessCallback = function (mappingModel, response) {
@ -3310,6 +3331,9 @@ Metamaps.Map = {
// update filters // update filters
Metamaps.Filter.reset(); Metamaps.Filter.reset();
// reset selected arrays
Metamaps.Selected.reset();
// set the proper mapinfobox content // set the proper mapinfobox content
Metamaps.Map.InfoBox.load(); Metamaps.Map.InfoBox.load();

View file

@ -32,20 +32,3 @@ function fetchRelatives(node) {
} }
}); });
} }
function centerOn(nodeid) {
if (!Mconsole.busy) {
var node = Mconsole.graph.getNode(nodeid);
$('div.index img').attr('src', imgArray[node.getData('metacode')].src);
$('div.index .mapName').html(node.name);
$(document).attr('title', node.name + ' | Metamaps');
window.history.pushState(node.name, "Metamaps", "/topics/" + node.id);
Mconsole.onClick(node.id, {
hideLabels: false,
duration: 1000,
onComplete: function () {
fetchRelatives(node);
}
});
}
}

View file

@ -108,9 +108,6 @@ class TopicsController < ApplicationController
@map = m.map @map = m.map
@map.touch(:updated_at) @map.touch(:updated_at)
#push notify to anyone viewing same map in realtime (see mapping.rb to understand the 'message' action)
m.message 'destroy',@current.id
m.delete m.delete
end end
@ -122,9 +119,6 @@ class TopicsController < ApplicationController
@map = mapping.map @map = mapping.map
@map.touch(:updated_at) @map.touch(:updated_at)
#push notify to anyone viewing a map with this topic in realtime (see mapping.rb to understand the 'message' action)
mapping.message 'destroy',@current.id
mapping.delete mapping.delete
end end

View file

@ -18,30 +18,4 @@ class Mapping < ActiveRecord::Base
super(:methods =>[:user_name, :user_image]) super(:methods =>[:user_name, :user_image])
end end
# sends push updates through redis to websockets for realtime updates
def message action, origin_user_id
if self.category == "Topic"
return if self.topic.permission == "private" and action == "create"
msg = { origin: origin_user_id,
mapid: self.map.id,
resource: self.category,
action: action,
id: self.topic.id,
obj: self.topic.selfonmap_as_json(self.map.id).html_safe }
elsif self.category == "Synapse"
return if self.synapse.permission == "private" and action == "create"
msg = { origin: origin_user_id,
mapid: self.map.id,
resource: self.category,
action: action,
id: self.synapse.id,
obj: self.synapse.self_as_json.html_safe }
end
$redis.publish 'maps', msg.to_json
end
end end

View file

@ -20,25 +20,6 @@ class Synapse < ActiveRecord::Base
super(:methods =>[:user_name, :user_image]) super(:methods =>[:user_name, :user_image])
end end
# sends push updates through redis to websockets for realtime updates
def message action, origin_user_id
return if self.permission == "private" and action == "create"
#get array of all maps topic appears in
@maps = self.maps
#sends update to all maps that topic appears in who have realtime on
@maps.each do |map|
msg = { origin: origin_user_id,
mapid: map.id,
resource: 'Synapse',
action: action,
id: self.id,
obj: self.self_as_json.html_safe }
$redis.publish 'maps', msg.to_json
end
end
##### PERMISSIONS ###### ##### PERMISSIONS ######
# returns false if user not allowed to 'show' Topic, Synapse, or Map # returns false if user not allowed to 'show' Topic, Synapse, or Map

View file

@ -58,25 +58,6 @@ class Topic < ActiveRecord::Base
super(:methods =>[:user_name, :user_image, :map_count, :synapse_count]) super(:methods =>[:user_name, :user_image, :map_count, :synapse_count])
end end
# sends push updates through redis to websockets for realtime updates
def message action, origin_user_id
return if self.permission == "private" and action == "create"
#get array of all maps topic appears in
@maps = self.maps
#sends update to all maps that topic appears in who have realtime on
@maps.each do |map|
msg = { origin: origin_user_id,
mapid: map.id,
resource: 'Topic',
action: action,
id: self.id,
obj: self.selfonmap_as_json(map.id).html_safe }
$redis.publish 'maps', msg.to_json
end
end
def topic_autocomplete_method def topic_autocomplete_method
"Get: #{self.name}" "Get: #{self.name}"
end end