metamaps--metamaps/app/views/items/create.js.erb
2012-12-14 13:31:39 -05:00

61 lines
1.9 KiB
Plaintext

$('#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 (console != null) {
var temp = fd.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") {
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?) %>
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');
}
console.fx.plotNode(temp, console.canvas);
console.fx.animate({
modes: ['node-property:dim'],
duration: 400
});
}
else {
json = newnode;
initialize("chaotic");
}
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();
}