root / trunk / web / dojo / dojox / mobile / app / SceneController.js @ 12
History | View | Annotate | Download (2.48 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.SceneController"]){ |
9 |
dojo._hasResource["dojox.mobile.app.SceneController"]=true; |
10 |
dojo.provide("dojox.mobile.app.SceneController");
|
11 |
dojo.experimental("dojox.mobile.app.SceneController");
|
12 |
dojo.require("dojox.mobile._base");
|
13 |
(function(){
|
14 |
var _1=dojox.mobile.app;
|
15 |
var _2={};
|
16 |
dojo.declare("dojox.mobile.app.SceneController",dojox.mobile.View,{stageController:null,init:function(_3,_4){ |
17 |
this.sceneName=_3;
|
18 |
this.params=_4;
|
19 |
var _5=_1.resolveTemplate(_3);
|
20 |
this._deferredInit=new dojo.Deferred(); |
21 |
dojo.xhrGet({url:_5,handleAs:"text"}).addCallback(dojo.hitch(this,this._setContents)); |
22 |
return this._deferredInit; |
23 |
},_setContents:function(_6){ |
24 |
_2[this.sceneName]=_6;
|
25 |
this.domNode.innerHTML="<div>"+_6+"</div>"; |
26 |
var _7=""; |
27 |
var _8=this.sceneName.split("-"); |
28 |
for(var i=0;i<_8.length;i++){ |
29 |
_7+=_8[i].substring(0,1).toUpperCase()+_8[i].substring(1); |
30 |
} |
31 |
_7+="Assistant";
|
32 |
this.sceneAssistantName=_7;
|
33 |
var _9=this; |
34 |
dojox.mobile.app.loadResourcesForScene(this.sceneName,function(){ |
35 |
var _a;
|
36 |
if(typeof (window[_7])!="undefined"){ |
37 |
_9._initAssistant(); |
38 |
}else{
|
39 |
var _b=_1.resolveAssistant(_9.sceneName);
|
40 |
dojo.xhrGet({url:_b,handleAs:"text"}).addCallback(function(_c){ |
41 |
dojo.eval(_c); |
42 |
_9._initAssistant(); |
43 |
}); |
44 |
} |
45 |
}); |
46 |
},_initAssistant:function(){ |
47 |
var _d=dojo.getObject(this.sceneAssistantName); |
48 |
if(!_d){
|
49 |
throw Error("Unable to resolve scene assistant "+this.sceneAssistantName); |
50 |
} |
51 |
this.assistant=new _d(this.params); |
52 |
this.assistant.controller=this; |
53 |
this.assistant.domNode=this.domNode.firstChild; |
54 |
this.assistant.setup();
|
55 |
this._deferredInit.callback();
|
56 |
},query:function(_e,_f){ |
57 |
return dojo.query(_e,_f||this.domNode); |
58 |
},parse:function(_10){ |
59 |
var _11=this._widgets=dojox.mobile.parser.parse(_10||this.domNode,{controller:this}); |
60 |
for(var i=0;i<_11.length;i++){ |
61 |
_11[i].attr("controller",this); |
62 |
} |
63 |
},getWindowSize:function(){ |
64 |
return {w:window.innerWidth,h:window.innerHeight}; |
65 |
},showAlertDialog:function(_12){ |
66 |
var _13=dojo.marginBox(this.assistant.domNode); |
67 |
var _14=new dojox.mobile.app.AlertDialog(dojo.mixin(_12,{controller:this})); |
68 |
this.assistant.domNode.appendChild(_14.domNode);
|
69 |
_14.show(); |
70 |
},popupSubMenu:function(_15){ |
71 |
var _16=new dojox.mobile.app.ListSelector({controller:this,destroyOnHide:true,onChoose:_15.onChoose}); |
72 |
this.assistant.domNode.appendChild(_16.domNode);
|
73 |
_16.set("data",_15.choices);
|
74 |
_16.show(_15.fromNode); |
75 |
}}); |
76 |
})(); |
77 |
} |