2012-10-21 17:19:59 +00:00
|
|
|
$('#new_item').fadeOut('fast');
|
2012-12-16 20:00:43 +00:00
|
|
|
$('#item_name').data().autocomplete.term = null;
|
|
|
|
$('.ui-autocomplete').children().remove();
|
|
|
|
$('.ui-autocomplete').css('display','none');
|
|
|
|
$('#item_name').attr('value','');
|
2012-12-21 04:45:44 +00:00
|
|
|
$('#item_grabItem').attr('value','null');
|
|
|
|
$('#item_addSynapse').attr('value','false');
|
2012-10-21 18:32:17 +00:00
|
|
|
|
2012-12-21 04:45:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
var newnode = <%= @item.self_as_json.html_safe %>;
|
|
|
|
var x = <%= @position['x'] %>;
|
|
|
|
var y = <%= @position['y'] %>;
|
|
|
|
|
|
|
|
|
2012-12-23 06:12:56 +00:00
|
|
|
if (!$.isEmptyObject(Mconsole.graph.nodes)) {
|
2012-12-21 04:45:44 +00:00
|
|
|
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('<%= @item.id %>');
|
|
|
|
temp.setData('dim', 1, 'start');
|
|
|
|
temp.setData('dim', 40, 'end');
|
|
|
|
|
|
|
|
if (gType == "centered") {
|
|
|
|
temp.setPos(new $jit.Polar(5.54, 347.6), 'current');
|
|
|
|
temp.setPos(new $jit.Polar(5.54, 347.6), 'start');
|
|
|
|
temp.setPos(new $jit.Polar(5.54, 347.6), 'end');
|
|
|
|
}
|
|
|
|
else if (gType == "arranged" || gType == "chaotic") {
|
|
|
|
temp.setData('xloc',0);
|
|
|
|
temp.setData('yloc',0);
|
|
|
|
temp.setData('mappingid', '<%= @mapping.id %>');
|
|
|
|
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_item1id').val(tempNode.id);
|
|
|
|
$('#synapse_item2id').val(temp.id);
|
|
|
|
$('#new_synapse').fadeIn('fast');
|
|
|
|
$('#synapse_desc').focus();
|
2012-12-21 05:08:52 +00:00
|
|
|
Mconsole.fx.animate({
|
|
|
|
modes: ['node-property:dim'],
|
|
|
|
duration: 500,
|
|
|
|
onComplete: function() {
|
|
|
|
renderMidArrow({ x: tempNode.pos.x, y: tempNode.pos.y }, { x: temp.pos.x, y: temp.pos.y }, 13, false, Mconsole.canvas);
|
|
|
|
Mconsole.fx.plotNode(tempNode, Mconsole.canvas);
|
|
|
|
Mconsole.fx.plotNode(temp, Mconsole.canvas);
|
|
|
|
tempNode = null;
|
|
|
|
tempNode2 = null;
|
|
|
|
tempInit = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Mconsole.fx.plotNode(temp, Mconsole.canvas);
|
|
|
|
Mconsole.fx.animate({
|
|
|
|
modes: ['node-property:dim'],
|
|
|
|
duration: 500
|
|
|
|
});
|
2012-12-21 04:45:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
json = newnode;
|
2012-12-23 06:12:56 +00:00
|
|
|
Mconsole.loadJSON(json);
|
|
|
|
var temp = Mconsole.graph.getNode('<%= @item.id %>');
|
|
|
|
temp.setData('dim', 1, 'start');
|
|
|
|
temp.setData('dim', 25, 'end');
|
|
|
|
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'],
|
|
|
|
duration: 500
|
|
|
|
});
|
2012-10-21 18:32:17 +00:00
|
|
|
}
|