metamaps--metamaps/app/views/items/create.js.erb

75 lines
2.3 KiB
Text

$('#new_item').fadeOut('fast');
$('#new_item')[0].reset()
// if there's a map, add the node to that, if its in card view add card
map2 = document.getElementById('container');
if (map2 != null) {
var newnode = <%= @item.self_as_json.html_safe %>;
if (fd != null) {
fd.graph.addNode(newnode);
var temp = fd.graph.getNode('<%= @item.id %>');
temp.setData('dim', 1, 'start');
temp.setData('dim', 40, 'end');
<% unless (@mapping.nil?) %>
temp.setData('xloc',0);
temp.setData('yloc',0);
temp.setData('mappingid', '<%= @mapping.id %>');
<% 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
});
}
else if (rg != null) {
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
});
}
else if (map != null) {
map.graph.addNode(newnode);
var temp = map.graph.getNode('<%= @item.id %>');
temp.setData('dim', 1, 'start');
temp.setData('dim', 40, 'end');
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');
map.fx.plotNode(temp, map.canvas);
map.fx.animate({
modes: ['node-property:dim'],
duration: 400
});
}
else {
json = newnode;
initFD();
}
console.log(temp);
// add the new node to the synapse select lists
$("#node1_id").prepend("<option value='<%= @item.id %>'><%= @item.name %></option>");
$("#node2_id").prepend("<option value='<%= @item.id %>'><%= @item.name %></option>");
}
else {
$('#cards').prepend('<%= escape_javascript(render(@item)) %>');
$(".scroll").mCustomScrollbar();
}