Commit e0eb38d7 authored by hy's avatar hy

对core中data下的方法做微调

parent a53b755f
...@@ -77,28 +77,6 @@ define(function(require, exports, module) { ...@@ -77,28 +77,6 @@ define(function(require, exports, module) {
return JSON.parse(JSON.stringify(json)); return JSON.parse(JSON.stringify(json));
}, },
/**
* @method importNode()
* @description 根据纯json {data, children}数据转换成为脑图节点
* @Editor: Naixor
* @Date: 2015.9.20
*/
importNode: function(node, json) {
var data = json.data;
node.data = {};
for (var field in data) {
node.setData(field, data[field]);
}
var childrenTreeData = json.children || [];
for (var i = 0; i < childrenTreeData.length; i++) {
var childNode = this.createNode(null, node);
this.importNode(childNode, childrenTreeData[i]);
}
return node;
},
/** /**
* function Text2Children(MinderNode, String) * function Text2Children(MinderNode, String)
* @param {MinderNode} node 要导入数据的节点 * @param {MinderNode} node 要导入数据的节点
...@@ -188,6 +166,45 @@ define(function(require, exports, module) { ...@@ -188,6 +166,45 @@ define(function(require, exports, module) {
minder.refresh(); minder.refresh();
}, },
/**
* @method exportNode(MinderNode)
* @param {MinderNode} node 当前要被导出的节点
* @return {Object} 返回只含有data和children的Object
* @Editor: Naixor
* @Date: 2015.9.22
*/
exportNode: function (node) {
var exported = {};
exported.data = node.getData();
var childNodes = node.getChildren();
exported.children = [];
for (var i = 0; i < childNodes.length; i++) {
exported.children.push(this.exportNode(childNodes[i]));
}
return exported;
},
/**
* @method importNode()
* @description 根据纯json {data, children}数据转换成为脑图节点
* @Editor: Naixor
* @Date: 2015.9.20
*/
importNode: function(node, json) {
var data = json.data;
node.data = {};
for (var field in data) {
node.setData(field, data[field]);
}
var childrenTreeData = json.children || [];
for (var i = 0; i < childrenTreeData.length; i++) {
var childNode = this.createNode(null, node);
this.importNode(childNode, childrenTreeData[i]);
}
return node;
},
/** /**
* @method importJson() * @method importJson()
* @for Minder * @for Minder
......
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