source:
trunk/workshop-routing-foss4g/web/ext/src/state/StateManager.js
@
79
Revision 76, 2.0 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Line | |
---|---|
1 | /*! |
2 | * Ext JS Library 3.4.0 |
3 | * Copyright(c) 2006-2011 Sencha Inc. |
4 | * licensing@sencha.com |
5 | * http://www.sencha.com/license |
6 | */ |
7 | /** |
8 | * @class Ext.state.Manager |
9 | * This is the global state manager. By default all components that are "state aware" check this class |
10 | * for state information if you don't pass them a custom state provider. In order for this class |
11 | * to be useful, it must be initialized with a provider when your application initializes. Example usage: |
12 | <pre><code> |
13 | // in your initialization function |
14 | init : function(){ |
15 | Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); |
16 | var win = new Window(...); |
17 | win.restoreState(); |
18 | } |
19 | </code></pre> |
20 | * @singleton |
21 | */ |
22 | Ext.state.Manager = function(){ |
23 | var provider = new Ext.state.Provider(); |
24 | |
25 | return { |
26 | /** |
27 | * Configures the default state provider for your application |
28 | * @param {Provider} stateProvider The state provider to set |
29 | */ |
30 | setProvider : function(stateProvider){ |
31 | provider = stateProvider; |
32 | }, |
33 | |
34 | /** |
35 | * Returns the current value for a key |
36 | * @param {String} name The key name |
37 | * @param {Mixed} defaultValue The default value to return if the key lookup does not match |
38 | * @return {Mixed} The state data |
39 | */ |
40 | get : function(key, defaultValue){ |
41 | return provider.get(key, defaultValue); |
42 | }, |
43 | |
44 | /** |
45 | * Sets the value for a key |
46 | * @param {String} name The key name |
47 | * @param {Mixed} value The state data |
48 | */ |
49 | set : function(key, value){ |
50 | provider.set(key, value); |
51 | }, |
52 | |
53 | /** |
54 | * Clears a value from the state |
55 | * @param {String} name The key name |
56 | */ |
57 | clear : function(key){ |
58 | provider.clear(key); |
59 | }, |
60 | |
61 | /** |
62 | * Gets the currently configured state provider |
63 | * @return {Provider} The state provider |
64 | */ |
65 | getProvider : function(){ |
66 | return provider; |
67 | } |
68 | }; |
69 | }(); |
Note: See TracBrowser
for help on using the repository browser.