Last change
on this file was
483,
checked in by hendrikvanantwerpen, 11 years ago
|
Added Dojo 1.9.3 release.
|
-
Property svn:executable set to
*
|
File size:
1.2 KB
|
Rev | Line | |
---|
[483] | 1 | define(["dojo", "../util/oo"],//, "../defaults"], |
---|
| 2 | function(dojo, oo){ |
---|
| 3 | |
---|
| 4 | //dojox.drawing.manager.Undo = |
---|
| 5 | return oo.declare( |
---|
| 6 | function(options){ |
---|
| 7 | this.keys = options.keys; |
---|
| 8 | this.undostack = []; |
---|
| 9 | this.redostack = []; |
---|
| 10 | dojo.connect(this.keys, "onKeyDown", this, "onKeyDown"); |
---|
| 11 | }, |
---|
| 12 | { |
---|
| 13 | // summary: |
---|
| 14 | // Handles the Undo in drawing. |
---|
| 15 | // NOTE: Only partially implemented!!! There is very |
---|
| 16 | // little actual undo functionality! |
---|
| 17 | |
---|
| 18 | onKeyDown: function(evt){ |
---|
| 19 | if(!evt.cmmd && !evt.ctrl){ return; } |
---|
| 20 | |
---|
| 21 | if(evt.keyCode==90 && !evt.shift){ |
---|
| 22 | this.undo(); |
---|
| 23 | }else if((evt.keyCode == 90 && evt.shift) || evt.keyCode==89){ |
---|
| 24 | this.redo(); |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | }, |
---|
| 28 | add: function(stack){ |
---|
| 29 | //console.log("undo add", stack) |
---|
| 30 | stack.args = dojo.mixin({}, stack.args); |
---|
| 31 | this.undostack.push(stack); |
---|
| 32 | }, |
---|
| 33 | apply: function(scope, method, args){ |
---|
| 34 | dojo.hitch(scope, method)(args); |
---|
| 35 | }, |
---|
| 36 | undo: function(){ |
---|
| 37 | |
---|
| 38 | var o = this.undostack.pop(); |
---|
| 39 | console.log("undo!", o); |
---|
| 40 | if(!o){ return; } |
---|
| 41 | |
---|
| 42 | o.before(); |
---|
| 43 | |
---|
| 44 | this.redostack.push(o); |
---|
| 45 | }, |
---|
| 46 | redo: function(){ |
---|
| 47 | console.log("redo!"); |
---|
| 48 | var o = this.redostack.pop(); |
---|
| 49 | if(!o){ return; } |
---|
| 50 | if(o.after){ |
---|
| 51 | o.after(); |
---|
| 52 | }else{ |
---|
| 53 | o.before(); ///?????? |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | this.undostack.push(o); |
---|
| 57 | } |
---|
| 58 | } |
---|
| 59 | ); |
---|
| 60 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.