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
......@@ -66,7 +66,7 @@ module.exports = function(grunt) {
// Metadata.
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,
......@@ -131,12 +131,21 @@ module.exports = function(grunt) {
}]
},
noCache: {
pageNoCache: {
src: distPages,
overwrite: true,
replacements: [{
from: /src=\"(.+?)\.js\"/ig,
to: 'src="$1.js?_=' + (+new Date()) + '"'
from: /(src|href)=\"(.+?)\.(js|css)\"/ig,
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 @@
(function() {
/* 可能的文件路径,已按照依赖关系排序 */
var pathInfo = [
/* 核心代码 */
'src/core/kityminder.js',
'src/core/utils.js',
......
Subproject commit 36b51b090c28d9d362f00e1023fcb3dc6317585d
Subproject commit 1275889df5d47e4e6c23112d65859ca39c45ca98
......@@ -2,7 +2,7 @@
"name": "kityminder",
"title": "kityminder",
"description": "Kity Minder",
"version": "1.3.2",
"version": "1.3.5",
"homepage": "https://github.com/fex-team/kityminder",
"author": {
"name": "f-cube @ FEX",
......
......@@ -36,7 +36,7 @@ var KityMinder = kity.createClass('KityMinder', {
}
});
KityMinder.version = '1.3.2';
KityMinder.version = '1.0.0';
KityMinder.registerInit = function(fn) {
_initFnQueue.push(fn);
......@@ -56,4 +56,3 @@ if (typeof(module) != 'undefined') {
window.KityMinder = KityMinder;
}
/* jshint +W079 */
\ No newline at end of file
......@@ -121,6 +121,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
getText: function(str2arr) {
var text = this.getData('text') || '';
text = text.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;');
if(str2arr){
text = text.split('\n');
}
......
......@@ -6,123 +6,23 @@ KityMinder.registerModule('Expand', function() {
STATE_EXPAND = 'expand',
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 上
kity.extendClass(MinderNode, {
/**
* 使用指定的策略展开节点
* 展开节点
* @param {Policy} policy 展开的策略,默认为 KEEP_STATE
*/
expand: function(policy) {
setExpandState(this, STATE_EXPAND, policy);
expand: function() {
this.setData(EXPAND_STATE_DATA, STATE_EXPAND);
return this;
},
/**
* 使用指定的策略收起节点
* @param {Policy} policy 展开的策略,默认为 KEEP_STATE
* 收起节点
*/
collapse: function(policy) {
setExpandState(this, STATE_COLLAPSE, policy);
collapse: function() {
this.setData(EXPAND_STATE_DATA, STATE_COLLAPSE);
return this;
},
......@@ -141,30 +41,41 @@ KityMinder.registerModule('Expand', function() {
return !this.isExpanded();
}
});
var ExpandNodeCommand = kity.createClass('ExpandNodeCommand', {
var ExpandCommand = kity.createClass('ExpandCommand', {
base: Command,
execute: function(km) {
var nodes = km.getRoot().getChildren();
nodes.forEach(function(node) {
node.expand(EXPAND_POLICY.DEEP_TO_LEAF);
});
execute: function(km, justParents) {
var node = km.getSelectedNode();
if (!node) return;
if (justParents) {
node = node.parent;
}
while(node.parent) {
node.expand();
node = node.parent;
}
node.renderTree();
km.layout(100);
},
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,
execute: function(km) {
var nodes = km.getRoot().getChildren();
nodes.forEach(function(node) {
node.collapse();
execute: function(km, level) {
km.getRoot().traverse(function(node) {
if (node.getLevel() < level) node.expand();
if (node.getLevel() == level) node.collapse();
});
km.refresh(100);
},
queryState: function(km) {
return !km.getSelectedNode() ? 0 : -1;
}
enableReadOnly: true
});
var Expander = kity.createClass('Expander', {
base: kity.Group,
......@@ -186,6 +97,8 @@ KityMinder.registerModule('Expand', function() {
} else {
node.expand();
}
node.renderTree().getMinder().layout(100);
node.getMinder().fire('contentchange');
e.stopPropagation();
e.preventDefault();
});
......@@ -240,8 +153,8 @@ KityMinder.registerModule('Expand', function() {
});
return {
commands: {
'expandtoleaf': ExpandNodeCommand,
'collapsetolevel1': CollapseNodeCommand
'expand': ExpandCommand,
'expandtolevel': ExpandToLevelCommand
},
events: {
'layoutapply': function(e) {
......@@ -267,25 +180,60 @@ KityMinder.registerModule('Expand', function() {
this.getSelectedNodes().forEach(function(node) {
if (expanded) node.collapse();
else node.expand();
node.renderTree();
});
this.layout(100);
this.fire('contentchange');
e.preventDefault();
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: {
outside: ExpanderRenderer
},
contextmenu: [{
command: 'expandtoleaf'
command: 'expandtoleaf',
query: function() {
return !minder.getSelectedNode();
},
fn: function(minder) {
minder.execCommand('expandtolevel', 9999);
}
}, {
command: 'collapsetolevel1'
command: 'expandtolevel1',
query: function() {
return !minder.getSelectedNode();
},
fn: function(minder) {
minder.execCommand('expandtolevel', 1);
}
}, {
divider: true
}],
commandShortcutKeys: {
'expandtoleaf': 'Alt+`',
'collapsetolevel1': 'Alt+1'
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
}]
};
});
\ No newline at end of file
......@@ -13,10 +13,8 @@ KityMinder.registerModule("fontmodule", function() {
var fontSize = getNodeDataOrStyle(node, 'font-size');
var fontHash = [fontFamily, fontSize].join('/');
if (foreColor.toString() != node.getTmpData('fore-color')) {
textGroup.fill(foreColor);
node.setTmpData('fore-color', foreColor.toString());
}
textGroup.eachItem(function(index,item){
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) {
var compact = name == 'classic-compact';
KityMinder.registerTheme(name, {
'background': '#3A4144 url(ui/theme/default/images/grid.png) repeat',
'root-color': '#430',
'root-background': '#e9df98',
'root-stroke': '#e9df98',
'root-font-size': 24,
'root-padding': [15, 25],
'root-margin': [30, 100],
'root-padding': compact ? [10, 25] : [15, 25],
'root-margin': compact ? [15, 25] : [30, 100],
'root-radius': 30,
'root-space': 10,
'root-shadow': 'rgba(0, 0, 0, .25)',
......@@ -15,8 +18,8 @@ KityMinder.registerTheme('classic', {
'main-background': '#a4c5c0',
'main-stroke': '#a4c5c0',
'main-font-size': 16,
'main-padding': [6, 20],
'main-margin': 20,
'main-padding': compact ? [5, 15] : [6, 20],
'main-margin': compact ? [5, 10] : 20,
'main-radius': 10,
'main-space': 5,
'main-shadow': 'rgba(0, 0, 0, .25)',
......@@ -26,7 +29,7 @@ KityMinder.registerTheme('classic', {
'sub-stroke': 'none',
'sub-font-size': 12,
'sub-padding': [5, 10],
'sub-margin': [15, 20],
'sub-margin': compact ? [5, 10] : [15, 20],
'sub-tree-margin': 30,
'sub-radius': 5,
'sub-space': 5,
......@@ -54,4 +57,5 @@ KityMinder.registerTheme('classic', {
'text-selection-color': 'rgb(27,171,255)',
'line-height':1.5
});
});
\ No newline at end of file
KityMinder.registerTheme('snow', {
['snow', 'snow-compact'].forEach(function(name) {
var compact = name == 'snow-compact';
KityMinder.registerTheme(name, {
'background': '#3A4144 url(ui/theme/default/images/grid.png) repeat',
'root-color': '#430',
'root-background': '#e9df98',
'root-stroke': '#e9df98',
'root-font-size': 24,
'root-padding': [15, 25],
'root-margin': 30,
'root-padding': compact ? [5, 10] : [15, 25],
'root-margin': compact ? 15 : 30,
'root-radius': 5,
'root-space': 10,
'root-shadow': 'rgba(0, 0, 0, .25)',
......@@ -15,8 +20,8 @@ KityMinder.registerTheme('snow', {
'main-background': '#a4c5c0',
'main-stroke': '#a4c5c0',
'main-font-size': 16,
'main-padding': [6, 20],
'main-margin': [20, 40],
'main-padding': compact ? [4, 10] : [6, 20],
'main-margin': compact ? [5, 10] : [20, 40],
'main-radius': 5,
'main-space': 5,
'main-shadow': 'rgba(0, 0, 0, .25)',
......@@ -26,7 +31,7 @@ KityMinder.registerTheme('snow', {
'sub-stroke': 'white',
'sub-font-size': 12,
'sub-padding': [5, 10],
'sub-margin': [10, 20],
'sub-margin': compact ? [5, 10] : [10, 20],
'sub-radius': 5,
'sub-space': 5,
......@@ -50,4 +55,5 @@ KityMinder.registerTheme('snow', {
'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