Commit 053e37b4 authored by techird's avatar techird

old data compatibility

parent 4cb30e8c
......@@ -10,6 +10,7 @@
'core/module.js',
'core/event.js',
'core/minder.js',
'core/minder.data.compatibility.js',
'core/minder.data.js',
'core/minder.event.js',
'core/minder.module.js',
......
......@@ -3,7 +3,7 @@ var KityMinder = window.KM = window.KityMinder = function() {
instanceId = 0,
uuidMap = {};
return {
version: '1.1.3.1',
version: '1.2.0',
uuid: function(name) {
name = name || 'unknown';
uuidMap[name] = uuidMap[name] || 0;
......
Utils.extend(KityMinder, {
compatibility: function(json) {
var version = json.version || '1.1.3';
function traverse(node, fn) {
fn(node);
if (node.children) node.children.forEach(function(child) {
traverse(child, fn);
});
}
/**
* 脑图数据升级
* v1.1.3 => v1.2.0
* */
function c_113_120(json) {
// 原本的布局风格
var ocs = json.data.currentstyle;
delete json.data.currentstyle;
// 为 1.2 选择模板,同时保留老版本文件的皮肤
if (ocs == 'bottom') {
json.template = 'structure';
json.theme = 'snow';
} else if (ocs == 'default') {
json.template = 'default';
json.theme = 'classic';
}
traverse(json, function(node) {
var data = node.data;
// 升级优先级、进度图标
if ('PriorityIcon' in data) {
data.priority = data.PriorityIcon;
delete data.PriorityIcon;
}
if ('ProgressIcon' in data) {
data.progress = 1 + ((data.ProgressIcon - 1) << 1);
delete data.ProgressIcon;
}
// 删除过时属性
delete data.point;
delete data.layout;
});
}
switch (version) {
case '1.1.3':
c_113_120(json);
case '1.2.0':
}
return json;
}
});
\ No newline at end of file
......@@ -53,6 +53,7 @@ kity.extendClass(Minder, {
json.template = this.getTemplate();
json.theme = this.getTheme();
json.version = KityMinder.version;
if (protocal) {
return protocal.encode(json, this);
......@@ -139,20 +140,10 @@ kity.extendClass(Minder, {
this.removeNode(this._root.getChildren()[0]);
}
// compality for v1.1.3
var ocs = json.data.currentstyle; // old current-style
delete json.data.currentstyle;
json = KityMinder.compatibility(json);
importNode(this._root, json, this);
if (ocs == 'bottom') {
json.template = 'structure';
json.theme = 'snow';
} else if (ocs == 'default') {
json.template = 'default';
json.theme = 'classic';
}
this.setTemplate(json.template || null);
this.setTheme(json.theme || null);
this.refresh();
......
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