Commit b193204d authored by techird's avatar techird

fix bugs and release

parent fb434582
...@@ -7,26 +7,26 @@ ...@@ -7,26 +7,26 @@
<meta name="description" content="百度脑图,便捷的脑图编辑工具。让您在线上直接创建、保存并分享你的思路。"> <meta name="description" content="百度脑图,便捷的脑图编辑工具。让您在线上直接创建、保存并分享你的思路。">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<script src="lib/jquery-2.1.0.min.js?_=1404819457295" charset="utf-8"></script> <script src="lib/jquery-2.1.0.min.js?_=1404914306873" charset="utf-8"></script>
<script src="lib/ZeroClipboard.min.js?_=1404819457295" charset="utf-8"></script> <script src="lib/ZeroClipboard.min.js?_=1404914306873" charset="utf-8"></script>
<script type="text/javascript"> <script type="text/javascript">
ZeroClipboard.setDefaults( { moviePath: 'lib/ZeroClipboard.swf' } ); ZeroClipboard.setDefaults( { moviePath: 'lib/ZeroClipboard.swf' } );
</script> </script>
<script src="lib/kity.min.js?_=1404819457295" charset="utf-8"></script> <script src="lib/kity.min.js?_=1404914306873" charset="utf-8"></script>
<script src="kityminder.all.min.js?_=1404819457295" charset="utf-8"></script> <script src="kityminder.all.min.js?_=1404914306873" charset="utf-8"></script>
<script src="kityminder.config.js?_=1404819457295" charset="utf-8"></script> <script src="kityminder.config.js?_=1404914306873" charset="utf-8"></script>
<script src="lang/zh-cn/zh-cn.js?_=1404819457295" charset="utf-8"></script> <script src="lang/zh-cn/zh-cn.js?_=1404914306873" charset="utf-8"></script>
<script src="lib/zip.js?_=1404819457295" charset="utf-8"></script> <script src="lib/zip.js?_=1404914306873" charset="utf-8"></script>
<script> <script>
zip.inflateJSPath = 'lib/inflate.js'; zip.inflateJSPath = 'lib/inflate.js';
</script> </script>
<script src="lib/jquery.xml2json.js?_=1404819457295" charset="utf-8"></script> <script src="lib/jquery.xml2json.js?_=1404914306873" charset="utf-8"></script>
<script src="lib/baidu-frontia-js-full-1.0.0.js?_=1404819457295" charset="utf-8"></script> <script src="lib/baidu-frontia-js-full-1.0.0.js?_=1404914306873" charset="utf-8"></script>
<script src="social/draftmanager.js?_=1404819457295" charset="utf-8"></script> <script src="social/draftmanager.js?_=1404914306873" charset="utf-8"></script>
<script src="social/social.js?_=1404819457295" charset="utf-8"></script> <script src="social/social.js?_=1404914306873" charset="utf-8"></script>
<link href="social/social.css" rel="stylesheet"> <link href="social/social.css" rel="stylesheet">
<link href="themes/default/css/import.css" type="text/css" rel="stylesheet" /> <link href="themes/default/css/import.css" type="text/css" rel="stylesheet" />
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
KityMinder.LANG['zh-cn'] = { KityMinder.LANG['zh-cn'] = {
'template': { 'template': {
'default': '思维导图', 'default': '思维导图',
'structure': '组织结构图' 'structure': '组织结构图',
'filetree': '文件夹'
}, },
'theme': { 'theme': {
'classic': '脑图经典', 'classic': '脑图经典',
......
KityMinder.LANG['zh-cn'] = { KityMinder.LANG['zh-cn'] = {
'template': { 'template': {
'default': '思维导图', 'default': '思维导图',
'structure': '组织结构图' 'structure': '组织结构图',
'filetree': '文件夹'
}, },
'theme': { 'theme': {
'classic': '脑图经典', 'classic': '脑图经典',
......
...@@ -112,6 +112,30 @@ kity.extendClass(MinderNode, { ...@@ -112,6 +112,30 @@ kity.extendClass(MinderNode, {
return this; return this;
}, },
setVertexIn: function(p) {
this._vertexIn = p;
},
setVertexOut: function(p) {
this._vertexOut = p;
},
getVertexIn: function() {
return this._vertexIn || new kity.Point();
},
getVertexOut: function() {
return this._vertexOut || new kity.Point();
},
getLayoutVertexIn: function() {
return this.getGlobalLayoutTransform().transformPoint(this.getVertexIn());
},
getLayoutVertexOut: function() {
return this.getGlobalLayoutTransform().transformPoint(this.getVertexOut());
},
getLayoutRoot: function() { getLayoutRoot: function() {
if (this.isLayoutRoot()) { if (this.isLayoutRoot()) {
return this; return this;
...@@ -292,21 +316,27 @@ var Layout = kity.createClass('Layout', { ...@@ -292,21 +316,27 @@ var Layout = kity.createClass('Layout', {
}, },
/** /**
* 工具方法:计算给节点的子树所占的布局区域 * 工具方法:计算给定的节点的子树所占的布局区域
* *
* @param {MinderNode} nodes 需要计算的节点 * @param {MinderNode} nodes 需要计算的节点
* *
* @return {Box} 计算的结果 * @return {Box} 计算的结果
*/ */
getTreeBox: function(nodes) { getTreeBox: function(nodes) {
var i, node, matrix, treeBox;
var g = KityMinder.Geometry;
var box = { var box = {
x: 0, x: 0,
y: 0, y: 0,
height: 0, height: 0,
width: 0 width: 0
}; };
var g = KityMinder.Geometry;
var i, node, matrix, treeBox; if (!(nodes instanceof Array)) nodes = [nodes];
for (i = 0; i < nodes.length; i++) { for (i = 0; i < nodes.length; i++) {
node = nodes[i]; node = nodes[i];
matrix = node.getLayoutTransform(); matrix = node.getLayoutTransform();
...@@ -319,6 +349,7 @@ var Layout = kity.createClass('Layout', { ...@@ -319,6 +349,7 @@ var Layout = kity.createClass('Layout', {
box = g.mergeBox(box, matrix.transformBox(treeBox)); box = g.mergeBox(box, matrix.transformBox(treeBox));
} }
return box; return box;
}, },
......
/* global Layout:true */ /* global Layout:true */
window.layoutSwitch = true; window.layoutSwitch = true;
KityMinder.registerLayout('bottom', kity.createClass({ KityMinder.registerLayout('bottom', kity.createClass({
base: Layout, base: Layout,
doLayout: function(node) { doLayout: function(node) {
var layout = this;
if (node.isLayoutRoot()) {
this.doLayoutRoot(node);
} else {
this.arrange(node);
}
},
doLayoutRoot: function(root) {
this.arrange(root);
},
arrange: function(node) {
var children = node.getChildren(); var children = node.getChildren();
var _this = this;
if (!children.length) { if (!children.length) {
return false; return false;
} else { }
var totalTreeWidth = 0;
// 计算每个 child 的树所占的矩形区域 var me = this;
var childTreeBoxes = children.map(function(node, index, children) {
var box = _this.getTreeBox([node]); // 子树的总宽度(包含间距)
totalTreeWidth += box.width; var totalTreeWidth = 0;
if (index > 0) {
totalTreeWidth += children[index - 1].getStyle('margin-left'); // 父亲所占的区域
totalTreeWidth += node.getStyle('margin-right'); var nodeContentBox = node.getContentBox();
}
return box; // 为每一颗子树准备的迭代变量
}); var i, x0, x, y, child, childTreeBox, childContentBox, matrix;
var nodeContentBox = node.getContentBox();
node.setLayoutVector(new kity.Vector(nodeContentBox.cx, nodeContentBox.bottom)); // 先最左对齐
var i, x, y, child, childTreeBox, childContentBox; x0 = x = nodeContentBox.left;
var transform = new kity.Matrix();
for (i = 0; i < children.length; i++) {
x = -totalTreeWidth / 2;
child = children[i];
for (i = 0; i < children.length; i++) { childContentBox = child.getContentBox();
child = children[i]; childTreeBox = this.getTreeBox(child);
childTreeBox = childTreeBoxes[i]; matrix = new kity.Matrix();
childContentBox = child.getContentBox();
if (!childContentBox.width) continue;
//水平方向上的布局
x += childTreeBox.width / 2;
if (i > 0) {
x += children[i].getStyle('margin-left');
}
y = nodeContentBox.bottom - childContentBox.top + node.getStyle('margin-bottom') + child.getStyle('margin-top');
children[i].setLayoutTransform(new kity.Matrix().translate(x, y));
x += childTreeBox.width / 2 + children[i].getStyle('margin-right');
}
if (node.isRoot()) { // 忽略无宽度的节点(收起的)
var branchBox = this.getBranchBox(children); if (!childContentBox.width) continue;
var dx = branchBox.cx - nodeContentBox.cx;
children.forEach(function(child) { if (i > 0) {
child.getLayoutTransform().translate(-dx, 0); x += child.getStyle('margin-left');
});
} }
x -= childTreeBox.left;
// arrange x
matrix.translate(x, 0);
// 为下个位置准备
x += childTreeBox.right;
if (i < children.length - 1) x += child.getStyle('margin-right');
y = nodeContentBox.bottom - childTreeBox.top +
node.getStyle('margin-bottom') + child.getStyle('margin-top');
matrix.translate(0, y);
// 设置结果
child.setLayoutTransform(matrix);
child.setVertexIn(new kity.Point(childContentBox.cx, childContentBox.top));
} }
// 设置布局矢量为向下
node.setLayoutVector(new kity.Vector(0, 1));
// 设置流出顶点
node.setVertexOut(new kity.Point(nodeContentBox.cx, nodeContentBox.bottom));
var dx = (x - x0 - nodeContentBox.width) / 2;
children.forEach(function(child) {
child.getLayoutTransform().translate(-dx, 0);
});
}, },
getOrderHint: function(node) { getOrderHint: function(node) {
...@@ -98,13 +107,14 @@ KityMinder.registerLayout('bottom', kity.createClass({ ...@@ -98,13 +107,14 @@ KityMinder.registerLayout('bottom', kity.createClass({
})); }));
KityMinder.registerConnectProvider('bottom', function(node, parent, connection) { KityMinder.registerConnectProvider('bottom', function(node, parent, connection) {
var box = node.getLayoutBox(), var pout = parent.getLayoutVertexOut(),
pBox = parent.getLayoutBox(); pin = node.getLayoutVertexIn();
var pathData = []; var pathData = [];
pathData.push('M', new kity.Point(pBox.cx, pBox.bottom)); var r = Math.round;
pathData.push('L', new kity.Point(pBox.cx, pBox.bottom + parent.getStyle('margin-bottom'))); pathData.push('M', new kity.Point(r(pout.x), pout.y));
pathData.push('L', new kity.Point(box.cx, pBox.bottom + parent.getStyle('margin-bottom'))); pathData.push('L', new kity.Point(r(pout.x), pout.y + parent.getStyle('margin-bottom')));
pathData.push('L', new kity.Point(box.cx, box.top)); pathData.push('L', new kity.Point(r(pin.x), pout.y + parent.getStyle('margin-bottom')));
pathData.push('L', new kity.Point(r(pin.x), pin.y));
connection.setMarker(null); connection.setMarker(null);
connection.setPathData(pathData); connection.setPathData(pathData);
}); });
\ No newline at end of file
...@@ -67,9 +67,11 @@ KityMinder.registerLayout('default', kity.createClass({ ...@@ -67,9 +67,11 @@ KityMinder.registerLayout('default', kity.createClass({
y = -totalTreeHeight / 2; y = -totalTreeHeight / 2;
if (side != 'left') { if (side != 'left') {
parent.setLayoutVector(new kity.Vector(nodeContentBox.right, nodeContentBox.cy)); parent.setVertexOut(new kity.Point(nodeContentBox.right, nodeContentBox.cy));
parent.setLayoutVector(new kity.Vector(1, 0));
} else { } else {
parent.setLayoutVector(new kity.Vector(nodeContentBox.left, nodeContentBox.cy)); parent.setVertexOut(new kity.Point(nodeContentBox.left, nodeContentBox.cy));
parent.setLayoutVector(new kity.Vector(-1, 0));
} }
for (i = 0; i < children.length; i++) { for (i = 0; i < children.length; i++) {
......
...@@ -27,10 +27,12 @@ KityMinder.registerLayout('filetree', kity.createClass({ ...@@ -27,10 +27,12 @@ KityMinder.registerLayout('filetree', kity.createClass({
return box; return box;
}); });
var nodeContentBox = node.getContentBox(); var nodeContentBox = node.getContentBox();
node.setLayoutVector(new kity.Vector(0, nodeContentBox.bottom));
var i, x, y, child, childTreeBox, childContentBox; var i, x, y, child, childTreeBox, childContentBox;
var transform = new kity.Matrix(); var transform = new kity.Matrix();
node.setVertexOut(new kity.Point(0, nodeContentBox.bottom));
node.setLayoutVector(new kity.Vector(0, 1));
y = nodeContentBox.bottom + node.getStyle('margin-bottom'); y = nodeContentBox.bottom + node.getStyle('margin-bottom');
for (i = 0; i < children.length; i++) { for (i = 0; i < children.length; i++) {
......
...@@ -205,15 +205,10 @@ KityMinder.registerModule('Expand', function() { ...@@ -205,15 +205,10 @@ KityMinder.registerModule('Expand', function() {
expander.setState(visible && node.children.length ? node.getData(EXPAND_STATE_DATA) : 'hide'); expander.setState(visible && node.children.length ? node.getData(EXPAND_STATE_DATA) : 'hide');
var x, y; var vector = node.getLayoutVector().normalize(expander.radius + node.getStyle('stroke-width'));
var position = node.getVertexOut().offset(vector);
var pos = node.getLayoutVector(); this.expander.setTranslate(position);
pos = new kity.Vector(pos.x, pos.y);
pos = pos.normalize(pos.length() + expander.radius + 1);
this.expander.setTranslate(pos);
} }
}); });
return { return {
......
KityMinder.registerTemplate('structure', { KityMinder.registerTemplate('structure', {
name: '组织结构图',
getLayout: function(node) { getLayout: function(node) {
return 'bottom';
}
});
KityMinder.registerTemplate('filetree', {
getLayout: function(node) {
if (node.getData('layout')) return node.getData('layout'); if (node.getData('layout')) return node.getData('layout');
if (node.isRoot()) return 'bottom'; if (node.isRoot()) return 'bottom';
......
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