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