merge with develop

This commit is contained in:
Shai Mor 2014-10-01 09:57:40 -04:00
commit db719abf0f
18 changed files with 587 additions and 300 deletions

View file

@ -7081,7 +7081,8 @@ Graph.Plot = {
var l = Metamaps.Mouse.synapseStartCoordinates.length;
for (var i = l - 1; i >= 0; i -= 1) {
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();
}

View file

@ -1,6 +1,11 @@
Metamaps.JIT = {
events: {
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',
zoom: 'Metamaps:JIT:events:zoom'
},
@ -20,6 +25,7 @@ Metamaps.JIT = {
*/
prepareVizData: function () {
var self = Metamaps.JIT;
var synapsesToRemove = [];
var topic;
var mapping;
var node;
@ -39,7 +45,12 @@ Metamaps.JIT = {
Metamaps.Synapses.each(function (s) {
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, {
nodeFrom: edge.nodeFrom,
nodeTo: edge.nodeTo
@ -53,15 +64,24 @@ Metamaps.JIT = {
// for when you're dealing with multiple relationships between the same two topics
if (Metamaps.Active.Map) {
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 {
// for when you're dealing with a topic that has relationships to many different nodes
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) {
self.vizData.push(node);
});
@ -319,7 +339,7 @@ Metamaps.JIT = {
if (Metamaps.Mouse.boxStartCoordinates) {
Metamaps.Visualize.mGraph.busy = false;
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
Metamaps.JIT.zoomToBox();
Metamaps.JIT.zoomToBox(e);
return;
}
@ -688,6 +708,11 @@ 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) {
var pos = eventInfo.getPos();
// 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
var whatToDo = self.handleSelectionBeforeDragging(node, e);
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 theta = Math.atan2(pos.y, pos.x);
node.pos.setp(theta, rho);
} else if (whatToDo == 'only-drag-this-one') {
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 {
var len = Metamaps.Selected.Nodes.length;
@ -719,9 +754,21 @@ Metamaps.JIT = {
var x = pos.x + xOffset[i];
var y = pos.y + yOffset[i];
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
if (Metamaps.Active.Map) {
$(document).trigger(Metamaps.JIT.events.topicDrag, [positionsToSend]);
$(document).trigger(Metamaps.JIT.events.mouseMove, [pos]);
}
} //if
if (whatToDo == 'deselect') {
@ -792,6 +839,7 @@ Metamaps.JIT = {
x: pos.x,
y: pos.y
};
$(document).trigger(Metamaps.JIT.events.mouseMove, [pos]);
}
}
}
@ -816,8 +864,8 @@ Metamaps.JIT = {
} else if (tempInit && tempNode2 != null) {
// this means you want to create a synapse between two existing topics
Metamaps.Create.newTopic.addSynapse = false;
Metamaps.Create.newSynapse.topic1id = tempNode.id;
Metamaps.Create.newSynapse.topic2id = tempNode2.id;
Metamaps.Create.newSynapse.topic1id = tempNode.getData('topic').id;
Metamaps.Create.newSynapse.topic2id = tempNode2.getData('topic').id;
tempNode2.setData('dim', 25, 'current');
Metamaps.Visualize.mGraph.plot();
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));
if (newSynapse) {
ctx.strokeStyle = "#222222";
ctx.strokeStyle = "#4fc059";
ctx.lineWidth = 2;
ctx.globalAlpha = 0.4;
ctx.globalAlpha = 1;
}
ctx.beginPath();
ctx.moveTo(from.x, from.y);
@ -1465,8 +1513,7 @@ Metamaps.JIT = {
y: posChild.y
}, 13, false, canvas, 0.7);
} else if (directionCat == "from-to") {
var direction = adj.data.$direction;
var inv = (direction && direction.length > 1 && direction[0] != adj.nodeFrom.id);
var inv = (direction[0] != adj.nodeFrom.id);
self.renderMidArrow({
x: pos.x,
y: pos.y
@ -1502,7 +1549,7 @@ Metamaps.JIT = {
canvas.translate(-1*offsetX,-1*offsetY);
},
zoomToBox: function () {
zoomToBox: function (event) {
var sX = Metamaps.Mouse.boxStartCoordinates.x,
sY = Metamaps.Mouse.boxStartCoordinates.y,
eX = Metamaps.Mouse.boxEndCoordinates.x,
@ -1538,14 +1585,14 @@ Metamaps.JIT = {
var cogY = (sY + eY)/2;
canvas.translate(-1* cogX, -1* cogY);
$(document).trigger(Metamaps.JIT.events.zoom, [event]);
Metamaps.Mouse.boxStartCoordinates = false;
Metamaps.Mouse.boxEndCoordinates = false;
Metamaps.Visualize.mGraph.plot();
},
zoomExtents: function () {
zoomExtents: function (event) {
Metamaps.JIT.centerMap();
var height = $(document).height(),
width = $(document).width(),

View file

@ -130,6 +130,7 @@
Metamaps.GlobalUI.Search.unlock();
Metamaps.GlobalUI.Search.close(0, true);
Metamaps.Loading.show();
Metamaps.Map.end();
Metamaps.Map.launch(id);
},

View file

@ -217,15 +217,15 @@ Metamaps.Backbone.init = function () {
else return false;
},
getTopic1: function () {
return Metamaps.Topic.get(this.get('node1_id'));
return Metamaps.Topics.get(this.get('node1_id'));
},
getTopic2: function () {
return Metamaps.Topic.get(this.get('node2_id'));
return Metamaps.Topics.get(this.get('node2_id'));
},
getDirection: function () {
return [
this.get('node1_id'),
this.get('node2_id')
this.getTopic1().get('node').id,
this.getTopic2().get('node').id
];
},
getMapping: function () {
@ -1232,11 +1232,15 @@ Metamaps.Visualize = {
topic.updateNode();
n.eachAdjacency(function (edge) {
l = edge.getData('synapseIDs').length;
for (i = 0; i < l; i++) {
synapse = Metamaps.Synapses.get(edge.getData('synapseIDs')[i]);
synapse.set('edge', edge);
synapse.updateEdge();
if(!edge.getData('init')) {
edge.setData('init', true);
l = edge.getData('synapseIDs').length;
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();
n.eachAdjacency(function (edge) {
l = edge.getData('synapseIDs').length;
for (i = 0; i < l; i++) {
synapse = Metamaps.Synapses.get(edge.getData('synapseIDs')[i]);
synapse.set('edge', edge);
synapse.updateEdge();
if(!edge.getData('init')) {
edge.setData('init', true);
l = edge.getData('synapseIDs').length;
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
*
* @param vizData a json structure containing the data to be rendered.
*/
render: function () {
var self = Metamaps.Visualize, RGraphSettings, FDSettings;
@ -1499,7 +1506,7 @@ Metamaps.Realtime = {
});
$('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();
},
toggleBox: function (event) {
@ -1612,14 +1619,30 @@ Metamaps.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, 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
socket.on('maps-' + Metamaps.Active.Map.id + '-updatePeerCoords', self.updatePeerCoords);
// local event listeners that trigger events
var sendCoords = function (event, coords) {
self.sendCoords(coords);
};
$(document).on(Metamaps.JIT.events.mouseMove, sendCoords);
var zoom = function (event, e) {
if (e) {
var pixels = {
@ -1631,9 +1654,35 @@ Metamaps.Realtime = {
}
self.positionPeerIcons();
};
$(document).on(Metamaps.JIT.events.mouseMove, sendCoords);
$(document).on(Metamaps.JIT.events.zoom, zoom);
$(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 () {
var self = Metamaps.Realtime;
@ -1892,120 +1941,169 @@ Metamaps.Realtime = {
socket.emit('updateMapperCoords', update);
}
},
contentUpdate: function (data) {
sendTopicDrag: function (positions) {
var self = Metamaps.Realtime;
var socket = Metamaps.Realtime.socket;
var graph = Metamaps.Visualize.mGraph.graph;
var socket = self.socket;
//as long as you weren't the origin of the changes, update your map
if (data.origin != Metamaps.Active.Mapper.id && self.status) {
if (data.resource == 'Topic') {
topic = $.parseJSON(data.obj);
if (Metamaps.Active.Map && self.status) {
positions.mapid = Metamaps.Active.Map.id;
socket.emit('topicDrag', positions);
}
},
topicDrag: function (positions) {
var self = Metamaps.Realtime;
var socket = self.socket;
if (data.action == 'create') {
self.addTopicToMap(topic);
} 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)
}
var topic;
var node;
return;
} else if (data.resource == 'Synapse') {
synapse = $.parseJSON(data.obj);
if (Metamaps.Active.Map && self.status) {
for (var key in positions) {
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') {
self.addSynapseToMap(synapse);
} else if (data.action == 'update' &&
graph.getAdjacence(synapse.data.$direction['0'], synapse.data.$direction['1']) != 'undefined') {
self.updateSynapseOnMap(synapse);
} else if (data.action == 'destroy' &&
graph.getAdjacence(synapse.data.$direction['0'], synapse.data.$direction['1']) != 'undefined') {
var edge = graph.getAdjacence(synapse.data.$direction['0'], synapse.data.$direction['1']);
Metamaps.Control.hideEdge(edge);
}
if (Metamaps.Active.Map && self.status) {
data.mapperid = Metamaps.Active.Mapper.id;
data.mapid = Metamaps.Active.Map.id;
socket.emit('newTopic', data);
}
},
newTopic: function (data) {
var topic, mapping, mapper, mapperCallback, cancel;
return;
function test() {
if (topic && mapping && mapper) {
Metamaps.Topic.renderTopic(mapping, topic, false, false);
}
else if (!cancel) {
setTimeout(test, 10);
}
}
},
addTopicToMap: function (topic) {
// TODO
var newPos, tempForT;
Metamaps.Visualize.mGraph.graph.addNode(topic);
tempForT = Metamaps.Visualize.mGraph.graph.getNode(topic.id);
tempForT.setData('dim', 1, 'start');
tempForT.setData('dim', 25, 'end');
newPos = new $jit.Complex();
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);
mapper = Metamaps.Mappers.get(data.mapperid);
if (mapper === undefined) {
mapperCallback = function (m) {
Metamaps.Mappers.add(m);
mapper = m;
};
Metamaps.Mapper.get(data.mapperid, mapperCallback);
}
newPos = new $jit.Complex();
newPos.x = tempForT.data.$xloc;
newPos.y = tempForT.data.$yloc;
tempForT.setPos(newPos, 'start');
tempForT.setPos(newPos, 'current');
tempForT.setPos(newPos, 'end');
return Metamaps.Visualize.mGraph.fx.animate({
modes: ['linear', 'node-property:dim', 'edge-property:lineWidth'],
transition: $jit.Trans.Quad.easeInOut,
duration: 500
$.ajax({
url: "/topics/" + data.topicid + ".json",
success: function (response) {
Metamaps.Topics.add(response);
topic = Metamaps.Topics.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;
}
});
},
addSynapseToMap: function (synapse) {
// TODO
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
});
test();
},
updateSynapseOnMap: function (synapse) {
// removeTopic
sendRemoveTopic: function (data) {
var self = Metamaps.Realtime;
var socket = self.socket;
// TODO
var k, tempForS, v, wasShowDesc, _ref;
tempForS = Metamaps.Visualize.mGraph.graph.getAdjacence(synapse.data.$direction[0], synapse.data.$direction[1]);
wasShowDesc = tempForS.data.$showDesc;
_ref = synapse.data;
for (k in _ref) {
v = _ref[k];
tempForS.data[k] = v;
if (Metamaps.Active.Map && self.status) {
data.mapid = Metamaps.Active.Map.id;
socket.emit('removeTopic', data);
}
tempForS.data.$showDesc = wasShowDesc;
if (MetamapsModel.edgecardInUse === synapse.data.$id) { // TODO
editEdge(tempForS, false);
},
removeTopic: function (data) {
},
// 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
@ -2895,13 +2993,15 @@ Metamaps.Topic = {
*
*
*/
renderTopic: function (mapping, topic, createNewInDB) {
renderTopic: function (mapping, topic, createNewInDB, permitCreateSynapseAfter) {
var self = Metamaps.Topic;
var nodeOnViz, tempPos;
var newnode = topic.createNode();
var midpoint = {}, pixelPos;
if (!$.isEmptyObject(Metamaps.Visualize.mGraph.graph.nodes)) {
Metamaps.Visualize.mGraph.graph.addNode(newnode);
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')), "end");
}
if (Metamaps.Create.newTopic.addSynapse) {
Metamaps.Create.newSynapse.topic1id = tempNode.id;
Metamaps.Create.newSynapse.topic2id = nodeOnViz.id;
if (Metamaps.Create.newTopic.addSynapse && permitCreateSynapseAfter) {
Metamaps.Create.newSynapse.topic1id = tempNode.getData('topic').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.Visualize.mGraph.fx.animate({
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 (topic.isNew()) {
topic.save(null, {
success: function (topicModel, response) {
if (Metamaps.Active.Map) {
mapping.save({ topic_id: topicModel.id });
}
},
success: topicSuccessCallback,
error: function (model, response) {
console.log('error saving topic to database');
}
});
} 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
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) {
var self = Metamaps.Topic;
@ -3028,7 +3156,7 @@ Metamaps.Topic = {
});
Metamaps.Mappings.add(mapping);
self.renderTopic(mapping, topic, true);
self.renderTopic(mapping, topic, true, true);
}
}; // end Metamaps.Topic
@ -3087,20 +3215,34 @@ Metamaps.Synapse = {
Metamaps.Visualize.mGraph.fx.plotLine(edgeOnViz, Metamaps.Visualize.mGraph.canvas);
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 (synapse.isNew()) {
synapse.save(null, {
success: function (synapseModel, response) {
if (Metamaps.Active.Map) {
mapping.save({ synapse_id: synapseModel.id });
}
},
success: synapseSuccessCallback,
error: function (model, response) {
console.log('error saving synapse to database');
}
});
} 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.
var synapsesToCreate = [];
node2 = Metamaps.Visualize.mGraph.graph.getNode(Metamaps.Create.newSynapse.topic2id);
topic2 = node2.getData('topic');
topic2 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic2id);
node2 = topic2.get('node');
var len = Metamaps.Selected.Nodes.length;
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) {
synapsesToCreate = Metamaps.Selected.Nodes;
}
@ -3150,6 +3293,8 @@ Metamaps.Synapse = {
},
getSynapseFromAutocomplete: function (id) {
var self = Metamaps.Synapse,
topic1,
topic2,
node1,
node2;
@ -3161,8 +3306,10 @@ Metamaps.Synapse = {
});
Metamaps.Mappings.add(mapping);
node1 = Metamaps.Visualize.mGraph.graph.getNode(Metamaps.Create.newSynapse.topic1id);
node2 = Metamaps.Visualize.mGraph.graph.getNode(Metamaps.Create.newSynapse.topic2id);
topic1 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic1id);
node1 = topic1.get('node');
topic1 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic2id);
node2 = topic2.get('node');
Metamaps.Create.newSynapse.hide();
self.renderSynapse(mapping, synapse, node1, node2, true);
@ -3220,6 +3367,7 @@ Metamaps.Map = {
Metamaps.Filter.checkMappers();
Metamaps.Realtime.startActiveMap();
Metamaps.Loading.hide();
}
$.ajax({

View file

@ -859,7 +859,7 @@ label[for="user_remember_me"] {
.sidebarFilterBox {
display:none;
width: 304px;
width: 319px;
padding: 16px 0;
overflow-y: auto;
}
@ -2148,6 +2148,9 @@ float: left;
.blackBox td.iconURL {
max-width: 415px;
word-wrap: break-word;
}
.blackBox td.iconColor {
}
.blackBox .field {
margin: 15px 0 5px;

View file

@ -292,7 +292,7 @@ cursor: pointer;
display: none;
width: 90%;
padding: 13px 0 9px 10%;
background-color: #64BC61;
background-color: #E0E0E0;
color: #424242;
}
.permission.canEdit .metacodeTitle {

View file

@ -627,6 +627,14 @@
background-color: #9150bc;
}
.github-fork-ribbon-wrapper {
display:none;
}
.homePage .github-fork-ribbon-wrapper {
display: block;
}
/* end home page */
/* infoAndHelp */

View file

@ -64,7 +64,7 @@
<%= render :partial => 'layouts/lightboxes' %>
<%= render :partial => 'layouts/templates' %>
<%= render :partial => 'shared/metacodeBgColors' %>
<script type="text/javascript" charset="utf-8">
BAROMETER.load('Scqak8nyHdFEkezKMNeQp');

View file

@ -21,6 +21,11 @@
<%= f.text_field :icon %>
<div class="clearfloat"></div>
</div>
<div class="field">
<%= f.label :color, "Color (hex with # sign)" %>
<%= f.text_field :color %>
<div class="clearfloat"></div>
</div>
<div class="actions">
<%= link_to 'Cancel', metacodes_path, { :class => 'button', 'data-bypass' => 'true' } %>
<%= f.submit :class => 'add' %>

View file

@ -6,6 +6,7 @@
<tr>
<th>Name</th>
<th>Icon</th>
<th>Color</th>
<th></th>
<th></th>
</tr>
@ -14,6 +15,13 @@
<tr>
<td><%= metacode.name %></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><%= link_to 'Edit', edit_metacode_path(metacode), :data => { :bypass => 'true'} %></td>
</tr>

View file

@ -33,9 +33,21 @@
end
end
@metacodes.sort! {|x,y| x.name <=> y.name }
@synapses.sort! {|x,y| x.desc <=> y.desc }
@mappers.sort! {|x,y| x.name <=> y.name }
@metacodes.sort! {|x,y|
n1 = x.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|
@metacodelist += '<li data-id="' + metacode.id.to_s + '">'
@ -43,8 +55,9 @@
@metacodelist += '<p>' + metacode.name.downcase + '</p></li>'
end
@synapses.each_with_index do |synapse, index|
@synapselist += '<li data-id="' + synapse.desc + '">'
@synapselist += '<img src="/assets/synapse16.png" alt="synapse icon" /><p>' + synapse.desc
d = synapse.desc || ""
@synapselist += '<li data-id="' + d + '">'
@synapselist += '<img src="/assets/synapse16.png" alt="synapse icon" /><p>' + d
@synapselist += '</p></li>'
end
@mappers.each_with_index do |mapper, index|

View 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>

View file

@ -15,8 +15,10 @@
<div class="accountName" onclick="Metamaps.Account.changeName()">
<div class="nameEdit"><%= @user.name %></div>
</div>
<div class="changeName"><%= form.label :name, "Name:", :class => "firstFieldText" %>
<%= form.email_field :name %></div>
<div class="changeName">
<%= form.label :name, "Name:", :class => "firstFieldText" %>
<%= form.text_field :name %>
</div>
<div><%= form.label :email, "Email:", :class => "firstFieldText" %>
<%= form.email_field :email %></div>
<div class="changePass" onclick="Metamaps.Account.showPass()">Change Password</div>

View file

@ -0,0 +1,5 @@
class AddColorToMetacodes < ActiveRecord::Migration
def change
add_column :metacodes, :color, :string
end
end

View file

@ -1,133 +1,134 @@
# encoding: UTF-8
# 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
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# 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
# 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).
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140815162253) do
create_table "in_metacode_sets", :force => true do |t|
t.integer "metacode_id"
t.integer "metacode_set_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
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"
create_table "mappings", :force => true do |t|
t.text "category"
t.integer "xloc"
t.integer "yloc"
t.integer "topic_id"
t.integer "synapse_id"
t.integer "map_id"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "maps", :force => true do |t|
t.text "name"
t.boolean "arranged"
t.text "desc"
t.text "permission"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "featured"
t.string "screenshot_file_name"
t.string "screenshot_content_type"
t.integer "screenshot_file_size"
t.datetime "screenshot_updated_at"
end
create_table "metacode_sets", :force => true do |t|
t.string "name"
t.text "desc"
t.integer "user_id"
t.boolean "mapperContributed"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "metacode_sets", ["user_id"], :name => "index_metacode_sets_on_user_id"
create_table "metacodes", :force => true do |t|
t.text "name"
t.string "icon"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "synapses", :force => true do |t|
t.text "desc"
t.text "category"
t.text "weight"
t.text "permission"
t.integer "node1_id"
t.integer "node2_id"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "topics", :force => true do |t|
t.text "name"
t.text "desc"
t.text "link"
t.text "permission"
t.integer "user_id"
t.integer "metacode_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.string "audio_file_name"
t.string "audio_content_type"
t.integer "audio_file_size"
t.datetime "audio_updated_at"
end
create_table "users", :force => true do |t|
t.string "name"
t.string "email"
t.text "settings"
t.string "code", :limit => 8
t.string "joinedwithcode", :limit => 8
t.string "crypted_password"
t.string "password_salt"
t.string "persistence_token"
t.string "perishable_token"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "encrypted_password", :limit => 128, :default => ""
t.string "remember_token"
t.datetime "remember_created_at"
t.string "reset_password_token"
t.datetime "last_sign_in_at"
t.string "last_sign_in_ip"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.string "current_sign_in_ip"
t.datetime "reset_password_sent_at"
t.boolean "admin"
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
end
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
end
# encoding: UTF-8
# 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
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# 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
# 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).
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140930013020) do
create_table "in_metacode_sets", :force => true do |t|
t.integer "metacode_id"
t.integer "metacode_set_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
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"
create_table "mappings", :force => true do |t|
t.text "category"
t.integer "xloc"
t.integer "yloc"
t.integer "topic_id"
t.integer "synapse_id"
t.integer "map_id"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "maps", :force => true do |t|
t.text "name"
t.boolean "arranged"
t.text "desc"
t.text "permission"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "featured"
t.string "screenshot_file_name"
t.string "screenshot_content_type"
t.integer "screenshot_file_size"
t.datetime "screenshot_updated_at"
end
create_table "metacode_sets", :force => true do |t|
t.string "name"
t.text "desc"
t.integer "user_id"
t.boolean "mapperContributed"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "metacode_sets", ["user_id"], :name => "index_metacode_sets_on_user_id"
create_table "metacodes", :force => true do |t|
t.text "name"
t.string "icon"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "color"
end
create_table "synapses", :force => true do |t|
t.text "desc"
t.text "category"
t.text "weight"
t.text "permission"
t.integer "node1_id"
t.integer "node2_id"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "topics", :force => true do |t|
t.text "name"
t.text "desc"
t.text "link"
t.text "permission"
t.integer "user_id"
t.integer "metacode_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.string "audio_file_name"
t.string "audio_content_type"
t.integer "audio_file_size"
t.datetime "audio_updated_at"
end
create_table "users", :force => true do |t|
t.string "name"
t.string "email"
t.text "settings"
t.string "code", :limit => 8
t.string "joinedwithcode", :limit => 8
t.string "crypted_password"
t.string "password_salt"
t.string "persistence_token"
t.string "perishable_token"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "encrypted_password", :limit => 128, :default => ""
t.string "remember_token"
t.datetime "remember_created_at"
t.string "reset_password_token"
t.datetime "last_sign_in_at"
t.string "last_sign_in_ip"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.string "current_sign_in_ip"
t.datetime "reset_password_sent_at"
t.boolean "admin"
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
end
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
end

View file

@ -113,6 +113,41 @@ function start() {
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);
});
});
}

View file

@ -7,6 +7,7 @@
one:
name: Action
icon: /assets/icons/action.png
color: #bd6c85
two:
name: Activity