Commit b27e5394 authored by techird's avatar techird

Merge remote-tracking branch 'product/dev' into clean-up

Conflicts:
	.gitmodules
	CHANGELOG.md
	edit.html
	import.js
	lang/zh-cn/zh-cn.js
	src/core/kityminder.js
	src/protocol/png.js
	ui/contextmenu.js
	ui/menu/share/share.js
	ui/ribbon/idea/image.js
	ui/ribbon/view/level.js
	ui/theme/default/css/_icons.less
	ui/theme/default/css/_kityminder.less
	ui/theme/default/css/_mainmenu.less
	ui/theme/default/css/_notice.less
	ui/theme/default/css/_resource_panel.less
	ui/theme/default/css/_tab.less
	ui/theme/default/css/_widgets.less
	ui/theme/default/css/import.less
	ui/theme/default/images/icons.png
	ui/topbar/search.js
	ui/ui.js
parents a95967d6 40160914
[submodule "lib/kity"] [submodule "lib/kity"]
path = lib/kity path = lib/kity
url = https://github.com/fex-team/kity url = https://github.com/fex-team/kity
\ No newline at end of file
...@@ -66,7 +66,7 @@ module.exports = function(grunt) { ...@@ -66,7 +66,7 @@ module.exports = function(grunt) {
// Metadata. // Metadata.
pkg: grunt.file.readJSON('package.json'), pkg: grunt.file.readJSON('package.json'),
clean: ['dist', 'native-support/upload', 'native-support/src/tmp'], clean: ['dist', 'native-support/upload/', 'native-support/src/tmp/'],
concat: concatConfigs, concat: concatConfigs,
...@@ -131,12 +131,21 @@ module.exports = function(grunt) { ...@@ -131,12 +131,21 @@ module.exports = function(grunt) {
}] }]
}, },
noCache: { pageNoCache: {
src: distPages, src: distPages,
overwrite: true, overwrite: true,
replacements: [{ replacements: [{
from: /src=\"(.+?)\.js\"/ig, from: /(src|href)=\"(.+?)\.(js|css)\"/ig,
to: 'src="$1.js?_=' + (+new Date()) + '"' to: '$1="$2.$3?_=' + (+new Date()) + '"'
}]
},
imageNoCache: {
src: 'dist/ui/theme/default/css/default.all.css',
overwrite: true,
replacements: [{
from: /\.png/ig,
to: '.png?_=' + (+new Date())
}] }]
} }
}, },
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
(function() { (function() {
/* 可能的文件路径,已按照依赖关系排序 */ /* 可能的文件路径,已按照依赖关系排序 */
var pathInfo = [ var pathInfo = [
/* 核心代码 */ /* 核心代码 */
'src/core/kityminder.js', 'src/core/kityminder.js',
'src/core/utils.js', 'src/core/utils.js',
......
Subproject commit 36b51b090c28d9d362f00e1023fcb3dc6317585d Subproject commit 1275889df5d47e4e6c23112d65859ca39c45ca98
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "kityminder", "name": "kityminder",
"title": "kityminder", "title": "kityminder",
"description": "Kity Minder", "description": "Kity Minder",
"version": "1.3.2", "version": "1.3.5",
"homepage": "https://github.com/fex-team/kityminder", "homepage": "https://github.com/fex-team/kityminder",
"author": { "author": {
"name": "f-cube @ FEX", "name": "f-cube @ FEX",
......
...@@ -36,7 +36,7 @@ var KityMinder = kity.createClass('KityMinder', { ...@@ -36,7 +36,7 @@ var KityMinder = kity.createClass('KityMinder', {
} }
}); });
KityMinder.version = '1.3.2'; KityMinder.version = '1.0.0';
KityMinder.registerInit = function(fn) { KityMinder.registerInit = function(fn) {
_initFnQueue.push(fn); _initFnQueue.push(fn);
...@@ -56,4 +56,3 @@ if (typeof(module) != 'undefined') { ...@@ -56,4 +56,3 @@ if (typeof(module) != 'undefined') {
window.KityMinder = KityMinder; window.KityMinder = KityMinder;
} }
/* jshint +W079 */
\ No newline at end of file
...@@ -121,6 +121,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', { ...@@ -121,6 +121,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
getText: function(str2arr) { getText: function(str2arr) {
var text = this.getData('text') || ''; var text = this.getData('text') || '';
text = text.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;');
if(str2arr){ if(str2arr){
text = text.split('\n'); text = text.split('\n');
} }
......
...@@ -6,123 +6,23 @@ KityMinder.registerModule('Expand', function() { ...@@ -6,123 +6,23 @@ KityMinder.registerModule('Expand', function() {
STATE_EXPAND = 'expand', STATE_EXPAND = 'expand',
STATE_COLLAPSE = 'collapse'; STATE_COLLAPSE = 'collapse';
/**
* 该函数返回一个策略,表示递归到节点指定的层数
*
* 返回的策略表示把操作(展开/收起)进行到指定的层数
* 也可以给出一个策略指定超过层数的节点如何操作,默认不进行任何操作
*
* @param {int} deep_level 指定的层数
* @param {Function} policy_after_level 超过的层数执行的策略
*/
function generateDeepPolicy(deep_level, policy_after_level) {
return function(node, state, policy, level) {
var children, child, i;
node.setData(EXPAND_STATE_DATA, state);
level = level || 1;
children = node.getChildren();
for (i = 0; i < children.length; i++) {
child = children[i];
if (level <= deep_level) {
policy(child, state, policy, level + 1);
} else if (policy_after_level) {
policy_after_level(child, state, policy, level + 1);
}
}
};
}
/**
* 节点展开和收缩的策略常量
*
* 策略是一个处理函数,处理函数接受 3 个参数:
*
* @param {MinderNode} node 要处理的节点
* @param {Enum} state 取值为 "expand" | "collapse",表示要对节点进行的操作是展开还是收缩
* @param {Function} policy 提供当前策略的函数,方便递归调用
*/
var EXPAND_POLICY = MinderNode.EXPAND_POLICY = {
/**
* 策略 1:只修改当前节点的状态,不递归子节点的状态
*/
KEEP_STATE: function(node, state, policy) {
node.setData(EXPAND_STATE_DATA, state);
},
generateDeepPolicy: generateDeepPolicy,
/**
* 策略 2:把操作进行到儿子
*/
DEEP_TO_CHILD: generateDeepPolicy(2),
/**
* 策略 3:把操作进行到叶子
*/
DEEP_TO_LEAF: generateDeepPolicy(Number.MAX_VALUE)
};
function setExpandState(node, state, policy) {
var changed = node.isExpanded() ? (state == STATE_COLLAPSE) : (state == STATE_EXPAND);
policy = policy || EXPAND_POLICY.KEEP_STATE;
policy(node, state, policy);
node.renderTree().getMinder().layout(100);
node.getMinder().fire('contentchange');
/* 如何加展开效果:
var vo = node.getVertexOut();
if (state == STATE_EXPAND) {
var m = node.getGlobalLayoutTransform().clone().translate(vo.x, vo.y);
node.traverse(function(child) {
child.setGlobalLayoutTransform(m);
child.getRenderContainer().setOpacity(0).fadeIn();
}, true);
node.renderTree().getMinder().layout(300);
} else {
node.traverse(function(child) {
child.setLayoutTransform(child.parent == node ? new kity.Matrix().translate(vo.x, vo.y) : null);
child.getRenderContainer().fadeOut(100);
}, true);
node.getMinder().applyLayoutResult(node, 150).then(function() {
node.renderTree().getMinder().layout(150);
});
}
*/
}
// 将展开的操作和状态读取接口拓展到 MinderNode 上 // 将展开的操作和状态读取接口拓展到 MinderNode 上
kity.extendClass(MinderNode, { kity.extendClass(MinderNode, {
/** /**
* 使用指定的策略展开节点 * 展开节点
* @param {Policy} policy 展开的策略,默认为 KEEP_STATE * @param {Policy} policy 展开的策略,默认为 KEEP_STATE
*/ */
expand: function(policy) { expand: function() {
setExpandState(this, STATE_EXPAND, policy); this.setData(EXPAND_STATE_DATA, STATE_EXPAND);
return this; return this;
}, },
/** /**
* 使用指定的策略收起节点 * 收起节点
* @param {Policy} policy 展开的策略,默认为 KEEP_STATE
*/ */
collapse: function(policy) { collapse: function() {
setExpandState(this, STATE_COLLAPSE, policy); this.setData(EXPAND_STATE_DATA, STATE_COLLAPSE);
return this; return this;
}, },
...@@ -141,30 +41,41 @@ KityMinder.registerModule('Expand', function() { ...@@ -141,30 +41,41 @@ KityMinder.registerModule('Expand', function() {
return !this.isExpanded(); return !this.isExpanded();
} }
}); });
var ExpandNodeCommand = kity.createClass('ExpandNodeCommand', {
var ExpandCommand = kity.createClass('ExpandCommand', {
base: Command, base: Command,
execute: function(km) {
var nodes = km.getRoot().getChildren(); execute: function(km, justParents) {
nodes.forEach(function(node) { var node = km.getSelectedNode();
node.expand(EXPAND_POLICY.DEEP_TO_LEAF); if (!node) return;
}); if (justParents) {
node = node.parent;
}
while(node.parent) {
node.expand();
node = node.parent;
}
node.renderTree();
km.layout(100);
}, },
queryState: function(km) { queryState: function(km) {
return !km.getSelectedNode() ? 0 : -1; return km.getSelectedNode() ? 0 : -1;
} }
}); });
var CollapseNodeCommand = kity.createClass('CollapseNodeCommand', {
var ExpandToLevelCommand = kity.createClass('ExpandToLevelCommand', {
base: Command, base: Command,
execute: function(km) { execute: function(km, level) {
var nodes = km.getRoot().getChildren(); km.getRoot().traverse(function(node) {
nodes.forEach(function(node) { if (node.getLevel() < level) node.expand();
node.collapse(); if (node.getLevel() == level) node.collapse();
}); });
km.refresh(100);
}, },
queryState: function(km) { enableReadOnly: true
return !km.getSelectedNode() ? 0 : -1;
}
}); });
var Expander = kity.createClass('Expander', { var Expander = kity.createClass('Expander', {
base: kity.Group, base: kity.Group,
...@@ -186,6 +97,8 @@ KityMinder.registerModule('Expand', function() { ...@@ -186,6 +97,8 @@ KityMinder.registerModule('Expand', function() {
} else { } else {
node.expand(); node.expand();
} }
node.renderTree().getMinder().layout(100);
node.getMinder().fire('contentchange');
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
}); });
...@@ -240,8 +153,8 @@ KityMinder.registerModule('Expand', function() { ...@@ -240,8 +153,8 @@ KityMinder.registerModule('Expand', function() {
}); });
return { return {
commands: { commands: {
'expandtoleaf': ExpandNodeCommand, 'expand': ExpandCommand,
'collapsetolevel1': CollapseNodeCommand 'expandtolevel': ExpandToLevelCommand
}, },
events: { events: {
'layoutapply': function(e) { 'layoutapply': function(e) {
...@@ -267,25 +180,60 @@ KityMinder.registerModule('Expand', function() { ...@@ -267,25 +180,60 @@ KityMinder.registerModule('Expand', function() {
this.getSelectedNodes().forEach(function(node) { this.getSelectedNodes().forEach(function(node) {
if (expanded) node.collapse(); if (expanded) node.collapse();
else node.expand(); else node.expand();
node.renderTree();
}); });
this.layout(100);
this.fire('contentchange');
e.preventDefault(); e.preventDefault();
e.stopPropagationImmediately(); e.stopPropagationImmediately();
} }
if (e.isShortcutKey('Alt+`')) {
this.execCommand('expandtolevel', 9999);
}
for (var i = 1; i < 6; i++) {
if (e.isShortcutKey('Alt+' + i)) {
this.execCommand('expandtolevel', i);
}
}
} }
}, },
renderers: { renderers: {
outside: ExpanderRenderer outside: ExpanderRenderer
}, },
contextmenu: [{ contextmenu: [{
command: 'expandtoleaf' command: 'expandtoleaf',
query: function() {
return !minder.getSelectedNode();
},
fn: function(minder) {
minder.execCommand('expandtolevel', 9999);
}
}, {
command: 'expandtolevel1',
query: function() {
return !minder.getSelectedNode();
},
fn: function(minder) {
minder.execCommand('expandtolevel', 1);
}
}, { }, {
command: 'collapsetolevel1' command: 'expandtolevel2',
query: function() {
return !minder.getSelectedNode();
},
fn: function(minder) {
minder.execCommand('expandtolevel', 2);
}
},{
command: 'expandtolevel3',
query: function() {
return !minder.getSelectedNode();
},
fn: function(minder) {
minder.execCommand('expandtolevel', 3);
}
}, { }, {
divider: true divider: true
}], }]
commandShortcutKeys: {
'expandtoleaf': 'Alt+`',
'collapsetolevel1': 'Alt+1'
}
}; };
}); });
\ No newline at end of file
...@@ -12,11 +12,9 @@ KityMinder.registerModule("fontmodule", function() { ...@@ -12,11 +12,9 @@ KityMinder.registerModule("fontmodule", function() {
var fontFamily = getNodeDataOrStyle(node, 'font-family'); var fontFamily = getNodeDataOrStyle(node, 'font-family');
var fontSize = getNodeDataOrStyle(node, 'font-size'); var fontSize = getNodeDataOrStyle(node, 'font-size');
var fontHash = [fontFamily, fontSize].join('/'); var fontHash = [fontFamily, fontSize].join('/');
if (foreColor.toString() != node.getTmpData('fore-color')) { textGroup.fill(foreColor);
textGroup.fill(foreColor); node.setTmpData('fore-color', foreColor.toString());
node.setTmpData('fore-color', foreColor.toString());
}
textGroup.eachItem(function(index,item){ textGroup.eachItem(function(index,item){
item.setFont({ item.setFont({
......
/**
* @fileOverview
*
* 支持节点详细信息(HTML)格式
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerModule('NoteModule', function() {
var NOTE_PATH = 'M9,9H3V8h6L9,9L9,9z M9,7H3V6h6V7z M9,5H3V4h6V5z M8.5,11H2V2h8v7.5 M9,12l2-2V1H1v11';
var NoteCommand = kity.createClass('NoteCommand', {
base: Command,
execute: function(minder, note) {
var node = minder.getSelectedNode();
node.setData('note', note);
node.render();
node.getMinder().layout(300);
},
queryState: function(minder) {
return minder.getSelectedNodes().length === 1 ? 0 : -1;
},
queryValue: function(minder) {
var node = minder.getSelectedNode();
return node && node.getData('note');
}
});
var NoteIcon = kity.createClass('NoteIcon', {
base: kity.Group,
constructor: function() {
this.callBase();
this.width = 16;
this.height = 17;
this.rect = new kity.Rect(16, 17, 0.5, -8.5, 2).fill('transparent');
this.path = new kity.Path().setPathData(NOTE_PATH).setTranslate(2.5, -6.5);
this.addShapes([this.rect, this.path]);
this.on('mouseover', function() {
this.rect.fill('rgba(255, 255, 200, .8)');
}).on('mouseout', function() {
this.rect.fill('transparent');
});
this.setStyle('cursor', 'pointer');
}
});
var NoteIconRenderer = kity.createClass('NoteIconRenderer', {
base: KityMinder.Renderer,
create: function(node) {
var icon = new NoteIcon();
icon.on('mousedown', function(e) {
e.preventDefault();
node.getMinder().fire('editnoterequest');
});
icon.on('mouseover', function() {
node.getMinder().fire('shownoterequest', {node: node, icon: icon});
});
icon.on('mouseout', function() {
node.getMinder().fire('hidenoterequest', {node: node, icon: icon});
});
return icon;
},
shouldRender: function(node) {
return node.getData('note');
},
update: function(icon, node, box) {
var x = box.right + node.getStyle('space-left');
var y = box.cy;
icon.path.fill(node.getStyle('color'));
icon.setTranslate(x, y);
return new kity.Box(x, Math.round(y - icon.height / 2), icon.width, icon.height);
}
});
return {
renderers: {
right: NoteIconRenderer
},
commands: {
'note': NoteCommand
}
};
});
\ No newline at end of file
KityMinder.registerTheme('classic', { ['classic', 'classic-compact'].forEach(function(name) {
'background': '#3A4144 url(ui/theme/default/images/grid.png) repeat', var compact = name == 'classic-compact';
'root-color': '#430', KityMinder.registerTheme(name, {
'root-background': '#e9df98', 'background': '#3A4144 url(ui/theme/default/images/grid.png) repeat',
'root-stroke': '#e9df98',
'root-font-size': 24, 'root-color': '#430',
'root-padding': [15, 25], 'root-background': '#e9df98',
'root-margin': [30, 100], 'root-stroke': '#e9df98',
'root-radius': 30, 'root-font-size': 24,
'root-space': 10, 'root-padding': compact ? [10, 25] : [15, 25],
'root-shadow': 'rgba(0, 0, 0, .25)', 'root-margin': compact ? [15, 25] : [30, 100],
'root-radius': 30,
'main-color': '#333', 'root-space': 10,
'main-background': '#a4c5c0', 'root-shadow': 'rgba(0, 0, 0, .25)',
'main-stroke': '#a4c5c0',
'main-font-size': 16, 'main-color': '#333',
'main-padding': [6, 20], 'main-background': '#a4c5c0',
'main-margin': 20, 'main-stroke': '#a4c5c0',
'main-radius': 10, 'main-font-size': 16,
'main-space': 5, 'main-padding': compact ? [5, 15] : [6, 20],
'main-shadow': 'rgba(0, 0, 0, .25)', 'main-margin': compact ? [5, 10] : 20,
'main-radius': 10,
'sub-color': 'white', 'main-space': 5,
'sub-background': 'transparent', 'main-shadow': 'rgba(0, 0, 0, .25)',
'sub-stroke': 'none',
'sub-font-size': 12, 'sub-color': 'white',
'sub-padding': [5, 10], 'sub-background': 'transparent',
'sub-margin': [15, 20], 'sub-stroke': 'none',
'sub-tree-margin': 30, 'sub-font-size': 12,
'sub-radius': 5, 'sub-padding': [5, 10],
'sub-space': 5, 'sub-margin': compact ? [5, 10] : [15, 20],
'sub-tree-margin': 30,
'connect-color': 'white', 'sub-radius': 5,
'connect-width': 2, 'sub-space': 5,
'main-connect-width': 3,
'connect-radius': 5, 'connect-color': 'white',
'connect-width': 2,
'selected-background': 'rgb(254, 219, 0)', 'main-connect-width': 3,
'selected-stroke': 'rgb(254, 219, 0)', 'connect-radius': 5,
'selected-color': 'black',
'selected-background': 'rgb(254, 219, 0)',
'marquee-background': 'rgba(255,255,255,.3)', 'selected-stroke': 'rgb(254, 219, 0)',
'marquee-stroke': 'white', 'selected-color': 'black',
'drop-hint-color': 'yellow', 'marquee-background': 'rgba(255,255,255,.3)',
'sub-drop-hint-width': 2, 'marquee-stroke': 'white',
'main-drop-hint-width': 4,
'root-drop-hint-width': 4, 'drop-hint-color': 'yellow',
'sub-drop-hint-width': 2,
'order-hint-area-color': 'rgba(0, 255, 0, .5)', 'main-drop-hint-width': 4,
'order-hint-path-color': '#0f0', 'root-drop-hint-width': 4,
'order-hint-path-width': 1,
'order-hint-area-color': 'rgba(0, 255, 0, .5)',
'text-selection-color': 'rgb(27,171,255)', 'order-hint-path-color': '#0f0',
'line-height':1.5 'order-hint-path-width': 1,
'text-selection-color': 'rgb(27,171,255)',
'line-height':1.5
});
}); });
\ No newline at end of file
KityMinder.registerTheme('snow', {
'background': '#3A4144 url(ui/theme/default/images/grid.png) repeat',
['snow', 'snow-compact'].forEach(function(name) {
'root-color': '#430', var compact = name == 'snow-compact';
'root-background': '#e9df98',
'root-stroke': '#e9df98', KityMinder.registerTheme(name, {
'root-font-size': 24, 'background': '#3A4144 url(ui/theme/default/images/grid.png) repeat',
'root-padding': [15, 25],
'root-margin': 30, 'root-color': '#430',
'root-radius': 5, 'root-background': '#e9df98',
'root-space': 10, 'root-stroke': '#e9df98',
'root-shadow': 'rgba(0, 0, 0, .25)', 'root-font-size': 24,
'root-padding': compact ? [5, 10] : [15, 25],
'main-color': '#333', 'root-margin': compact ? 15 : 30,
'main-background': '#a4c5c0', 'root-radius': 5,
'main-stroke': '#a4c5c0', 'root-space': 10,
'main-font-size': 16, 'root-shadow': 'rgba(0, 0, 0, .25)',
'main-padding': [6, 20],
'main-margin': [20, 40], 'main-color': '#333',
'main-radius': 5, 'main-background': '#a4c5c0',
'main-space': 5, 'main-stroke': '#a4c5c0',
'main-shadow': 'rgba(0, 0, 0, .25)', 'main-font-size': 16,
'main-padding': compact ? [4, 10] : [6, 20],
'sub-color': 'black', 'main-margin': compact ? [5, 10] : [20, 40],
'sub-background': 'white', 'main-radius': 5,
'sub-stroke': 'white', 'main-space': 5,
'sub-font-size': 12, 'main-shadow': 'rgba(0, 0, 0, .25)',
'sub-padding': [5, 10],
'sub-margin': [10, 20], 'sub-color': 'black',
'sub-radius': 5, 'sub-background': 'white',
'sub-space': 5, 'sub-stroke': 'white',
'sub-font-size': 12,
'connect-color': 'white', 'sub-padding': [5, 10],
'connect-width': 2, 'sub-margin': compact ? [5, 10] : [10, 20],
'main-connect-width': 3, 'sub-radius': 5,
'connect-radius': 5, 'sub-space': 5,
'selected-background': 'rgb(254, 219, 0)', 'connect-color': 'white',
'selected-stroke': 'rgb(254, 219, 0)', 'connect-width': 2,
'main-connect-width': 3,
'marquee-background': 'rgba(255,255,255,.3)', 'connect-radius': 5,
'marquee-stroke': 'white',
'selected-background': 'rgb(254, 219, 0)',
'drop-hint-color': 'yellow', 'selected-stroke': 'rgb(254, 219, 0)',
'drop-hint-width': 4,
'marquee-background': 'rgba(255,255,255,.3)',
'order-hint-area-color': 'rgba(0, 255, 0, .5)', 'marquee-stroke': 'white',
'order-hint-path-color': '#0f0',
'order-hint-path-width': 1, 'drop-hint-color': 'yellow',
'drop-hint-width': 4,
'text-selection-color': 'rgb(27,171,255)',
'line-height':1.5 'order-hint-area-color': 'rgba(0, 255, 0, .5)',
'order-hint-path-color': '#0f0',
'order-hint-path-width': 1,
'text-selection-color': 'rgb(27,171,255)',
'line-height':1.5
});
}); });
\ No newline at end of file
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