Commit 501b821c authored by techird's avatar techird

dev

parent 9f0ab629
......@@ -27,7 +27,7 @@ module.exports = function (grunt) {
var getPath = function (readFile) {
var sources = require("fs").readFileSync(readFile);
sources = /Array\(([^)]+)\)/.exec(sources);
sources = /paths\s=\s\[([\s\S]*?)\]/ig.exec(sources);
sources = sources[1].replace(/\/\/.*\n/g, '\n').replace(/'|"|\n|\t|\s/g, '');
sources = sources.split(",");
sources.forEach(function (filepath, index) {
......@@ -65,7 +65,6 @@ module.exports = function (grunt) {
files: (function () {
var files = {};
files[distPath + 'kityminder.all.min.js'] = distPath + 'kityminder.all.js';
console.log(files);
return files;
})()
}
......@@ -101,7 +100,7 @@ module.exports = function (grunt) {
overwrite: true,
replacements: [{
from: /kity\/dist\/kity\.js/ig,
to: 'lib/kitygraph.all.min.js'
to: 'lib/kity.min.js'
}, {
from: /import\.js/,
to: 'kityminder.all.min.js'
......@@ -154,13 +153,15 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-text-replace');
// Build task(s).
grunt.registerTask('default', ['concat', 'uglify', 'copy', 'replace']);
/* [liverload plugin & task ] ------------------------------------*/
grunt.loadNpmTasks('grunt-regarde');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-livereload');
// Build task(s).
grunt.registerTask('default', ['concat', 'uglify', 'copy', 'replace']);
grunt.registerTask('live', ['livereload-start', 'connect', 'regarde']);
};
\ No newline at end of file
Subproject commit 7c5ee097334581f51ae994ff3c5d51f96d5ac260
Subproject commit 5382742eb5b1764af2bb4fdf4fa7565318bfbb78
......@@ -2,7 +2,7 @@
"name": "kityminder",
"title": "kityminder",
"description": "Kity Minder",
"version": "1.1.3.1",
"version": "1.1.3",
"homepage": "https://github.com/fex-team/kityminder",
"author": {
"name": "f-cube @ FEX",
......
......@@ -128,7 +128,7 @@ kity.extendClass(MinderNode, {
}
}
this.getMinder().layout(this, duration);
this.getMinder().layout(duration);
return this;
},
......@@ -140,18 +140,11 @@ kity.extendClass(MinderNode, {
kity.extendClass(Minder, {
layout: function(root, duration) {
if (+root === root) {
duration = root;
root = null;
}
root = root || this.getRoot();
layout: function(duration) {
// traverse without root
root.traverse(function(node) {
this.getRoot().traverse(function(node) {
node.setLayoutTransform(null);
}, true);
});
function layoutNode(node) {
......@@ -167,9 +160,9 @@ kity.extendClass(Minder, {
layout.doLayout(node);
}
layoutNode(root);
layoutNode(this.getRoot());
this.applyLayoutResult(root, duration);
this.applyLayoutResult(this.getRoot(), duration);
return this.fire('layout');
},
......
......@@ -37,6 +37,13 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
return this.root === this;
},
/**
* 判断节点是否叶子
*/
isLeaf: function() {
return this.children.length === 0;
},
/**
* 获取节点的根节点
*/
......@@ -65,11 +72,14 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
},
/**
* 获得节点的复杂度
* @return {[type]} [description]
* 获得节点的复杂度(即子树中节点的数量)
*/
getComplex: function() {
var complex = 0;
this.traverse(function() {
complex++;
});
return complex;
},
/**
......
......@@ -75,7 +75,7 @@ KityMinder.registerModule('Expand', function() {
node.traverse(function(node) {
node.render();
});
node.getMinder().layout(null, 200);
node.getMinder().layout(200);
}
// 将展开的操作和状态读取接口拓展到 MinderNode 上
......
......@@ -30,7 +30,7 @@ var AppendSiblingCommand = kity.createClass('AppendSiblingCommand', {
km.select(node, true);
node.render();
node._lastLayoutTransform = sibling._lastLayoutTransform;
km.layout(3000);
km.layout(300);
},
queryState: function(km) {
var selectedNode = km.getSelectedNode();
......
/* global Renderer: true */
var wireframe = /wire/.test(window.location.href);
var OutlineRenderer = kity.createClass('OutlineRenderer', {
base: Renderer,
create: function(node) {
var group = new kity.Group();
var outline = this.outline = new kity.Rect()
var outline = new kity.Rect()
.setId(KityMinder.uuid('node_outline'));
var shadow = this.shadow = new kity.Rect()
.setId(KityMinder.uuid('node_shadow'));
group.addShapes([shadow, outline]);
if (wireframe) {
var oxy = this.oxy = new kity.Path()
.stroke('#f6f')
.setPathData('M0,-50L0,50M-50,0L50,0');
var box = this.wireframe = new kity.Rect()
.stroke('lightgreen');
group.addShapes([oxy, box]);
}
this.bringToBack = true;
return group;
return outline;
},
update: function(created, node) {
var contentBox = node.getContentBox();
update: function(outline, node, box) {
var paddingLeft = node.getStyle('padding-left'),
paddingRight = node.getStyle('padding-right'),
......@@ -40,51 +22,78 @@ var OutlineRenderer = kity.createClass('OutlineRenderer', {
paddingBottom = node.getStyle('padding-bottom');
var outlineBox = {
x: contentBox.x - paddingLeft,
y: contentBox.y - paddingTop,
width: contentBox.width + paddingLeft + paddingRight,
height: contentBox.height + paddingTop + paddingBottom
x: box.x - paddingLeft,
y: box.y - paddingTop,
width: box.width + paddingLeft + paddingRight,
height: box.height + paddingTop + paddingBottom
};
this.outline
.setPosition(outlineBox.x, outlineBox.y)
.setSize(outlineBox.width, outlineBox.height)
.setRadius(node.getStyle('radius'));
var prefix = node.isSelected() ? 'selected-' : '';
this.outline.fill(node.getStyle(prefix + 'background'));
this.outline.stroke(node.getStyle(prefix + 'stroke'),
node.getStyle(prefix + 'stroke-width'));
if (node.getStyle('shadow')) {
this.shadow
.setVisible(true)
.setPosition(outlineBox.x + 4, outlineBox.y + 5)
.setSize(outlineBox.width, outlineBox.height)
.fill(node.getStyle('shadow'))
.setRadius(node.getStyle('radius'));
} else {
this.shadow.setVisible(false);
}
outline
.setPosition(outlineBox.x, outlineBox.y)
.setSize(outlineBox.width, outlineBox.height)
.setRadius(node.getStyle('radius'))
.fill(node.getStyle(prefix + 'background'))
.stroke(node.getStyle(prefix + 'stroke'),
node.getStyle(prefix + 'stroke-width'));
if (wireframe) {
this.wireframe
.setPosition(outlineBox.x, outlineBox.y)
.setSize(outlineBox.width, outlineBox.height);
}
return outlineBox;
}
});
var ShadowRenderer = kity.createClass('ShadowRenderer', {
base: Renderer,
create: function(node) {
this.bringToBack = true;
return new kity.Rect();
},
shouldRender: function(node) {
return node.getStyle('shadow');
},
update: function(shadow, node, box) {
shadow.setPosition(box.x + 4, box.y + 5)
.setSize(box.width, box.height)
.fill(node.getStyle('shadow'))
.setRadius(node.getStyle('radius'));
}
});
var wireframeOption = /wire/.test(window.location.href);
var WireframeRenderer = kity.createClass('WireframeRenderer', {
base: Renderer,
create: function() {
var wireframe = new kity.Group();
var oxy = this.oxy = new kity.Path()
.stroke('#f6f')
.setPathData('M0,-50L0,50M-50,0L50,0');
var box = this.wireframe = new kity.Rect()
.stroke('lightgreen');
return wireframe.addShapes([oxy, box]);
},
shouldRender: function() {
return wireframeOption;
},
update: function(created, node, box) {
this.wireframe
.setPosition(box.x, box.y)
.setSize(box.width, box.height);
}
});
KityMinder.registerModule('OutlineModule', function() {
return {
renderers: {
outline: OutlineRenderer
outline: OutlineRenderer,
outside: [ShadowRenderer, WireframeRenderer]
}
};
});
\ No newline at end of file
......@@ -26,7 +26,7 @@ KityMinder.registerModule('Select', function() {
return this.selectEnd();
}
startPosition = g.snapToSharp(e.getPosition());
startPosition = g.snapToSharp(e.getPosition('paper'));
},
selectMove: function(e) {
if (minder.isTextEditStatus()) {
......@@ -35,7 +35,9 @@ KityMinder.registerModule('Select', function() {
if (!startPosition) return;
var p1 = startPosition,
p2 = e.getPosition();
p2 = e.getPosition('paper');
console.log(e.kityEvent.targetShape);
// 检测是否要进入选区模式
if (!marqueeMode) {
......
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