root / trunk / web / dojo / dojox / mobile / app / _base.js
History | View | Annotate | Download (2.95 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.mobile.app._base"]){ |
9 |
dojo._hasResource["dojox.mobile.app._base"]=true; |
10 |
dojo.provide("dojox.mobile.app._base");
|
11 |
dojo.experimental("dojox.mobile.app._base");
|
12 |
dojo.require("dijit._base");
|
13 |
dojo.require("dijit._Widget");
|
14 |
dojo.require("dojox.mobile");
|
15 |
dojo.require("dojox.mobile.parser");
|
16 |
dojo.require("dojox.mobile.app._event");
|
17 |
dojo.require("dojox.mobile.app._Widget");
|
18 |
dojo.require("dojox.mobile.app.StageController");
|
19 |
dojo.require("dojox.mobile.app.SceneController");
|
20 |
dojo.require("dojox.mobile.app.SceneAssistant");
|
21 |
dojo.require("dojox.mobile.app.AlertDialog");
|
22 |
dojo.require("dojox.mobile.app.List");
|
23 |
dojo.require("dojox.mobile.app.ListSelector");
|
24 |
dojo.require("dojox.mobile.app.TextBox");
|
25 |
dojo.require("dojox.mobile.app.ImageView");
|
26 |
dojo.require("dojox.mobile.app.ImageThumbView");
|
27 |
(function(){
|
28 |
var _1;
|
29 |
var _2;
|
30 |
var _3=["dojox.mobile","dojox.mobile.parser"]; |
31 |
var _4={};
|
32 |
var _5;
|
33 |
var _6;
|
34 |
var _7=[];
|
35 |
function _8(_9,_a){ |
36 |
var _b;
|
37 |
var _c;
|
38 |
do{
|
39 |
_b=_9.pop(); |
40 |
if(_b.source){
|
41 |
_c=_b.source; |
42 |
}else{
|
43 |
if(_b.module){
|
44 |
_c=dojo.baseUrl+dojo._getModuleSymbols(_b.module).join("/")+".js"; |
45 |
}else{
|
46 |
alert("Error: invalid JavaScript resource "+dojo.toJson(_b));
|
47 |
return;
|
48 |
} |
49 |
} |
50 |
}while(_9.length>0&&_4[_c]); |
51 |
if(_9.length<1&&_4[_c]){ |
52 |
_a(); |
53 |
return;
|
54 |
} |
55 |
dojo.xhrGet({url:_c,sync:false}).addCallbacks(function(_d){ |
56 |
dojo["eval"](_d);
|
57 |
if(_9.length>0){ |
58 |
_8(_9,_a); |
59 |
}else{
|
60 |
_a(); |
61 |
} |
62 |
},function(){
|
63 |
alert("Failed to load resource "+_c);
|
64 |
}); |
65 |
}; |
66 |
var _e=function(){ |
67 |
_1=new dojox.mobile.app.StageController(_6);
|
68 |
var _f={id:"com.test.app",version:"1.0.0",initialScene:"main"}; |
69 |
if(window["appInfo"]){ |
70 |
dojo.mixin(_f,window["appInfo"]);
|
71 |
} |
72 |
_2=dojox.mobile.app.info=_f; |
73 |
if(_2.title){
|
74 |
var _10=dojo.query("head title")[0]||dojo.create("title",{},dojo.query("head")[0]); |
75 |
document.title=_2.title; |
76 |
} |
77 |
_1.pushScene(_2.initialScene); |
78 |
}; |
79 |
dojo.mixin(dojox.mobile.app,{init:function(_11){ |
80 |
_6=_11||dojo.body(); |
81 |
dojo.subscribe("/dojox/mobile/app/goback",function(){ |
82 |
_1.popScene(); |
83 |
}); |
84 |
dojo.subscribe("/dojox/mobile/app/alert",function(_12){ |
85 |
dojox.mobile.app.getActiveSceneController().showAlertDialog(_12); |
86 |
}); |
87 |
dojo.xhrGet({url:"view-resources.json",load:function(_13){ |
88 |
var _14=[];
|
89 |
if(_13){
|
90 |
_7=_13=dojo.fromJson(_13); |
91 |
for(var i=0;i<_13.length;i++){ |
92 |
if(!_13[i].scene){
|
93 |
_14.push(_13[i]); |
94 |
} |
95 |
} |
96 |
} |
97 |
if(_14.length>0){ |
98 |
_8(_14,_e); |
99 |
}else{
|
100 |
_e(); |
101 |
} |
102 |
},error:_e});
|
103 |
},getActiveSceneController:function(){ |
104 |
return _1.getActiveSceneController();
|
105 |
},getStageController:function(){ |
106 |
return _1;
|
107 |
},loadResources:function(_15,_16){ |
108 |
_8(_15,_16); |
109 |
},loadResourcesForScene:function(_17,_18){ |
110 |
var _19=[];
|
111 |
for(var i=0;i<_7.length;i++){ |
112 |
if(_7[i].scene==_17){
|
113 |
_19.push(_7[i]); |
114 |
} |
115 |
} |
116 |
if(_19.length>0){ |
117 |
_8(_19,_18); |
118 |
}else{
|
119 |
_18(); |
120 |
} |
121 |
},resolveTemplate:function(_1a){ |
122 |
return "app/views/"+_1a+"/"+_1a+"-scene.html"; |
123 |
},resolveAssistant:function(_1b){ |
124 |
return "app/assistants/"+_1b+"-assistant.js"; |
125 |
}}); |
126 |
})(); |
127 |
} |