2012-12-23 06:12:56 +00:00
|
|
|
$('.getTopicsInput').attr('value','');
|
|
|
|
|
|
|
|
var h = Mconsole.canvas.element.clientHeight / 2;
|
|
|
|
var w = Mconsole.canvas.element.clientWidth / 2;
|
|
|
|
|
2012-12-25 23:29:20 +00:00
|
|
|
var myX = -w + 400;
|
2012-12-23 06:12:56 +00:00
|
|
|
var myY = -h + 100;
|
2012-12-25 23:29:20 +00:00
|
|
|
var even = true;
|
2012-12-23 06:12:56 +00:00
|
|
|
|
|
|
|
<% @items.each do |item| %>
|
|
|
|
if ($.isEmptyObject(Mconsole.graph.nodes)) {
|
|
|
|
json = <%= item.self_as_json.html_safe %>;
|
|
|
|
Mconsole.loadJSON(json);
|
|
|
|
var temp = Mconsole.graph.getNode('<%= item.id %>');
|
|
|
|
temp.setData('dim', 1, 'start');
|
|
|
|
temp.setData('dim', 25, 'end');
|
2012-12-25 23:29:20 +00:00
|
|
|
temp.setData('inCommons',true);
|
2012-12-23 06:12:56 +00:00
|
|
|
temp.setPos(new $jit.Complex(myX, myY), 'current');
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY), 'start');
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY), 'end');
|
|
|
|
Mconsole.fx.plotNode(temp, Mconsole.canvas);
|
|
|
|
myX += 100;
|
2012-12-25 23:29:20 +00:00
|
|
|
even = !even;
|
2012-12-23 06:12:56 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
var temp = Mconsole.graph.getNode('<%= item.id %>');
|
|
|
|
if (temp == null) {
|
|
|
|
var newnode = <%= item.self_as_json.html_safe %>;
|
|
|
|
Mconsole.graph.addNode(newnode);
|
|
|
|
var temp = Mconsole.graph.getNode('<%= item.id %>');
|
|
|
|
temp.setData('dim', 1, 'start');
|
|
|
|
temp.setData('dim', 25, 'end');
|
2012-12-25 23:29:20 +00:00
|
|
|
temp.setData('inCommons',true);
|
2012-12-23 06:12:56 +00:00
|
|
|
if (myX > (w-100)) {
|
2012-12-25 23:29:20 +00:00
|
|
|
myX = -w + 400;
|
|
|
|
myY += 200;
|
|
|
|
even = true;
|
|
|
|
}
|
|
|
|
if (even) {
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY), 'current');
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY), 'start');
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY), 'end');
|
|
|
|
}
|
|
|
|
else if (!even) {
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY+100), 'current');
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY+100), 'start');
|
|
|
|
temp.setPos(new $jit.Complex(myX, myY+100), 'end');
|
2012-12-23 06:12:56 +00:00
|
|
|
}
|
|
|
|
Mconsole.fx.plotNode(temp, Mconsole.canvas);
|
|
|
|
myX += 100;
|
2012-12-25 23:29:20 +00:00
|
|
|
even = !even;
|
2012-12-23 06:12:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
Mconsole.fx.animate({
|
|
|
|
modes: ['node-property:dim'],
|
|
|
|
duration: 500
|
|
|
|
});
|