merge with develop
This commit is contained in:
commit
db719abf0f
18 changed files with 587 additions and 300 deletions
|
@ -7081,7 +7081,8 @@ Graph.Plot = {
|
||||||
var l = Metamaps.Mouse.synapseStartCoordinates.length;
|
var l = Metamaps.Mouse.synapseStartCoordinates.length;
|
||||||
for (var i = l - 1; i >= 0; i -= 1) {
|
for (var i = l - 1; i >= 0; i -= 1) {
|
||||||
start = Metamaps.Mouse.synapseStartCoordinates[i];
|
start = Metamaps.Mouse.synapseStartCoordinates[i];
|
||||||
Metamaps.JIT.renderMidArrow(start, end, 13, false, canvas, 0.5, true);
|
Metamaps.JIT.renderMidArrow(start, end, 13, false, canvas, 0.3, true);
|
||||||
|
Metamaps.JIT.renderMidArrow(start, end, 13, false, canvas, 0.7, true);
|
||||||
}
|
}
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
Metamaps.JIT = {
|
Metamaps.JIT = {
|
||||||
events: {
|
events: {
|
||||||
mouseMove: 'Metamaps:JIT:events:mouseMove',
|
mouseMove: 'Metamaps:JIT:events:mouseMove',
|
||||||
|
topicDrag: 'Metamaps:JIT:events:topicDrag',
|
||||||
|
newTopic: 'Metamaps:JIT:events:newTopic',
|
||||||
|
removeTopic: 'Metamaps:JIT:events:removeTopic',
|
||||||
|
newSynapse: 'Metamaps:JIT:events:newSynapse',
|
||||||
|
removeSynapse: 'Metamaps:JIT:events:removeSynapse',
|
||||||
pan: 'Metamaps:JIT:events:pan',
|
pan: 'Metamaps:JIT:events:pan',
|
||||||
zoom: 'Metamaps:JIT:events:zoom'
|
zoom: 'Metamaps:JIT:events:zoom'
|
||||||
},
|
},
|
||||||
|
@ -20,6 +25,7 @@ Metamaps.JIT = {
|
||||||
*/
|
*/
|
||||||
prepareVizData: function () {
|
prepareVizData: function () {
|
||||||
var self = Metamaps.JIT;
|
var self = Metamaps.JIT;
|
||||||
|
var synapsesToRemove = [];
|
||||||
var topic;
|
var topic;
|
||||||
var mapping;
|
var mapping;
|
||||||
var node;
|
var node;
|
||||||
|
@ -39,7 +45,12 @@ Metamaps.JIT = {
|
||||||
Metamaps.Synapses.each(function (s) {
|
Metamaps.Synapses.each(function (s) {
|
||||||
edge = s.createEdge();
|
edge = s.createEdge();
|
||||||
|
|
||||||
if (nodes[edge.nodeFrom] && nodes[edge.nodeTo]) {
|
if(Metamaps.Topics.get(s.get('node1_id')) === undefined || Metamaps.Topics.get(s.get('node2_id')) === undefined) {
|
||||||
|
// this means it's an invalid synapse
|
||||||
|
synapsesToRemove.push(s);
|
||||||
|
}
|
||||||
|
else if (nodes[edge.nodeFrom] && nodes[edge.nodeTo]) {
|
||||||
|
|
||||||
existingEdge = _.findWhere(edges, {
|
existingEdge = _.findWhere(edges, {
|
||||||
nodeFrom: edge.nodeFrom,
|
nodeFrom: edge.nodeFrom,
|
||||||
nodeTo: edge.nodeTo
|
nodeTo: edge.nodeTo
|
||||||
|
@ -53,15 +64,24 @@ Metamaps.JIT = {
|
||||||
// for when you're dealing with multiple relationships between the same two topics
|
// for when you're dealing with multiple relationships between the same two topics
|
||||||
if (Metamaps.Active.Map) {
|
if (Metamaps.Active.Map) {
|
||||||
mapping = s.getMapping();
|
mapping = s.getMapping();
|
||||||
existingEdge['$mappingIDs'].push(mapping.isNew() ? mapping.cid : mapping.id);
|
existingEdge.data['$mappingIDs'].push(mapping.id);
|
||||||
}
|
}
|
||||||
existingEdge['$synapseIDs'].push(s.id);
|
existingEdge.data['$synapseIDs'].push(s.id);
|
||||||
} else {
|
} else {
|
||||||
// for when you're dealing with a topic that has relationships to many different nodes
|
// for when you're dealing with a topic that has relationships to many different nodes
|
||||||
nodes[edge.nodeFrom].adjacencies.push(edge);
|
nodes[edge.nodeFrom].adjacencies.push(edge);
|
||||||
|
edges.push(edge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// clean up the synapses array in case of any faulty data
|
||||||
|
_.each(synapsesToRemove, function (synapse) {
|
||||||
|
mapping = synapse.getMapping();
|
||||||
|
Metamaps.Synapses.remove(synapse);
|
||||||
|
Metamaps.Mappings.remove(mapping);
|
||||||
|
});
|
||||||
|
|
||||||
_.each(nodes, function (node) {
|
_.each(nodes, function (node) {
|
||||||
self.vizData.push(node);
|
self.vizData.push(node);
|
||||||
});
|
});
|
||||||
|
@ -319,7 +339,7 @@ Metamaps.JIT = {
|
||||||
if (Metamaps.Mouse.boxStartCoordinates) {
|
if (Metamaps.Mouse.boxStartCoordinates) {
|
||||||
Metamaps.Visualize.mGraph.busy = false;
|
Metamaps.Visualize.mGraph.busy = false;
|
||||||
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
|
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
|
||||||
Metamaps.JIT.zoomToBox();
|
Metamaps.JIT.zoomToBox(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -688,6 +708,11 @@ Metamaps.JIT = {
|
||||||
|
|
||||||
var self = Metamaps.JIT;
|
var self = Metamaps.JIT;
|
||||||
|
|
||||||
|
// this is used to send nodes that are moving to
|
||||||
|
// other realtime collaborators on the same map
|
||||||
|
var positionsToSend = {};
|
||||||
|
var topic;
|
||||||
|
|
||||||
if (node && !node.nodeFrom) {
|
if (node && !node.nodeFrom) {
|
||||||
var pos = eventInfo.getPos();
|
var pos = eventInfo.getPos();
|
||||||
// if it's a left click, or a touch, move the node
|
// if it's a left click, or a touch, move the node
|
||||||
|
@ -695,13 +720,23 @@ Metamaps.JIT = {
|
||||||
//if the node dragged isn't already selected, select it
|
//if the node dragged isn't already selected, select it
|
||||||
var whatToDo = self.handleSelectionBeforeDragging(node, e);
|
var whatToDo = self.handleSelectionBeforeDragging(node, e);
|
||||||
if (node.pos.rho || node.pos.rho === 0) {
|
if (node.pos.rho || node.pos.rho === 0) {
|
||||||
|
// this means we're in topic view
|
||||||
var rho = Math.sqrt(pos.x * pos.x + pos.y * pos.y);
|
var rho = Math.sqrt(pos.x * pos.x + pos.y * pos.y);
|
||||||
var theta = Math.atan2(pos.y, pos.x);
|
var theta = Math.atan2(pos.y, pos.x);
|
||||||
node.pos.setp(theta, rho);
|
node.pos.setp(theta, rho);
|
||||||
} else if (whatToDo == 'only-drag-this-one') {
|
} else if (whatToDo == 'only-drag-this-one') {
|
||||||
node.pos.setc(pos.x, pos.y);
|
node.pos.setc(pos.x, pos.y);
|
||||||
node.setData('xloc', pos.x);
|
|
||||||
node.setData('yloc', pos.y);
|
if (Metamaps.Active.Map) {
|
||||||
|
topic = node.getData('topic');
|
||||||
|
// we use the topic ID not the node id
|
||||||
|
// because we can't depend on the node id
|
||||||
|
// to be the same as on other collaborators
|
||||||
|
// maps
|
||||||
|
positionsToSend[topic.id] = pos;
|
||||||
|
$(document).trigger(Metamaps.JIT.events.topicDrag, [positionsToSend]);
|
||||||
|
$(document).trigger(Metamaps.JIT.events.mouseMove, [pos]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
var len = Metamaps.Selected.Nodes.length;
|
var len = Metamaps.Selected.Nodes.length;
|
||||||
|
|
||||||
|
@ -719,9 +754,21 @@ Metamaps.JIT = {
|
||||||
var x = pos.x + xOffset[i];
|
var x = pos.x + xOffset[i];
|
||||||
var y = pos.y + yOffset[i];
|
var y = pos.y + yOffset[i];
|
||||||
n.pos.setc(x, y);
|
n.pos.setc(x, y);
|
||||||
n.setData('xloc', x);
|
|
||||||
n.setData('yloc', y);
|
if (Metamaps.Active.Map) {
|
||||||
|
topic = n.getData('topic');
|
||||||
|
// we use the topic ID not the node id
|
||||||
|
// because we can't depend on the node id
|
||||||
|
// to be the same as on other collaborators
|
||||||
|
// maps
|
||||||
|
positionsToSend[topic.id] = n.pos;
|
||||||
|
}
|
||||||
} //for
|
} //for
|
||||||
|
|
||||||
|
if (Metamaps.Active.Map) {
|
||||||
|
$(document).trigger(Metamaps.JIT.events.topicDrag, [positionsToSend]);
|
||||||
|
$(document).trigger(Metamaps.JIT.events.mouseMove, [pos]);
|
||||||
|
}
|
||||||
} //if
|
} //if
|
||||||
|
|
||||||
if (whatToDo == 'deselect') {
|
if (whatToDo == 'deselect') {
|
||||||
|
@ -792,6 +839,7 @@ Metamaps.JIT = {
|
||||||
x: pos.x,
|
x: pos.x,
|
||||||
y: pos.y
|
y: pos.y
|
||||||
};
|
};
|
||||||
|
$(document).trigger(Metamaps.JIT.events.mouseMove, [pos]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -816,8 +864,8 @@ Metamaps.JIT = {
|
||||||
} else if (tempInit && tempNode2 != null) {
|
} else if (tempInit && tempNode2 != null) {
|
||||||
// this means you want to create a synapse between two existing topics
|
// this means you want to create a synapse between two existing topics
|
||||||
Metamaps.Create.newTopic.addSynapse = false;
|
Metamaps.Create.newTopic.addSynapse = false;
|
||||||
Metamaps.Create.newSynapse.topic1id = tempNode.id;
|
Metamaps.Create.newSynapse.topic1id = tempNode.getData('topic').id;
|
||||||
Metamaps.Create.newSynapse.topic2id = tempNode2.id;
|
Metamaps.Create.newSynapse.topic2id = tempNode2.getData('topic').id;
|
||||||
tempNode2.setData('dim', 25, 'current');
|
tempNode2.setData('dim', 25, 'current');
|
||||||
Metamaps.Visualize.mGraph.plot();
|
Metamaps.Visualize.mGraph.plot();
|
||||||
midpoint.x = tempNode.pos.getc().x + (tempNode2.pos.getc().x - tempNode.pos.getc().x) / 2;
|
midpoint.x = tempNode.pos.getc().x + (tempNode2.pos.getc().x - tempNode.pos.getc().x) / 2;
|
||||||
|
@ -1414,9 +1462,9 @@ Metamaps.JIT = {
|
||||||
var v2 = intermediatePoint.$add(normal.$scale(-1));
|
var v2 = intermediatePoint.$add(normal.$scale(-1));
|
||||||
|
|
||||||
if (newSynapse) {
|
if (newSynapse) {
|
||||||
ctx.strokeStyle = "#222222";
|
ctx.strokeStyle = "#4fc059";
|
||||||
ctx.lineWidth = 2;
|
ctx.lineWidth = 2;
|
||||||
ctx.globalAlpha = 0.4;
|
ctx.globalAlpha = 1;
|
||||||
}
|
}
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.moveTo(from.x, from.y);
|
ctx.moveTo(from.x, from.y);
|
||||||
|
@ -1465,8 +1513,7 @@ Metamaps.JIT = {
|
||||||
y: posChild.y
|
y: posChild.y
|
||||||
}, 13, false, canvas, 0.7);
|
}, 13, false, canvas, 0.7);
|
||||||
} else if (directionCat == "from-to") {
|
} else if (directionCat == "from-to") {
|
||||||
var direction = adj.data.$direction;
|
var inv = (direction[0] != adj.nodeFrom.id);
|
||||||
var inv = (direction && direction.length > 1 && direction[0] != adj.nodeFrom.id);
|
|
||||||
self.renderMidArrow({
|
self.renderMidArrow({
|
||||||
x: pos.x,
|
x: pos.x,
|
||||||
y: pos.y
|
y: pos.y
|
||||||
|
@ -1502,7 +1549,7 @@ Metamaps.JIT = {
|
||||||
|
|
||||||
canvas.translate(-1*offsetX,-1*offsetY);
|
canvas.translate(-1*offsetX,-1*offsetY);
|
||||||
},
|
},
|
||||||
zoomToBox: function () {
|
zoomToBox: function (event) {
|
||||||
var sX = Metamaps.Mouse.boxStartCoordinates.x,
|
var sX = Metamaps.Mouse.boxStartCoordinates.x,
|
||||||
sY = Metamaps.Mouse.boxStartCoordinates.y,
|
sY = Metamaps.Mouse.boxStartCoordinates.y,
|
||||||
eX = Metamaps.Mouse.boxEndCoordinates.x,
|
eX = Metamaps.Mouse.boxEndCoordinates.x,
|
||||||
|
@ -1538,14 +1585,14 @@ Metamaps.JIT = {
|
||||||
var cogY = (sY + eY)/2;
|
var cogY = (sY + eY)/2;
|
||||||
|
|
||||||
canvas.translate(-1* cogX, -1* cogY);
|
canvas.translate(-1* cogX, -1* cogY);
|
||||||
|
$(document).trigger(Metamaps.JIT.events.zoom, [event]);
|
||||||
|
|
||||||
Metamaps.Mouse.boxStartCoordinates = false;
|
Metamaps.Mouse.boxStartCoordinates = false;
|
||||||
Metamaps.Mouse.boxEndCoordinates = false;
|
Metamaps.Mouse.boxEndCoordinates = false;
|
||||||
Metamaps.Visualize.mGraph.plot();
|
Metamaps.Visualize.mGraph.plot();
|
||||||
|
|
||||||
},
|
},
|
||||||
zoomExtents: function () {
|
zoomExtents: function (event) {
|
||||||
Metamaps.JIT.centerMap();
|
Metamaps.JIT.centerMap();
|
||||||
var height = $(document).height(),
|
var height = $(document).height(),
|
||||||
width = $(document).width(),
|
width = $(document).width(),
|
||||||
|
|
|
@ -130,6 +130,7 @@
|
||||||
Metamaps.GlobalUI.Search.unlock();
|
Metamaps.GlobalUI.Search.unlock();
|
||||||
Metamaps.GlobalUI.Search.close(0, true);
|
Metamaps.GlobalUI.Search.close(0, true);
|
||||||
|
|
||||||
|
Metamaps.Loading.show();
|
||||||
Metamaps.Map.end();
|
Metamaps.Map.end();
|
||||||
Metamaps.Map.launch(id);
|
Metamaps.Map.launch(id);
|
||||||
},
|
},
|
||||||
|
|
|
@ -217,15 +217,15 @@ Metamaps.Backbone.init = function () {
|
||||||
else return false;
|
else return false;
|
||||||
},
|
},
|
||||||
getTopic1: function () {
|
getTopic1: function () {
|
||||||
return Metamaps.Topic.get(this.get('node1_id'));
|
return Metamaps.Topics.get(this.get('node1_id'));
|
||||||
},
|
},
|
||||||
getTopic2: function () {
|
getTopic2: function () {
|
||||||
return Metamaps.Topic.get(this.get('node2_id'));
|
return Metamaps.Topics.get(this.get('node2_id'));
|
||||||
},
|
},
|
||||||
getDirection: function () {
|
getDirection: function () {
|
||||||
return [
|
return [
|
||||||
this.get('node1_id'),
|
this.getTopic1().get('node').id,
|
||||||
this.get('node2_id')
|
this.getTopic2().get('node').id
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
getMapping: function () {
|
getMapping: function () {
|
||||||
|
@ -1232,11 +1232,15 @@ Metamaps.Visualize = {
|
||||||
topic.updateNode();
|
topic.updateNode();
|
||||||
|
|
||||||
n.eachAdjacency(function (edge) {
|
n.eachAdjacency(function (edge) {
|
||||||
l = edge.getData('synapseIDs').length;
|
if(!edge.getData('init')) {
|
||||||
for (i = 0; i < l; i++) {
|
edge.setData('init', true);
|
||||||
synapse = Metamaps.Synapses.get(edge.getData('synapseIDs')[i]);
|
|
||||||
synapse.set('edge', edge);
|
l = edge.getData('synapseIDs').length;
|
||||||
synapse.updateEdge();
|
for (i = 0; i < l; i++) {
|
||||||
|
synapse = Metamaps.Synapses.get(edge.getData('synapseIDs')[i]);
|
||||||
|
synapse.set('edge', edge);
|
||||||
|
synapse.updateEdge();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1254,11 +1258,15 @@ Metamaps.Visualize = {
|
||||||
mapping = topic.getMapping();
|
mapping = topic.getMapping();
|
||||||
|
|
||||||
n.eachAdjacency(function (edge) {
|
n.eachAdjacency(function (edge) {
|
||||||
l = edge.getData('synapseIDs').length;
|
if(!edge.getData('init')) {
|
||||||
for (i = 0; i < l; i++) {
|
edge.setData('init', true);
|
||||||
synapse = Metamaps.Synapses.get(edge.getData('synapseIDs')[i]);
|
|
||||||
synapse.set('edge', edge);
|
l = edge.getData('synapseIDs').length;
|
||||||
synapse.updateEdge();
|
for (i = 0; i < l; i++) {
|
||||||
|
synapse = Metamaps.Synapses.get(edge.getData('synapseIDs')[i]);
|
||||||
|
synapse.set('edge', edge);
|
||||||
|
synapse.updateEdge();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1274,7 +1282,6 @@ Metamaps.Visualize = {
|
||||||
/**
|
/**
|
||||||
* render does the heavy lifting of creating the engine that renders the graph with the properties we desire
|
* render does the heavy lifting of creating the engine that renders the graph with the properties we desire
|
||||||
*
|
*
|
||||||
* @param vizData a json structure containing the data to be rendered.
|
|
||||||
*/
|
*/
|
||||||
render: function () {
|
render: function () {
|
||||||
var self = Metamaps.Visualize, RGraphSettings, FDSettings;
|
var self = Metamaps.Visualize, RGraphSettings, FDSettings;
|
||||||
|
@ -1499,7 +1506,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://gentle-savannah-1303.herokuapp.com');
|
||||||
self.startActiveMap();
|
self.startActiveMap();
|
||||||
},
|
},
|
||||||
toggleBox: function (event) {
|
toggleBox: function (event) {
|
||||||
|
@ -1612,14 +1619,30 @@ Metamaps.Realtime = {
|
||||||
// receive word that there's a mapper turned on realtime
|
// receive word that there's a mapper turned on realtime
|
||||||
socket.on('maps-' + Metamaps.Active.Map.id + '-lostrealtime', self.lostCollaborator);
|
socket.on('maps-' + Metamaps.Active.Map.id + '-lostrealtime', self.lostCollaborator);
|
||||||
|
|
||||||
socket.on('maps-' + Metamaps.Active.Map.id, self.contentUpdate);
|
//
|
||||||
|
socket.on('maps-' + Metamaps.Active.Map.id + '-topicDrag', self.topicDrag);
|
||||||
|
|
||||||
|
//
|
||||||
|
socket.on('maps-' + Metamaps.Active.Map.id + '-newTopic', self.newTopic);
|
||||||
|
|
||||||
|
//
|
||||||
|
socket.on('maps-' + Metamaps.Active.Map.id + '-removeTopic', self.removeTopic);
|
||||||
|
|
||||||
|
//
|
||||||
|
socket.on('maps-' + Metamaps.Active.Map.id + '-newSynapse', self.newSynapse);
|
||||||
|
|
||||||
|
//
|
||||||
|
socket.on('maps-' + Metamaps.Active.Map.id + '-removeSynapse', self.removeSynapse);
|
||||||
|
|
||||||
// update mapper compass position
|
// update mapper compass position
|
||||||
socket.on('maps-' + Metamaps.Active.Map.id + '-updatePeerCoords', self.updatePeerCoords);
|
socket.on('maps-' + Metamaps.Active.Map.id + '-updatePeerCoords', self.updatePeerCoords);
|
||||||
|
|
||||||
|
// local event listeners that trigger events
|
||||||
var sendCoords = function (event, coords) {
|
var sendCoords = function (event, coords) {
|
||||||
self.sendCoords(coords);
|
self.sendCoords(coords);
|
||||||
};
|
};
|
||||||
|
$(document).on(Metamaps.JIT.events.mouseMove, sendCoords);
|
||||||
|
|
||||||
var zoom = function (event, e) {
|
var zoom = function (event, e) {
|
||||||
if (e) {
|
if (e) {
|
||||||
var pixels = {
|
var pixels = {
|
||||||
|
@ -1631,9 +1654,35 @@ Metamaps.Realtime = {
|
||||||
}
|
}
|
||||||
self.positionPeerIcons();
|
self.positionPeerIcons();
|
||||||
};
|
};
|
||||||
$(document).on(Metamaps.JIT.events.mouseMove, sendCoords);
|
|
||||||
$(document).on(Metamaps.JIT.events.zoom, zoom);
|
$(document).on(Metamaps.JIT.events.zoom, zoom);
|
||||||
|
|
||||||
$(document).on(Metamaps.JIT.events.pan, self.positionPeerIcons);
|
$(document).on(Metamaps.JIT.events.pan, self.positionPeerIcons);
|
||||||
|
|
||||||
|
var sendTopicDrag = function (event, positions) {
|
||||||
|
self.sendTopicDrag(positions);
|
||||||
|
};
|
||||||
|
$(document).on(Metamaps.JIT.events.topicDrag, sendTopicDrag);
|
||||||
|
|
||||||
|
var sendNewTopic = function (event, data) {
|
||||||
|
self.sendNewTopic(data);
|
||||||
|
};
|
||||||
|
$(document).on(Metamaps.JIT.events.newTopic, sendNewTopic);
|
||||||
|
|
||||||
|
var sendRemoveTopic = function (event, data) {
|
||||||
|
self.sendRemoveTopic(data);
|
||||||
|
};
|
||||||
|
$(document).on(Metamaps.JIT.events.removeTopic, sendRemoveTopic);
|
||||||
|
|
||||||
|
var sendNewSynapse = function (event, data) {
|
||||||
|
self.sendNewSynapse(data);
|
||||||
|
};
|
||||||
|
$(document).on(Metamaps.JIT.events.newSynapse, sendNewSynapse);
|
||||||
|
|
||||||
|
var sendRemoveSynapse = function (event, data) {
|
||||||
|
self.sendRemoveSynapse(data);
|
||||||
|
};
|
||||||
|
$(document).on(Metamaps.JIT.events.removeSynapse, sendRemoveSynapse);
|
||||||
|
|
||||||
},
|
},
|
||||||
sendRealtimeOn: function () {
|
sendRealtimeOn: function () {
|
||||||
var self = Metamaps.Realtime;
|
var self = Metamaps.Realtime;
|
||||||
|
@ -1892,120 +1941,169 @@ Metamaps.Realtime = {
|
||||||
socket.emit('updateMapperCoords', update);
|
socket.emit('updateMapperCoords', update);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
contentUpdate: function (data) {
|
sendTopicDrag: function (positions) {
|
||||||
var self = Metamaps.Realtime;
|
var self = Metamaps.Realtime;
|
||||||
var socket = Metamaps.Realtime.socket;
|
var socket = self.socket;
|
||||||
var graph = Metamaps.Visualize.mGraph.graph;
|
|
||||||
|
|
||||||
//as long as you weren't the origin of the changes, update your map
|
if (Metamaps.Active.Map && self.status) {
|
||||||
if (data.origin != Metamaps.Active.Mapper.id && self.status) {
|
positions.mapid = Metamaps.Active.Map.id;
|
||||||
if (data.resource == 'Topic') {
|
socket.emit('topicDrag', positions);
|
||||||
topic = $.parseJSON(data.obj);
|
}
|
||||||
|
},
|
||||||
|
topicDrag: function (positions) {
|
||||||
|
var self = Metamaps.Realtime;
|
||||||
|
var socket = self.socket;
|
||||||
|
|
||||||
if (data.action == 'create') {
|
var topic;
|
||||||
self.addTopicToMap(topic);
|
var node;
|
||||||
} else if (data.action == 'update' && graph.getNode(topic.id) != 'undefined') {
|
|
||||||
self.updateTopicOnMap(topic);
|
|
||||||
} else if (data.action == 'destroy' && graph.getNode(topic.id) != 'undefined') {
|
|
||||||
Metamaps.Control.hideNode(topic.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
if (Metamaps.Active.Map && self.status) {
|
||||||
} else if (data.resource == 'Synapse') {
|
for (var key in positions) {
|
||||||
synapse = $.parseJSON(data.obj);
|
topic = Metamaps.Topics.get(key);
|
||||||
|
if (topic) node = topic.get('node');
|
||||||
|
if (node) node.pos.setc(positions[key].x, positions[key].y);
|
||||||
|
} //for
|
||||||
|
Metamaps.Visualize.mGraph.plot();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// newTopic
|
||||||
|
sendNewTopic: function (data) {
|
||||||
|
var self = Metamaps.Realtime;
|
||||||
|
var socket = self.socket;
|
||||||
|
|
||||||
if (data.action == 'create') {
|
if (Metamaps.Active.Map && self.status) {
|
||||||
self.addSynapseToMap(synapse);
|
data.mapperid = Metamaps.Active.Mapper.id;
|
||||||
} else if (data.action == 'update' &&
|
data.mapid = Metamaps.Active.Map.id;
|
||||||
graph.getAdjacence(synapse.data.$direction['0'], synapse.data.$direction['1']) != 'undefined') {
|
socket.emit('newTopic', data);
|
||||||
self.updateSynapseOnMap(synapse);
|
}
|
||||||
} else if (data.action == 'destroy' &&
|
},
|
||||||
graph.getAdjacence(synapse.data.$direction['0'], synapse.data.$direction['1']) != 'undefined') {
|
newTopic: function (data) {
|
||||||
var edge = graph.getAdjacence(synapse.data.$direction['0'], synapse.data.$direction['1']);
|
var topic, mapping, mapper, mapperCallback, cancel;
|
||||||
Metamaps.Control.hideEdge(edge);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
function test() {
|
||||||
|
if (topic && mapping && mapper) {
|
||||||
|
Metamaps.Topic.renderTopic(mapping, topic, false, false);
|
||||||
|
}
|
||||||
|
else if (!cancel) {
|
||||||
|
setTimeout(test, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
addTopicToMap: function (topic) {
|
|
||||||
|
|
||||||
// TODO
|
mapper = Metamaps.Mappers.get(data.mapperid);
|
||||||
var newPos, tempForT;
|
if (mapper === undefined) {
|
||||||
Metamaps.Visualize.mGraph.graph.addNode(topic);
|
mapperCallback = function (m) {
|
||||||
tempForT = Metamaps.Visualize.mGraph.graph.getNode(topic.id);
|
Metamaps.Mappers.add(m);
|
||||||
tempForT.setData('dim', 1, 'start');
|
mapper = m;
|
||||||
tempForT.setData('dim', 25, 'end');
|
};
|
||||||
newPos = new $jit.Complex();
|
Metamaps.Mapper.get(data.mapperid, mapperCallback);
|
||||||
newPos.x = tempForT.data.$xloc;
|
|
||||||
newPos.y = tempForT.data.$yloc;
|
|
||||||
tempForT.setPos(newPos, 'start');
|
|
||||||
tempForT.setPos(newPos, 'current');
|
|
||||||
tempForT.setPos(newPos, 'end');
|
|
||||||
Metamaps.Visualize.mGraph.fx.plotNode(tempForT, Metamaps.Visualize.mGraph.canvas);
|
|
||||||
},
|
|
||||||
updateTopicOnMap: function (topic) {
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
var newPos, tempForT;
|
|
||||||
tempForT = Metamaps.Visualize.mGraph.graph.getNode(topic.id);
|
|
||||||
tempForT.data = topic.data;
|
|
||||||
tempForT.name = topic.name;
|
|
||||||
if (MetamapsModel.showcardInUse === topic.id) {
|
|
||||||
populateShowCard(tempForT);
|
|
||||||
}
|
}
|
||||||
newPos = new $jit.Complex();
|
$.ajax({
|
||||||
newPos.x = tempForT.data.$xloc;
|
url: "/topics/" + data.topicid + ".json",
|
||||||
newPos.y = tempForT.data.$yloc;
|
success: function (response) {
|
||||||
tempForT.setPos(newPos, 'start');
|
Metamaps.Topics.add(response);
|
||||||
tempForT.setPos(newPos, 'current');
|
topic = Metamaps.Topics.get(response.id);
|
||||||
tempForT.setPos(newPos, 'end');
|
},
|
||||||
return Metamaps.Visualize.mGraph.fx.animate({
|
error: function () {
|
||||||
modes: ['linear', 'node-property:dim', 'edge-property:lineWidth'],
|
cancel = true;
|
||||||
transition: $jit.Trans.Quad.easeInOut,
|
}
|
||||||
duration: 500
|
});
|
||||||
|
$.ajax({
|
||||||
|
url: "/mappings/" + data.mappingid + ".json",
|
||||||
|
success: function (response) {
|
||||||
|
Metamaps.Mappings.add(response);
|
||||||
|
mapping = Metamaps.Mappings.get(response.id);
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
cancel = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
|
||||||
addSynapseToMap: function (synapse) {
|
|
||||||
|
|
||||||
// TODO
|
test();
|
||||||
var Node1, Node2, tempForS;
|
|
||||||
Node1 = Metamaps.Visualize.mGraph.graph.getNode(synapse.data.$direction[0]);
|
|
||||||
Node2 = Metamaps.Visualize.mGraph.graph.getNode(synapse.data.$direction[1]);
|
|
||||||
Metamaps.Visualize.mGraph.graph.addAdjacence(Node1, Node2, {});
|
|
||||||
tempForS = Metamaps.Visualize.mGraph.graph.getAdjacence(Node1.id, Node2.id);
|
|
||||||
tempForS.setDataset('start', {
|
|
||||||
lineWidth: 0.4
|
|
||||||
});
|
|
||||||
tempForS.setDataset('end', {
|
|
||||||
lineWidth: 2
|
|
||||||
});
|
|
||||||
tempForS.data = synapse.data;
|
|
||||||
Metamaps.Visualize.mGraph.fx.plotLine(tempForS, Metamaps.Visualize.mGraph.canvas);
|
|
||||||
return Metamaps.Visualize.mGraph.fx.animate({
|
|
||||||
modes: ['linear', 'node-property:dim', 'edge-property:lineWidth'],
|
|
||||||
transition: $jit.Trans.Quad.easeInOut,
|
|
||||||
duration: 500
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
updateSynapseOnMap: function (synapse) {
|
// removeTopic
|
||||||
|
sendRemoveTopic: function (data) {
|
||||||
|
var self = Metamaps.Realtime;
|
||||||
|
var socket = self.socket;
|
||||||
|
|
||||||
// TODO
|
if (Metamaps.Active.Map && self.status) {
|
||||||
var k, tempForS, v, wasShowDesc, _ref;
|
data.mapid = Metamaps.Active.Map.id;
|
||||||
tempForS = Metamaps.Visualize.mGraph.graph.getAdjacence(synapse.data.$direction[0], synapse.data.$direction[1]);
|
socket.emit('removeTopic', data);
|
||||||
wasShowDesc = tempForS.data.$showDesc;
|
|
||||||
_ref = synapse.data;
|
|
||||||
for (k in _ref) {
|
|
||||||
v = _ref[k];
|
|
||||||
tempForS.data[k] = v;
|
|
||||||
}
|
}
|
||||||
tempForS.data.$showDesc = wasShowDesc;
|
},
|
||||||
if (MetamapsModel.edgecardInUse === synapse.data.$id) { // TODO
|
removeTopic: function (data) {
|
||||||
editEdge(tempForS, false);
|
|
||||||
|
},
|
||||||
|
// newSynapse
|
||||||
|
sendNewSynapse: function (data) {
|
||||||
|
var self = Metamaps.Realtime;
|
||||||
|
var socket = self.socket;
|
||||||
|
|
||||||
|
if (Metamaps.Active.Map && self.status) {
|
||||||
|
data.mapperid = Metamaps.Active.Mapper.id;
|
||||||
|
data.mapid = Metamaps.Active.Map.id;
|
||||||
|
socket.emit('newSynapse', data);
|
||||||
}
|
}
|
||||||
return Metamaps.Visualize.mGraph.plot();
|
},
|
||||||
}
|
newSynapse: function (data) {
|
||||||
|
var topic1, topic2, node1, node2, synapse, mapping, cancel;
|
||||||
|
|
||||||
|
function test() {
|
||||||
|
if (synapse && mapping && mapper) {
|
||||||
|
topic1 = synapse.getTopic1();
|
||||||
|
node1 = topic1.get('node');
|
||||||
|
topic2 = synapse.getTopic2();
|
||||||
|
node2 = topic2.get('node');
|
||||||
|
|
||||||
|
Metamaps.Synapse.renderSynapse(mapping, synapse, node1, node2, false);
|
||||||
|
}
|
||||||
|
else if (!cancel) {
|
||||||
|
setTimeout(test, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mapper = Metamaps.Mappers.get(data.mapperid);
|
||||||
|
if (mapper === undefined) {
|
||||||
|
mapperCallback = function (m) {
|
||||||
|
Metamaps.Mappers.add(m);
|
||||||
|
mapper = m;
|
||||||
|
};
|
||||||
|
Metamaps.Mapper.get(data.mapperid, mapperCallback);
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: "/synapses/" + data.synapseid + ".json",
|
||||||
|
success: function (response) {
|
||||||
|
Metamaps.Synapses.add(response);
|
||||||
|
synapse = Metamaps.Synapses.get(response.id);
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
cancel = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$.ajax({
|
||||||
|
url: "/mappings/" + data.mappingid + ".json",
|
||||||
|
success: function (response) {
|
||||||
|
Metamaps.Mappings.add(response);
|
||||||
|
mapping = Metamaps.Mappings.get(response.id);
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
cancel = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
test();
|
||||||
|
},
|
||||||
|
// removeSynapse
|
||||||
|
sendRemoveSynapse: function (data) {
|
||||||
|
var self = Metamaps.Realtime;
|
||||||
|
var socket = self.socket;
|
||||||
|
|
||||||
|
if (Metamaps.Active.Map && self.status) {
|
||||||
|
data.mapid = Metamaps.Active.Map.id;
|
||||||
|
socket.emit('removeSynapse', data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
removeSynapse: function (data) {
|
||||||
|
|
||||||
|
},
|
||||||
}; // end Metamaps.Realtime
|
}; // end Metamaps.Realtime
|
||||||
|
|
||||||
|
|
||||||
|
@ -2895,13 +2993,15 @@ Metamaps.Topic = {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
renderTopic: function (mapping, topic, createNewInDB) {
|
renderTopic: function (mapping, topic, createNewInDB, permitCreateSynapseAfter) {
|
||||||
var self = Metamaps.Topic;
|
var self = Metamaps.Topic;
|
||||||
|
|
||||||
var nodeOnViz, tempPos;
|
var nodeOnViz, tempPos;
|
||||||
|
|
||||||
var newnode = topic.createNode();
|
var newnode = topic.createNode();
|
||||||
|
|
||||||
|
var midpoint = {}, pixelPos;
|
||||||
|
|
||||||
if (!$.isEmptyObject(Metamaps.Visualize.mGraph.graph.nodes)) {
|
if (!$.isEmptyObject(Metamaps.Visualize.mGraph.graph.nodes)) {
|
||||||
Metamaps.Visualize.mGraph.graph.addNode(newnode);
|
Metamaps.Visualize.mGraph.graph.addNode(newnode);
|
||||||
Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
|
Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
|
||||||
|
@ -2926,9 +3026,16 @@ Metamaps.Topic = {
|
||||||
nodeOnViz.setPos(new $jit.Complex(mapping.get('xloc'), mapping.get('yloc')), "start");
|
nodeOnViz.setPos(new $jit.Complex(mapping.get('xloc'), mapping.get('yloc')), "start");
|
||||||
nodeOnViz.setPos(new $jit.Complex(mapping.get('xloc'), mapping.get('yloc')), "end");
|
nodeOnViz.setPos(new $jit.Complex(mapping.get('xloc'), mapping.get('yloc')), "end");
|
||||||
}
|
}
|
||||||
if (Metamaps.Create.newTopic.addSynapse) {
|
if (Metamaps.Create.newTopic.addSynapse && permitCreateSynapseAfter) {
|
||||||
Metamaps.Create.newSynapse.topic1id = tempNode.id;
|
Metamaps.Create.newSynapse.topic1id = tempNode.getData('topic').id;
|
||||||
Metamaps.Create.newSynapse.topic2id = nodeOnViz.id;
|
|
||||||
|
// position the form
|
||||||
|
midpoint.x = tempNode.pos.getc().x + (nodeOnViz.pos.getc().x - tempNode.pos.getc().x) / 2;
|
||||||
|
midpoint.y = tempNode.pos.getc().y + (nodeOnViz.pos.getc().y - tempNode.pos.getc().y) / 2;
|
||||||
|
pixelPos = Metamaps.Util.coordsToPixels(midpoint);
|
||||||
|
$('#new_synapse').css('left', pixelPos.x + "px");
|
||||||
|
$('#new_synapse').css('top', pixelPos.y + "px");
|
||||||
|
// show the form
|
||||||
Metamaps.Create.newSynapse.open();
|
Metamaps.Create.newSynapse.open();
|
||||||
Metamaps.Visualize.mGraph.fx.animate({
|
Metamaps.Visualize.mGraph.fx.animate({
|
||||||
modes: ["node-property:dim"],
|
modes: ["node-property:dim"],
|
||||||
|
@ -2970,20 +3077,41 @@ Metamaps.Topic = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var mappingSuccessCallback = function (mappingModel, response) {
|
||||||
|
var newTopicData = {
|
||||||
|
mappingid: mappingModel.id,
|
||||||
|
topicid: mappingModel.get('topic_id')
|
||||||
|
};
|
||||||
|
|
||||||
|
$(document).trigger(Metamaps.JIT.events.newTopic, [newTopicData]);
|
||||||
|
};
|
||||||
|
var topicSuccessCallback = function (topicModel, response) {
|
||||||
|
if (Metamaps.Active.Map) {
|
||||||
|
mapping.save({ topic_id: topicModel.id }, {
|
||||||
|
success: mappingSuccessCallback,
|
||||||
|
error: function (model, response) {
|
||||||
|
console.log('error saving mapping to database');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Metamaps.Create.newTopic.addSynapse) {
|
||||||
|
Metamaps.Create.newSynapse.topic2id = topicModel.id;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (!Metamaps.Settings.sandbox && createNewInDB) {
|
if (!Metamaps.Settings.sandbox && createNewInDB) {
|
||||||
if (topic.isNew()) {
|
if (topic.isNew()) {
|
||||||
topic.save(null, {
|
topic.save(null, {
|
||||||
success: function (topicModel, response) {
|
success: topicSuccessCallback,
|
||||||
if (Metamaps.Active.Map) {
|
|
||||||
mapping.save({ topic_id: topicModel.id });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function (model, response) {
|
error: function (model, response) {
|
||||||
console.log('error saving topic to database');
|
console.log('error saving topic to database');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (!topic.isNew() && Metamaps.Active.Map) {
|
} else if (!topic.isNew() && Metamaps.Active.Map) {
|
||||||
mapping.save();
|
mapping.save(null, {
|
||||||
|
success: mappingSuccessCallback
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -3011,7 +3139,7 @@ Metamaps.Topic = {
|
||||||
//these can't happen until the value is retrieved, which happens in the line above
|
//these can't happen until the value is retrieved, which happens in the line above
|
||||||
Metamaps.Create.newTopic.hide();
|
Metamaps.Create.newTopic.hide();
|
||||||
|
|
||||||
self.renderTopic(mapping, topic, true); // this function also includes the creation of the topic in the database
|
self.renderTopic(mapping, topic, true, true); // this function also includes the creation of the topic in the database
|
||||||
},
|
},
|
||||||
getTopicFromAutocomplete: function (id) {
|
getTopicFromAutocomplete: function (id) {
|
||||||
var self = Metamaps.Topic;
|
var self = Metamaps.Topic;
|
||||||
|
@ -3028,7 +3156,7 @@ Metamaps.Topic = {
|
||||||
});
|
});
|
||||||
Metamaps.Mappings.add(mapping);
|
Metamaps.Mappings.add(mapping);
|
||||||
|
|
||||||
self.renderTopic(mapping, topic, true);
|
self.renderTopic(mapping, topic, true, true);
|
||||||
}
|
}
|
||||||
}; // end Metamaps.Topic
|
}; // end Metamaps.Topic
|
||||||
|
|
||||||
|
@ -3087,20 +3215,34 @@ Metamaps.Synapse = {
|
||||||
Metamaps.Visualize.mGraph.fx.plotLine(edgeOnViz, Metamaps.Visualize.mGraph.canvas);
|
Metamaps.Visualize.mGraph.fx.plotLine(edgeOnViz, Metamaps.Visualize.mGraph.canvas);
|
||||||
Metamaps.Control.selectEdge(edgeOnViz);
|
Metamaps.Control.selectEdge(edgeOnViz);
|
||||||
|
|
||||||
|
var mappingSuccessCallback = function (mappingModel, response) {
|
||||||
|
var newSynapseData = {
|
||||||
|
mappingid: mappingModel.id,
|
||||||
|
synapseid: mappingModel.get('synapse_id')
|
||||||
|
};
|
||||||
|
|
||||||
|
$(document).trigger(Metamaps.JIT.events.newSynapse, [newSynapseData]);
|
||||||
|
};
|
||||||
|
var synapseSuccessCallback = function (synapseModel, response) {
|
||||||
|
if (Metamaps.Active.Map) {
|
||||||
|
mapping.save({ synapse_id: synapseModel.id }, {
|
||||||
|
success: mappingSuccessCallback
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (!Metamaps.Settings.sandbox && createNewInDB) {
|
if (!Metamaps.Settings.sandbox && createNewInDB) {
|
||||||
if (synapse.isNew()) {
|
if (synapse.isNew()) {
|
||||||
synapse.save(null, {
|
synapse.save(null, {
|
||||||
success: function (synapseModel, response) {
|
success: synapseSuccessCallback,
|
||||||
if (Metamaps.Active.Map) {
|
|
||||||
mapping.save({ synapse_id: synapseModel.id });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function (model, response) {
|
error: function (model, response) {
|
||||||
console.log('error saving synapse to database');
|
console.log('error saving synapse to database');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (!synapse.isNew() && Metamaps.Active.Map) {
|
} else if (!synapse.isNew() && Metamaps.Active.Map) {
|
||||||
mapping.save();
|
mapping.save(null, {
|
||||||
|
success: mappingSuccessCallback
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -3116,12 +3258,13 @@ Metamaps.Synapse = {
|
||||||
//for each node in this array we will create a synapse going to the position2 node.
|
//for each node in this array we will create a synapse going to the position2 node.
|
||||||
var synapsesToCreate = [];
|
var synapsesToCreate = [];
|
||||||
|
|
||||||
node2 = Metamaps.Visualize.mGraph.graph.getNode(Metamaps.Create.newSynapse.topic2id);
|
topic2 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic2id);
|
||||||
topic2 = node2.getData('topic');
|
node2 = topic2.get('node');
|
||||||
|
|
||||||
var len = Metamaps.Selected.Nodes.length;
|
var len = Metamaps.Selected.Nodes.length;
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
synapsesToCreate[0] = Metamaps.Visualize.mGraph.graph.getNode(Metamaps.Create.newSynapse.topic1id);
|
topic1 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic1id);
|
||||||
|
synapsesToCreate[0] = topic1.get('node');
|
||||||
} else if (len > 0) {
|
} else if (len > 0) {
|
||||||
synapsesToCreate = Metamaps.Selected.Nodes;
|
synapsesToCreate = Metamaps.Selected.Nodes;
|
||||||
}
|
}
|
||||||
|
@ -3150,6 +3293,8 @@ Metamaps.Synapse = {
|
||||||
},
|
},
|
||||||
getSynapseFromAutocomplete: function (id) {
|
getSynapseFromAutocomplete: function (id) {
|
||||||
var self = Metamaps.Synapse,
|
var self = Metamaps.Synapse,
|
||||||
|
topic1,
|
||||||
|
topic2,
|
||||||
node1,
|
node1,
|
||||||
node2;
|
node2;
|
||||||
|
|
||||||
|
@ -3161,8 +3306,10 @@ Metamaps.Synapse = {
|
||||||
});
|
});
|
||||||
Metamaps.Mappings.add(mapping);
|
Metamaps.Mappings.add(mapping);
|
||||||
|
|
||||||
node1 = Metamaps.Visualize.mGraph.graph.getNode(Metamaps.Create.newSynapse.topic1id);
|
topic1 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic1id);
|
||||||
node2 = Metamaps.Visualize.mGraph.graph.getNode(Metamaps.Create.newSynapse.topic2id);
|
node1 = topic1.get('node');
|
||||||
|
topic1 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic2id);
|
||||||
|
node2 = topic2.get('node');
|
||||||
Metamaps.Create.newSynapse.hide();
|
Metamaps.Create.newSynapse.hide();
|
||||||
|
|
||||||
self.renderSynapse(mapping, synapse, node1, node2, true);
|
self.renderSynapse(mapping, synapse, node1, node2, true);
|
||||||
|
@ -3220,6 +3367,7 @@ Metamaps.Map = {
|
||||||
Metamaps.Filter.checkMappers();
|
Metamaps.Filter.checkMappers();
|
||||||
|
|
||||||
Metamaps.Realtime.startActiveMap();
|
Metamaps.Realtime.startActiveMap();
|
||||||
|
Metamaps.Loading.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
|
@ -859,7 +859,7 @@ label[for="user_remember_me"] {
|
||||||
|
|
||||||
.sidebarFilterBox {
|
.sidebarFilterBox {
|
||||||
display:none;
|
display:none;
|
||||||
width: 304px;
|
width: 319px;
|
||||||
padding: 16px 0;
|
padding: 16px 0;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
@ -2148,6 +2148,9 @@ float: left;
|
||||||
.blackBox td.iconURL {
|
.blackBox td.iconURL {
|
||||||
max-width: 415px;
|
max-width: 415px;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
.blackBox td.iconColor {
|
||||||
|
|
||||||
}
|
}
|
||||||
.blackBox .field {
|
.blackBox .field {
|
||||||
margin: 15px 0 5px;
|
margin: 15px 0 5px;
|
||||||
|
|
|
@ -292,7 +292,7 @@ cursor: pointer;
|
||||||
display: none;
|
display: none;
|
||||||
width: 90%;
|
width: 90%;
|
||||||
padding: 13px 0 9px 10%;
|
padding: 13px 0 9px 10%;
|
||||||
background-color: #64BC61;
|
background-color: #E0E0E0;
|
||||||
color: #424242;
|
color: #424242;
|
||||||
}
|
}
|
||||||
.permission.canEdit .metacodeTitle {
|
.permission.canEdit .metacodeTitle {
|
||||||
|
|
|
@ -627,6 +627,14 @@
|
||||||
background-color: #9150bc;
|
background-color: #9150bc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.github-fork-ribbon-wrapper {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.homePage .github-fork-ribbon-wrapper {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
/* end home page */
|
/* end home page */
|
||||||
|
|
||||||
/* infoAndHelp */
|
/* infoAndHelp */
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
|
|
||||||
<%= render :partial => 'layouts/lightboxes' %>
|
<%= render :partial => 'layouts/lightboxes' %>
|
||||||
<%= render :partial => 'layouts/templates' %>
|
<%= render :partial => 'layouts/templates' %>
|
||||||
|
<%= render :partial => 'shared/metacodeBgColors' %>
|
||||||
<script type="text/javascript" charset="utf-8">
|
<script type="text/javascript" charset="utf-8">
|
||||||
BAROMETER.load('Scqak8nyHdFEkezKMNeQp');
|
BAROMETER.load('Scqak8nyHdFEkezKMNeQp');
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,11 @@
|
||||||
<%= f.text_field :icon %>
|
<%= f.text_field :icon %>
|
||||||
<div class="clearfloat"></div>
|
<div class="clearfloat"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<%= f.label :color, "Color (hex with # sign)" %>
|
||||||
|
<%= f.text_field :color %>
|
||||||
|
<div class="clearfloat"></div>
|
||||||
|
</div>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<%= link_to 'Cancel', metacodes_path, { :class => 'button', 'data-bypass' => 'true' } %>
|
<%= link_to 'Cancel', metacodes_path, { :class => 'button', 'data-bypass' => 'true' } %>
|
||||||
<%= f.submit :class => 'add' %>
|
<%= f.submit :class => 'add' %>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Icon</th>
|
<th>Icon</th>
|
||||||
|
<th>Color</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -14,6 +15,13 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= metacode.name %></td>
|
<td><%= metacode.name %></td>
|
||||||
<td class="iconURL"><%= metacode.icon %></td>
|
<td class="iconURL"><%= metacode.icon %></td>
|
||||||
|
<% if metacode.color %>
|
||||||
|
<td class="iconColor" style="background-color: <%= metacode.color %>">
|
||||||
|
<%= metacode.color %>
|
||||||
|
</td>
|
||||||
|
<% else %>
|
||||||
|
<td></td>
|
||||||
|
<% end %>
|
||||||
<td><img width='40' src='<%= metacode.icon %>' /></td>
|
<td><img width='40' src='<%= metacode.icon %>' /></td>
|
||||||
<td><%= link_to 'Edit', edit_metacode_path(metacode), :data => { :bypass => 'true'} %></td>
|
<td><%= link_to 'Edit', edit_metacode_path(metacode), :data => { :bypass => 'true'} %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -33,9 +33,21 @@
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@metacodes.sort! {|x,y| x.name <=> y.name }
|
@metacodes.sort! {|x,y|
|
||||||
@synapses.sort! {|x,y| x.desc <=> y.desc }
|
n1 = x.name || ""
|
||||||
@mappers.sort! {|x,y| x.name <=> y.name }
|
n2 = y.name || ""
|
||||||
|
n1 <=> n2
|
||||||
|
}
|
||||||
|
@synapses.sort! {|x,y|
|
||||||
|
d1 = x.desc || ""
|
||||||
|
d2 = y.desc || ""
|
||||||
|
d1 <=> d2
|
||||||
|
}
|
||||||
|
@mappers.sort! {|x,y|
|
||||||
|
n1 = x.name || ""
|
||||||
|
n2 = y.name || ""
|
||||||
|
n1 <=> n2
|
||||||
|
}
|
||||||
|
|
||||||
@metacodes.each_with_index do |metacode, index|
|
@metacodes.each_with_index do |metacode, index|
|
||||||
@metacodelist += '<li data-id="' + metacode.id.to_s + '">'
|
@metacodelist += '<li data-id="' + metacode.id.to_s + '">'
|
||||||
|
@ -43,8 +55,9 @@
|
||||||
@metacodelist += '<p>' + metacode.name.downcase + '</p></li>'
|
@metacodelist += '<p>' + metacode.name.downcase + '</p></li>'
|
||||||
end
|
end
|
||||||
@synapses.each_with_index do |synapse, index|
|
@synapses.each_with_index do |synapse, index|
|
||||||
@synapselist += '<li data-id="' + synapse.desc + '">'
|
d = synapse.desc || ""
|
||||||
@synapselist += '<img src="/assets/synapse16.png" alt="synapse icon" /><p>' + synapse.desc
|
@synapselist += '<li data-id="' + d + '">'
|
||||||
|
@synapselist += '<img src="/assets/synapse16.png" alt="synapse icon" /><p>' + d
|
||||||
@synapselist += '</p></li>'
|
@synapselist += '</p></li>'
|
||||||
end
|
end
|
||||||
@mappers.each_with_index do |mapper, index|
|
@mappers.each_with_index do |mapper, index|
|
||||||
|
|
9
app/views/shared/_metacodeBgColors.html.erb
Normal file
9
app/views/shared/_metacodeBgColors.html.erb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<style>
|
||||||
|
<% Metacode.all.each do |m| %>
|
||||||
|
<% if m.color %>
|
||||||
|
<%= ".mbg" + m.name.gsub(/\s+/, "") + "{" %>
|
||||||
|
<%= "background-color:" + m.color + " !important;" %>
|
||||||
|
<%= "}" %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</style>
|
|
@ -15,8 +15,10 @@
|
||||||
<div class="accountName" onclick="Metamaps.Account.changeName()">
|
<div class="accountName" onclick="Metamaps.Account.changeName()">
|
||||||
<div class="nameEdit"><%= @user.name %></div>
|
<div class="nameEdit"><%= @user.name %></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="changeName"><%= form.label :name, "Name:", :class => "firstFieldText" %>
|
<div class="changeName">
|
||||||
<%= form.email_field :name %></div>
|
<%= form.label :name, "Name:", :class => "firstFieldText" %>
|
||||||
|
<%= form.text_field :name %>
|
||||||
|
</div>
|
||||||
<div><%= form.label :email, "Email:", :class => "firstFieldText" %>
|
<div><%= form.label :email, "Email:", :class => "firstFieldText" %>
|
||||||
<%= form.email_field :email %></div>
|
<%= form.email_field :email %></div>
|
||||||
<div class="changePass" onclick="Metamaps.Account.showPass()">Change Password</div>
|
<div class="changePass" onclick="Metamaps.Account.showPass()">Change Password</div>
|
||||||
|
|
5
db/migrate/20140930013020_add_color_to_metacodes.rb
Normal file
5
db/migrate/20140930013020_add_color_to_metacodes.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddColorToMetacodes < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :metacodes, :color, :string
|
||||||
|
end
|
||||||
|
end
|
267
db/schema.rb
267
db/schema.rb
|
@ -1,133 +1,134 @@
|
||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
# This file is auto-generated from the current state of the database. Instead
|
# This file is auto-generated from the current state of the database. Instead
|
||||||
# of editing this file, please use the migrations feature of Active Record to
|
# of editing this file, please use the migrations feature of Active Record to
|
||||||
# incrementally modify your database, and then regenerate this schema definition.
|
# incrementally modify your database, and then regenerate this schema definition.
|
||||||
#
|
#
|
||||||
# Note that this schema.rb definition is the authoritative source for your
|
# Note that this schema.rb definition is the authoritative source for your
|
||||||
# database schema. If you need to create the application database on another
|
# database schema. If you need to create the application database on another
|
||||||
# system, you should be using db:schema:load, not running all the migrations
|
# system, you should be using db:schema:load, not running all the migrations
|
||||||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||||
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20140815162253) do
|
ActiveRecord::Schema.define(:version => 20140930013020) do
|
||||||
|
|
||||||
create_table "in_metacode_sets", :force => true do |t|
|
create_table "in_metacode_sets", :force => true do |t|
|
||||||
t.integer "metacode_id"
|
t.integer "metacode_id"
|
||||||
t.integer "metacode_set_id"
|
t.integer "metacode_set_id"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "in_metacode_sets", ["metacode_id"], :name => "index_in_metacode_sets_on_metacode_id"
|
add_index "in_metacode_sets", ["metacode_id"], :name => "index_in_metacode_sets_on_metacode_id"
|
||||||
add_index "in_metacode_sets", ["metacode_set_id"], :name => "index_in_metacode_sets_on_metacode_set_id"
|
add_index "in_metacode_sets", ["metacode_set_id"], :name => "index_in_metacode_sets_on_metacode_set_id"
|
||||||
|
|
||||||
create_table "mappings", :force => true do |t|
|
create_table "mappings", :force => true do |t|
|
||||||
t.text "category"
|
t.text "category"
|
||||||
t.integer "xloc"
|
t.integer "xloc"
|
||||||
t.integer "yloc"
|
t.integer "yloc"
|
||||||
t.integer "topic_id"
|
t.integer "topic_id"
|
||||||
t.integer "synapse_id"
|
t.integer "synapse_id"
|
||||||
t.integer "map_id"
|
t.integer "map_id"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "maps", :force => true do |t|
|
create_table "maps", :force => true do |t|
|
||||||
t.text "name"
|
t.text "name"
|
||||||
t.boolean "arranged"
|
t.boolean "arranged"
|
||||||
t.text "desc"
|
t.text "desc"
|
||||||
t.text "permission"
|
t.text "permission"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.boolean "featured"
|
t.boolean "featured"
|
||||||
t.string "screenshot_file_name"
|
t.string "screenshot_file_name"
|
||||||
t.string "screenshot_content_type"
|
t.string "screenshot_content_type"
|
||||||
t.integer "screenshot_file_size"
|
t.integer "screenshot_file_size"
|
||||||
t.datetime "screenshot_updated_at"
|
t.datetime "screenshot_updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "metacode_sets", :force => true do |t|
|
create_table "metacode_sets", :force => true do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.text "desc"
|
t.text "desc"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.boolean "mapperContributed"
|
t.boolean "mapperContributed"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "metacode_sets", ["user_id"], :name => "index_metacode_sets_on_user_id"
|
add_index "metacode_sets", ["user_id"], :name => "index_metacode_sets_on_user_id"
|
||||||
|
|
||||||
create_table "metacodes", :force => true do |t|
|
create_table "metacodes", :force => true do |t|
|
||||||
t.text "name"
|
t.text "name"
|
||||||
t.string "icon"
|
t.string "icon"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
t.string "color"
|
||||||
|
end
|
||||||
create_table "synapses", :force => true do |t|
|
|
||||||
t.text "desc"
|
create_table "synapses", :force => true do |t|
|
||||||
t.text "category"
|
t.text "desc"
|
||||||
t.text "weight"
|
t.text "category"
|
||||||
t.text "permission"
|
t.text "weight"
|
||||||
t.integer "node1_id"
|
t.text "permission"
|
||||||
t.integer "node2_id"
|
t.integer "node1_id"
|
||||||
t.integer "user_id"
|
t.integer "node2_id"
|
||||||
t.datetime "created_at", :null => false
|
t.integer "user_id"
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
end
|
t.datetime "updated_at", :null => false
|
||||||
|
end
|
||||||
create_table "topics", :force => true do |t|
|
|
||||||
t.text "name"
|
create_table "topics", :force => true do |t|
|
||||||
t.text "desc"
|
t.text "name"
|
||||||
t.text "link"
|
t.text "desc"
|
||||||
t.text "permission"
|
t.text "link"
|
||||||
t.integer "user_id"
|
t.text "permission"
|
||||||
t.integer "metacode_id"
|
t.integer "user_id"
|
||||||
t.datetime "created_at", :null => false
|
t.integer "metacode_id"
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.string "image_file_name"
|
t.datetime "updated_at", :null => false
|
||||||
t.string "image_content_type"
|
t.string "image_file_name"
|
||||||
t.integer "image_file_size"
|
t.string "image_content_type"
|
||||||
t.datetime "image_updated_at"
|
t.integer "image_file_size"
|
||||||
t.string "audio_file_name"
|
t.datetime "image_updated_at"
|
||||||
t.string "audio_content_type"
|
t.string "audio_file_name"
|
||||||
t.integer "audio_file_size"
|
t.string "audio_content_type"
|
||||||
t.datetime "audio_updated_at"
|
t.integer "audio_file_size"
|
||||||
end
|
t.datetime "audio_updated_at"
|
||||||
|
end
|
||||||
create_table "users", :force => true do |t|
|
|
||||||
t.string "name"
|
create_table "users", :force => true do |t|
|
||||||
t.string "email"
|
t.string "name"
|
||||||
t.text "settings"
|
t.string "email"
|
||||||
t.string "code", :limit => 8
|
t.text "settings"
|
||||||
t.string "joinedwithcode", :limit => 8
|
t.string "code", :limit => 8
|
||||||
t.string "crypted_password"
|
t.string "joinedwithcode", :limit => 8
|
||||||
t.string "password_salt"
|
t.string "crypted_password"
|
||||||
t.string "persistence_token"
|
t.string "password_salt"
|
||||||
t.string "perishable_token"
|
t.string "persistence_token"
|
||||||
t.datetime "created_at", :null => false
|
t.string "perishable_token"
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.string "encrypted_password", :limit => 128, :default => ""
|
t.datetime "updated_at", :null => false
|
||||||
t.string "remember_token"
|
t.string "encrypted_password", :limit => 128, :default => ""
|
||||||
t.datetime "remember_created_at"
|
t.string "remember_token"
|
||||||
t.string "reset_password_token"
|
t.datetime "remember_created_at"
|
||||||
t.datetime "last_sign_in_at"
|
t.string "reset_password_token"
|
||||||
t.string "last_sign_in_ip"
|
t.datetime "last_sign_in_at"
|
||||||
t.integer "sign_in_count", :default => 0
|
t.string "last_sign_in_ip"
|
||||||
t.datetime "current_sign_in_at"
|
t.integer "sign_in_count", :default => 0
|
||||||
t.string "current_sign_in_ip"
|
t.datetime "current_sign_in_at"
|
||||||
t.datetime "reset_password_sent_at"
|
t.string "current_sign_in_ip"
|
||||||
t.boolean "admin"
|
t.datetime "reset_password_sent_at"
|
||||||
t.string "image_file_name"
|
t.boolean "admin"
|
||||||
t.string "image_content_type"
|
t.string "image_file_name"
|
||||||
t.integer "image_file_size"
|
t.string "image_content_type"
|
||||||
t.datetime "image_updated_at"
|
t.integer "image_file_size"
|
||||||
end
|
t.datetime "image_updated_at"
|
||||||
|
end
|
||||||
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
|
|
||||||
|
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
|
||||||
end
|
|
||||||
|
end
|
||||||
|
|
|
@ -113,6 +113,41 @@ function start() {
|
||||||
socket.broadcast.emit('maps-' + data.mapid + '-updatePeerCoords', peer);
|
socket.broadcast.emit('maps-' + data.mapid + '-updatePeerCoords', peer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('topicDrag', function (data) {
|
||||||
|
var mapId = data.mapid;
|
||||||
|
delete data.mapid;
|
||||||
|
|
||||||
|
socket.broadcast.emit('maps-' + mapId + '-topicDrag', data);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('newTopic', function (data) {
|
||||||
|
var mapId = data.mapid;
|
||||||
|
delete data.mapid;
|
||||||
|
|
||||||
|
socket.broadcast.emit('maps-' + mapId + '-newTopic', data);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('removeTopic', function (data) {
|
||||||
|
var mapId = data.mapid;
|
||||||
|
delete data.mapid;
|
||||||
|
|
||||||
|
socket.broadcast.emit('maps-' + mapId + '-removeTopic', data);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('newSynapse', function (data) {
|
||||||
|
var mapId = data.mapid;
|
||||||
|
delete data.mapid;
|
||||||
|
|
||||||
|
socket.broadcast.emit('maps-' + mapId + '-newSynapse', data);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('removeSynapse', function (data) {
|
||||||
|
var mapId = data.mapid;
|
||||||
|
delete data.mapid;
|
||||||
|
|
||||||
|
socket.broadcast.emit('maps-' + mapId + '-removeSynapse', data);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
test/fixtures/metacodes.yml
vendored
1
test/fixtures/metacodes.yml
vendored
|
@ -7,6 +7,7 @@
|
||||||
one:
|
one:
|
||||||
name: Action
|
name: Action
|
||||||
icon: /assets/icons/action.png
|
icon: /assets/icons/action.png
|
||||||
|
color: #bd6c85
|
||||||
|
|
||||||
two:
|
two:
|
||||||
name: Activity
|
name: Activity
|
||||||
|
|
Loading…
Reference in a new issue