mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 06:07:57 +01:00
supporting change of layouts
This commit is contained in:
parent
75564c17ec
commit
0f496bb4b3
@ -20,7 +20,7 @@ core.Utils =
|
||||
{
|
||||
isDefined: function(val)
|
||||
{
|
||||
return val !== null && val !== undefined;
|
||||
return val !== null && val !== undefined && typeof val !="undefined";
|
||||
},
|
||||
escapeInvalidTags: function (text)
|
||||
{
|
||||
|
@ -354,7 +354,7 @@ mindplot.MindmapDesigner.prototype.save = function(onSavedHandler, saveHistory)
|
||||
var persistantManager = mindplot.PersistanceManager;
|
||||
var mindmap = this._mindmap;
|
||||
|
||||
var properties = {zoom:this._zoom};
|
||||
var properties = {zoom:this._zoom, layoutManager:this._layoutManager.getClassName()};
|
||||
persistantManager.save(mindmap, properties, onSavedHandler, saveHistory);
|
||||
this._fireEvent("save", {type:saveHistory});
|
||||
|
||||
@ -461,7 +461,7 @@ mindplot.MindmapDesigner.prototype._nodeModelToNodeGraph = function(nodeModel, i
|
||||
|
||||
var children = nodeModel.getChildren().slice();
|
||||
|
||||
children = this._layoutManager.prepareChildrenList(nodeGraph, children);
|
||||
children = this._layoutManager.prepareNode(nodeGraph, children);
|
||||
|
||||
for (var i = 0; i < children.length; i++)
|
||||
{
|
||||
|
@ -227,6 +227,7 @@ mindplot.XMLMindmapSerializer_Pela.prototype.loadFromDom = function(dom)
|
||||
// Is a wisemap?.
|
||||
core.assert(rootElem.tagName == mindplot.XMLMindmapSerializer_Pela.MAP_ROOT_NODE, "This seem not to be a map document.");
|
||||
|
||||
this._idsMap = new Hash();
|
||||
// Start the loading process ...
|
||||
var mindmap = new mindplot.Mindmap();
|
||||
|
||||
@ -251,6 +252,7 @@ mindplot.XMLMindmapSerializer_Pela.prototype.loadFromDom = function(dom)
|
||||
}
|
||||
}
|
||||
}
|
||||
this._idsMap=null;
|
||||
return mindmap;
|
||||
};
|
||||
|
||||
@ -263,6 +265,12 @@ mindplot.XMLMindmapSerializer_Pela.prototype._deserializeNode = function(domElem
|
||||
id=parseInt(id);
|
||||
}
|
||||
|
||||
if(this._idsMap.hasKey(id)){
|
||||
id=null;
|
||||
}else{
|
||||
this._idsMap.set(id,domElem);
|
||||
}
|
||||
|
||||
var topic = mindmap.createNode(type, id);
|
||||
|
||||
var text = domElem.getAttribute('text');
|
||||
@ -272,7 +280,7 @@ mindplot.XMLMindmapSerializer_Pela.prototype._deserializeNode = function(domElem
|
||||
|
||||
var order = domElem.getAttribute('order');
|
||||
if (order) {
|
||||
topic.setOrder(order);
|
||||
topic.setOrder(parseInt(order));
|
||||
}
|
||||
|
||||
var shape = domElem.getAttribute('shape');
|
||||
|
@ -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){
|
||||
|
@ -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)
|
||||
|
@ -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){
|
||||
|
Loading…
Reference in New Issue
Block a user