supporting change of layouts

This commit is contained in:
Pablo Luna
2011-04-15 12:59:21 +01:00
parent 75564c17ec
commit 0f496bb4b3
6 changed files with 44 additions and 19 deletions

View File

@@ -60,7 +60,7 @@ mindplot.layoutManagers.BaseLayoutManager = new Class({
_createCentralTopicBoard:function(node){
return new mindplot.layoutManagers.boards.Board(node, this);
},
prepareChildrenList:function(node, children){
prepareNode:function(node, children){
},
addHelpers:function(node){

View File

@@ -24,13 +24,20 @@ mindplot.layoutManagers.FreeMindLayoutManager = mindplot.layoutManagers.BaseLayo
_nodeShrinkEvent:function(node){
this._updateBoard(node,[]);
},
prepareChildrenList:function(node, children){
var result = children.sort(function(n1, n2){
if(n1.getPosition() && n2.getPosition())
return n1.getPosition().y>n2.getPosition().y;
else
return true;
});
prepareNode:function(node, children){
var layoutManagerName = editorProperties.layoutManager;
//if last layout used is this one
if(typeof layoutManagerName != "undefined" && layoutManagerName == this.getClassName()){
var result = children.sort(function(n1, n2){
if(n1.getPosition() && n2.getPosition())
return n1.getPosition().y>n2.getPosition().y;
else
return true;
});
} else {
delete node.getModel()._finalPosition;
result = children;
}
return result;
},
registerListenersOnNode : function(topic)

View File

@@ -12,24 +12,34 @@ mindplot.layoutManagers.OriginalLayoutManager = mindplot.layoutManagers.BaseLayo
// Add shapes to speed up the loading process ...
mindplot.DragTopic.initialize(workSpace);
},
prepareChildrenList:function(node, children){
prepareNode:function(node, children){
// Sort children by order to solve adding order in for OriginalLayoutManager...
var nodesByOrder = new Hash();
var maxOrder =0;
var result = [];
if (node.getTopicType()!=mindplot.NodeModel.CENTRAL_TOPIC_TYPE && children.length > 0)
if (children.length > 0)
{
for (var i = 0; i < children.length; i++)
{
var child = children[i];
var order = child.getOrder();
if (order != null)
if (!core.Utils.isDefined(order))
{
result[order] = child;
} else
{
result.push(child);
order = maxOrder++;
}
if(nodesByOrder.hasKey(order)){
//duplicated order. Change order to next available.
order = maxOrder++;
}else{
nodesByOrder.set(order, child);
if(order>maxOrder)
maxOrder=order;
}
result[order] = child;
}
}
nodesByOrder=null;
return result;
},
_nodeResizeEvent:function(node){