Commit 342ffba9 authored by campaign's avatar campaign

by zhanyi

parent 68fb69e2
// 选区管理 // 选区管理
kity.extendClass( Minder, function () { kity.extendClass( Minder, function () {
function highlightNode( km, node ) { function highlightNode( km, node ) {
node.setData( "highlight", true ); node.setAttr( "highlight", true );
km.highlightNode( node ); km.highlightNode( node );
} }
function unhighlightNode( km, node ) { function unhighlightNode( km, node ) {
node.setData( "highlight", false ); node.setAttr( "highlight", false );
km.highlightNode( node ); km.highlightNode( node );
} }
return { return {
......
...@@ -269,5 +269,24 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -269,5 +269,24 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
}, },
clearChildren: function () { clearChildren: function () {
this.children = []; this.children = [];
},
isHighlight : function(){
return this.getAttr('highlight')
},
setAttr : function(a,v){
var me = this;
if(utils.isObject(a)){
utils.each(a,function(val,key){
me.setAttr(key,val)
})
}
if(v === undefined || v === null || v === ''){
this.node.removeAttribute(a);
}else {
this.node.setAttribute(a,v);
}
},
getAttr:function(a){
return this.node.getAttribute(a)
} }
} ); } );
\ No newline at end of file
KityMinder.registerModule( "HistoryModule", function () { KityMinder.registerModule( "HistoryModule", function () {
var km = this;
var Scene = kity.createClass( 'Scene', { var Scene = kity.createClass( 'Scene', {
constructor: function ( root ) { constructor: function ( root ) {
this.data = root.clone(); this.data = root.clone();
...@@ -51,8 +53,11 @@ KityMinder.registerModule( "HistoryModule", function () { ...@@ -51,8 +53,11 @@ KityMinder.registerModule( "HistoryModule", function () {
}, },
restore: function () { restore: function () {
var scene = this.list[ this.index ]; var scene = this.list[ this.index ];
this.km.setRoot( scene.cloneData() ); this.km.setRoot( scene.cloneData() );
this.km.removeAllSelectedNodes();
this.km.initStyle(); this.km.initStyle();
this.update(); this.update();
}, },
getScene: function () { getScene: function () {
...@@ -88,9 +93,18 @@ KityMinder.registerModule( "HistoryModule", function () { ...@@ -88,9 +93,18 @@ KityMinder.registerModule( "HistoryModule", function () {
//为km实例添加history管理 //为km实例添加history管理
this.historyManager = new HistoryManager( this ); this.historyManager = new HistoryManager( this );
var keys = {
// /*Backspace*/ 8:1, /*Delete*/ 46:1,
/*Shift*/ 16:1, /*Ctrl*/ 17:1, /*Alt*/ 18:1,
37:1, 38:1, 39:1, 40:1
},
keycont = 0,
lastKeyCode,
saveSceneTimer;
return { return {
defaultOptions: { defaultOptions: {
maxUndoCount: 20 maxUndoCount: 20,
maxInputCount:20
}, },
"commands": { "commands": {
"undo": kity.createClass( "UndoCommand", { "undo": kity.createClass( "UndoCommand", {
...@@ -130,6 +144,34 @@ KityMinder.registerModule( "HistoryModule", function () { ...@@ -130,6 +144,34 @@ KityMinder.registerModule( "HistoryModule", function () {
"events": { "events": {
"saveScene": function ( e ) { "saveScene": function ( e ) {
this.historyManager.saveScene(); this.historyManager.saveScene();
},
"renderNode":function(e){
var node = e.node;
if(node.isHighlight()){
km.select(node);
}
},
"keydown":function(e){
// var orgEvt = e.originEvent;
// var keyCode = orgEvt.keyCode || orgEvt.which;
// if (!keys[keyCode] && !orgEvt.ctrlKey && !orgEvt.metaKey && !orgEvt.shiftKey && !orgEvt.altKey) {
//
//
// if (km.historyManager.list.length == 0) {
// km.historyManager.saveScene();
// }
// clearTimeout(saveSceneTimer);
//
// saveSceneTimer = setTimeout(function(){
// km.historyManager.saveScene();
// },200);
//
// lastKeyCode = keyCode;
// keycont++;
// if (keycont >= km.getOptions('maxInputCount') ) {
// km.historyManager.saveScene()
// }
// }
} }
} }
}; };
......
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