root / trunk / web / dojo / dojox / drawing / manager / Undo.js @ 13
History | View | Annotate | Download (1.04 KB)
| 1 |
/*
|
|---|---|
| 2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
| 3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
| 4 |
see: http://dojotoolkit.org/license for details
|
| 5 |
*/
|
| 6 |
|
| 7 |
|
| 8 |
if(!dojo._hasResource["dojox.drawing.manager.Undo"]){ |
| 9 |
dojo._hasResource["dojox.drawing.manager.Undo"]=true; |
| 10 |
dojo.provide("dojox.drawing.manager.Undo");
|
| 11 |
dojox.drawing.manager.Undo=dojox.drawing.util.oo.declare(function(_1){
|
| 12 |
this.keys=_1.keys;
|
| 13 |
this.undostack=[];
|
| 14 |
this.redostack=[];
|
| 15 |
dojo.connect(this.keys,"onKeyDown",this,"onKeyDown"); |
| 16 |
},{onKeyDown:function(_2){
|
| 17 |
if(!_2.cmmd){
|
| 18 |
return;
|
| 19 |
} |
| 20 |
if(_2.keyCode==90&&!_2.shift){ |
| 21 |
this.undo();
|
| 22 |
}else{
|
| 23 |
if((_2.keyCode==90&&_2.shift)||_2.keyCode==89){ |
| 24 |
this.redo();
|
| 25 |
} |
| 26 |
} |
| 27 |
},add:function(_3){ |
| 28 |
_3.args=dojo.mixin({},_3.args);
|
| 29 |
this.undostack.push(_3);
|
| 30 |
},apply:function(_4,_5,_6){ |
| 31 |
dojo.hitch(_4,_5)(_6); |
| 32 |
},undo:function(){ |
| 33 |
var o=this.undostack.pop(); |
| 34 |
if(!o){
|
| 35 |
return;
|
| 36 |
} |
| 37 |
o.before(); |
| 38 |
this.redostack.push(o);
|
| 39 |
},redo:function(){ |
| 40 |
var o=this.redostack.pop(); |
| 41 |
if(!o){
|
| 42 |
return;
|
| 43 |
} |
| 44 |
if(o.after){
|
| 45 |
o.after(); |
| 46 |
}else{
|
| 47 |
o.before(); |
| 48 |
} |
| 49 |
this.undostack.push(o);
|
| 50 |
}}); |
| 51 |
} |