StateManager_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
/*
* Ext JS Library 2.0.2
* Copyright(c) 2006-2008, Ext JS, LLC.
* licensing@extjs.com
*
* http://extjs.com/license
*/
/**
* @class Ext.state.Manager
* This is the global state manager. By default all components that are "state aware" check this class
* for state information if you don't pass them a custom state provider. In order for this class
* to be useful, it must be initialized with a provider when your application initializes.
<pre><code>
// in your initialization function
init : function(){
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
...
// supposed you have a {@link Ext.BorderLayout}
var layout = new Ext.BorderLayout(...);
layout.restoreState();
// or a {Ext.BasicDialog}
var dialog = new Ext.BasicDialog(...);
dialog.restoreState();
</code></pre>
* @singleton
*/
Ext.state.Manager = function(){
var provider = new Ext.state.Provider();
return {
/**
* Configures the default state provider for your application
* @param {Provider} stateProvider The state provider to set
*/
setProvider : function(stateProvider){
provider = stateProvider;
},
/**
* Returns the current value for a key
* @param {String} name The key name
* @param {Mixed} defaultValue The default value to return if the key lookup does not match
* @return {Mixed} The state data
*/
get : function(key, defaultValue){
return provider.get(key, defaultValue);
},
/**
* Sets the value for a key
* @param {String} name The key name
* @param {Mixed} value The state data
*/
set : function(key, value){
provider.set(key, value);
},
/**
* Clears a value from the state
* @param {String} name The key name
*/
clear : function(key){
provider.clear(key);
},
/**
* Gets the currently configured state provider
* @return {Provider} The state provider
*/
getProvider : function(){
return provider;
}
};
}();