Commit e4c96c31 authored by campaign's avatar campaign

Merge branch 'dev' of https://github.com/kitygraph/kityminder into dev

parents 0e874edc 424e8b4b
...@@ -16,5 +16,6 @@ ...@@ -16,5 +16,6 @@
<script> <script>
minder = KM.createMinder(kityminder); minder = KM.createMinder(kityminder);
minder.execCommand("switchlayout","default"); minder.execCommand("switchlayout","default");
minder.execCommand("appendchildnode",new MinderNode());
</script> </script>
</html> </html>
\ No newline at end of file
...@@ -13,18 +13,12 @@ $dependency = Array( ...@@ -13,18 +13,12 @@ $dependency = Array(
'src/core/minder.module.js', 'src/core/minder.module.js',
'src/core/minder.command.js', 'src/core/minder.command.js',
'src/core/minder.node.js', 'src/core/minder.node.js',
'src/core/minder.select.js',
'src/module/history.js', 'src/module/history.js',
'src/module/icon.js', 'src/module/icon.js',
'src/module/layout.js', 'src/module/layout.js',
'src/module/layout.default.js', 'src/module/layout.default.js',
'src/module/layout.green.js', 'src/module/layout.green.js',
'src/module/mouse.js', 'src/core/minder.select.js',
'src/module/keyboard.js',
'src/module/editor.js',
'src/module/editor.cursor.js',
'src/module/editor.range.js',
'src/module/editor.receiver.js'
); );
$content = ""; $content = "";
......
<?php
/**
* Created by PhpStorm.
* User: dongyancen
* Date: 14-1-15
* Time: 下午6:50
*/
Header('Location:../spec/tools/list.php');
?>
\ No newline at end of file
...@@ -24,7 +24,7 @@ kity.extendClass( Minder, { ...@@ -24,7 +24,7 @@ kity.extendClass( Minder, {
execCommand: function ( name ) { execCommand: function ( name ) {
name = name.toLowerCase(); name = name.toLowerCase();
var cmdArgs = utils.argsToArray(arguments,1), var cmdArgs = Utils.argsToArray( arguments, 1 ),
cmd, stoped, result, eventParams; cmd, stoped, result, eventParams;
var me = this; var me = this;
cmd = this._getCommand( name ); cmd = this._getCommand( name );
......
...@@ -15,6 +15,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -15,6 +15,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
constructor: function ( options ) { constructor: function ( options ) {
this._options = Utils.extend( window.KITYMINDER_CONFIG || {}, MinderDefaultOptions, options ); this._options = Utils.extend( window.KITYMINDER_CONFIG || {}, MinderDefaultOptions, options );
this._layoutStyles = {}; this._layoutStyles = {};
this._currentStyle = "";
this._initEvents(); this._initEvents();
this._initMinder(); this._initMinder();
this._initSelection(); this._initSelection();
...@@ -54,6 +55,13 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -54,6 +55,13 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
getLayoutStyle: function ( name ) { getLayoutStyle: function ( name ) {
return this._layoutStyles[ name ]; return this._layoutStyles[ name ];
}, },
getCurrentStyle: function () {
return this._currentStyle;
},
setCurrentStyle: function ( name ) {
this._currentStyle = name;
return name;
},
getRenderTarget: function () { getRenderTarget: function () {
return this._renderTarget; return this._renderTarget;
} }
......
// 选区管理 // 选区管理
kity.extendClass( Minder, function(){ kity.extendClass( Minder, function () {
function highlightNode(km,node){ function highlightNode( km, node ) {
node.setData( "highlight", true ); node.setData( "highlight", true );
km.renderNode( node ); km.renderNode( node );
} }
function unhighlightNode(km,node){
function unhighlightNode( km, node ) {
node.setData( "highlight", false ); node.setData( "highlight", false );
km.renderNode( node ); km.renderNode( node );
} }
...@@ -14,52 +15,53 @@ kity.extendClass( Minder, function(){ ...@@ -14,52 +15,53 @@ kity.extendClass( Minder, function(){
}, },
getSelectedNodes: function () { getSelectedNodes: function () {
//如果没有选中节点,默认是root节点 //如果没有选中节点,默认是root节点
if(this._selectedNodes.length == 0){ if ( this._selectedNodes.length === 0 ) {
this._selectedNodes.push(this.getRoot()) this._selectedNodes.push( this.getRoot() );
} }
//不能克隆返回,会对当前选区操作,从而影响querycommand //不能克隆返回,会对当前选区操作,从而影响querycommand
return this._selectedNodes; return this._selectedNodes;
}, },
getSelectedNode:function(){ getSelectedNode: function () {
return this.getSelectedNodes()[0] return this.getSelectedNodes()[ 0 ];
}, },
removeAllSelectedNodes:function(){ removeAllSelectedNodes: function () {
utils.each(this.getSelectedNodes(),function(i,n){ var me = this;
unhighlightNode(this,n); Utils.each( this.getSelectedNodes(), function ( i, n ) {
}); unhighlightNode( me, n );
this._selectedNodes = [] } );
this._selectedNodes = [];
}, },
select: function ( nodes ) { select: function ( nodes ) {
this.removeAllSelectedNodes(); this.removeAllSelectedNodes();
var me = this; var me = this;
utils.each( utils.isArray(nodes) ? nodes : [nodes],function(i,n){ utils.each( utils.isArray( nodes ) ? nodes : [ nodes ], function ( i, n ) {
me._selectedNodes.push(n); me._selectedNodes.push( n );
highlightNode(this,n) highlightNode( me, n );
}); } );
return this; return this;
}, },
isNodeSelected: function ( node ) { isNodeSelected: function ( node ) {
return node.getData('highlight') === true return node.getData( 'highlight' ) === true
}, },
//当前选区中的节点在给定的节点范围内的保留选中状态,没在给定范围的取消选中,给定范围中的但没在当前选中范围的也做选中效果 //当前选区中的节点在给定的节点范围内的保留选中状态,没在给定范围的取消选中,给定范围中的但没在当前选中范围的也做选中效果
toggleSelect: function ( nodes ) { toggleSelect: function ( nodes ) {
nodes = utils.isArray(nodes) ? nodes : [nodes]; nodes = utils.isArray( nodes ) ? nodes : [ nodes ];
var selectedNodes = this.getSelectedNodes().slice(0); var selectedNodes = this.getSelectedNodes().slice( 0 );
this.removeAllSelectedNodes(); this.removeAllSelectedNodes();
for(var i= 0,n; n = selectedNodes[i];){ for ( var i = 0, n; n = selectedNodes[ i ]; ) {
var index = utils.indexOf(nodes,n); var index = utils.indexOf( nodes, n );
if(index != -1){ if ( index != -1 ) {
nodes.push(n); nodes.push( n );
i++; i++;
}else{ } else {
unhighlightNode(this,n); unhighlightNode( this, n );
selectedNodes.splice(i,1) selectedNodes.splice( i, 1 )
} }
} }
var me = this; var me = this;
utils.each(nodes,function(i,n){ utils.each( nodes, function ( i, n ) {
highlightNode(me,n) highlightNode( me, n )
}); } );
this._selectedNodes = nodes; this._selectedNodes = nodes;
} }
} }
......
This diff is collapsed.
...@@ -7,8 +7,8 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -7,8 +7,8 @@ KityMinder.registerModule( "LayoutModule", function () {
if ( !_style ) return false; if ( !_style ) return false;
km.renderNode = _style.renderNode; km.renderNode = _style.renderNode;
km.initStyle = _style.initStyle; km.initStyle = _style.initStyle;
km.createChildNode = _style.createChildNode; km.appendChildNode = _style.appendChildNode;
km.createSiblingNode = _style.createSiblingNode; km.appendSiblingNode = _style.appendSiblingNode;
km.removeNode = _style.removeNode; km.removeNode = _style.removeNode;
//清空节点上附加的数据 //清空节点上附加的数据
var _root = km.getRoot(); var _root = km.getRoot();
...@@ -21,35 +21,42 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -21,35 +21,42 @@ KityMinder.registerModule( "LayoutModule", function () {
} }
}; };
} )() ); } )() );
var CreateChildNodeCommand = kity.createClass( "CreateChildNodeCommand", ( function () { var AppendChildNodeCommand = kity.createClass( "AppendChildNodeCommand", ( function () {
return { return {
base: Command, base: Command,
execute: function ( km, parent ) { execute: function ( km, node ) {
return km.createChildNode( parent ); var parent = km.getSelectedNode();
km.appendChildNode( parent, node );
km.select( node );
return node;
} }
}; };
} )() ); } )() );
var CreateSiblingNodeCommand = kity.createClass( "CreateSiblingNodeCommand", ( function () { var AppendSiblingNodeCommand = kity.createClass( "AppendSiblingNodeCommand", ( function () {
return { return {
base: Command, base: Command,
execute: function ( km, sibling ) { execute: function ( km, node ) {
return km.createSiblingNode( sibling ); //km.select( node );
var sibling = km.getSelectedNode();
km.appendSiblingNode( sibling, node );
km.select( node );
return node;
} }
}; };
} )() ); } )() );
var RemoveNodeCommand = kity.createClass( "RemoveNodeCommand", ( function () { var RemoveNodeCommand = kity.createClass( "RemoveNodeCommand", ( function () {
return { return {
base: Command, base: Command,
execute: function ( km, node ) { execute: function ( km, nodes ) {
km.removeNode( node ); km.removeNode( nodes );
} }
}; };
} )() ); } )() );
return { return {
"commands": { "commands": {
"createchildnode": CreateChildNodeCommand, "appendchildnode": AppendChildNodeCommand,
"createsiblingnode": CreateSiblingNodeCommand, "appendsiblingnode": AppendSiblingNodeCommand,
"removenode": RemoveNodeCommand, "removenode": RemoveNodeCommand,
"switchlayout": SwitchLayoutCommand "switchlayout": SwitchLayoutCommand
} }
......
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