Commit 2e8c962d authored by Jérome Perrin's avatar Jérome Perrin

Enable a button to layout the graph from the gui

parent 47b1476d
......@@ -20,6 +20,7 @@
<fieldset id="general-fieldset">
</fieldset>
<a id="run_simulation">Run Simulation</a>
<a id="layout_graph">Layout Graph</a>
</form>
</div>
</div>
......
......@@ -160,6 +160,14 @@
return false;
});
// Enable "Layout Graph" button
$("#layout_graph").button().click(
function(e){
dream_instance.positionGraph();
// XXX dirty way to redisplay after jio is saved
setTimeout(function() {window.history.go(0)}, 500);
});
// Enable "Clear All" button
$("#clear_all").button().click(
function(e){
......
......@@ -132,6 +132,24 @@
$.publish("Dream.Gui.onDataChange", priv.getData());
};
that.positionGraph = function() {
$.ajax(
'/positionGraph', {
data: JSON.stringify(priv.getData()),
contentType: 'application/json',
type: 'POST',
success: function(data, textStatus, jqXHR){
$.each(data, function(node, pos) {
priv.updateElementCoordinate(node,
{top: (Math.floor(pos.top*$("#main").height()) - 45) + "px",
left: Math.floor(pos.left*$("#main").width()) + "px"});
});
}
});
}
priv.getData = function() {
return { "element": priv.element_container,
"preference": priv.preference_container,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment