2012-10-21 17:19:59 +00:00
|
|
|
$('#new_item').fadeOut('fast');
|
2012-10-21 17:46:27 +00:00
|
|
|
$('#new_item')[0].reset()
|
2012-10-21 18:32:17 +00:00
|
|
|
|
|
|
|
// if there's a map, add the node to that, if its in card view add card
|
2012-10-24 06:47:08 +00:00
|
|
|
map2 = document.getElementById('container');
|
2012-10-21 18:32:17 +00:00
|
|
|
|
2012-10-24 06:47:08 +00:00
|
|
|
if (map2 != null) {
|
2012-10-21 18:32:17 +00:00
|
|
|
var newnode = <%= @item.self_as_json.html_safe %>;
|
2012-10-24 06:47:08 +00:00
|
|
|
console.log(newnode);
|
2012-10-21 20:08:41 +00:00
|
|
|
|
|
|
|
if (fd != null) {
|
2012-10-24 06:47:08 +00:00
|
|
|
fd.graph.addNode(newnode);
|
|
|
|
var temp = fd.graph.getNode('<%= @item.id %>');
|
|
|
|
temp.setData('dim', 1, 'start');
|
|
|
|
temp.setData('dim', 40, 'end');
|
|
|
|
temp.setPos(new $jit.Complex(0, 0), 'current');
|
|
|
|
temp.setPos(new $jit.Complex(0, 0), 'start');
|
|
|
|
temp.setPos(new $jit.Complex(0, 0), 'end');
|
|
|
|
fd.fx.plotNode(temp, fd.canvas);
|
|
|
|
fd.fx.animate({
|
|
|
|
modes: ['node-property:dim'],
|
|
|
|
duration: 400
|
|
|
|
});
|
2012-10-21 20:08:41 +00:00
|
|
|
}
|
|
|
|
else if (rg != null) {
|
2012-10-24 06:47:08 +00:00
|
|
|
rg.graph.addNode(newnode);
|
|
|
|
var temp = rg.graph.getNode('<%= @item.id %>');
|
|
|
|
temp.setData('dim', 1, 'start');
|
|
|
|
temp.setData('dim', 40, 'end');
|
|
|
|
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');
|
|
|
|
rg.fx.plotNode(temp, rg.canvas);
|
|
|
|
rg.fx.animate({
|
|
|
|
modes: ['node-property:dim'],
|
|
|
|
duration: 400
|
|
|
|
});
|
|
|
|
}
|
2012-10-26 10:04:52 +00:00
|
|
|
else {
|
|
|
|
json = newnode;
|
|
|
|
initFD();
|
|
|
|
}
|
2012-10-24 06:47:08 +00:00
|
|
|
// add the new node to the synapse select list
|
|
|
|
$("#node1_id").prepend("<option value='<%= @item.id %>'><%= @item.name %></option>");
|
|
|
|
$("#node2_id").prepend("<option value='<%= @item.id %>'><%= @item.name %></option>");
|
|
|
|
|
2012-10-21 18:32:17 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#cards').prepend('<%= escape_javascript(render(@item)) %>');
|
2012-10-31 22:53:11 +00:00
|
|
|
$(".scroll").mCustomScrollbar();
|
2012-10-21 18:32:17 +00:00
|
|
|
}
|
|
|
|
|