2013-01-11 23:49:59 +00:00
|
|
|
/*
|
|
|
|
* @file
|
|
|
|
* This javascript is returned and executed when you create a new node.
|
|
|
|
*/
|
2013-02-19 14:44:43 +00:00
|
|
|
$('#topic_name').autocomplete('disable');
|
2013-03-08 01:09:18 +00:00
|
|
|
$('.ui-autocomplete.ui-widget').fadeOut('fast');
|
2013-01-01 22:45:35 +00:00
|
|
|
$('#new_topic').fadeOut('fast');
|
|
|
|
$('#topic_name').attr('value','');
|
|
|
|
$('#topic_grabTopic').attr('value','null');
|
|
|
|
$('#topic_addSynapse').attr('value','false');
|
|
|
|
|
|
|
|
var newnode = <%= @topic.self_as_json.html_safe %>;
|
|
|
|
var x = <%= @position['x'] %>;
|
|
|
|
var y = <%= @position['y'] %>;
|
|
|
|
|
|
|
|
|
|
|
|
if (!$.isEmptyObject(Mconsole.graph.nodes)) {
|
|
|
|
Mconsole.graph.addNode(newnode);
|
|
|
|
|
|
|
|
// set the animation for everything back to normal
|
|
|
|
Mconsole.graph.eachNode( function (n) {
|
|
|
|
n.setData('dim', 25, 'start');
|
|
|
|
n.setData('dim', 25, 'end');
|
|
|
|
});
|
|
|
|
var temp = Mconsole.graph.getNode('<%= @topic.id %>');
|
|
|
|
temp.setData('dim', 1, 'start');
|
|
|
|
temp.setData('dim', 40, 'end');
|
2013-01-03 08:53:25 +00:00
|
|
|
temp.setData('onCanvas', false);
|
|
|
|
temp.setData('inCommons', false);
|
2013-01-01 22:45:35 +00:00
|
|
|
|
|
|
|
if (gType == "centered") {
|
|
|
|
var tempPos = new $jit.Complex(x, y);
|
|
|
|
tempPos = tempPos.toPolar();
|
|
|
|
temp.setPos(tempPos, 'current');
|
|
|
|
temp.setPos(tempPos, 'start');
|
|
|
|
temp.setPos(tempPos, 'end');
|
|
|
|
}
|
|
|
|
else if (gType == "arranged" || gType == "chaotic") {
|
|
|
|
temp.setData('xloc',0);
|
|
|
|
temp.setData('yloc',0);
|
2013-02-17 00:03:21 +00:00
|
|
|
<% if not @mapping.nil? %>
|
|
|
|
temp.setData('mappingid', <%= @mapping.id %>);
|
|
|
|
<% elsif @mapping.nil? %>
|
|
|
|
temp.setData('mappingid', null);
|
|
|
|
<% end %>
|
2013-01-01 22:45:35 +00:00
|
|
|
temp.setPos(new $jit.Complex(x, y), 'current');
|
|
|
|
temp.setPos(new $jit.Complex(x, y), 'start');
|
|
|
|
temp.setPos(new $jit.Complex(x, y), 'end');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( '<%= @synapse %>' == "true" ) {
|
|
|
|
$('#synapse_topic1id').val(tempNode.id);
|
|
|
|
$('#synapse_topic2id').val(temp.id);
|
2013-02-16 01:00:05 +00:00
|
|
|
$('#synapse_desc').autocomplete('enable');
|
2013-01-01 22:45:35 +00:00
|
|
|
$('#new_synapse').fadeIn('fast');
|
|
|
|
$('#synapse_desc').focus();
|
|
|
|
Mconsole.fx.animate({
|
|
|
|
modes: ['node-property:dim'],
|
|
|
|
duration: 500,
|
|
|
|
onComplete: function() {
|
|
|
|
renderMidArrow({ x: tempNode.pos.getc().x, y: tempNode.pos.getc().y }, { x: temp.pos.getc().x, y: temp.pos.getc().y }, 13, false, Mconsole.canvas);
|
|
|
|
Mconsole.fx.plotNode(tempNode, Mconsole.canvas);
|
|
|
|
Mconsole.fx.plotNode(temp, Mconsole.canvas);
|
|
|
|
tempNode = null;
|
|
|
|
tempNode2 = null;
|
|
|
|
tempInit = false;
|
|
|
|
}
|
|
|
|
});
|
2013-01-03 08:53:25 +00:00
|
|
|
} else if ( '<%= @synapse %>' == "false" ) {
|
2013-01-01 22:45:35 +00:00
|
|
|
Mconsole.fx.plotNode(temp, Mconsole.canvas);
|
|
|
|
Mconsole.fx.animate({
|
|
|
|
modes: ['node-property:dim'],
|
2013-01-03 08:53:25 +00:00
|
|
|
duration: 500,
|
|
|
|
onComplete: function() {
|
|
|
|
selectNodeOnClickHandler(temp);
|
|
|
|
}
|
2013-01-01 22:45:35 +00:00
|
|
|
});
|
2013-01-03 08:53:25 +00:00
|
|
|
|
2013-01-01 22:45:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
json = newnode;
|
|
|
|
Mconsole.loadJSON(json);
|
|
|
|
var temp = Mconsole.graph.getNode('<%= @topic.id %>');
|
|
|
|
temp.setData('dim', 1, 'start');
|
|
|
|
temp.setData('dim', 25, 'end');
|
2013-01-03 08:53:25 +00:00
|
|
|
temp.setData('onCanvas', false);
|
|
|
|
temp.setData('inCommons', false);
|
2013-02-17 00:03:21 +00:00
|
|
|
if (gType == "arranged" || gType == "chaotic") {
|
|
|
|
<% if not @mapping.nil? %>
|
|
|
|
temp.setData('mappingid', <%= @mapping.id %>);
|
|
|
|
<% elsif @mapping.nil? %>
|
|
|
|
temp.setData('mappingid', null);
|
|
|
|
<% end %>
|
2013-02-11 01:22:18 +00:00
|
|
|
}
|
2013-01-01 22:45:35 +00:00
|
|
|
temp.setPos(new $jit.Complex(x, y), 'current');
|
|
|
|
temp.setPos(new $jit.Complex(x, y), 'start');
|
|
|
|
temp.setPos(new $jit.Complex(x, y), 'end');
|
|
|
|
Mconsole.fx.plotNode(temp, Mconsole.canvas);
|
|
|
|
Mconsole.fx.animate({
|
|
|
|
modes: ['node-property:dim'],
|
2013-01-03 08:53:25 +00:00
|
|
|
duration: 500,
|
|
|
|
onComplete: function() {
|
|
|
|
selectNodeOnClickHandler(temp);
|
|
|
|
}
|
2013-01-01 22:45:35 +00:00
|
|
|
});
|
2013-03-08 01:09:18 +00:00
|
|
|
}
|