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