source: Dev/branches/rest-dojo-ui/client/dojox/drawing/manager/Undo.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

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