root / trunk / web / dojo / dojox / storage / manager.js
History | View | Annotate | Download (2.31 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.storage.manager"]){ |
9 |
dojo._hasResource["dojox.storage.manager"]=true; |
10 |
dojo.provide("dojox.storage.manager");
|
11 |
dojox.storage.manager=new function(){ |
12 |
this.currentProvider=null; |
13 |
this.available=false; |
14 |
this.providers=[];
|
15 |
this._initialized=false; |
16 |
this._onLoadListeners=[];
|
17 |
this.initialize=function(){ |
18 |
this.autodetect();
|
19 |
}; |
20 |
this.register=function(_1,_2){ |
21 |
this.providers.push(_2);
|
22 |
this.providers[_1]=_2;
|
23 |
}; |
24 |
this.setProvider=function(_3){ |
25 |
}; |
26 |
this.autodetect=function(){ |
27 |
if(this._initialized){ |
28 |
return;
|
29 |
} |
30 |
var _4=dojo.config["forceStorageProvider"]||false; |
31 |
var _5;
|
32 |
for(var i=0;i<this.providers.length;i++){ |
33 |
_5=this.providers[i];
|
34 |
if(_4&&_4==_5.declaredClass){
|
35 |
_5.isAvailable(); |
36 |
break;
|
37 |
}else{
|
38 |
if(!_4&&_5.isAvailable()){
|
39 |
break;
|
40 |
} |
41 |
} |
42 |
} |
43 |
if(!_5){
|
44 |
this._initialized=true; |
45 |
this.available=false; |
46 |
this.currentProvider=null; |
47 |
console.warn("No storage provider found for this platform");
|
48 |
this.loaded();
|
49 |
return;
|
50 |
} |
51 |
this.currentProvider=_5;
|
52 |
dojo.mixin(dojox.storage,this.currentProvider);
|
53 |
dojox.storage.initialize(); |
54 |
this._initialized=true; |
55 |
this.available=true; |
56 |
}; |
57 |
this.isAvailable=function(){ |
58 |
return this.available; |
59 |
}; |
60 |
this.addOnLoad=function(_6){ |
61 |
this._onLoadListeners.push(_6);
|
62 |
if(this.isInitialized()){ |
63 |
this._fireLoaded();
|
64 |
} |
65 |
}; |
66 |
this.removeOnLoad=function(_7){ |
67 |
for(var i=0;i<this._onLoadListeners.length;i++){ |
68 |
if(_7==this._onLoadListeners[i]){ |
69 |
this._onLoadListeners=this._onLoadListeners.splice(i,1); |
70 |
break;
|
71 |
} |
72 |
} |
73 |
}; |
74 |
this.isInitialized=function(){ |
75 |
if(this.currentProvider!=null&&this.currentProvider.declaredClass=="dojox.storage.FlashStorageProvider"&&dojox.flash.ready==false){ |
76 |
return false; |
77 |
}else{
|
78 |
return this._initialized; |
79 |
} |
80 |
}; |
81 |
this.supportsProvider=function(_8){ |
82 |
try{
|
83 |
var _9=eval("new "+_8+"()"); |
84 |
var _a=_9.isAvailable();
|
85 |
if(!_a){
|
86 |
return false; |
87 |
} |
88 |
return _a;
|
89 |
} |
90 |
catch(e){
|
91 |
return false; |
92 |
} |
93 |
}; |
94 |
this.getProvider=function(){ |
95 |
return this.currentProvider; |
96 |
}; |
97 |
this.loaded=function(){ |
98 |
this._fireLoaded();
|
99 |
}; |
100 |
this._fireLoaded=function(){ |
101 |
dojo.forEach(this._onLoadListeners,function(i){ |
102 |
try{
|
103 |
i(); |
104 |
} |
105 |
catch(e){
|
106 |
} |
107 |
}); |
108 |
}; |
109 |
this.getResourceList=function(){ |
110 |
var _b=[];
|
111 |
dojo.forEach(dojox.storage.manager.providers,function(_c){
|
112 |
_b=_b.concat(_c.getResourceList()); |
113 |
}); |
114 |
return _b;
|
115 |
}; |
116 |
}; |
117 |
} |