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