now if you double click 'inCanvas' nodes they will be added to the map. TODO they don't have a mapping yet
This commit is contained in:
parent
d283797deb
commit
88522be80c
2 changed files with 33 additions and 6 deletions
|
@ -28,10 +28,39 @@ function selectEdgeOnClickHandler(adj, e) {
|
||||||
Mconsole.plot();
|
Mconsole.plot();
|
||||||
}//selectEdgeOnClickHandler
|
}//selectEdgeOnClickHandler
|
||||||
|
|
||||||
function selectNodeOnClickHandler(node, e) {
|
function nodeDoubleClickHandler(node, e) {
|
||||||
|
node.setData('onCanvas', true);
|
||||||
|
node.setData('inCommons', false);
|
||||||
|
console.log("Here's the node you clicked:");
|
||||||
|
console.log(node);
|
||||||
|
//if ($('.maps.onMap').length > 0 && node.getData('mappingid')) {
|
||||||
|
// //TODO
|
||||||
|
// var mappingId = createAMapping(alert('unimp'));
|
||||||
|
// node.setData('mappingid', mappingId);
|
||||||
|
//}
|
||||||
|
}//doubleClickNodeHandler
|
||||||
|
|
||||||
|
function nodeWasDoubleClicked() {
|
||||||
|
//grab the timestamp of the click
|
||||||
|
var storedTime = MetamapsModel.lastNodeClick;
|
||||||
|
var now = Date.now(); //not compatible with IE8 FYI
|
||||||
|
MetamapsModel.lastNodeClick = now;
|
||||||
|
|
||||||
|
if (now - storedTime < MetamapsModel.DOUBLE_CLICK_TOLERANCE) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}//nodeWasDoubleClicked;
|
||||||
|
|
||||||
|
function selectNodeOnClickHandler(node, e) {
|
||||||
if (Mconsole.busy) return;
|
if (Mconsole.busy) return;
|
||||||
|
|
||||||
|
if (nodeWasDoubleClicked()) {
|
||||||
|
nodeDoubleClickHandler(node, e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (gType != "centered") {
|
if (gType != "centered") {
|
||||||
//set final styles
|
//set final styles
|
||||||
if (!e.shiftKey) {
|
if (!e.shiftKey) {
|
||||||
|
@ -70,13 +99,12 @@ function selectNodeOnClickHandler(node, e) {
|
||||||
}//selectNodeOnClickHandler
|
}//selectNodeOnClickHandler
|
||||||
|
|
||||||
function canvasDoubleClickHandler(canvasLoc,e) {
|
function canvasDoubleClickHandler(canvasLoc,e) {
|
||||||
var DOUBLE_CLICK_TOLERANCE = 300; //0.3 seconds
|
|
||||||
|
|
||||||
//grab the location and timestamp of the click
|
//grab the location and timestamp of the click
|
||||||
var storedTime = MetamapsModel.lastCanvasClick;
|
var storedTime = MetamapsModel.lastCanvasClick;
|
||||||
var now = Date.now(); //not compatible with IE8 FYI
|
var now = Date.now(); //not compatible with IE8 FYI
|
||||||
|
MetamapsModel.lastCanvasClick = now;
|
||||||
|
|
||||||
if (now - storedTime < DOUBLE_CLICK_TOLERANCE) {
|
if (now - storedTime < MetamapsModel.DOUBLE_CLICK_TOLERANCE) {
|
||||||
//pop up node creation :)
|
//pop up node creation :)
|
||||||
$('#topic_grabTopic').val("null");
|
$('#topic_grabTopic').val("null");
|
||||||
$('#topic_addSynapse').val("false");
|
$('#topic_addSynapse').val("false");
|
||||||
|
@ -89,7 +117,6 @@ function canvasDoubleClickHandler(canvasLoc,e) {
|
||||||
addMetacode();
|
addMetacode();
|
||||||
$('#topic_name').focus();
|
$('#topic_name').focus();
|
||||||
} else {
|
} else {
|
||||||
MetamapsModel.lastCanvasClick = now;
|
|
||||||
$('#new_topic').fadeOut('fast');
|
$('#new_topic').fadeOut('fast');
|
||||||
$('#new_synapse').fadeOut('fast');
|
$('#new_synapse').fadeOut('fast');
|
||||||
tempInit = false;
|
tempInit = false;
|
||||||
|
|
|
@ -66,7 +66,7 @@ var even = true;
|
||||||
var temp1 = null, temp2 = null;
|
var temp1 = null, temp2 = null;
|
||||||
temp1 = Mconsole.graph.getNode(<%= synapse.topic1.id %>);
|
temp1 = Mconsole.graph.getNode(<%= synapse.topic1.id %>);
|
||||||
temp2 = Mconsole.graph.getNode(<%= synapse.topic2.id %>);
|
temp2 = Mconsole.graph.getNode(<%= synapse.topic2.id %>);
|
||||||
if (!(temp1 == undefined || temp2 == undefined)) {
|
if (temp1 != undefined && temp2 != undefined) {
|
||||||
Mconsole.graph.addAdjacence(temp1, temp2, {});
|
Mconsole.graph.addAdjacence(temp1, temp2, {});
|
||||||
temp = Mconsole.graph.getAdjacence(temp1.id, temp2.id);
|
temp = Mconsole.graph.getAdjacence(temp1.id, temp2.id);
|
||||||
temp.setDataset('start', {
|
temp.setDataset('start', {
|
||||||
|
|
Loading…
Reference in a new issue