Commit 6810fcd8 authored by Akikonata's avatar Akikonata

store

parent d3a35581
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
'KITYMINDER_HOME_URL': getKMBasePath(), 'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏 //定义工具栏
toolbars: [ toolbars: [
'hand zoom-in zoom-out expand contract | undo redo | bold italic | fontfamily fontsize forecolor | saveto | hyperlink unhyperlink | markers | node | preference | help' 'hand zoom-in zoom-out expand contract | undo redo | bold italic | fontfamily fontsize forecolor | saveto | hyperlink unhyperlink | markers | node | help'
] ]
//只读模式,默认是false //只读模式,默认是false
//readOnly: true //readOnly: true
...@@ -82,10 +82,10 @@ ...@@ -82,10 +82,10 @@
//,zIndex : 1000 //,zIndex : 1000
//设置初始加载时展开的层数和子节点数目阈值 //设置初始加载时展开的层数和子节点数目阈值
//默认是全部展开,0表示全部展开 //默认是全部展开,0表示全部展开
, // ,
defaultExpand: { // defaultExpand: {
defaultLayer: 1, // defaultLayer: 1,
defaultSubShow: 5 // defaultSubShow: 5
} // }
}; };
} )(); } )();
\ No newline at end of file
...@@ -510,6 +510,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -510,6 +510,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
}, },
initStyle: function ( expandall ) { initStyle: function ( expandall ) {
var _root = minder.getRoot(); var _root = minder.getRoot();
console.log( _root.getLayout() );
var historyPoint = _root.getPoint(); var historyPoint = _root.getPoint();
if ( historyPoint ) historyPoint = JSON.parse( JSON.stringify( historyPoint ) ); if ( historyPoint ) historyPoint = JSON.parse( JSON.stringify( historyPoint ) );
minder.handelNodeInsert( _root ); minder.handelNodeInsert( _root );
...@@ -541,50 +542,74 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -541,50 +542,74 @@ 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 _buffer = [ _root ];
var cur_layer = 0;
var expand_layer = expandoptions.defaultLayer;
var mains = _root.getChildren();
for ( var i = 0; i < mains.length; i++ ) {
this.appendChildNode( _root, mains[ i ] );
}
cur_layer++;
var clonelayer0 = function () {
var items = [];
for ( var i = 0; i < mains.length; i++ ) {
items.push( mains[ i ] );
}
return items;
};
//创建一级节点的副本
var _buffer = clonelayer0();
next = [];
var layer_nolimit = expandall || ( expand_layer < 1 ) || false;
var sub_nolimit = expandall || ( expandoptions.defaultSubShow < 1 ) || false;
while ( _buffer.length !== 0 ) { while ( _buffer.length !== 0 ) {
cur_layer++; var parent = _buffer[ 0 ].getParent();
var layer_len = _buffer.length; var c = _buffer[ 0 ].getChildren();
for ( var j = 0; j < layer_len; j++ ) { if ( parent ) {
var c = _buffer[ j ].getChildren(); for ( var i = 0; i < c.length; i++ ) {
if ( this.appendChildNode( parent, c[ i ] );
(
( ( sub_nolimit || ( c.length <= expandoptions.defaultSubShow ) ) && ( layer_nolimit || ( cur_layer <= expand_layer ) ) ) ||
_buffer[ j ].getLayout().expand
) && c.length !== 0 ) {
this.expandNode( _buffer[ j ] );
_buffer = _buffer.concat( _buffer[ j ].getChildren() );
} }
} }
_buffer.splice( 0, layer_len ); _buffer = _buffer.concat( c );
_buffer.shift();
} }
// var expandoptions = minder.getOptions( 'defaultExpand' );
// var cur_layer = 0;
// var expand_layer = expandoptions.defaultLayer;
// var mains = _root.getChildren();
// for ( var i = 0; i < mains.length; i++ ) {
// this.appendChildNode( _root, mains[ i ] );
// }
// cur_layer++;
// var clonelayer0 = function () {
// var items = [];
// for ( var i = 0; i < mains.length; i++ ) {
// items.push( mains[ i ] );
// }
// return items;
// };
//创建一级节点的副本
// var _buffer = clonelayer0();
// while ( _buffer.length !== 0 ) {
// var layer_len = _buffer.length;
// for ( var j = 0; j < layer_len; j++ ) {
// var c = _buffer[ j ].getChildren();
// if ( c.length !== 0 ) {
// this.expandNode( _buffer[ j ] );
// _buffer = _buffer.concat( _buffer[ j ].getChildren() );
// }
// }
// _buffer.splice( 0, layer_len );
// }
// var layer_nolimit = expandall || ( expand_layer < 1 ) || false;
// var sub_nolimit = expandall || ( expandoptions.defaultSubShow < 1 ) || false;
// while ( _buffer.length !== 0 ) {
// 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 ) ) && ( layer_nolimit || ( cur_layer <= expand_layer ) ) ) ||
// // _buffer[ j ].getLayout().expand
// // ) && c.length !== 0 ) {
// if ( 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 ) {
minder.handelNodeInsert( node ); minder.handelNodeInsert( node );
var oldLayout = node.getLayout();
node.clearLayout(); node.clearLayout();
node.getContRc().clear(); node.getContRc().clear();
var Layout = node.getLayout(); var Layout = node.getLayout();
Layout.expand = false; Layout.expand = false;
if ( oldLayout ) Layout.expand = oldLayout;
if ( parent.getType() !== 'root' ) { if ( parent.getType() !== 'root' ) {
parent.getLayout().expand = true; parent.getLayout().expand = true;
} }
...@@ -741,6 +766,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -741,6 +766,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
var isExpand, node; var isExpand, node;
if ( ico instanceof MinderNode ) { if ( ico instanceof MinderNode ) {
node = ico; node = ico;
debugger;
isExpand = node.getLayout().shicon.switchState(); isExpand = node.getLayout().shicon.switchState();
} else { } else {
isExpand = ico.icon.switchState(); isExpand = ico.icon.switchState();
......
...@@ -46,6 +46,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -46,6 +46,7 @@ KityMinder.registerModule( "LayoutModule", function () {
var _root = this.getRoot(); var _root = this.getRoot();
_root.preTraverse( function ( n ) { _root.preTraverse( function ( n ) {
var oldLayout = n.getLayout();
n.clearLayout(); n.clearLayout();
} ); } );
this.getLayoutStyle( curStyle ).initStyle.call( this, expandall ); this.getLayoutStyle( curStyle ).initStyle.call( this, expandall );
......
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