Commit 651acd74 authored by techird's avatar techird

使用 Module 规范组织代码

parent b27e5394
{
"directory": "lib"
}
\ No newline at end of file
...@@ -5,7 +5,3 @@ ...@@ -5,7 +5,3 @@
dist/ dist/
node_modules/ node_modules/
_drafts/ _drafts/
native-support/archive/src/tmp/
native-support/archive/upload/
ui/theme/default/css/*.css
ui/theme/default/css/*.css.map
\ No newline at end of file
[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
[submodule "lib/promise"]
path = lib/promise
url = https://github.com/jakearchibald/es6-promise
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
"disallowSpacesInsideParentheses": true, "disallowSpacesInsideParentheses": true,
// 行尾「MUST NOT」使用空格 // 行尾「MUST NOT」使用空格
"disallowTrailingWhitespace": false, "disallowTrailingWhitespace": true,
// 每行「MUST NOT」超过 120 个字符 // 每行「MUST NOT」超过 120 个字符
"maximumLineLength": 120, "maximumLineLength": 120,
......
...@@ -10,23 +10,7 @@ ...@@ -10,23 +10,7 @@
"browser": true, "browser": true,
"boss": true, "boss": true,
"predef" : [ "predef" : [
"module", "define",
"require", "Promise"
"console",
"kity",
"KityMinder",
"KM",
"Minder",
"MinderNode",
"MinderEvent",
"Command",
"KITYMINDER_CONFIG",
"keymap",
"Utils",
"utils",
"$",
"KM",
"keymap",
"browser"
] ]
} }
\ No newline at end of file
/*----------------------------------------------------- /* global require, module */
* livereload Default Setting
*-----------------------------------------------------*/
'use strict';
var path = require('path'); var path = require('path');
/*-----------------------------------------------------
* Module Setting
*-----------------------------------------------------*/
module.exports = function(grunt) { module.exports = function(grunt) {
'use strict';
// These plugins provide necessary tasks. // These plugins provide necessary tasks.
/* [Build plugin & task ] ------------------------------------*/ /* [Build plugin & task ] ------------------------------------*/
grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-module-dependence');
grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-postcss');
grunt.loadNpmTasks('grunt-autoprefixer');
var banner = '/*!\n' + var banner = '/*!\n' +
' * ====================================================\n' + ' * ====================================================\n' +
...@@ -32,153 +22,22 @@ module.exports = function(grunt) { ...@@ -32,153 +22,22 @@ module.exports = function(grunt) {
' * ====================================================\n' + ' * ====================================================\n' +
' */\n\n'; ' */\n\n';
var packs = ['index', 'edit', 'share', 'm-share'];
var sources = require('./import.js');
var srcPath = 'src/';
var distPath = 'dist/';
var distPages = ['index', 'edit', 'viewshare', 'm-share'].map(function(name) {
return distPath + name + '.html';
});
var concatConfigs = {};
packs.forEach(function(pack) {
concatConfigs[pack] = {
options: {
banner: banner + '(function(window) {\n\n',
footer: '\n\n})(window)',
sourceMap: true,
sourceMapStyle: 'link'
},
src: sources.filter(function(source) {
return source.pack == '*' || source.pack.split('|').indexOf(pack) !== -1;
}).map(function(source) {
return source.path;
}),
dest: distPath + 'kityminder.' + pack + '.js'
};
});
// Project configuration. // Project configuration.
grunt.initConfig({ grunt.initConfig({
// Metadata. // Metadata.
pkg: grunt.file.readJSON('package.json'), pkg: grunt.file.readJSON('package.json'),
clean: ['dist', 'native-support/upload/', 'native-support/src/tmp/'], dependence: {
concat: concatConfigs,
uglify: {
minimize: {
options: { options: {
banner: banner, base: 'src',
sourceMap: true entrance: 'kityminder'
}, },
files: (function() { merge: {
var files = {};
packs.forEach(function(pack) {
files[distPath + 'kityminder.' + pack + '.min.js'] = distPath + 'kityminder.' + pack + '.js';
});
return files;
})()
}
},
copy: {
dir: {
files: [{ files: [{
src: [ src: 'src/**/*.js',
'ui/theme/**/css/*.css', dest: 'release/kityminder.all.js'
'ui/theme/**/css/*.css.map',
'ui/theme/**/images/*',
'lang/**/*',
'static/**/*',
'native-support/**/*',
'lib/ZeroClipboard.swf',
'lib/inflate.js',
'lib/source-map.min.js',
'index.html',
'edit.html',
'viewshare.html',
'm-share.html',
'download.php'
],
dest: distPath
}] }]
},
km_config: {
expand: true,
src: 'kityminder.config.js',
dest: distPath
},
mise: {
files: [{
src: ['LICENSE', 'favicon.ico', 'README.md', 'CHANGELOG.md'],
dest: distPath
}]
}
},
replace: {
online: {
src: distPages,
overwrite: true,
replacements: [{
from: /import\.js\?pack=([\w-]+)\"/,
to: 'kityminder.$1.min.js"'
}]
},
pageNoCache: {
src: distPages,
overwrite: true,
replacements: [{
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())
}]
}
},
watch: {
less: {
files: ['ui/theme/**/*.less'],
tasks: ['less:compile', 'autoprefixer']
}
},
less: {
compile: {
files: {
'ui/theme/default/css/default.all.temp.css': [
'ui/theme/default/css/import.less'
]
},
options: {
sourceMap: true,
sourceMapFilename: 'ui/theme/default/css/default.all.temp.css.map',
sourceMapBasepath: 'ui/theme/default/css/'
}
}
},
autoprefixer: {
all: {
options: {
map: true
},
src: 'ui/theme/default/css/default.all.temp.css',
dest: 'ui/theme/default/css/default.all.css'
} }
} }
...@@ -186,7 +45,6 @@ module.exports = function(grunt) { ...@@ -186,7 +45,6 @@ module.exports = function(grunt) {
// Build task(s). // Build task(s).
grunt.registerTask('default', ['clean', 'concat', 'uglify', 'less', 'autoprefixer', 'copy', 'replace']); grunt.registerTask('default', ['dependence']);
grunt.registerTask('dev', ['less', 'autoprefixer', 'watch']);
}; };
\ No newline at end of file
{
"name": "kityminder-core",
"title": "Kity Minder Core",
"description": "Powerful online mind graphic visualization and editor (command based)",
"version": "1.3.6",
"main": "src/kityminder.js",
"keywords": ["kityminder", "kity", "svg"],
"homepage": "https://github.com/fex-team/kityminder-core",
"devDependencies": {
"seajs": "~2.3.0"
},
"licenses": [{
"type": "BSD",
"url": "https://github.com/fex-team/kityminder-core/blob/dev/LICENSE"
}],
"bugs": {
"url": "https://github.com/fex-team/kityminder-core/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/fex-team/kityminder-core.git"
},
"author": {
"name": "Baidu FEX",
"url": "http://fex.baidu.com"
}
}
\ No newline at end of file
...@@ -4,13 +4,6 @@ ...@@ -4,13 +4,6 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title>KityMinder Example</title> <title>KityMinder Example</title>
<script type="text/javascript" src="lib/kity/dist/kity.js"></script>
<!--dev mode 引入-->
<script type="text/javascript" src="import.js"></script>
<!--dist mode 引入 -->
<!--<script type="text/javascript" src="../dist/kityminder.min.js">-->
<link href="favicon.ico" type="image/x-icon" rel="shortcut icon"> <link href="favicon.ico" type="image/x-icon" rel="shortcut icon">
<style type="text/css"> <style type="text/css">
body { body {
...@@ -37,9 +30,33 @@ ...@@ -37,9 +30,33 @@
<body> <body>
<div id="minder-view"></div> <div id="minder-view"></div>
</body> </body>
<!-- *************************** Module 形式加载引入 **************************** -->
<script type="text/javascript" src="lib/seajs/dist/sea-debug.js"></script>
<script type="text/javascript"> <script type="text/javascript">
window.km = new KityMinder({ /* global seajs */
seajs.config({
base: './src'
});
define('start', function(require) {
var Minder = require('kityminder').Minder;
// 创建 km 实例
var km = window.km = new Minder({
renderTo: 'minder-view' renderTo: 'minder-view'
}); });
});
seajs.use('start');
</script> </script>
<!-- *********************** 打包文件引入(需要先 grunt 发布) ************************* -->
<!--
<script type="text/javascript" src="../release/kityminder.all.min.js">
<script type="text/javascript">
// 创建 km 实例
window.km = new kityminder.Minder('minder-view');
</script>
-->
</html> </html>
\ No newline at end of file
This diff is collapsed.
{
"name": "seajs",
"version": "2.3.0",
"main": "./dist/sea.js",
"ignore": [
"**/.*",
"docs",
"lib",
"src",
"tests",
"CNAME",
"component.json",
"CONTRIBUTING.md",
"index.html",
"Makefile",
"package.json",
"README.md"
],
"homepage": "https://github.com/seajs/seajs",
"_release": "2.3.0",
"_resolution": {
"type": "version",
"tag": "2.3.0",
"commit": "9c6299636991fbca73a9aa7b2eb152c6e8614854"
},
"_source": "git://github.com/seajs/seajs.git",
"_target": "~2.3.0",
"_originalSource": "seajs"
}
\ No newline at end of file
MIT LICENSE
Copyright (c) 2009 - 2099 Frank Wang, http://seajs.org/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{
"name": "seajs",
"version": "2.3.0",
"main": "./dist/sea.js",
"ignore": [
"**/.*",
"docs",
"lib",
"src",
"tests",
"CNAME",
"component.json",
"CONTRIBUTING.md",
"index.html",
"Makefile",
"package.json",
"README.md"
]
}
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
"title": "kityminder", "title": "kityminder",
"description": "Kity Minder", "description": "Kity Minder",
"version": "1.3.5", "version": "1.3.5",
"homepage": "https://github.com/fex-team/kityminder", "homepage": "https://github.com/fex-team/kityminder-core",
"author": { "author": {
"name": "f-cube @ FEX", "name": "f-cube @ FEX",
"url": "http://fex.baidu.com" "url": "http://fex.baidu.com"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/fex-team/kityminder.git" "url": "https://github.com/fex-team/kityminder-core.git"
}, },
"keywords": [ "keywords": [
"kityminder", "kityminder",
...@@ -21,23 +21,20 @@ ...@@ -21,23 +21,20 @@
"javascript" "javascript"
], ],
"bugs": { "bugs": {
"url": "https://github.com/fex-team/kityminder/issues" "url": "https://github.com/fex-team/kityminder-core/issues"
}, },
"licenses": [ { "licenses": [ {
"type": "MIT", "type": "MIT",
"url": "https://github.com/fex-team/kityminder/blob/dev/LICENSE" "url": "https://github.com/fex-team/kityminder-core/blob/dev/LICENSE"
} ], } ],
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"grunt": "~0.4.1", "grunt": "~0.4.1",
"grunt-module-dependence": "~0.1.4",
"grunt-contrib-concat": "~0.5.0", "grunt-contrib-concat": "~0.5.0",
"grunt-contrib-uglify": "~0.4.0", "grunt-contrib-uglify": "~0.4.0",
"grunt-contrib-copy": "~0.5.0", "grunt-contrib-copy": "~0.5.0",
"grunt-text-replace": "~0.3.9", "grunt-contrib-clean": "~0.5.0"
"grunt-contrib-watch": "~0.6.1",
"grunt-contrib-less": "~0.11.3",
"grunt-contrib-clean": "~0.6.0",
"grunt-autoprefixer": "~1.0.1"
} }
} }
\ No newline at end of file
...@@ -7,16 +7,20 @@ ...@@ -7,16 +7,20 @@
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
var connectMarker = new kity.Marker().pipe(function() { define(function(require, exports, module) {
var kity = require('core/kity');
var connect = require('core/connect');
var connectMarker = new kity.Marker().pipe(function() {
var r = 7; var r = 7;
var dot = new kity.Circle(r - 1); var dot = new kity.Circle(r - 1);
this.addShape(dot); this.addShape(dot);
this.setRef(r - 1, 0).setViewBox(-r, -r, r + r, r + r).setWidth(r).setHeight(r); this.setRef(r - 1, 0).setViewBox(-r, -r, r + r, r + r).setWidth(r).setHeight(r);
this.dot = dot; this.dot = dot;
this.node.setAttribute('markerUnits', 'userSpaceOnUse'); this.node.setAttribute('markerUnits', 'userSpaceOnUse');
}); });
KityMinder.registerConnectProvider('arc', function(node, parent, connection, width, color) { connect.register('arc', function(node, parent, connection, width, color) {
var box = node.getLayoutBox(), var box = node.getLayoutBox(),
pBox = parent.getLayoutBox(); pBox = parent.getLayoutBox();
...@@ -41,4 +45,5 @@ KityMinder.registerConnectProvider('arc', function(node, parent, connection, wid ...@@ -41,4 +45,5 @@ KityMinder.registerConnectProvider('arc', function(node, parent, connection, wid
connectMarker.dot.fill(color); connectMarker.dot.fill(color);
connection.setPathData(pathData); connection.setPathData(pathData);
});
}); });
\ No newline at end of file
...@@ -7,7 +7,11 @@ ...@@ -7,7 +7,11 @@
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
KityMinder.registerConnectProvider('bezier', function(node, parent, connection) { define(function(require, exports, module) {
var kity = require('core/kity');
var connect = require('core/connect');
connect.register('bezier', function(node, parent, connection) {
// 连线起点和终点 // 连线起点和终点
var po = parent.getLayoutVertexOut(), var po = parent.getLayoutVertexOut(),
...@@ -34,4 +38,5 @@ KityMinder.registerConnectProvider('bezier', function(node, parent, connection) ...@@ -34,4 +38,5 @@ KityMinder.registerConnectProvider('bezier', function(node, parent, connection)
connection.setMarker(null); connection.setMarker(null);
connection.setPathData(pathData); connection.setPathData(pathData);
});
}); });
\ No newline at end of file
...@@ -7,7 +7,11 @@ ...@@ -7,7 +7,11 @@
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
KityMinder.registerConnectProvider('fish-bone-master', function(node, parent, connection) { define(function(require, exports, module) {
var kity = require('core/kity');
var connect = require('core/connect');
connect.register('fish-bone-master', function(node, parent, connection) {
var pout = parent.getLayoutVertexOut(), var pout = parent.getLayoutVertexOut(),
pin = node.getLayoutVertexIn(); pin = node.getLayoutVertexIn();
...@@ -25,4 +29,5 @@ KityMinder.registerConnectProvider('fish-bone-master', function(node, parent, co ...@@ -25,4 +29,5 @@ KityMinder.registerConnectProvider('fish-bone-master', function(node, parent, co
connection.setMarker(null); connection.setMarker(null);
connection.setPathData(pathData); connection.setPathData(pathData);
});
}); });
\ No newline at end of file
...@@ -7,7 +7,11 @@ ...@@ -7,7 +7,11 @@
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
KityMinder.registerConnectProvider('l', function(node, parent, connection) { define(function(require, exports, module) {
var kity = require('core/kity');
var connect = require('core/connect');
connect.register('l', function(node, parent, connection) {
var po = parent.getLayoutVertexOut(); var po = parent.getLayoutVertexOut();
var pi = node.getLayoutVertexIn(); var pi = node.getLayoutVertexIn();
...@@ -26,4 +30,5 @@ KityMinder.registerConnectProvider('l', function(node, parent, connection) { ...@@ -26,4 +30,5 @@ KityMinder.registerConnectProvider('l', function(node, parent, connection) {
pathData.push('L', pi); pathData.push('L', pi);
connection.setPathData(pathData); connection.setPathData(pathData);
});
}); });
\ No newline at end of file
...@@ -7,7 +7,11 @@ ...@@ -7,7 +7,11 @@
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
KityMinder.registerConnectProvider('poly', function(node, parent, connection, width) { define(function(require, exports, module) {
var kity = require('core/kity');
var connect = require('core/connect');
connect.register('poly', function(node, parent, connection, width) {
// 连线起点和终点 // 连线起点和终点
var po = parent.getLayoutVertexOut(), var po = parent.getLayoutVertexOut(),
...@@ -55,4 +59,5 @@ KityMinder.registerConnectProvider('poly', function(node, parent, connection, wi ...@@ -55,4 +59,5 @@ KityMinder.registerConnectProvider('poly', function(node, parent, connection, wi
connection.setMarker(null); connection.setMarker(null);
connection.setPathData(pathData); connection.setPathData(pathData);
});
}); });
\ No newline at end of file
...@@ -7,7 +7,11 @@ ...@@ -7,7 +7,11 @@
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
KityMinder.registerConnectProvider('under', function(node, parent, connection, width, color) { define(function(require, exports, module) {
var kity = require('core/kity');
var connect = require('core/connect');
connect.register('under', function(node, parent, connection, width, color) {
var box = node.getLayoutBox(), var box = node.getLayoutBox(),
pBox = parent.getLayoutBox(); pBox = parent.getLayoutBox();
...@@ -42,4 +46,5 @@ KityMinder.registerConnectProvider('under', function(node, parent, connection, w ...@@ -42,4 +46,5 @@ KityMinder.registerConnectProvider('under', function(node, parent, connection, w
connection.setMarker(null); connection.setMarker(null);
connection.setPathData(pathData); connection.setPathData(pathData);
});
}); });
\ No newline at end of file
KityMinder.COMMAND_STATE_NORMAL = 0; define(function(require, exports, module) {
KityMinder.COMMAND_STATE_DISABLED = -1; var kity = require('./kity');
KityMinder.COMMAND_STATE_ACTIVED = 1; var utils = require('./utils');
var Minder = require('./minder');
var Command = kity.createClass( "Command", { var MinderNode = require('./node');
constructor: function () { var MinderEvent = require('./event');
var COMMAND_STATE_NORMAL = 0;
var COMMAND_STATE_DISABLED = -1;
var COMMAND_STATE_ACTIVED = 1;
/**
* @class Command
*
* 表示一个命令,包含命令的查询及执行
*/
var Command = kity.createClass('Command', {
constructor: function() {
this._isContentChange = true; this._isContentChange = true;
this._isSelectionChange = false; this._isSelectionChange = false;
}, },
execute: function ( minder, args ) { execute: function(minder, args) {
throw new Error('Not Implement: Command.execute()');
}, },
setContentChanged: function ( val ) { setContentChanged: function(val) {
this._isContentChange = !! val; this._isContentChange = !!val;
}, },
isContentChanged: function () { isContentChanged: function() {
return this._isContentChange; return this._isContentChange;
}, },
setSelectionChanged: function ( val ) { setSelectionChanged: function(val) {
this._isSelectionChange = !! val; this._isSelectionChange = !!val;
}, },
isSelectionChanged: function () { isSelectionChanged: function() {
return this._isContentChange; return this._isContentChange;
}, },
queryState: function ( km ) { queryState: function(km) {
return KityMinder.COMMAND_STATE_NORMAL; return COMMAND_STATE_NORMAL;
}, },
queryValue: function ( km ) { queryValue: function(km) {
return 0; return 0;
}, },
isNeedUndo: function () {
isNeedUndo: function() {
return true; return true;
} }
} ); });
kity.extendClass(KityMinder, { Command.STATE_NORMAL = COMMAND_STATE_NORMAL;
_getCommand: function (name) { Command.STATE_ACTIVE = COMMAND_STATE_ACTIVED;
Command.STATE_DISABLED = COMMAND_STATE_DISABLED;
kity.extendClass(Minder, {
_getCommand: function(name) {
return this._commands[name.toLowerCase()]; return this._commands[name.toLowerCase()];
}, },
_queryCommand: function (name, type, args) { _queryCommand: function(name, type, args) {
var cmd = this._getCommand(name); var cmd = this._getCommand(name);
if (cmd) { if (cmd) {
var queryCmd = cmd['query' + type]; var queryCmd = cmd['query' + type];
...@@ -55,18 +72,18 @@ kity.extendClass(KityMinder, { ...@@ -55,18 +72,18 @@ kity.extendClass(KityMinder, {
return 0; return 0;
}, },
queryCommandState: function (name) { queryCommandState: function(name) {
return this._queryCommand(name, "State", Utils.argsToArray(1)); return this._queryCommand(name, 'State', [].slice.call(arguments, 1));
}, },
queryCommandValue: function (name) { queryCommandValue: function(name) {
return this._queryCommand(name, "Value", Utils.argsToArray(1)); return this._queryCommand(name, 'Value', [].slice.call(arguments, 1));
}, },
execCommand: function (name) { execCommand: function(name) {
name = name.toLowerCase(); name = name.toLowerCase();
var cmdArgs = Utils.argsToArray(arguments, 1), var cmdArgs = [].slice.call(arguments, 1),
cmd, stoped, result, eventParams; cmd, stoped, result, eventParams;
var me = this; var me = this;
cmd = this._getCommand(name); cmd = this._getCommand(name);
...@@ -88,7 +105,7 @@ kity.extendClass(KityMinder, { ...@@ -88,7 +105,7 @@ kity.extendClass(KityMinder, {
//保存场景 //保存场景
this._fire(new MinderEvent('saveScene')); this._fire(new MinderEvent('saveScene'));
this._fire(new MinderEvent("preExecCommand", eventParams, false)); this._fire(new MinderEvent('preExecCommand', eventParams, false));
result = cmd.execute.apply(cmd, [me].concat(cmdArgs)); result = cmd.execute.apply(cmd, [me].concat(cmdArgs));
...@@ -114,4 +131,7 @@ kity.extendClass(KityMinder, { ...@@ -114,4 +131,7 @@ kity.extendClass(KityMinder, {
return result === undefined ? null : result; return result === undefined ? null : result;
} }
});
module.exports = Command;
}); });
\ No newline at end of file
Utils.extend(KityMinder, { define(function(require, exports, module) {
var utils = require('./utils');
compatibility: function(json) { function compatibility(json) {
var version = json.version || '1.1.3'; var version = json.version || '1.1.3';
switch (version) {
case '1.1.3':
c_113_120(json);
/* falls through */
case '1.2.0':
case '1.2.1':
c_120_130(json);
/* falls through */
}
return json;
}
function traverse(node, fn) { function traverse(node, fn) {
fn(node); fn(node);
if (node.children) node.children.forEach(function(child) { if (node.children) node.children.forEach(function(child) {
...@@ -58,14 +71,5 @@ Utils.extend(KityMinder, { ...@@ -58,14 +71,5 @@ Utils.extend(KityMinder, {
}); });
} }
switch (version) { module.exports = compatibility;
case '1.1.3':
c_113_120(json);
case '1.2.0':
case '1.2.1':
c_120_130(json);
}
return json;
}
}); });
\ No newline at end of file
/* global Renderer: true */ define(function(require, exports, module) {
var kity = require('./kity');
utils.extend(KityMinder, { var utils = require('./utils');
_connectProviders: {}, var Module = require('./module');
var Minder = require('./minder');
var MinderNode = require('./node');
// 连线提供方
var _connectProviders = {};
function register(name, provider) {
_connectProviders[name] = provider;
}
_defaultConnectProvider: function(node, parent, connection) { register('default', function(node, parent, connection) {
connection.setPathData([ connection.setPathData([
'M', parent.getLayoutVertexOut(), 'M', parent.getLayoutVertexOut(),
'L', node.getLayoutVertexIn() 'L', node.getLayoutVertexIn()
]); ]);
}, });
registerConnectProvider: function(name, provider) { kity.extendClass(MinderNode, {
KityMinder._connectProviders[name] = provider; getConnect: function() {
return this.data.connect || 'default';
}, },
getConnectProvider: function(name) {
return KityMinder._connectProviders[name] || KityMinder._defaultConnectProvider;
}
});
kity.extendClass(MinderNode, {
getConnectProvider: function() { getConnectProvider: function() {
return KityMinder.getConnectProvider(this.getConnect()); return _connectProviders[this.getConnect()] || _connectProviders['default'];
},
getConnect: function() {
return null;
}, },
getConnection: function() { getConnection: function() {
return this._connection || null; return this._connection || null;
} }
}); });
kity.extendClass(KityMinder, { kity.extendClass(Minder, {
getConnectContainer: function() { getConnectContainer: function() {
return this._connectContainer; return this._connectContainer;
...@@ -86,11 +86,11 @@ kity.extendClass(KityMinder, { ...@@ -86,11 +86,11 @@ kity.extendClass(KityMinder, {
connection.setTranslate(0, 0); connection.setTranslate(0, 0);
} }
} }
}); });
KityMinder.registerModule('Connect', { Module.register('Connect', {
init: function() { init: function() {
this._connectContainer = new kity.Group().setId(KityMinder.uuid('minder_connect_group')); this._connectContainer = new kity.Group().setId(utils.uuid('minder_connect_group'));
this.getRenderContainer().prependShape(this._connectContainer); this.getRenderContainer().prependShape(this._connectContainer);
}, },
events: { events: {
...@@ -104,4 +104,7 @@ KityMinder.registerModule('Connect', { ...@@ -104,4 +104,7 @@ KityMinder.registerModule('Connect', {
this.updateConnect(e.node); this.updateConnect(e.node);
} }
} }
});
exports.register = register;
}); });
\ No newline at end of file
Utils.extend(KityMinder, { define(function(require, exports, module) {
_protocols: {}, var kity = require('./kity');
registerProtocol: function(name, protocolDeal) { var utils = require('./utils');
KityMinder._protocols[name] = protocolDeal; var Minder = require('./minder');
} var MinderNode = require('./node');
}); var MinderEvent = require('./event');
var compatibility = require('./compatibility');
var DEFAULT_TEXT = {
'root': 'maintopic',
'main': 'topic',
'sub': 'topic'
};
KityMinder.registerInit(function() { // 导入导出
this._initProtocols(); kity.extendClass(Minder, {
});
// 导入导出
kity.extendClass(KityMinder, {
_initProtocols: function(options) {
var protocols = this._protocols = {};
var pool = KityMinder._protocols;
for (var name in pool) {
if (pool.hasOwnProperty(name))
protocols[name] = pool[name](this);
protocols[name].name = name;
}
},
getProtocol: function(name) {
return this._protocols[name] || null;
},
getSupportedProtocols: function() {
var protocols = this._protocols;
return Utils.keys(protocols).map(function(name) {
return protocols[name];
});
},
exportJson: function() { exportJson: function() {
/* 导出 node 上整棵树的数据为 JSON */ /* 导出 node 上整棵树的数据为 JSON */
...@@ -58,7 +28,7 @@ kity.extendClass(KityMinder, { ...@@ -58,7 +28,7 @@ kity.extendClass(KityMinder, {
json.template = this.getTemplate(); json.template = this.getTemplate();
json.theme = this.getTheme(); json.theme = this.getTheme();
json.version = KityMinder.version; json.version = Minder.version;
return json; return json;
}, },
...@@ -72,7 +42,7 @@ kity.extendClass(KityMinder, { ...@@ -72,7 +42,7 @@ kity.extendClass(KityMinder, {
node.setData(field, data[field]); node.setData(field, data[field]);
} }
node.setData('text', data.text || km.getLang(DEFAULT_TEXT[node.getType()])); node.setData('text', data.text);
var childrenTreeData = json.children || []; var childrenTreeData = json.children || [];
for (var i = 0; i < childrenTreeData.length; i++) { for (var i = 0; i < childrenTreeData.length; i++) {
...@@ -91,7 +61,7 @@ kity.extendClass(KityMinder, { ...@@ -91,7 +61,7 @@ kity.extendClass(KityMinder, {
this.removeNode(this._root.getChildren()[0]); this.removeNode(this._root.getChildren()[0]);
} }
json = KityMinder.compatibility(json); json = Minder.compatibility(json);
importNode(this._root, json, this); importNode(this._root, json, this);
...@@ -105,72 +75,6 @@ kity.extendClass(KityMinder, { ...@@ -105,72 +75,6 @@ kity.extendClass(KityMinder, {
type: 'contentchange' type: 'contentchange'
}); });
this._interactChange(); this._interactChange();
},
exportData: function(protocolName, options) {
var json, protocol;
json = this.exportJson();
// 指定了协议进行导出,需要检测协议是否支持
if (protocolName) {
protocol = this.getProtocol(protocolName);
if (!protocol || !protocol.encode) {
return Promise.reject(new Error('Not supported protocol:' + protocolName));
}
}
// 导出前抛个事件
this._fire(new MinderEvent('beforeexport', {
json: json,
protocolName: protocolName,
protocol: protocol
}));
if (protocol) {
return Promise.resolve(protocol.encode(json, this, options));
} else {
return Promise.resolve(json);
} }
},
importData: function(local, protocolName) {
var json, protocol;
var minder = this;
// 指定了协议进行导入,需要检测协议是否支持
if (protocolName) {
protocol = this.getProtocol(protocolName);
if (!protocol || !protocol.decode) {
return Promise.reject(new Error('Not supported protocol:' + protocolName));
}
}
var params = {
local: local,
protocolName: protocolName,
protocol: protocol
};
// 导入前抛事件
this._fire(new MinderEvent('beforeimport', params));
return new Promise(function(resolve, reject) {
resolve(protocol ? protocol.decode(local) : local);
}).then(function(json) {
minder.importJson(json, params);
return json;
}); });
}
}); });
\ No newline at end of file
var MinderEvent = kity.createClass('MindEvent', { define(function(require, exports, module) {
var kity = require('./kity');
var utils = require('./utils');
var Minder = require('./minder');
function listen(element, type, handler) {
var types = utils.isArray(type) ? type : utils.trim(type).split(' '),
k = types.length;
types.forEach(function(name) {
element.addEventListener(name, handler, false);
});
}
var MinderEvent = kity.createClass('MindEvent', {
constructor: function(type, params, canstop) { constructor: function(type, params, canstop) {
params = params || {}; params = params || {};
if (params.getType && params.getType() == 'ShapeEvent') { if (params.getType && params.getType() == 'ShapeEvent') {
...@@ -49,9 +62,9 @@ var MinderEvent = kity.createClass('MindEvent', { ...@@ -49,9 +62,9 @@ var MinderEvent = kity.createClass('MindEvent', {
if (!this.originEvent) { if (!this.originEvent) {
return false; return false;
} }
if ("which" in this.originEvent) if ('which' in this.originEvent)
isRightMB = this.originEvent.which == 3; isRightMB = this.originEvent.which == 3;
else if ("button" in this.originEvent) else if ('button' in this.originEvent)
isRightMB = this.originEvent.button == 2; isRightMB = this.originEvent.button == 2;
return isRightMB; return isRightMB;
}, },
...@@ -59,39 +72,44 @@ var MinderEvent = kity.createClass('MindEvent', { ...@@ -59,39 +72,44 @@ var MinderEvent = kity.createClass('MindEvent', {
var evt = this.originEvent; var evt = this.originEvent;
return evt.keyCode || evt.which; return evt.keyCode || evt.which;
} }
}); });
KityMinder.registerInit(function() { Minder.registerInitHook(function() {
this._initEvents(); this._initEvents();
}); });
kity.extendClass(Minder, {
// 事件机制
kity.extendClass(KityMinder, {
_initEvents: function() { _initEvents: function() {
this._eventCallbacks = {}; this._eventCallbacks = {};
}, },
_bindEvents: function() { _bindEvents: function() {
this._bindPaperEvents(); this._bindPaperEvents();
this._bindKeyboardEvents(); this._bindKeyboardEvents();
}, },
_resetEvents: function() { _resetEvents: function() {
this._initEvents(); this._initEvents();
this._bindEvents(); this._bindEvents();
}, },
// TODO: mousemove lazy bind
_bindPaperEvents: function() { _bindPaperEvents: function() {
/* jscs:disable maximumLineLength */
this._paper.on('click dblclick mousedown contextmenu mouseup mousemove mouseover mousewheel DOMMouseScroll touchstart touchmove touchend dragenter dragleave drop', this._firePharse.bind(this)); this._paper.on('click dblclick mousedown contextmenu mouseup mousemove mouseover mousewheel DOMMouseScroll touchstart touchmove touchend dragenter dragleave drop', this._firePharse.bind(this));
if (window) { if (window) {
window.addEventListener('resize', this._firePharse.bind(this)); window.addEventListener('resize', this._firePharse.bind(this));
window.addEventListener('blur', this._firePharse.bind(this)); window.addEventListener('blur', this._firePharse.bind(this));
} }
}, },
_bindKeyboardEvents: function() { _bindKeyboardEvents: function() {
if ((navigator.userAgent.indexOf('iPhone') == -1) && (navigator.userAgent.indexOf('iPod') == -1) && (navigator.userAgent.indexOf('iPad') == -1)) { if ((navigator.userAgent.indexOf('iPhone') == -1) && (navigator.userAgent.indexOf('iPod') == -1) && (navigator.userAgent.indexOf('iPad') == -1)) {
//只能在这里做,要不无法触发 //只能在这里做,要不无法触发
Utils.listen(document.body, 'keydown keyup keypress paste', this._firePharse.bind(this)); listen(document.body, 'keydown keyup keypress paste', this._firePharse.bind(this));
} }
}, },
_firePharse: function(e) { _firePharse: function(e) {
// //只读模式下强了所有的事件操作 // //只读模式下强了所有的事件操作
// if(this.readOnly === true){ // if(this.readOnly === true){
...@@ -117,6 +135,7 @@ kity.extendClass(KityMinder, { ...@@ -117,6 +135,7 @@ kity.extendClass(KityMinder, {
this._fire(executeEvent)) this._fire(executeEvent))
this._fire(new MinderEvent('after' + e.type, e, false)); this._fire(new MinderEvent('after' + e.type, e, false));
}, },
_interactChange: function(e) { _interactChange: function(e) {
var me = this; var me = this;
if (me._interactScheduled) return; if (me._interactScheduled) return;
...@@ -126,31 +145,26 @@ kity.extendClass(KityMinder, { ...@@ -126,31 +145,26 @@ kity.extendClass(KityMinder, {
}, 100); }, 100);
me._interactScheduled = true; me._interactScheduled = true;
}, },
_listen: function(type, callback) { _listen: function(type, callback) {
var callbacks = this._eventCallbacks[type] || (this._eventCallbacks[type] = []); var callbacks = this._eventCallbacks[type] || (this._eventCallbacks[type] = []);
callbacks.push(callback); callbacks.push(callback);
}, },
_fire: function(e) {
_fire: function(e) {
var status = this.getStatus(); var status = this.getStatus();
var callbacks = this._eventCallbacks[e.type.toLowerCase()] || []; var callbacks = this._eventCallbacks[e.type.toLowerCase()] || [];
if (status) { if (status) {
callbacks = callbacks.concat(this._eventCallbacks[status + '.' + e.type.toLowerCase()] || []); callbacks = callbacks.concat(this._eventCallbacks[status + '.' + e.type.toLowerCase()] || []);
} }
if (callbacks.length === 0) { if (callbacks.length === 0) {
return; return;
} }
var lastStatus = this.getStatus();
var lastStatus = this.getStatus();
for (var i = 0; i < callbacks.length; i++) { for (var i = 0; i < callbacks.length; i++) {
callbacks[i].call(this, e); callbacks[i].call(this, e);
/* this.getStatus() != lastStatus ||*/ /* this.getStatus() != lastStatus ||*/
...@@ -158,15 +172,18 @@ kity.extendClass(KityMinder, { ...@@ -158,15 +172,18 @@ kity.extendClass(KityMinder, {
break; break;
} }
} }
return e.shouldStopPropagation(); return e.shouldStopPropagation();
}, },
on: function(name, callback) { on: function(name, callback) {
var km = this; var km = this;
utils.each(name.split(/\s+/), function(i, n) { name.split(/\s+/).forEach(function(n) {
km._listen(n.toLowerCase(), callback); km._listen(n.toLowerCase(), callback);
}); });
return this; return this;
}, },
off: function(name, callback) { off: function(name, callback) {
var types = name.split(/\s+/); var types = name.split(/\s+/);
...@@ -187,9 +204,13 @@ kity.extendClass(KityMinder, { ...@@ -187,9 +204,13 @@ kity.extendClass(KityMinder, {
} }
} }
}, },
fire: function(type, params) { fire: function(type, params) {
var e = new MinderEvent(type, params); var e = new MinderEvent(type, params);
this._fire(e); this._fire(e);
return this; return this;
} }
});
module.exports = MinderEvent;
}); });
...@@ -7,12 +7,19 @@ ...@@ -7,12 +7,19 @@
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
/** define(function(require, exports, module) {
var kity = require('./kity.js');
var utils = require('./utils');
var keymap = require('./keymap');
var Minder = require('./minder');
var MinderEvent = require('./event');
/**
* 计算包含 meta 键的 keycode * 计算包含 meta 键的 keycode
* *
* @param {String|KeyEvent} unknown * @param {String|KeyEvent} unknown
*/ */
function getMetaKeyCode(unknown) { function getMetaKeyCode(unknown) {
var CTRL_MASK = 0x1000; var CTRL_MASK = 0x1000;
var ALT_MASK = 0x2000; var ALT_MASK = 0x2000;
var SHIFT_MASK = 0x4000; var SHIFT_MASK = 0x4000;
...@@ -51,21 +58,21 @@ function getMetaKeyCode(unknown) { ...@@ -51,21 +58,21 @@ function getMetaKeyCode(unknown) {
} }
return metaKeyCode; return metaKeyCode;
} }
kity.extendClass(MinderEvent, { kity.extendClass(MinderEvent, {
isShortcutKey: function(keyCombine) { isShortcutKey: function(keyCombine) {
var keyEvent = this.originEvent; var keyEvent = this.originEvent;
if (!keyEvent) return false; if (!keyEvent) return false;
return getMetaKeyCode(keyCombine) == getMetaKeyCode(keyEvent); return getMetaKeyCode(keyCombine) == getMetaKeyCode(keyEvent);
} }
}); });
KityMinder.registerInit(function() { Minder.registerInitHook(function() {
this._initShortcutKey(); this._initShortcutKey();
}); });
kity.extendClass(KityMinder, { kity.extendClass(Minder, {
_initShortcutKey: function() { _initShortcutKey: function() {
this._bindShortcutKeys(); this._bindShortcutKeys();
...@@ -113,7 +120,7 @@ kity.extendClass(KityMinder, { ...@@ -113,7 +120,7 @@ kity.extendClass(KityMinder, {
var minder = this; var minder = this;
utils.each(obj, function(command, keys) { utils.each(obj, function(keys, command) {
binds[command] = keys; binds[command] = keys;
...@@ -129,4 +136,5 @@ kity.extendClass(KityMinder, { ...@@ -129,4 +136,5 @@ kity.extendClass(KityMinder, {
var binds = this._commandShortcutKeys; var binds = this._commandShortcutKeys;
return binds && binds[cmd] || null; return binds && binds[cmd] || null;
} }
});
}); });
\ No newline at end of file
var keymap = KityMinder.keymap = (function(origin) { define(function(require, exports, module) {
var ret = {}; var keymap = {
for (var key in origin) {
if (origin.hasOwnProperty(key)) {
ret[key] = origin[key];
ret[key.toLowerCase()] = origin[key];
}
}
var aKeyCode = 65;
var aCharCode = 'a'.charCodeAt(0);
// letters
'abcdefghijklmnopqrstuvwxyz'.split('').forEach(function(letter) {
ret[letter] = aKeyCode + (letter.charCodeAt(0) - aCharCode);
});
// numbers
var n = 9;
do {
ret[n.toString()] = n + 48;
} while(--n);
return ret;
})({
'Backspace': 8, 'Backspace': 8,
'Tab': 9, 'Tab': 9,
'Enter': 13, 'Enter': 13,
...@@ -124,5 +102,27 @@ var keymap = KityMinder.keymap = (function(origin) { ...@@ -124,5 +102,27 @@ var keymap = KityMinder.keymap = (function(origin) {
13: 1, 13: 1,
9: 1 9: 1
} }
};
// 小写适配
for (var key in keymap) {
if (keymap.hasOwnProperty(key)) {
keymap[key.toLowerCase()] = keymap[key];
}
}
var aKeyCode = 65;
var aCharCode = 'a'.charCodeAt(0);
// letters
'abcdefghijklmnopqrstuvwxyz'.split('').forEach(function(letter) {
keymap[letter] = aKeyCode + (letter.charCodeAt(0) - aCharCode);
});
// numbers
var n = 9;
do {
keymap[n.toString()] = n + 48;
} while(--n);
module.exports = keymap;
}); });
\ No newline at end of file
/**
* @fileOverview
*
* Kity 引入
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
define(function(require, exports, module) {
module.exports = require('../../lib/kity/src/kity.js');
});
\ No newline at end of file
/**
* @fileOverview
*
* KityMinder 类,暴露在 window 上的唯一变量
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
/* jshint -W079 */
var _initFnQueue = [];
var _uuidMap = {};
var KityMinder = kity.createClass('KityMinder', {
constructor: function(options) {
this._options = Utils.extend({}, options);
var initQueue = _initFnQueue.slice();
// @see option.js
// @see event.js
// @see status.js
// @see paper.js
// @see select.js
// @see key.js
// @see contextmenu.js
// @see module.js
// @see data.js
// @see readonly.js
// @see layout.js
// @see theme.js
while (initQueue.length) initQueue.shift().call(this, options);
this.fire('ready');
}
});
KityMinder.version = '1.0.0';
KityMinder.registerInit = function(fn) {
_initFnQueue.push(fn);
};
KityMinder.uuid = function(name) {
name = name || 'unknown';
_uuidMap[name] = _uuidMap[name] || 0;
++_uuidMap[name];
return name + '_' + _uuidMap[name];
};
// expose
if (typeof(module) != 'undefined') {
module.exports = KityMinder;
} else {
window.KityMinder = KityMinder;
}
This diff is collapsed.
/**
* @fileOverview
*
* KityMinder 类,暴露在 window 上的唯一变量
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
define(function(require, exports, module) {
var kity = require('./kity');
var utils = require('./utils');
var _initHooks = [];
var Minder = kity.createClass('Minder', {
constructor: function(options) {
this._options = utils.extend({}, options);
var initHooks = _initHooks.slice();
var initHook;
while (initHooks.length) {
initHook = initHooks.shift();
if (typeof(initHook) == 'function') {
initHook.call(this, this._options);
}
}
this.fire('ready');
}
});
Minder.version = '1.3.6';
Minder.registerInitHook = function(hook) {
_initHooks.push(hook);
};
module.exports = Minder;
});
//模块注册&暴露模块接口 define(function(require, exports, module) {
( function () { var kity = require('./kity');
var _modules; var utils = require('./utils');
KityMinder.registerModule = function ( name, module ) { var Minder = require('./minder');
//初始化模块列表
if ( !_modules ) { /* 已注册的模块 */
_modules = {}; var _modules = {};
}
_modules[ name ] = module; exports.register = function(name, module) {
}; _modules[name] = module;
KityMinder.getModules = function () {
return _modules;
}; };
} )();
KityMinder.registerInit(function() { /* 模块初始化 */
Minder.registerInitHook(function() {
this._initModules(); this._initModules();
}); });
// 模块声明周期维护 // 模块声明周期维护
kity.extendClass(KityMinder, { kity.extendClass(Minder, {
_initModules: function() { _initModules: function() {
var modulesPool = KityMinder.getModules(); var modulesPool = _modules;
var modulesToLoad = this._options.modules || Utils.keys(modulesPool); var modulesToLoad = this._options.modules || utils.keys(modulesPool);
this._commands = {}; this._commands = {};
this._query = {}; this._query = {};
...@@ -74,7 +72,7 @@ kity.extendClass(KityMinder, { ...@@ -74,7 +72,7 @@ kity.extendClass(KityMinder, {
for (type in dealRenderers) { for (type in dealRenderers) {
this._rendererClasses[type] = this._rendererClasses[type] || []; this._rendererClasses[type] = this._rendererClasses[type] || [];
if (Utils.isArray(dealRenderers[type])) { if (utils.isArray(dealRenderers[type])) {
this._rendererClasses[type] = this._rendererClasses[type].concat(dealRenderers[type]); this._rendererClasses[type] = this._rendererClasses[type].concat(dealRenderers[type]);
} else { } else {
this._rendererClasses[type].push(dealRenderers[type]); this._rendererClasses[type].push(dealRenderers[type]);
...@@ -82,6 +80,11 @@ kity.extendClass(KityMinder, { ...@@ -82,6 +80,11 @@ kity.extendClass(KityMinder, {
} }
} }
//添加模块的快捷键
if (moduleDeals.commandShortcutKeys) {
this.addCommandShortcutKeys(moduleDeals.commandShortcutKeys);
}
} }
}, },
...@@ -115,4 +118,5 @@ kity.extendClass(KityMinder, { ...@@ -115,4 +118,5 @@ kity.extendClass(KityMinder, {
modules[key].reset.call(this); modules[key].reset.call(this);
} }
} }
});
}); });
\ No newline at end of file
This diff is collapsed.
/**
* @fileOverview
*
* 提供脑图选项支持
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
define(function(require, exports, module) {
var kity = require('./kity');
var Minder = require('./minder');
kity.extendClass(Minder, {
getOption: function(key) {
if (key) {
return this._options[key];
} else {
return this._options;
}
}
});
});
\ No newline at end of file
/**
* @fileOverview
*
* 提供脑图选项支持
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
kity.extendClass(KityMinder, {
getOptions: function(key) {
if (key) {
return this._options[key];
} else {
return this._options;
}
}
});
\ No newline at end of file
...@@ -6,15 +6,20 @@ ...@@ -6,15 +6,20 @@
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
KityMinder.registerInit(function() { define(function(require, exports, module) {
var kity = require('./kity');
var utils = require('./utils');
var Minder = require('./minder');
Minder.registerInitHook(function() {
this._initPaper(); this._initPaper();
}); });
kity.extendClass(KityMinder, {
kity.extendClass(Minder, {
_initPaper: function() { _initPaper: function() {
this._paper = new kity.Paper(); this._paper = new kity.Paper();
this._paper.getNode().setAttribute('contenteditable', true);
this._paper.getNode().ondragstart = function(e) { this._paper.getNode().ondragstart = function(e) {
e.preventDefault(); e.preventDefault();
}; };
...@@ -30,7 +35,7 @@ kity.extendClass(KityMinder, { ...@@ -30,7 +35,7 @@ kity.extendClass(KityMinder, {
}, },
_addRenderContainer: function() { _addRenderContainer: function() {
this._rc = new kity.Group().setId(KityMinder.uuid('minder')); this._rc = new kity.Group().setId(utils.uuid('minder'));
this._paper.addShape(this._rc); this._paper.addShape(this._rc);
}, },
...@@ -38,8 +43,12 @@ kity.extendClass(KityMinder, { ...@@ -38,8 +43,12 @@ kity.extendClass(KityMinder, {
if (typeof(target) == 'string') { if (typeof(target) == 'string') {
target = document.getElementById(target); target = document.getElementById(target);
} }
if (target) {
this._paper.renderTo(this._renderTarget = target); this._paper.renderTo(this._renderTarget = target);
this._bindEvents(); this._bindEvents();
this.fire('paperrender');
}
return this;
}, },
getRenderContainer: function() { getRenderContainer: function() {
...@@ -53,4 +62,5 @@ kity.extendClass(KityMinder, { ...@@ -53,4 +62,5 @@ kity.extendClass(KityMinder, {
getRenderTarget: function() { getRenderTarget: function() {
return this._renderTarget; return this._renderTarget;
}, },
});
}); });
\ No newline at end of file
/** /**
* @fileOverview * @fileOverview
* *
* * 只读模式支持
* *
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
KityMinder.registerInit(function(options) {
define(function(require, exports, module) {
var kity = require('./kity');
var Minder = require('./minder');
Minder.registerInitHook(function(options) {
if (options.readOnly) { if (options.readOnly) {
this.setDisabled(); this.setDisabled();
} }
}); });
kity.extendClass(KityMinder, {
kity.extendClass(Minder, {
disable: function() { disable: function() {
var me = this; var me = this;
...@@ -52,4 +58,5 @@ kity.extendClass(KityMinder, { ...@@ -52,4 +58,5 @@ kity.extendClass(KityMinder, {
me._interactChange(); me._interactChange();
} }
});
}); });
\ No newline at end of file
var Renderer = KityMinder.Renderer = kity.createClass('Renderer', { define(function(require, exports, module) {
var kity = require('./kity');
var Minder = require('./minder');
var MinderNode = require('./node');
var Renderer = kity.createClass('Renderer', {
constructor: function(node) { constructor: function(node) {
this.node = node; this.node = node;
}, },
...@@ -49,9 +55,9 @@ var Renderer = KityMinder.Renderer = kity.createClass('Renderer', { ...@@ -49,9 +55,9 @@ var Renderer = KityMinder.Renderer = kity.createClass('Renderer', {
setRenderShape: function(shape) { setRenderShape: function(shape) {
this._renderShape = shape; this._renderShape = shape;
} }
}); });
kity.extendClass(KityMinder, (function() { function createMinderExtension() {
function createRendererForNode(node, registered) { function createRendererForNode(node, registered) {
var renderers = []; var renderers = [];
...@@ -77,7 +83,6 @@ kity.extendClass(KityMinder, (function() { ...@@ -77,7 +83,6 @@ kity.extendClass(KityMinder, (function() {
} }
return { return {
renderNodeBatch: function(nodes) { renderNodeBatch: function(nodes) {
var rendererClasses = this._rendererClasses; var rendererClasses = this._rendererClasses;
var lastBoxes = []; var lastBoxes = [];
...@@ -158,7 +163,6 @@ kity.extendClass(KityMinder, (function() { ...@@ -158,7 +163,6 @@ kity.extendClass(KityMinder, (function() {
renderNode: function(node) { renderNode: function(node) {
var rendererClasses = this._rendererClasses; var rendererClasses = this._rendererClasses;
var g = KityMinder.Geometry;
var i, latestBox, renderer; var i, latestBox, renderer;
if (!node._renderers) { if (!node._renderers) {
...@@ -212,9 +216,11 @@ kity.extendClass(KityMinder, (function() { ...@@ -212,9 +216,11 @@ kity.extendClass(KityMinder, (function() {
}); });
} }
}; };
})()); }
kity.extendClass(Minder, createMinderExtension());
kity.extendClass(MinderNode, { kity.extendClass(MinderNode, {
render: function() { render: function() {
if (!this.attached) return; if (!this.attached) return;
this.getMinder().renderNode(this); this.getMinder().renderNode(this);
...@@ -240,4 +246,7 @@ kity.extendClass(MinderNode, { ...@@ -240,4 +246,7 @@ kity.extendClass(MinderNode, {
//if (!this._contentBox) this.render(); //if (!this._contentBox) this.render();
return this.parent && this.parent.isCollapsed() ? new kity.Box() : (this._contentBox || new kity.Box()); return this.parent && this.parent.isCollapsed() ? new kity.Box() : (this._contentBox || new kity.Box());
} }
});
module.exports = Renderer;
}); });
\ No newline at end of file
KityMinder.registerInit(function() { define(function(require, exports, module) {
var kity = require('./kity');
var utils = require('./utils');
var Minder = require('./minder');
var MinderNode = require('./node');
Minder.registerInitHook(function() {
this._initSelection(); this._initSelection();
}); });
// 选区管理 // 选区管理
kity.extendClass(KityMinder, { kity.extendClass(Minder, {
_initSelection: function() { _initSelection: function() {
this._selectedNodes = []; this._selectedNodes = [];
}, },
renderChangedSelection: function(last) { renderChangedSelection: function(last) {
var current = this.getSelectedNodes(); var current = this.getSelectedNodes();
var changed = []; var changed = [];
var i = 0;
current.forEach(function(node) { current.forEach(function(node) {
if (last.indexOf(node) == -1) { if (last.indexOf(node) == -1) {
changed.push(node); changed.push(node);
node.setTmpData('selected', true);
} }
}); });
last.forEach(function(node) { last.forEach(function(node) {
if (current.indexOf(node) == -1) { if (current.indexOf(node) == -1) {
changed.push(node); changed.push(node);
node.setTmpData('selected', false);
} }
}); });
...@@ -31,7 +34,9 @@ kity.extendClass(KityMinder, { ...@@ -31,7 +34,9 @@ kity.extendClass(KityMinder, {
this._interactChange(); this._interactChange();
this.fire('selectionchange'); this.fire('selectionchange');
} }
while (i < changed.length) changed[i++].render(); while (changed.length) {
changed.shift().render();
}
}, },
getSelectedNodes: function() { getSelectedNodes: function() {
//不能克隆返回,会对当前选区操作,从而影响querycommand //不能克隆返回,会对当前选区操作,从而影响querycommand
...@@ -50,12 +55,14 @@ kity.extendClass(KityMinder, { ...@@ -50,12 +55,14 @@ kity.extendClass(KityMinder, {
removeSelectedNodes: function(nodes) { removeSelectedNodes: function(nodes) {
var me = this; var me = this;
var last = this._selectedNodes.slice(0); var last = this._selectedNodes.slice(0);
nodes = Utils.isArray(nodes) ? nodes : [nodes]; nodes = utils.isArray(nodes) ? nodes : [nodes];
Utils.each(nodes, function(i, n) {
nodes.forEach(function(node) {
var index; var index;
if ((index = me._selectedNodes.indexOf(n)) === -1) return; if ((index = me._selectedNodes.indexOf(node)) === -1) return;
me._selectedNodes.splice(index, 1); me._selectedNodes.splice(index, 1);
}); });
this.renderChangedSelection(last); this.renderChangedSelection(last);
return this; return this;
}, },
...@@ -65,10 +72,10 @@ kity.extendClass(KityMinder, { ...@@ -65,10 +72,10 @@ kity.extendClass(KityMinder, {
this._selectedNodes = []; this._selectedNodes = [];
} }
var me = this; var me = this;
nodes = Utils.isArray(nodes) ? nodes : [nodes]; nodes = utils.isArray(nodes) ? nodes : [nodes];
Utils.each(nodes, function(i, n) { nodes.forEach(function(node) {
if (me._selectedNodes.indexOf(n) !== -1) return; if (me._selectedNodes.indexOf(node) !== -1) return;
me._selectedNodes.push(n); me._selectedNodes.push(node);
}); });
this.renderChangedSelection(lastSelect); this.renderChangedSelection(lastSelect);
return this; return this;
...@@ -77,7 +84,7 @@ kity.extendClass(KityMinder, { ...@@ -77,7 +84,7 @@ kity.extendClass(KityMinder, {
//当前选区中的节点在给定的节点范围内的保留选中状态, //当前选区中的节点在给定的节点范围内的保留选中状态,
//没在给定范围的取消选中,给定范围中的但没在当前选中范围的也做选中效果 //没在给定范围的取消选中,给定范围中的但没在当前选中范围的也做选中效果
toggleSelect: function(node) { toggleSelect: function(node) {
if (Utils.isArray(node)) { if (utils.isArray(node)) {
node.forEach(this.toggleSelect.bind(this)); node.forEach(this.toggleSelect.bind(this));
} else { } else {
if (node.isSelected()) this.removeSelectedNodes(node); if (node.isSelected()) this.removeSelectedNodes(node);
...@@ -123,16 +130,12 @@ kity.extendClass(KityMinder, { ...@@ -123,16 +130,12 @@ kity.extendClass(KityMinder, {
return ancestors; return ancestors;
} }
}); });
kity.extendClass(MinderNode, { kity.extendClass(MinderNode, {
isSelected: function() { isSelected: function() {
return this.getTmpData('selected'); return this.getMinder().getSelectedNodes().indexOf(this) != -1;
},
clearSelectedFlag:function(){
this.setTmpData('selected');
},
setSelectedFlag:function(){
this.setTmpData('selected',true);
} }
});
}); });
\ No newline at end of file
...@@ -7,23 +7,26 @@ ...@@ -7,23 +7,26 @@
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
KityMinder.registerInit(function() { define(function(require, exports, module) {
var kity = require('./kity');
var Minder = require('./minder');
var sf = ~window.location.href.indexOf('status');
var tf = ~window.location.href.indexOf('trace');
Minder.registerInitHook(function() {
this._initStatus(); this._initStatus();
}); });
kity.extendClass(KityMinder, { kity.extendClass(Minder, {
_initStatus: function() { _initStatus: function() {
this._status = 'normal'; this._status = 'normal';
this._rollbackStatus = 'normal'; this._rollbackStatus = 'normal';
}, },
setStatus: (function() { setStatus: function(status, force) {
var sf = ~window.location.href.indexOf('status');
var tf = ~window.location.href.indexOf('trace');
// 在 readonly 模式下,只有 force 为 true 才能切换回来 // 在 readonly 模式下,只有 force 为 true 才能切换回来
return function(status, force) {
if (this._status == 'readonly' && !force) return this; if (this._status == 'readonly' && !force) return this;
if (status != this._status) { if (status != this._status) {
this._rollbackStatus = this._status; this._rollbackStatus = this._status;
...@@ -33,6 +36,7 @@ kity.extendClass(KityMinder, { ...@@ -33,6 +36,7 @@ kity.extendClass(KityMinder, {
currentStatus: this._status currentStatus: this._status
}); });
if (sf) { if (sf) {
/* global console: true */
console.log(window.event.type, this._rollbackStatus, '->', this._status); console.log(window.event.type, this._rollbackStatus, '->', this._status);
if (tf) { if (tf) {
console.trace(); console.trace();
...@@ -40,8 +44,7 @@ kity.extendClass(KityMinder, { ...@@ -40,8 +44,7 @@ kity.extendClass(KityMinder, {
} }
} }
return this; return this;
}; },
})(),
rollbackStatus: function() { rollbackStatus: function() {
this.setStatus(this._rollbackStatus); this.setStatus(this._rollbackStatus);
...@@ -52,4 +55,6 @@ kity.extendClass(KityMinder, { ...@@ -52,4 +55,6 @@ kity.extendClass(KityMinder, {
getStatus: function() { getStatus: function() {
return this._status; return this._status;
} }
});
}); });
\ No newline at end of file
utils.extend(KityMinder, { define(function(require, exports, module) {
_templates: {}, var kity = require('./kity');
registerTemplate: function(name, supports) { var utils = require('./utils');
KityMinder._templates[name] = supports; var Minder = require('./minder');
}, var Command = require('./command');
var MinderNode = require('./node');
var Module = require('./module');
var _templates = {};
function register(name, supports) {
_templates[name] = supports;
}
exports.register = register;
utils.extend(Minder, {
getTemplateList: function() { getTemplateList: function() {
return KityMinder._templates; return _templates;
} }
}); });
kity.extendClass(KityMinder, (function() { kity.extendClass(Minder, (function() {
var originGetTheme = KityMinder.prototype.getTheme; var originGetTheme = Minder.prototype.getTheme;
return { return {
useTemplate: function(name, duration) { useTemplate: function(name, duration) {
this.setTemplate(name); this.setTemplate(name);
...@@ -25,7 +36,7 @@ kity.extendClass(KityMinder, (function() { ...@@ -25,7 +36,7 @@ kity.extendClass(KityMinder, (function() {
}, },
getTemplateSupport: function(method) { getTemplateSupport: function(method) {
var supports = KityMinder._templates[this.getTemplate()]; var supports = _templates[this.getTemplate()];
return supports && supports[method]; return supports && supports[method];
}, },
...@@ -34,10 +45,10 @@ kity.extendClass(KityMinder, (function() { ...@@ -34,10 +45,10 @@ kity.extendClass(KityMinder, (function() {
return support.call(this, node); return support.call(this, node);
} }
}; };
})()); })());
kity.extendClass(MinderNode, (function() { kity.extendClass(MinderNode, (function() {
var originGetLayout = MinderNode.prototype.getLayout; var originGetLayout = MinderNode.prototype.getLayout;
var originGetConnect = MinderNode.prototype.getConnect; var originGetConnect = MinderNode.prototype.getConnect;
return { return {
...@@ -51,9 +62,9 @@ kity.extendClass(MinderNode, (function() { ...@@ -51,9 +62,9 @@ kity.extendClass(MinderNode, (function() {
return support.call(this, this); return support.call(this, this);
} }
}; };
})()); })());
KityMinder.registerModule('TemplateModule', { Module.register('TemplateModule', {
commands: { commands: {
'template': kity.createClass('TemplateCommand', { 'template': kity.createClass('TemplateCommand', {
base: Command, base: Command,
...@@ -68,4 +79,5 @@ KityMinder.registerModule('TemplateModule', { ...@@ -68,4 +79,5 @@ KityMinder.registerModule('TemplateModule', {
} }
}) })
} }
});
}); });
\ No newline at end of file
var cssLikeValueMatcher = { define(function(require, exports, module) {
var kity = require('./kity');
var utils = require('./utils');
var Minder = require('./minder');
var MinderNode = require('./node');
var Module = require('./module');
var Command = require('./command');
var cssLikeValueMatcher = {
left: function(value) { left: function(value) {
return 3 in value && value[3] || return 3 in value && value[3] ||
1 in value && value[1] || 1 in value && value[1] ||
...@@ -13,10 +21,9 @@ var cssLikeValueMatcher = { ...@@ -13,10 +21,9 @@ var cssLikeValueMatcher = {
bottom: function(value) { bottom: function(value) {
return 2 in value && value[2] || value[0]; return 2 in value && value[2] || value[0];
} }
}; };
Utils.extend(KityMinder, { var _themes = {};
_themes: {},
/** /**
* 注册一个主题 * 注册一个主题
...@@ -25,22 +32,24 @@ Utils.extend(KityMinder, { ...@@ -25,22 +32,24 @@ Utils.extend(KityMinder, {
* @param {Plain} theme 主题的样式描述 * @param {Plain} theme 主题的样式描述
* *
* @example * @example
* KityMinder.registerTheme('default', { * Minder.registerTheme('default', {
* 'root-color': 'red', * 'root-color': 'red',
* 'root-stroke': 'none', * 'root-stroke': 'none',
* 'root-padding': [10, 20] * 'root-padding': [10, 20]
* }); * });
*/ */
registerTheme: function(name, theme) { function register(name, theme) {
KityMinder._themes[name] = theme; _themes[name] = theme;
}, }
exports.register = register;
utils.extend(Minder, {
getThemeList: function() { getThemeList: function() {
return KityMinder._themes; return _themes;
} }
}); });
kity.extendClass(KityMinder, { kity.extendClass(Minder, {
/** /**
* 切换脑图实例上的主题 * 切换脑图实例上的主题
...@@ -67,12 +76,12 @@ kity.extendClass(KityMinder, { ...@@ -67,12 +76,12 @@ kity.extendClass(KityMinder, {
* @return {[type]} [description] * @return {[type]} [description]
*/ */
getTheme: function(node) { getTheme: function(node) {
return this._theme || this.getOptions('defaultTheme') || 'fresh-blue'; return this._theme || this.getOption('defaultTheme') || 'fresh-blue';
}, },
getThemeItems: function(node) { getThemeItems: function(node) {
var theme = this.getTheme(node); var theme = this.getTheme(node);
return KityMinder._themes[this.getTheme(node)]; return _themes[this.getTheme(node)];
}, },
/** /**
...@@ -96,7 +105,7 @@ kity.extendClass(KityMinder, { ...@@ -96,7 +105,7 @@ kity.extendClass(KityMinder, {
if (item in items) { if (item in items) {
value = items[item]; value = items[item];
if (Utils.isArray(value) && (matcher = cssLikeValueMatcher[dir])) { if (utils.isArray(value) && (matcher = cssLikeValueMatcher[dir])) {
return matcher(value); return matcher(value);
} }
if (!isNaN(value)) return value; if (!isNaN(value)) return value;
...@@ -113,15 +122,15 @@ kity.extendClass(KityMinder, { ...@@ -113,15 +122,15 @@ kity.extendClass(KityMinder, {
var value = this.getStyle(node.getType() + '-' + name, node); var value = this.getStyle(node.getType() + '-' + name, node);
return value !== null ? value : this.getStyle(name, node); return value !== null ? value : this.getStyle(name, node);
} }
}); });
kity.extendClass(MinderNode, { kity.extendClass(MinderNode, {
getStyle: function(name) { getStyle: function(name) {
return this.getMinder().getNodeStyle(this, name); return this.getMinder().getNodeStyle(this, name);
} }
}); });
KityMinder.registerModule('Theme', { Module.register('Theme', {
defaultOptions: { defaultOptions: {
defaultTheme: 'fresh-blue' defaultTheme: 'fresh-blue'
}, },
...@@ -138,8 +147,10 @@ KityMinder.registerModule('Theme', { ...@@ -138,8 +147,10 @@ KityMinder.registerModule('Theme', {
} }
}) })
} }
}); });
KityMinder.registerInit(function() { Minder.registerInitHook(function() {
this.setTheme(); this.setTheme();
});
}); });
\ No newline at end of file
This diff is collapsed.
/**
* @fileOverview
*
* 默认导出(全部模块)
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
define(function(require, exports, module) {
var kityminder = {
version: require('core/minder').version
};
// 核心导出,大写的部分导出类,小写的部分简单 require 一下
require('core/kity');
require('core/utils');
kityminder.Minder = require('core/minder');
kityminder.Command = require('core/command');
kityminder.Node = require('core/node');
require('core/option');
kityminder.Event = require('core/event');
kityminder.KeyMap = require('core/keymap');
require('core/key');
require('core/status');
require('core/paper');
require('core/select');
kityminder.Module = require('core/module');
kityminder.Data = require('core/data');
require('core/compatibility');
require('core/readonly');
kityminder.Render = require('core/render');
kityminder.Connect = require('core/connect');
kityminder.Layout = require('core/layout');
kityminder.Theme = require('core/theme');
kityminder.Template = require('core/template');
// 模块依赖
require('module/arrange');
require('module/basestyle');
require('module/clipboard');
require('module/dragtree');
require('module/expand');
require('module/font');
require('module/history');
require('module/hyperlink');
require('module/image');
require('module/keynav');
require('module/layout');
require('module/node');
require('module/note');
require('module/outline');
require('module/priority');
require('module/progress');
require('module/resource');
require('module/select');
require('module/style');
require('module/text');
require('module/view');
require('module/zoom');
require('layout/mind');
require('layout/btree');
require('layout/filetree');
require('layout/fish-bone-master');
require('layout/fish-bone-slave');
require('theme/default');
require('theme/snow');
require('theme/fresh');
require('theme/fish');
require('theme/snow');
require('connect/arc');
require('connect/bezier');
require('connect/fish-bone-master');
require('connect/l');
require('connect/poly');
require('connect/under');
require('template/default');
require('template/structure');
require('template/filetree');
require('template/right');
require('template/fish-bone');
module.exports = kityminder;
});
\ No newline at end of file
/* global Layout:true */ define(function(require, exports, module) {
var kity = require('core/kity');
var Layout = require('core/layout');
var layouts = ['left', 'right', 'top', 'bottom']; ['left', 'right', 'top', 'bottom'].forEach(registerLayoutForDirection);
layouts.forEach(function(name) { function registerLayoutForDirection(name) {
var axis = (name == 'left' || name == 'right') ? 'x' : 'y'; var axis = (name == 'left' || name == 'right') ? 'x' : 'y';
var dir = (name == 'left' || name == 'top') ? -1 : 1; var dir = (name == 'left' || name == 'top') ? -1 : 1;
...@@ -73,7 +75,7 @@ layouts.forEach(function(name) { ...@@ -73,7 +75,7 @@ layouts.forEach(function(name) {
return hint; return hint;
} }
KityMinder.registerLayout(name, kity.createClass({ Layout.register(name, kity.createClass({
base: Layout, base: Layout,
...@@ -137,4 +139,5 @@ layouts.forEach(function(name) { ...@@ -137,4 +139,5 @@ layouts.forEach(function(name) {
getOrderHint: getOrderHint getOrderHint: getOrderHint
})); }));
}
}); });
\ No newline at end of file
/* global Layout:true */ define(function(require, exports, module) {
var kity = require('core/kity');
var Layout = require('core/layout');
[-1, 1].forEach(function (dir) { [-1, 1].forEach(registerLayoutForDir);
function registerLayoutForDir(dir) {
var name = 'filetree-' + (dir > 0 ? 'down' : 'up'); var name = 'filetree-' + (dir > 0 ? 'down' : 'up');
KityMinder.registerLayout(name, kity.createClass({ Layout.register(name, kity.createClass({
base: Layout, base: Layout,
doLayout: function(parent, children, round) { doLayout: function(parent, children, round) {
...@@ -80,4 +84,6 @@ ...@@ -80,4 +84,6 @@
} }
})); }));
}
}); });
\ No newline at end of file
...@@ -6,8 +6,12 @@ ...@@ -6,8 +6,12 @@
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
/* global Layout:true */
KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLayout', { define(function(require, exports, module) {
var kity = require('core/kity');
var Layout = require('core/layout');
Layout.register('fish-bone-master', kity.createClass('FishBoneMasterLayout', {
base: Layout, base: Layout,
doLayout: function(parent, children, round) { doLayout: function(parent, children, round) {
...@@ -58,16 +62,7 @@ KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLa ...@@ -58,16 +62,7 @@ KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLa
this.move(upPart, xAdjust, yAdjustUp); this.move(upPart, xAdjust, yAdjustUp);
this.move(downPart, xAdjust + cMarginLeft, yAdjustDown); this.move(downPart, xAdjust + cMarginLeft, yAdjustDown);
// children.forEach(function(child, index) {
// var matrix = child.getLayoutTransform();
// var dx, dy;
// dx = matrix.getMatrix().e;
// dy = matrix.getMatrix().f;
// matrix.translate(-dx, -dy);
// matrix.rotate(index % 2 ? 45 : -45);
// matrix.translate(dx, dy);
// });
} }
})); }));
\ No newline at end of file
});
\ No newline at end of file
...@@ -7,8 +7,11 @@ ...@@ -7,8 +7,11 @@
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
/* global Layout: true */ define(function(require, exports, module) {
KityMinder.registerLayout('fish-bone-slave', kity.createClass('FishBoneSlaveLayout', { var kity = require('core/kity');
var Layout = require('core/layout');
Layout.register('fish-bone-slave', kity.createClass('FishBoneSlaveLayout', {
base: Layout, base: Layout,
doLayout: function (parent, children, round) { doLayout: function (parent, children, round) {
...@@ -39,8 +42,8 @@ KityMinder.registerLayout('fish-bone-slave', kity.createClass('FishBoneSlaveLayo ...@@ -39,8 +42,8 @@ KityMinder.registerLayout('fish-bone-slave', kity.createClass('FishBoneSlaveLayo
this.stack(children, 'y'); this.stack(children, 'y');
this.align(children, 'left'); this.align(children, 'left');
var xAdjust = 0, yAdjust = 0;
var xAdjust = 0, yAdjust = 0;
xAdjust += pout.x; xAdjust += pout.x;
if (parent.getLayoutVectorOut().y < 0) { if (parent.getLayoutVectorOut().y < 0) {
...@@ -65,4 +68,5 @@ KityMinder.registerLayout('fish-bone-slave', kity.createClass('FishBoneSlaveLayo ...@@ -65,4 +68,5 @@ KityMinder.registerLayout('fish-bone-slave', kity.createClass('FishBoneSlaveLayo
}); });
} }
} }
})); }));
\ No newline at end of file });
\ No newline at end of file
/* global Layout:true */ define(function(require, exports, module) {
KityMinder.registerLayout('mind', kity.createClass({ var kity = require('core/kity');
var Layout = require('core/layout');
var Minder = require('core/minder');
Layout.register('mind', kity.createClass({
base: Layout, base: Layout,
doLayout: function(node, children) { doLayout: function(node, children) {
...@@ -13,8 +17,8 @@ KityMinder.registerLayout('mind', kity.createClass({ ...@@ -13,8 +17,8 @@ KityMinder.registerLayout('mind', kity.createClass({
else left.push(child); else left.push(child);
}); });
var leftLayout = KityMinder.getLayoutInstance('left'); var leftLayout = Minder.getLayoutInstance('left');
var rightLayout = KityMinder.getLayoutInstance('right'); var rightLayout = Minder.getLayoutInstance('right');
leftLayout.doLayout(node, left); leftLayout.doLayout(node, left);
rightLayout.doLayout(node, right); rightLayout.doLayout(node, right);
...@@ -54,4 +58,5 @@ KityMinder.registerLayout('mind', kity.createClass({ ...@@ -54,4 +58,5 @@ KityMinder.registerLayout('mind', kity.createClass({
}); });
return hint; return hint;
} }
})); }));
\ No newline at end of file });
\ No newline at end of file
kity.extendClass(MinderNode, {
define(function(require, exports, module) {
var kity = require('core/kity');
var MinderNode = require('core/node');
var Command = require('core/command');
var Module = require('core/module');
kity.extendClass(MinderNode, {
arrange: function(index) { arrange: function(index) {
var parent = this.parent; var parent = this.parent;
if (!parent) return; if (!parent) return;
...@@ -9,21 +16,21 @@ kity.extendClass(MinderNode, { ...@@ -9,21 +16,21 @@ kity.extendClass(MinderNode, {
sibling.splice(index, 0, this); sibling.splice(index, 0, this);
return this; return this;
} }
}); });
function asc(nodeA, nodeB) { function asc(nodeA, nodeB) {
return nodeA.getIndex() - nodeB.getIndex(); return nodeA.getIndex() - nodeB.getIndex();
} }
function desc(nodeA, nodeB) { function desc(nodeA, nodeB) {
return -asc(nodeA, nodeB); return -asc(nodeA, nodeB);
} }
function canArrange(km) { function canArrange(km) {
var selected = km.getSelectedNode(); var selected = km.getSelectedNode();
return selected && selected.parent && selected.parent.children.length > 1; return selected && selected.parent && selected.parent.children.length > 1;
} }
var ArrangeUpCommand = kity.createClass('ArrangeUpCommand', { var ArrangeUpCommand = kity.createClass('ArrangeUpCommand', {
base: Command, base: Command,
execute: function(km) { execute: function(km) {
...@@ -42,9 +49,9 @@ var ArrangeUpCommand = kity.createClass('ArrangeUpCommand', { ...@@ -42,9 +49,9 @@ var ArrangeUpCommand = kity.createClass('ArrangeUpCommand', {
var selected = km.getSelectedNode(); var selected = km.getSelectedNode();
return selected ? 0 : -1; return selected ? 0 : -1;
} }
}); });
var ArrangeDownCommand = kity.createClass('ArrangeUpCommand', { var ArrangeDownCommand = kity.createClass('ArrangeUpCommand', {
base: Command, base: Command,
execute: function(km) { execute: function(km) {
...@@ -63,9 +70,9 @@ var ArrangeDownCommand = kity.createClass('ArrangeUpCommand', { ...@@ -63,9 +70,9 @@ var ArrangeDownCommand = kity.createClass('ArrangeUpCommand', {
var selected = km.getSelectedNode(); var selected = km.getSelectedNode();
return selected ? 0 : -1; return selected ? 0 : -1;
} }
}); });
var ArrangeCommand = kity.createClass('ArrangeCommand', { var ArrangeCommand = kity.createClass('ArrangeCommand', {
base: Command, base: Command,
execute: function(km, nodes, index) { execute: function(km, nodes, index) {
...@@ -101,9 +108,9 @@ var ArrangeCommand = kity.createClass('ArrangeCommand', { ...@@ -101,9 +108,9 @@ var ArrangeCommand = kity.createClass('ArrangeCommand', {
var selected = km.getSelectedNode(); var selected = km.getSelectedNode();
return selected ? 0 : -1; return selected ? 0 : -1;
} }
}); });
KityMinder.registerModule('ArrangeModule', { Module.register('ArrangeModule', {
commands: { commands: {
'arrangeup': ArrangeUpCommand, 'arrangeup': ArrangeUpCommand,
'arrangedown': ArrangeDownCommand, 'arrangedown': ArrangeDownCommand,
...@@ -120,4 +127,5 @@ KityMinder.registerModule('ArrangeModule', { ...@@ -120,4 +127,5 @@ KityMinder.registerModule('ArrangeModule', {
'arrangeup': 'normal::alt+Up', 'arrangeup': 'normal::alt+Up',
'arrangedown': 'normal::alt+Down' 'arrangedown': 'normal::alt+Down'
} }
});
}); });
\ No newline at end of file
KityMinder.registerModule('basestylemodule', function() {
define(function(require, exports, module) {
var kity = require('core/kity');
var utils = require('core/utils');
var Minder = require('core/minder');
var MinderNode = require('core/node');
var Command = require('core/command');
var Module = require('core/module');
var TextRenderer = require('./text');
Module.register('basestylemodule', function() {
var km = this; var km = this;
function getNodeDataOrStyle(node, name) { function getNodeDataOrStyle(node, name) {
return node.getData(name) || node.getStyle(name); return node.getData(name) || node.getStyle(name);
} }
KityMinder.TextRenderer.registerStyleHook(function(node, textGroup) { TextRenderer.registerStyleHook(function(node, textGroup) {
var fontWeight = getNodeDataOrStyle(node,'font-weight'); var fontWeight = getNodeDataOrStyle(node,'font-weight');
var fontStyle = getNodeDataOrStyle(node, 'font-style'); var fontStyle = getNodeDataOrStyle(node, 'font-style');
var styleHash = [fontWeight, fontStyle].join('/'); var styleHash = [fontWeight, fontStyle].join('/');
textGroup.eachItem(function(index,item){ textGroup.eachItem(function(index,item) {
item.setFont({ item.setFont({
'weight': fontWeight, 'weight': fontWeight,
'style': fontStyle 'style': fontStyle
...@@ -28,11 +40,11 @@ KityMinder.registerModule('basestylemodule', function() { ...@@ -28,11 +40,11 @@ KityMinder.registerModule('basestylemodule', function() {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
if (this.queryState('bold') == 1) { if (this.queryState('bold') == 1) {
utils.each(nodes, function(i, n) { nodes.forEach(function(n) {
n.setData('font-weight').render(); n.setData('font-weight').render();
}); });
} else { } else {
utils.each(nodes, function(i, n) { nodes.forEach(function(n) {
n.setData('font-weight', 'bold').render(); n.setData('font-weight', 'bold').render();
}); });
} }
...@@ -44,7 +56,7 @@ KityMinder.registerModule('basestylemodule', function() { ...@@ -44,7 +56,7 @@ KityMinder.registerModule('basestylemodule', function() {
if (nodes.length === 0) { if (nodes.length === 0) {
return -1; return -1;
} }
utils.each(nodes, function(i, n) { nodes.forEach(function(n) {
if (n && n.getData('font-weight')) { if (n && n.getData('font-weight')) {
result = 1; result = 1;
return false; return false;
...@@ -60,11 +72,11 @@ KityMinder.registerModule('basestylemodule', function() { ...@@ -60,11 +72,11 @@ KityMinder.registerModule('basestylemodule', function() {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
if (this.queryState('italic') == 1) { if (this.queryState('italic') == 1) {
utils.each(nodes, function(i, n) { nodes.forEach(function(n) {
n.setData('font-style').render(); n.setData('font-style').render();
}); });
} else { } else {
utils.each(nodes, function(i, n) { nodes.forEach(function(n) {
n.setData('font-style', 'italic').render(); n.setData('font-style', 'italic').render();
}); });
} }
...@@ -77,7 +89,7 @@ KityMinder.registerModule('basestylemodule', function() { ...@@ -77,7 +89,7 @@ KityMinder.registerModule('basestylemodule', function() {
if (nodes.length === 0) { if (nodes.length === 0) {
return -1; return -1;
} }
utils.each(nodes, function(i, n) { nodes.forEach(function(n) {
if (n && n.getData('font-style')) { if (n && n.getData('font-style')) {
result = 1; result = 1;
return false; return false;
...@@ -92,4 +104,5 @@ KityMinder.registerModule('basestylemodule', function() { ...@@ -92,4 +104,5 @@ KityMinder.registerModule('basestylemodule', function() {
'italic': 'ctrl+i' //italic 'italic': 'ctrl+i' //italic
} }
}; };
});
}); });
\ No newline at end of file
KityMinder.registerModule( "ClipboardModule", function () { define(function(require, exports, module) {
var kity = require('core/kity');
var utils = require('core/utils');
var MinderNode = require('core/node');
var Command = require('core/command');
var Module = require('core/module');
Module.register('ClipboardModule', function() {
var km = this, var km = this,
_clipboardNodes = [], _clipboardNodes = [],
...@@ -11,7 +18,8 @@ KityMinder.registerModule( "ClipboardModule", function () { ...@@ -11,7 +18,8 @@ KityMinder.registerModule( "ClipboardModule", function () {
child.render(); child.render();
child.setLayoutOffset(null); child.setLayoutOffset(null);
var children = utils.cloneArr(child.children); var children = utils.cloneArr(child.children);
for (var i = 0, ci; (ci = children[i]); i++) { for (var i = 0, ci;
(ci = children[i]); i++) {
appendChildNode(child, ci); appendChildNode(child, ci);
} }
} }
...@@ -60,7 +68,8 @@ KityMinder.registerModule( "ClipboardModule", function () { ...@@ -60,7 +68,8 @@ KityMinder.registerModule( "ClipboardModule", function () {
var node = km.getSelectedNode(); var node = km.getSelectedNode();
if (!node) return; if (!node) return;
for(var i= 0, ni; (ni = _clipboardNodes[i]); i++) { for (var i = 0, ni;
(ni = _clipboardNodes[i]); i++) {
appendChildNode(node, ni.clone()); appendChildNode(node, ni.clone());
} }
...@@ -88,4 +97,5 @@ KityMinder.registerModule( "ClipboardModule", function () { ...@@ -88,4 +97,5 @@ KityMinder.registerModule( "ClipboardModule", function () {
'paste': 'normal::ctrl+v' 'paste': 'normal::ctrl+v'
} }
}; };
} ); });
\ No newline at end of file });
\ No newline at end of file
var GM = KityMinder.Geometry; define(function(require, exports, module) {
var kity = require('core/kity');
var utils = require('core/utils');
var MinderNode = require('core/node');
var Command = require('core/command');
var Module = require('core/module');
// 矩形的变形动画定义 // 矩形的变形动画定义
var MoveToParentCommand = kity.createClass('MoveToParentCommand', { var MoveToParentCommand = kity.createClass('MoveToParentCommand', {
base: Command, base: Command,
execute: function(minder, nodes, parent) { execute: function(minder, nodes, parent) {
var node; var node;
...@@ -17,9 +22,9 @@ var MoveToParentCommand = kity.createClass('MoveToParentCommand', { ...@@ -17,9 +22,9 @@ var MoveToParentCommand = kity.createClass('MoveToParentCommand', {
parent.expand(); parent.expand();
minder.select(nodes, true); minder.select(nodes, true);
} }
}); });
var DropHinter = kity.createClass('DropHinter', { var DropHinter = kity.createClass('DropHinter', {
base: kity.Group, base: kity.Group,
constructor: function() { constructor: function() {
...@@ -41,9 +46,9 @@ var DropHinter = kity.createClass('DropHinter', { ...@@ -41,9 +46,9 @@ var DropHinter = kity.createClass('DropHinter', {
this.bringTop(); this.bringTop();
} }
} }
}); });
var OrderHinter = kity.createClass('OrderHinter', { var OrderHinter = kity.createClass('OrderHinter', {
base: kity.Group, base: kity.Group,
constructor: function() { constructor: function() {
...@@ -64,12 +69,12 @@ var OrderHinter = kity.createClass('OrderHinter', { ...@@ -64,12 +69,12 @@ var OrderHinter = kity.createClass('OrderHinter', {
hint.node.getStyle('order-hint-path-width') || 1); hint.node.getStyle('order-hint-path-width') || 1);
} }
} }
}); });
// 对拖动对象的一个替代盒子,控制整个拖放的逻辑,包括: // 对拖动对象的一个替代盒子,控制整个拖放的逻辑,包括:
// 1. 从节点列表计算出拖动部分 // 1. 从节点列表计算出拖动部分
// 2. 计算可以 drop 的节点,产生 drop 交互提示 // 2. 计算可以 drop 的节点,产生 drop 交互提示
var TreeDragger = kity.createClass('TreeDragger', { var TreeDragger = kity.createClass('TreeDragger', {
constructor: function(minder) { constructor: function(minder) {
this._minder = minder; this._minder = minder;
...@@ -97,7 +102,7 @@ var TreeDragger = kity.createClass('TreeDragger', { ...@@ -97,7 +102,7 @@ var TreeDragger = kity.createClass('TreeDragger', {
if (!this._dragMode) { if (!this._dragMode) {
// 判断拖放模式是否该启动 // 判断拖放模式是否该启动
if (GM.getDistance(this._dragPosition, this._startPosition) < DRAG_MOVE_THRESHOLD) { if (kity.Vector.fromPoints(this._dragPosition, this._startPosition).length() < DRAG_MOVE_THRESHOLD) {
return; return;
} }
if (!this._enterDragMode()) { if (!this._enterDragMode()) {
...@@ -296,7 +301,7 @@ var TreeDragger = kity.createClass('TreeDragger', { ...@@ -296,7 +301,7 @@ var TreeDragger = kity.createClass('TreeDragger', {
for (j = 0; j < sourceBoxes.length; j++) { for (j = 0; j < sourceBoxes.length; j++) {
sourceBox = sourceBoxes[j]; sourceBox = sourceBoxes[j];
var intersectBox = GM.getIntersectBox(sourceBox, targetBox); var intersectBox = sourceBox.intersect(targetBox);
if (judge(intersectBox, sourceBox, targetBox)) { if (judge(intersectBox, sourceBox, targetBox)) {
return target; return target;
} }
...@@ -342,9 +347,9 @@ var TreeDragger = kity.createClass('TreeDragger', { ...@@ -342,9 +347,9 @@ var TreeDragger = kity.createClass('TreeDragger', {
preventDragMove: function() { preventDragMove: function() {
this._startPosition = null; this._startPosition = null;
} }
}); });
KityMinder.registerModule('DragTree', function() { Module.register('DragTree', function() {
var dragger; var dragger;
return { return {
...@@ -380,4 +385,5 @@ KityMinder.registerModule('DragTree', function() { ...@@ -380,4 +385,5 @@ KityMinder.registerModule('DragTree', function() {
'movetoparent': MoveToParentCommand 'movetoparent': MoveToParentCommand
} }
}; };
});
}); });
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
KityMinder.Range = kity.createClass('Range',function(){
function getOffset(rng,dir){
var node = rng[dir + 'Container'],
offset = rng[dir + 'Offset'],
rOffset = 0;
if(node.nodeType == 1){
//默认不会出现得不到子节点的情况
node = node.childNodes[offset];
if(!node && rng.startContainer && rng.startContainer.nodeName == 'DIV' ) {
rng.startContainer.innerHTML = '<p></p>';
offset = 0;
}else if(node.nodeType == 3){
offset = 0;
}
}
utils.each(rng.container.childNodes,function(index,n){
if(n === node){
if(n.nodeType == 1){
return false;
}else{
rOffset += offset;
return false;
}
}
rOffset += (n.nodeType == 1 ? 1 : utils.clearWhitespace(n.nodeValue).length);
});
return rOffset;
}
function setBoundary(rng,offset,dir){
var rOffset = 0,cont = rng.container;
utils.each(cont.childNodes,function(index,node){
if(node.nodeType == 1){
if(rOffset == offset){
rng['set' + dir](cont,index);
return false;
}
rOffset++;
return;
}
var currentLength = utils.clearWhitespace(node.nodeValue).length;
if(rOffset + currentLength >= offset){
rng['set' + dir](node,offset - rOffset);
return false;
}
rOffset += currentLength;
});
}
return {
constructor : function(container){
this.nativeRange = document.createRange();
this.nativeSel = window.getSelection();
this.startContainer =
this.endContainer =
this.startOffset =
this.endOffset = null;
this.collapsed = false;
this.container = container || null;
},
hasNativeRange : function(){
return this.nativeSel.rangeCount !== 0 ;
},
deleteContents : function(){
this.nativeRange.deleteContents();
return this._updateBoundary();
},
select:function(){
var start = this.nativeRange.startContainer;
if(start.nodeType == 1 && start.childNodes.length === 0){
var char = document.createTextNode('\u200b');
start.appendChild(char);
this.nativeRange.setStart(char,1);
this.nativeRange.collapse(true);
}else if(this.collapsed && start.nodeType == 1){
start = start.childNodes[this.startOffset];
if(start && start.nodeType == 3 && start.nodeValue.length === 0){
this.nativeRange.setStart(start,1);
this.nativeRange.collapse(true);
}
}
try{
this.nativeSel.removeAllRanges();
}catch(e){
}
this.nativeSel.addRange(this.nativeRange);
return this;
},
_updateBoundary : function(){
var nRange = this.nativeRange;
this.startContainer = nRange.startContainer;
this.startContainer = nRange.startContainer;
this.endContainer = nRange.endContainer;
this.startOffset = nRange.startOffset;
this.endOffset = nRange.endOffset;
this.collapsed = nRange.collapsed;
return this;
},
setStartOffset:function(offset){
setBoundary(this,offset,'Start');
return this;
},
setEndOffset:function(offset){
setBoundary(this,offset,'End');
return this;
},
setStart:function(node,offset){
this.nativeRange.setStart(node,offset);
this._updateBoundary();
return this;
},
setStartAfter:function(node){
return this.setStart(node.parentNode,utils.getNodeIndex(node) + 1);
},
setStartBefore:function(node){
return this.setStart(node.parentNode,utils.getNodeIndex(node));
},
setEnd:function(node,offset){
this.nativeRange.setEnd(node,offset);
this._updateBoundary();
return this;
},
update:function(){
this.updateNativeRange()
._updateBoundary();
return this;
},
getStart:function(){
this.update();
return {
startContainer:this.startContainer,
startOffset:this.startOffset
};
},
getStartOffset:function(){
return getOffset(this,'start');
},
getEndOffset:function(){
return getOffset(this,'end');
},
collapse:function(toStart){
this.nativeRange.collapse(toStart === true);
this._updateBoundary();
return this;
},
isCollapsed:function(){
this._updateBoundary();
return this.collapsed;
},
insertNode:function(node){
this.nativeRange.insertNode(node);
return this._updateBoundary();
},
updateNativeRange:function(){
this.nativeRange = this.nativeSel.getRangeAt(0);
return this;
},
clear : function(){
this.nativeSel.removeAllRanges();
return this;
}
};
}());
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
/* global Renderer: true */ define(function(require, exports, module) {
var kity = require('core/kity');
KityMinder.registerModule('Expand', function() { var utils = require('core/utils');
var keymap = require('core/keymap');
var MinderNode = require('core/node');
var Command = require('core/command');
var Module = require('core/module');
var Renderer = require('core/render');
Module.register('Expand', function() {
var minder = this; var minder = this;
var EXPAND_STATE_DATA = 'expandState', var EXPAND_STATE_DATA = 'expandState',
STATE_EXPAND = 'expand', STATE_EXPAND = 'expand',
...@@ -86,7 +93,7 @@ KityMinder.registerModule('Expand', function() { ...@@ -86,7 +93,7 @@ KityMinder.registerModule('Expand', function() {
this.sign = new kity.Path().stroke('gray'); this.sign = new kity.Path().stroke('gray');
this.addShapes([this.outline, this.sign]); this.addShapes([this.outline, this.sign]);
this.initEvent(node); this.initEvent(node);
this.setId(KityMinder.uuid('node_expander')); this.setId(utils.uuid('node_expander'));
this.setStyle('cursor', 'pointer'); this.setStyle('cursor', 'pointer');
}, },
...@@ -236,4 +243,5 @@ KityMinder.registerModule('Expand', function() { ...@@ -236,4 +243,5 @@ KityMinder.registerModule('Expand', function() {
divider: true divider: true
}] }]
}; };
});
}); });
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
KityMinder.registerModule('KeyboardModule', function() { define(function(require, exports, module) {
var kity = require('core/kity');
var utils = require('core/utils');
var keymap = require('core/keymap');
var Minder = require('core/minder');
var MinderNode = require('core/node');
var Command = require('core/command');
var Module = require('core/module');
var Renderer = require('core/render');
Module.register('KeyboardModule', function() {
var min = Math.min, var min = Math.min,
max = Math.max, max = Math.max,
abs = Math.abs, abs = Math.abs,
...@@ -171,9 +182,8 @@ KityMinder.registerModule('KeyboardModule', function() { ...@@ -171,9 +182,8 @@ KityMinder.registerModule('KeyboardModule', function() {
}, },
'normal.keyup': function(e) { 'normal.keyup': function(e) {
if (kity.Browser.ipad) { if (kity.Browser.ipad) {
var keys = KityMinder.keymap; var keys = keymap;
var node = e.getTargetNode(); var node = e.getTargetNode();
var lang = this.getLang();
if (this.receiver) this.receiver.keydownNode = node; if (this.receiver) this.receiver.keydownNode = node;
...@@ -183,7 +193,7 @@ KityMinder.registerModule('KeyboardModule', function() { ...@@ -183,7 +193,7 @@ KityMinder.registerModule('KeyboardModule', function() {
switch (keyEvent.keyCode) { switch (keyEvent.keyCode) {
case keys.Enter: case keys.Enter:
this.execCommand('AppendSiblingNode', lang.topic); this.execCommand('AppendSiblingNode');
e.preventDefault(); e.preventDefault();
break; break;
...@@ -199,4 +209,5 @@ KityMinder.registerModule('KeyboardModule', function() { ...@@ -199,4 +209,5 @@ KityMinder.registerModule('KeyboardModule', function() {
} }
} }
}; };
});
}); });
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -6,8 +6,10 @@ ...@@ -6,8 +6,10 @@
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
define(function(require, exports, module) {
var template = require('core/template');
KityMinder.registerTemplate('default', { template.register('default', {
getLayout: function(node) { getLayout: function(node) {
...@@ -32,4 +34,5 @@ KityMinder.registerTemplate('default', { ...@@ -32,4 +34,5 @@ KityMinder.registerTemplate('default', {
if (node.getLevel() == 1) return 'arc'; if (node.getLevel() == 1) return 'arc';
return 'under'; return 'under';
} }
});
}); });
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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