Subversion Repositories eFlore/Applications.cel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
27 jpm 1
/*
2
 * Ext JS Library 2.0.2
3
 * Copyright(c) 2006-2008, Ext JS, LLC.
4
 * licensing@extjs.com
5
 *
6
 * http://extjs.com/license
7
 */
8
 
9
/*
10
 * Private internal class for reading and applying state
11
 */
12
Ext.LayoutStateManager = function(layout){
13
     // default empty state
14
     this.state = {
15
        north: {},
16
        south: {},
17
        east: {},
18
        west: {}
19
    };
20
};
21
 
22
Ext.LayoutStateManager.prototype = {
23
    init : function(layout, provider){
24
        this.provider = provider;
25
        var state = provider.get(layout.id+"-layout-state");
26
        if(state){
27
            var wasUpdating = layout.isUpdating();
28
            if(!wasUpdating){
29
                layout.beginUpdate();
30
            }
31
            for(var key in state){
32
                if(typeof state[key] != "function"){
33
                    var rstate = state[key];
34
                    var r = layout.getRegion(key);
35
                    if(r && rstate){
36
                        if(rstate.size){
37
                            r.resizeTo(rstate.size);
38
                        }
39
                        if(rstate.collapsed == true){
40
                            r.collapse(true);
41
                        }else{
42
                            r.expand(null, true);
43
                        }
44
                    }
45
                }
46
            }
47
            if(!wasUpdating){
48
                layout.endUpdate();
49
            }
50
            this.state = state;
51
        }
52
        this.layout = layout;
53
        layout.on("regionresized", this.onRegionResized, this);
54
        layout.on("regioncollapsed", this.onRegionCollapsed, this);
55
        layout.on("regionexpanded", this.onRegionExpanded, this);
56
    },
57
 
58
    storeState : function(){
59
        this.provider.set(this.layout.id+"-layout-state", this.state);
60
    },
61
 
62
    onRegionResized : function(region, newSize){
63
        this.state[region.getPosition()].size = newSize;
64
        this.storeState();
65
    },
66
 
67
    onRegionCollapsed : function(region){
68
        this.state[region.getPosition()].collapsed = true;
69
        this.storeState();
70
    },
71
 
72
    onRegionExpanded : function(region){
73
        this.state[region.getPosition()].collapsed = false;
74
        this.storeState();
75
    }
76
};