Commit 4735257a authored by techird's avatar techird

Merge branch 'dev' of https://github.com/fex-team/kityminder into dev

parents d9aca907 af830a57
# KityMinder 更新日志 # KityMinder 更新日志
##1.2.0 ##1.1.3
###功能更新 ###功能更新
1. 添加保存时可修改文件名 1. 添加保存时可修改文件名
2. 添加超链接 2. 添加超链接
3. 优化了当输入中文时,中文显示位置与光标距离过远的问题 3. 优化了当输入中文时,中文显示位置与光标距离过远的问题4.
###问题修复 ###问题修复
1. 修复当滚动鼠标滚轮时,光标不跟着移动的问题 1. 修复当滚动鼠标滚轮时,光标不跟着移动的问题
2. 优化了拖拽节点操作体验
## v1.1.3
### 功能更新
### 问题修复
1. 优化加载速度、拖拽速度
## v1.1.2 ## v1.1.2
......
( function () {
var preferenceContent = '<div class="help-content" style="padding:20px;width:360px;">';
preferenceContent += '<h3>展开属性设置</h3>';
preferenceContent += '<p><label><input type="radio" name="expand" checked value="all"/>全部展开</label><label><input type="radio" name="expand" value="limit"/>局部展开</label></p>';
preferenceContent += '</div>';
KM.registerWidget( 'preference', {
tpl: preferenceContent,
initContent: function ( km ) {
var lang = km.getLang( 'dialogs.help' ),
html;
if ( lang ) {
html = $.parseTmpl( this.tpl, lang );
}
this.root().html( html );
},
initEvent: function ( km, $w ) {
$w.on( 'click', '.kmui-close', function ( e ) {
//写cookies
var setCookie = function ( name, value, exp ) {
document.cookie = name + "=" + escape( value ) + ";expires=" + exp.toGMTString();
}
var expand = $( "input[type='radio'][name='expand']:checked" ).val();
var Days = 30;
var exp = new Date();
exp.setTime( exp.getTime() + Days * 24 * 60 * 60 * 1000 );
setCookie( 'expand', expand, exp );
console.log( document.cookie );
} );
},
width: 400
} );
} )();
\ No newline at end of file
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
,'adapter/node.js' ,'adapter/node.js'
,'adapter/contextmenu.js' ,'adapter/contextmenu.js'
,'adapter/dialog.js' ,'adapter/dialog.js'
,'adapter/preference.js'
,'protocal/xmind.js' ,'protocal/xmind.js'
,'protocal/freemind.js' ,'protocal/freemind.js'
,'protocal/mindmanager.js' ,'protocal/mindmanager.js'
...@@ -77,6 +78,7 @@ ...@@ -77,6 +78,7 @@
,'protocal/json.js' ,'protocal/json.js'
,'protocal/png.js' ,'protocal/png.js'
,'protocal/svg.js' ,'protocal/svg.js'
), ),
baseURL = 'src/'; baseURL = 'src/';
for (var i=0,pi;pi = paths[i++];) { for (var i=0,pi;pi = paths[i++];) {
......
...@@ -60,10 +60,10 @@ ...@@ -60,10 +60,10 @@
} }
window.KITYMINDER_CONFIG = { window.KITYMINDER_CONFIG = {
'KITYMINDER_HOME_URL': getKMBasePath() 'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏 //定义工具栏
,toolbars: [ toolbars: [
'hand zoom-in zoom-out | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers | node | help' 'hand zoom-in zoom-out | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers | node | preference | help'
] ]
//只读模式,默认是false //只读模式,默认是false
//readOnly: true //readOnly: true
...@@ -80,5 +80,12 @@ ...@@ -80,5 +80,12 @@
//设置km整体的z-index大小 //设置km整体的z-index大小
//,zIndex : 1000 //,zIndex : 1000
//设置初始加载时展开的层数和子节点数目阈值
//默认是全部展开,0表示全部展开
,
defaultExpand: {
defaultLayer: 2,
defaultSubShow: 5
}
}; };
} )(); } )();
\ No newline at end of file
...@@ -17,7 +17,8 @@ KityMinder.LANG[ 'zh-cn' ] = { ...@@ -17,7 +17,8 @@ KityMinder.LANG[ 'zh-cn' ] = {
'zoom-out': '缩小', 'zoom-out': '缩小',
'markers': '添加标签', 'markers': '添加标签',
'switchlayout': '切换主题', 'switchlayout': '切换主题',
'help': '帮助' 'help': '帮助',
'preference': '偏好设置'
}, },
'popupcolor': { 'popupcolor': {
'clearColor': '清空颜色', 'clearColor': '清空颜色',
...@@ -48,7 +49,8 @@ KityMinder.LANG[ 'zh-cn' ] = { ...@@ -48,7 +49,8 @@ KityMinder.LANG[ 'zh-cn' ] = {
'node': { 'node': {
'appendsiblingnode': '插入同级节点', 'appendsiblingnode': '插入同级节点',
'appendchildnode': '插入子节点', 'appendchildnode': '插入子节点',
'removenode': '删除节点' 'removenode': '删除节点',
'editnode': '编辑节点'
}, },
'layout': { 'layout': {
'default': '左右展开', 'default': '左右展开',
......
...@@ -449,7 +449,7 @@ $( function () { ...@@ -449,7 +449,7 @@ $( function () {
// 从路径中抽取文件名 // 从路径中抽取文件名
function getFileName( path ) { function getFileName( path ) {
var filename = path.substr( path.lastIndexOf( '/' ) + 1 ); var filename = path.substr( path.lastIndexOf( '/' ) + 1 );
return filename.substr( 0, filename.lastIndexOf( '.' ) ); return filename//.substr( 0, filename.lastIndexOf( '.' ) );
} }
// 点击文件菜单 // 点击文件菜单
......
KM.registerToolbarUI( 'markers help', function ( name ) { KM.registerToolbarUI( 'markers help preference', function ( name ) {
var me = this, var me = this,
currentRange, $dialog, currentRange, $dialog,
......
...@@ -2,7 +2,8 @@ KM.registerToolbarUI( 'node', function ( name ) { ...@@ -2,7 +2,8 @@ KM.registerToolbarUI( 'node', function ( name ) {
var shortcutKeys = { var shortcutKeys = {
"appendsiblingnode": "enter", "appendsiblingnode": "enter",
"appendchildnode": "tab", "appendchildnode": "tab",
"removenode": "del|backspace" "removenode": "del|backspace",
"editnode": "F2"
}; };
var me = this, var me = this,
......
KM.registerUI( 'preference',
function ( name ) {
var km = this;
//读取偏好设置,设置参数
}
);
\ No newline at end of file
...@@ -3,41 +3,45 @@ var keymap = KityMinder.keymap = { ...@@ -3,41 +3,45 @@ var keymap = KityMinder.keymap = {
'Tab' : 9, 'Tab' : 9,
'Enter' : 13, 'Enter' : 13,
'Shift':16, 'Shift' : 16,
'Control':17, 'Control' : 17,
'Alt':18, 'Alt' : 18,
'CapsLock':20, 'CapsLock' : 20,
'Esc':27, 'Esc': 27,
'Spacebar':32, 'Spacebar' : 32,
'PageUp':33, 'PageUp' : 33,
'PageDown':34, 'PageDown' : 34,
'End':35, 'End' : 35,
'Home':36, 'Home' : 36,
'Left':37, 'Left' : 37,
'Up':38, 'Up' : 38,
'Right':39, 'Right' : 39,
'Down':40, 'Down' : 40,
'Insert':45, 'Insert' : 45,
'Del':46, 'Del' : 46,
'NumLock':144, 'NumLock' : 144,
'Cmd':91, 'Cmd' : 91,
'=':187, 'F2' : 113,
'-':189, 'F3' : 114,
'F4' : 115,
"b":66, '=' : 187,
'i':73, '-' : 189,
"b" : 66,
'i' : 73,
//回退 //回退
'z':90, 'z' : 90,
'y':89, 'y' : 89,
//粘贴 //粘贴
'v' : 86, 'v' : 86,
'x' : 88, 'x' : 88,
......
var KityMinder = window.KM = window.KityMinder = function () { var KityMinder = window.KM = window.KityMinder = function () {
var instanceMap = {}, instanceId = 0; var instanceMap = {}, instanceId = 0;
return { return {
version: '1.2.0', version: '1.1.3',
createMinder: function ( renderTarget, options ) { createMinder: function ( renderTarget, options ) {
options = options || {}; options = options || {};
options.renderTo = Utils.isString( renderTarget ) ? document.getElementById( renderTarget ) : renderTarget; options.renderTo = Utils.isString( renderTarget ) ? document.getElementById( renderTarget ) : renderTarget;
......
...@@ -18,14 +18,17 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -18,14 +18,17 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
getOptions: function ( key ) { getOptions: function ( key ) {
return this._options[ key ]; return this._options[ key ];
}, },
setDefaultOptions: function ( key, val ) { setDefaultOptions: function ( key, val,cover) {
var obj = {}; var obj = {};
if ( Utils.isString( key ) ) { if ( Utils.isString( key ) ) {
obj[ key ] = val; obj[ key ] = val;
} else { } else {
obj = key; obj = key;
} }
utils.extend( this._options, obj, true ); utils.extend( this._options, obj, !cover );
},
setOptions: function ( key, val ) {
this.setDefaultOptions(key,val,true)
}, },
_initMinder: function () { _initMinder: function () {
......
...@@ -21,11 +21,10 @@ var MoveToParentCommand = kity.createClass( 'MoveToParentCommand', { ...@@ -21,11 +21,10 @@ var MoveToParentCommand = kity.createClass( 'MoveToParentCommand', {
for ( var i = nodes.length - 1; i >= 0; i-- ) { for ( var i = nodes.length - 1; i >= 0; i-- ) {
node = nodes[ i ]; node = nodes[ i ];
if ( node.getParent() ) { if ( node.getParent() ) {
node.getParent().removeChild( node ); minder.removeNode( [ node ] );
parent.appendChild( node ); minder.appendChildNode( parent, node );
} }
} }
minder.initStyle( minder.getRoot() );
minder.select( nodes, true ); minder.select( nodes, true );
} }
} ); } );
...@@ -128,6 +127,7 @@ var DragBox = kity.createClass( "DragBox", { ...@@ -128,6 +127,7 @@ var DragBox = kity.createClass( "DragBox", {
this.remove(); this.remove();
this._dragMode = false; this._dragMode = false;
this._dropSucceedTarget = null; this._dropSucceedTarget = null;
this._removeDropHint();
}, },
_drawForDragMode: function () { _drawForDragMode: function () {
this._text.setContent( this._dragSources.length + ' items' ); this._text.setContent( this._dragSources.length + ' items' );
...@@ -192,6 +192,13 @@ var DragBox = kity.createClass( "DragBox", { ...@@ -192,6 +192,13 @@ var DragBox = kity.createClass( "DragBox", {
this._lastSucceedTarget = target; this._lastSucceedTarget = target;
}, },
_removeDropHint: function () {
var lastTarget = this._lastSucceedTarget;
if ( lastTarget ) {
this._removeDropStyle( lastTarget );
}
},
_removeDropStyle: function ( node ) { _removeDropStyle: function ( node ) {
node._layout.bgRect.stroke( 'none' ); node._layout.bgRect.stroke( 'none' );
this._rect.stroke( '#3399ff', 1 ); this._rect.stroke( '#3399ff', 1 );
......
...@@ -97,7 +97,8 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -97,7 +97,8 @@ KityMinder.registerModule( "TextEditModule", function () {
var offset = e.getPosition(); var offset = e.getPosition();
if(Math.abs(offset.y - lastEvtPosition.y) > 2 && Math.abs(lastEvtPosition.x - offset.x) < 1 ){ if(Math.abs(offset.y - lastEvtPosition.y) >= 1 && Math.abs(lastEvtPosition.x - offset.x) <= 1 ){
sel.setHide(); sel.setHide();
mouseDownStatus = false; mouseDownStatus = false;
return; return;
...@@ -134,12 +135,13 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -134,12 +135,13 @@ KityMinder.registerModule( "TextEditModule", function () {
"resize": function ( e ) { "resize": function ( e ) {
sel.setHide(); sel.setHide();
}, },
'execCommand':function(e){ "execCommand": function( e ) {
var cmds = { var cmds = {
'appendchildnode':1, 'appendchildnode' : 1,
'appendsiblingnode':1 'appendsiblingnode' : 1,
'editnode' : 1
}; };
if(cmds[e.commandName]){ if ( cmds[ e.commandName ] ){
var node = km.getSelectedNode(); var node = km.getSelectedNode();
if( !node ){ if( !node ){
......
...@@ -175,6 +175,7 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -175,6 +175,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
switch ( keyCode ) { switch ( keyCode ) {
case keymap.Enter: case keymap.Enter:
case keymap.Tab: case keymap.Tab:
case keymap.F2:
if ( this.keydownNode === this.minderNode ) { if ( this.keydownNode === this.minderNode ) {
this.rollbackStatus(); this.rollbackStatus();
this.setTextEditStatus( false ); this.setTextEditStatus( false );
...@@ -226,8 +227,12 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -226,8 +227,12 @@ Minder.Receiver = kity.createClass( 'Receiver', {
} }
return this; return this;
}, },
getBaseOffset: function ( node ) { getBaseOffset: function ( ) {
var rb = this.textShape.getRenderBox( this.km.getRenderContainer() ); var rb = this.textShape.getRenderBox( this.km.getRenderContainer() );
// if(!this.pr) {
// this.km.getRenderContainer().addShape(this.pr = new kity.Rect().stroke('green'));
// }
// this.pr.setSize(rb.width, rb.height).setPosition(rb.x, rb.y);
return rb; return rb;
}, },
setBaseOffset: function () { setBaseOffset: function () {
...@@ -235,7 +240,7 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -235,7 +240,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
return this; return this;
}, },
setContainerStyle: function () { setContainerStyle: function () {
var textShapeBox = this.getBaseOffset( 'top' ); var textShapeBox = this.getBaseOffset();
this.container.style.cssText = ";left:" + textShapeBox.x + 'px;top:' + ( textShapeBox.y - 5 ) + 'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;'; this.container.style.cssText = ";left:" + textShapeBox.x + 'px;top:' + ( textShapeBox.y - 5 ) + 'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;';
return this; return this;
......
KityMinder.registerModule( "IconModule", function () { KityMinder.registerModule( "IconModule", function () {
var minder = this;
var renderPriorityIcon = function ( node, val ) { var renderPriorityIcon = function ( node, val ) {
var colors = [ "", "#A92E24", "#29A6BD", "#1E8D54", "#eb6100", "#876DDA" ]; var colors = [ "", "#A92E24", "#29A6BD", "#1E8D54", "#eb6100", "#876DDA" ];
var _bg = new kity.Rect().fill( colors[ val ] ).setRadius( 3 ).setWidth( 20 ).setHeight( 20 ); var _bg = new kity.Rect().fill( colors[ val ] ).setRadius( 3 ).setWidth( 20 ).setHeight( 20 );
...@@ -45,8 +46,9 @@ KityMinder.registerModule( "IconModule", function () { ...@@ -45,8 +46,9 @@ KityMinder.registerModule( "IconModule", function () {
if ( val < 5 ) d.close(); if ( val < 5 ) d.close();
_percent.fill( "#29A6BD" ); _percent.fill( "#29A6BD" );
var pre = node.getData( "PriorityIcon" ); var pre = node.getData( "PriorityIcon" );
if ( !pre ) _rc.setTranslate( _contRc.getWidth() - _rc.getWidth() / 2, 0 ); var style = minder.getCurrentLayoutStyle()[ node.getType() ];
else _rc.setTranslate( _contRc.getWidth() + _rc.getWidth() / 2, 0 ); if ( !pre ) _rc.setTranslate( _rc.getWidth() / 2, 0 );
else _rc.setTranslate( _contRc.getWidth() + style.spaceLeft, 0 );
}; };
var setPriorityCommand = kity.createClass( "SetPriorityCommand", ( function () { var setPriorityCommand = kity.createClass( "SetPriorityCommand", ( function () {
return { return {
......
...@@ -146,6 +146,10 @@ KityMinder.registerModule( "KeyboardModule", function () { ...@@ -146,6 +146,10 @@ KityMinder.registerModule( "KeyboardModule", function () {
e.preventDefault(); e.preventDefault();
if ( this.queryCommandState( 'removenode' ) !== -1 ) this.execCommand( 'removenode' ); if ( this.queryCommandState( 'removenode' ) !== -1 ) this.execCommand( 'removenode' );
break; break;
case keys.F2:
e.preventDefault();
if ( this.queryCommandState( 'editnode' ) !== -1 ) this.execCommand( 'editnode' );
break;
case keys.Left: case keys.Left:
navigateTo( this, 'left' ); navigateTo( this, 'left' );
......
...@@ -33,7 +33,6 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -33,7 +33,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
minder.getRenderContainer().addShape( iconShape ); minder.getRenderContainer().addShape( iconShape );
iconShape.addShapes( [ circle, plus, dec ] ); iconShape.addShapes( [ circle, plus, dec ] );
this.update(); this.update();
//this.switchState();
}, },
switchState: function () { switchState: function () {
if ( !this._show ) { if ( !this._show ) {
...@@ -84,7 +83,11 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -84,7 +83,11 @@ KityMinder.registerModule( "LayoutDefault", function () {
padding: [ 15.5, 25.5, 15.5, 25.5 ], padding: [ 15.5, 25.5, 15.5, 25.5 ],
margin: [ 0, 0, 0, 0 ], margin: [ 0, 0, 0, 0 ],
radius: 30, radius: 30,
highlight: 'rgb(254, 219, 0)' highlight: 'rgb(254, 219, 0)',
spaceLeft: 3,
spaceRight: 0,
spaceTop: 3,
spaceBottom: 3
}, },
"main": { "main": {
stroke: new kity.Pen( "white", 2 ).setLineCap( "round" ).setLineJoin( "round" ), stroke: new kity.Pen( "white", 2 ).setLineCap( "round" ).setLineJoin( "round" ),
...@@ -94,7 +97,12 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -94,7 +97,12 @@ KityMinder.registerModule( "LayoutDefault", function () {
fontSize: 16, fontSize: 16,
margin: [ 0, 10, 30, 50 ], margin: [ 0, 10, 30, 50 ],
radius: 10, radius: 10,
highlight: 'rgb(254, 219, 0)' highlight: 'rgb(254, 219, 0)',
spaceLeft: 5,
spaceRight: 0,
spaceTop: 2,
spaceBottom: 2
}, },
"sub": { "sub": {
stroke: new kity.Pen( "white", 2 ).setLineCap( "round" ).setLineJoin( "round" ), stroke: new kity.Pen( "white", 2 ).setLineCap( "round" ).setLineJoin( "round" ),
...@@ -102,7 +110,11 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -102,7 +110,11 @@ KityMinder.registerModule( "LayoutDefault", function () {
fontSize: 12, fontSize: 12,
margin: [ 0, 10, 20, 6 ], margin: [ 0, 10, 20, 6 ],
padding: [ 5, 10, 5.5, 10 ], padding: [ 5, 10, 5.5, 10 ],
highlight: 'rgb(254, 219, 0)' highlight: 'rgb(254, 219, 0)',
spaceLeft: 4,
spaceRight: 0,
spaceTop: 2,
spaceBottom: 2
} }
}; };
//更新背景 //更新背景
...@@ -392,7 +404,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -392,7 +404,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
.clear() .clear()
.moveTo( sX, sY ) .moveTo( sX, sY )
.lineTo( sX, nodeY > sY ? ( nodeY - nodeStyle.margin[ 3 ] ) : ( nodeY + nodeStyle.margin[ 3 ] ) ); .lineTo( sX, nodeY > sY ? ( nodeY - nodeStyle.margin[ 3 ] ) : ( nodeY + nodeStyle.margin[ 3 ] ) );
if ( nodeY > sY ) connect.getDrawer().carcTo( nodeStyle.margin[ 3 ], 0, 1, nodeX, nodeY, 0, 1 ); if ( nodeY > sY ) connect.getDrawer().carcTo( nodeStyle.margin[ 3 ], 0, 1, nodeX, nodeY );
else connect.getDrawer().carcTo( nodeStyle.margin[ 3 ], 0, 0, nodeX, nodeY ); else connect.getDrawer().carcTo( nodeStyle.margin[ 3 ], 0, 0, nodeX, nodeY );
connect.stroke( nodeStyle.stroke ); connect.stroke( nodeStyle.stroke );
} else { } else {
...@@ -430,7 +442,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -430,7 +442,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
var dx = offset.x < 0 ? -offset.x : Math.min( tmpX, 0 ); var dx = offset.x < 0 ? -offset.x : Math.min( tmpX, 0 );
var dy = offset.y < 0 ? -offset.y : Math.min( tmpY, 0 ); var dy = offset.y < 0 ? -offset.y : Math.min( tmpY, 0 );
km.getRenderContainer().fxTranslate( dx, dy, 100, "easeOutQuint" ); minder.getRenderContainer().fxTranslate( dx, dy, 100, "easeOutQuint" );
}; };
var _style = { var _style = {
...@@ -524,20 +536,46 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -524,20 +536,46 @@ KityMinder.registerModule( "LayoutDefault", function () {
updateLayoutVertical( _root ); updateLayoutVertical( _root );
translateNode( _root ); translateNode( _root );
if ( historyPoint ) _root.setPoint( historyPoint.x, historyPoint.y ); if ( historyPoint ) _root.setPoint( historyPoint.x, historyPoint.y );
var expandoptions = minder.getOptions( 'defaultExpand' );
var cur_layer = 0;
var expand_layer = expandoptions.defaultLayer;
var mains = _root.getChildren(); var mains = _root.getChildren();
for ( var i = 0; i < mains.length; i++ ) { for ( var i = 0; i < mains.length; i++ ) {
this.appendChildNode( _root, mains[ i ] ); this.appendChildNode( _root, mains[ i ] );
} }
for ( var j = 0; j < mains.length; j++ ) { cur_layer++;
var c = mains[ j ].getChildren(); //创建一级节点的副本
if ( c.length < 10 && c.length !== 0 ) { var _buffer = ( function () {
this.expandNode( mains[ j ] ); var items = [];
for ( var i = 0; i < mains.length; i++ ) {
items.push( mains[ i ] );
}
return items;
} )();
next = [];
var layer_nolimit = ( expand_layer < 1 ) || false;
var sub_nolimit = ( expandoptions.defaultSubShow < 1 ) || false;
var loopcontinue = function () {
return ( layer_nolimit ? ( _buffer.length !== 0 ) : ( _buffer.length !== 0 && cur_layer < expand_layer ) );
};
while ( loopcontinue() ) {
cur_layer++;
var layer_len = _buffer.length;
for ( var j = 0; j < layer_len; j++ ) {
var c = _buffer[ j ].getChildren();
if ( ( sub_nolimit || ( c.length <= expandoptions.defaultSubShow ) ) && c.length !== 0 ) {
this.expandNode( _buffer[ j ] );
_buffer = _buffer.concat( _buffer[ j ].getChildren() );
}
} }
_buffer.splice( 0, layer_len );
} }
_root.setPoint( _root.getLayout().x, _root.getLayout().y ); _root.setPoint( _root.getLayout().x, _root.getLayout().y );
}, },
appendChildNode: function ( parent, node, focus, sibling ) { appendChildNode: function ( parent, node, focus, sibling ) {
if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && parent.getData( "expand" ) === false ) {
minder.expandNode( parent );
}
minder.handelNodeInsert( node ); minder.handelNodeInsert( node );
node.clearLayout(); node.clearLayout();
node.getContRc().clear(); node.getContRc().clear();
......
...@@ -195,18 +195,54 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -195,18 +195,54 @@ KityMinder.registerModule( "LayoutModule", function () {
} }
}; };
} )() ); } )() );
var EditNodeCommand = kity.createClass( "EditNodeCommand", ( function () {
return {
base: Command,
execute: function ( km ) {
var selectedNode = km.getSelectedNode();
if ( !selectedNode ) {
return null;
}
km.select( selectedNode, true );
},
queryState: function ( km ) {
var selectedNode = km.getSelectedNode();
if ( !selectedNode ) {
return -1;
} else {
return 0;
}
}
};
} )() );
return { return {
"commands": { "commands": {
"appendchildnode": AppendChildNodeCommand, "appendchildnode": AppendChildNodeCommand,
"appendsiblingnode": AppendSiblingNodeCommand, "appendsiblingnode": AppendSiblingNodeCommand,
"removenode": RemoveNodeCommand, "removenode": RemoveNodeCommand,
"editnode": EditNodeCommand,
"switchlayout": SwitchLayoutCommand "switchlayout": SwitchLayoutCommand
}, },
"events": { "events": {
"ready": function () { "ready": function () {
this.setDefaultOptions( 'layoutstyle', this.getLayoutStyleItems() ); this.setDefaultOptions( 'layoutstyle', this.getLayoutStyleItems() );
switchLayout( this, this.getOptions( 'defaultlayoutstyle' ) ); switchLayout( this, this.getOptions( 'defaultlayoutstyle' ) );
//读取cookies
var getCookie = function ( name ) {
var arr, reg = new RegExp( "(^| )" + name + "=([^;]*)(;|$)" );
if ( arr = document.cookie.match( reg ) ) return unescape( arr[ 2 ] );
else return null;
}
var expand = getCookie( 'expand' );
if ( expand ) {
if ( expand === 'all' ) {
this.setOptions( 'defaultExpand', {
'defaultLayer': 0,
'defaultSubShow': 0
} );
}
}
}, },
"click": function ( e ) { "click": function ( e ) {
var ico = e.kityEvent.targetShape && e.kityEvent.targetShape.container; var ico = e.kityEvent.targetShape && e.kityEvent.targetShape.container;
...@@ -236,6 +272,12 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -236,6 +272,12 @@ KityMinder.registerModule( "LayoutModule", function () {
this.execCommand( 'appendchildnode', new MinderNode( this.getLang( 'topic' ) ) ) this.execCommand( 'appendchildnode', new MinderNode( this.getLang( 'topic' ) ) )
}, },
cmdName: 'appendchildnode' cmdName: 'appendchildnode'
}, {
label: this.getLang( 'node.editnode' ),
exec: function () {
this.execCommand( 'editnode', null );
},
cmdName: 'editnode'
}, { }, {
label: this.getLang( 'node.removenode' ), label: this.getLang( 'node.removenode' ),
cmdName: 'removenode' cmdName: 'removenode'
...@@ -249,7 +291,12 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -249,7 +291,12 @@ KityMinder.registerModule( "LayoutModule", function () {
"node": { "node": {
'appendsiblingnode': 'appendsiblingnode', 'appendsiblingnode': 'appendsiblingnode',
'appendchildnode': 'appendchildnode', 'appendchildnode': 'appendchildnode',
'editnode': 'editnode',
'removenode': 'removenode' 'removenode': 'removenode'
},
'defaultExpand': {
'defaultLayer': 0,
'defaultSubShow': 0
} }
} }
}; };
......
...@@ -9,7 +9,8 @@ KityMinder.registerModule( "NodeText", function () { ...@@ -9,7 +9,8 @@ KityMinder.registerModule( "NodeText", function () {
node.getContRc().appendShape( textShape ); node.getContRc().appendShape( textShape );
var style = this.getCurrentLayoutStyle()[ node.getType() ]; var style = this.getCurrentLayoutStyle()[ node.getType() ];
textShape.fill( style.color ).setSize( style.fontSize ); textShape.fill( style.color ).setSize( style.fontSize );
textShape.setPosition( width, textShape.getHeight() * .25 ) textShape.setTranslate( width + style.spaceLeft, 0 );
textShape.setVerticalAlign( 'middle' );
} }
} }
} }
......
...@@ -31,4 +31,7 @@ ...@@ -31,4 +31,7 @@
} }
.kmui-btn-toolbar .kmui-btn .kmui-icon-help { .kmui-btn-toolbar .kmui-btn .kmui-icon-help {
background: url(../images/help.png) no-repeat 2px 2px; background: url(../images/help.png) no-repeat 2px 2px;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-preference {
background: url(../images/setting.png) no-repeat 2px 2px;
} }
\ 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