Skip to content

Commit

Permalink
1.规范了代码
Browse files Browse the repository at this point in the history
  • Loading branch information
baipgydx729 committed Apr 3, 2015
1 parent 0d2dd94 commit 62ba94a
Show file tree
Hide file tree
Showing 16 changed files with 250 additions and 310 deletions.
396 changes: 197 additions & 199 deletions import.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion kityminder.config.js
Expand Up @@ -26,6 +26,6 @@
maxImageHeight: 200,

// 修改后自动保存时间间隔(单位:秒);设置为 false 不自动保存
autoSave: 1000
autoSave: 2
};
})();
2 changes: 1 addition & 1 deletion src/connect/arc.js
Expand Up @@ -35,7 +35,7 @@ KityMinder.registerConnectProvider('arc', function(node, parent, connection, wid

vector = kity.Vector.fromPoints(start, end);
pathData.push('M', start);
pathData.push('A', abs(vector.x), abs(vector.y), 0, 0 , (vector.x * vector.y > 0 ? 0 : 1), end);
pathData.push('A', abs(vector.x), abs(vector.y), 0, 0, (vector.x * vector.y > 0 ? 0 : 1), end);

connection.setMarker(connectMarker);
connectMarker.dot.fill(color);
Expand Down
21 changes: 10 additions & 11 deletions src/connect/arc_tp.js
@@ -1,13 +1,12 @@
/**
* @fileOverview
*
* 圆弧连线
*
* @author: techird
* @copyright: Baidu FEX, 2014
* @author: along
* @copyright: bpd729@163.com , 2015
*/

var connectMarker = new kity.Marker().pipe(function() {
var connectMarker = new kity.Marker().pipe(function () {
var r = 7;
var dot = new kity.Circle(r - 1);
this.addShape(dot);
Expand All @@ -16,14 +15,14 @@ var connectMarker = new kity.Marker().pipe(function() {
this.node.setAttribute('markerUnits', 'userSpaceOnUse');
});

KityMinder.registerConnectProvider('arc_tp', function(node, parent, connection, width, color) {
KityMinder.registerConnectProvider('arc_tp', function (node, parent, connection, width, color) {
var end_box = node.getLayoutBox(),
start_box = parent.getLayoutBox();


if(node.getIndex()>0){
var index = node.getIndex();
start_box = parent.getChildren()[index-1].getLayoutBox();
if (node.getIndex() > 0) {
var index = node.getIndex();
start_box = parent.getChildren()[index - 1].getLayoutBox();
}


Expand All @@ -38,13 +37,13 @@ KityMinder.registerConnectProvider('arc_tp', function(node, parent, connection,
start = new kity.Point(start_box.cx, start_box.cy);
end = new kity.Point(end_box.cx, end_box.cy);

var jl = Math.sqrt(Math.abs(start.x -end.x) * Math.abs(start.x - end.x) + Math.abs(start.y -end.y) * Math.abs(start.y -end.y)); //两圆中心点距离
var jl = Math.sqrt(Math.abs(start.x - end.x) * Math.abs(start.x - end.x) + Math.abs(start.y - end.y) * Math.abs(start.y - end.y)); //两圆中心点距离

jl = node.getIndex()==0 ? jl *0.4 : jl;
jl = node.getIndex() == 0 ? jl * 0.4 : jl;

vector = kity.Vector.fromPoints(start, end);
pathData.push('M', start);
pathData.push('A', jl, jl, 0, 0 , 1, end);
pathData.push('A', jl, jl, 0, 0, 1, end);

connection.setMarker(connectMarker);
connectMarker.dot.fill(color);
Expand Down
11 changes: 3 additions & 8 deletions src/layout/fish-bone-master.js
Expand Up @@ -18,11 +18,8 @@ KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLa
var child = children[0];
var pBox = parent.getContentBox();

var point = new kity.Point(pBox.right, pBox.cy);
parent.setVertexOut(point);
var vector = new kity.Vector(1, 0);
parent.setLayoutVectorOut(vector);

parent.setVertexOut(new kity.Point(pBox.right, pBox.cy));
parent.setLayoutVectorOut(new kity.Vector(1, 0));

if (!child) return;

Expand All @@ -32,7 +29,6 @@ KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLa
var cMarginTop = child.getStyle('margin-top');
var cMarginBottom = child.getStyle('margin-bottom');


children.forEach(function(child, index) {
child.setLayoutTransform(new kity.Matrix());
var cBox = child.getContentBox();
Expand All @@ -47,9 +43,8 @@ KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLa
child.setVertexIn(new kity.Point(cBox.left, cBox.bottom));
child.setLayoutVectorIn(new kity.Vector(1, -1));
}
});


});

this.stack(upPart, 'x');
this.stack(downPart, 'x');
Expand Down
3 changes: 1 addition & 2 deletions src/layout/fish-bone-slave.js
Expand Up @@ -13,7 +13,6 @@ KityMinder.registerLayout('fish-bone-slave', kity.createClass('FishBoneSlaveLayo

doLayout: function (parent, children, round) {

//debugger
var layout = this;
var abs = Math.abs;
var GOLD_CUT = 1 - 0.618;
Expand Down Expand Up @@ -51,7 +50,7 @@ KityMinder.registerLayout('fish-bone-slave', kity.createClass('FishBoneSlaveLayo
yAdjust -= child.getStyle('margin-bottom');
} else {
yAdjust += parent.getContentBox().bottom;
yAdjust += parent.getStyle('margin-botttom');
yAdjust += parent.getStyle('margin-bottom');
yAdjust += child.getStyle('margin-top');
}

Expand Down
1 change: 0 additions & 1 deletion src/layout/mind.js
Expand Up @@ -3,7 +3,6 @@ KityMinder.registerLayout('mind', kity.createClass({
base: Layout,

doLayout: function(node, children) {

var layout = this;
var half = Math.ceil(node.children.length / 2);
var right = [];
Expand Down
93 changes: 19 additions & 74 deletions src/layout/tianpan.js
@@ -1,98 +1,43 @@
/**
* Created with JetBrains WebStorm.
* User: chenbaolong
* Date: 15-3-20
* Time: 上午11:04
* To change this template use File | Settings | File Templates.
* @fileOverview
*
* 天盘模板
*
* @author: along
* @copyright: bpd729@163.com, 2015
*/
/* global Layout:true */

KityMinder.registerLayout('tianpan', kity.createClass({
base: Layout,

doLayout: function(parent, children) {
if(children.length==0) return;
doLayout: function (parent, children) {
if (children.length == 0) return;

var layout = this;
var pbox = parent.getContentBox();

var x, y;
var _theta = 5;
var _r = Math.max(pbox.width,50);
children.forEach(function(child, index) {
var x, y,box;
var _theta = 5;
var _r = Math.max(pbox.width, 50);
children.forEach(function (child, index) {
child.setLayoutTransform(new kity.Matrix());
var box = layout.getTreeBox(child);
var w = Math.max(box.width,box.height);
_r = Math.max(w,_r);
box = layout.getTreeBox(child);
_r = Math.max(Math.max(box.width, box.height), _r);
})
_r = _r / 1.5 / Math.PI;
_r = _r / 1.5 / Math.PI;

children.forEach(function(child, index) {
// x = _r * (Math.cos(alpha) + Math.sin(alpha)* alpha * Math.PI/180);
// y = _r * (Math.sin(alpha) - Math.cos(alpha)* alpha * Math.PI/180);
children.forEach(function (child, index) {
x = _r * (Math.cos(_theta) + Math.sin(_theta) * _theta);
y = _r * (Math.sin(_theta) - Math.cos(_theta) * _theta);

_theta += (0.9 - index * 0.02);
child.setLayoutVectorIn(new kity.Vector(1, 0));
child.setVertexIn(new kity.Point(pbox.left+15, pbox.cy+25));
child.setVertexIn(new kity.Point(pbox.cx, pbox.cy));
child.setLayoutTransform(new kity.Matrix());
layout.move([child],x,y);

//
// child.getContentBox().translate(x, y);
// console.log(child.getContentBox());
// debugger


// _tmp_rects.forEach(function (tmpRect) {
// debugger
// if (g.getIntersectBox(tmpRect,_cut_rect)) {
// _cover = true;
// }
// })
//
// if (_cover) {
// _r += 2;
// console.log('true')
// } else {
// _do = false;
// _tempchilds.push({child: child, r: _r, theta: _theta, area: _cut_rect})
// _theta += 0.9;
// _tmp_rects.push(_cut_rect);
// }
// }
});



return;

//debugger
var layout = this;
var half = Math.ceil(node.children.length / 2);
var right = [];
var left = [];

children.forEach(function(child) {
if (child.getIndex() < half) right.push(child);
else left.push(child);
layout.move([child], x, y);
});

var leftLayout = KityMinder.getLayoutInstance('left');
var rightLayout = KityMinder.getLayoutInstance('right');

leftLayout.doLayout(node, left);
rightLayout.doLayout(node, right);

var box = node.getContentBox();
node.setVertexOut(new kity.Point(box.cx, box.cy));
node.setLayoutVectorOut(new kity.Vector(0, 0));
},

getOrderHint: function(node) {


getOrderHint: function (node) {
var hint = [];
var box = node.getLayoutBox();
var offset = 5;
Expand Down
5 changes: 2 additions & 3 deletions src/template/tianpan.js
Expand Up @@ -8,7 +8,7 @@
*/

KityMinder.registerTemplate('tianpan', {
getLayout: function(node) {
getLayout: function (node) {
if (node.getData('layout')) return node.getData('layout');
var level = node.getLevel();

Expand All @@ -20,8 +20,7 @@ KityMinder.registerTemplate('tianpan', {
return node.parent.getLayout();
},

getConnect: function(node) {
if (node.getLevel() == 1) return 'arc_tp';
getConnect: function (node) {
return 'arc_tp';
}
});
10 changes: 5 additions & 5 deletions src/theme/tianpan.js
@@ -1,4 +1,4 @@
['tianpan', 'tianpan-compact'].forEach(function(name) {
['tianpan', 'tianpan-compact'].forEach(function (name) {
var compact = name == 'tianpan-compact';

KityMinder.registerTheme(name, {
Expand All @@ -13,7 +13,7 @@
'root-radius': 30,
'root-space': 10,
'root-shadow': 'rgba(0, 0, 0, .25)',
'root-shape':'circle',
'root-shape': 'circle',

'main-color': '#333',
'main-background': '#a4c5c0',
Expand All @@ -24,7 +24,7 @@
'main-radius': 10,
'main-space': 5,
'main-shadow': 'rgba(0, 0, 0, .25)',
'main-shape':'circle',
'main-shape': 'circle',

'sub-color': '#333',
'sub-background': '#99ca6a',
Expand All @@ -36,7 +36,7 @@
'sub-radius': 5,
'sub-space': 5,
'sub-shadow': 'rgba(0, 0, 0, .25)',
'sub-shape':'circle',
'sub-shape': 'circle',

'connect-color': 'white',
'connect-width': 2,
Expand All @@ -60,6 +60,6 @@
'order-hint-path-width': 1,

'text-selection-color': 'rgb(27,171,255)',
'line-height':1.4
'line-height': 1.4
});
});
4 changes: 4 additions & 0 deletions ui/theme/default/css/_mainmenu.new.less
Expand Up @@ -60,6 +60,10 @@
&.fish-bone:after {
background-position: -400px 0;
}

&.tianpan:after {
background-position: -500px 0;
}

&:hover {
a {
Expand Down
Binary file modified ui/theme/default/images/template.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ui/theme/default/images/template_large.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions ui/topbar/feedback.js
Expand Up @@ -6,16 +6,17 @@
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('topbar/feedback', function(minder) {
KityMinder.registerUI('topbar/feedback', function (minder) {
var $quickvisit = minder.getUI('topbar/quickvisit');

var $feedback = $quickvisit.add('feedback', 'right');

function quickFeedback() {
var $menu = minder.getUI('menu/menu');
$menu.$tabs.select(5);
$menu.$tabs.select(6);
$menu.show();
}

$feedback.click(quickFeedback);
minder.addShortcut('f1', quickFeedback);

Expand Down
2 changes: 1 addition & 1 deletion ui/topbar/quickvisit.js
Expand Up @@ -65,7 +65,7 @@ KityMinder.registerUI('topbar/quickvisit', function (minder) {

minder.addShortcut('ctrl+alt+n', quickNew);
minder.addShortcut('ctrl+s', quickSave);
minder.addShortcut('ctrl+shift+s', function() {
minder.addShortcut('ctrl+shift+s', function () {
var $menu = minder.getUI('menu/menu');
$menu.$tabs.select(2);
$menu.show();
Expand Down
5 changes: 3 additions & 2 deletions ui/topbar/share.js
Expand Up @@ -6,16 +6,17 @@
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('topbar/share', function(minder) {
KityMinder.registerUI('topbar/share', function (minder) {
var $quickvisit = minder.getUI('topbar/quickvisit');

var $share = $quickvisit.add('share', 'right');

function quickShare() {
var $menu = minder.getUI('menu/menu');
$menu.$tabs.select(5);
$menu.$tabs.select(3);
$menu.show();
}

$share.click(quickShare);
minder.addShortcut('ctrl+alt+s', quickShare);
return $share;
Expand Down

1 comment on commit 62ba94a

@skyoflove111
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

引入 kityminder.config.js 修改后没有自动保存是什么原因?

Please sign in to comment.