root / trunk / web / dojo / dojox / mobile / app / AlertDialog.js @ 13
History | View | Annotate | Download (2.66 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.AlertDialog"]){ |
9 |
dojo._hasResource["dojox.mobile.app.AlertDialog"]=true; |
10 |
dojo.provide("dojox.mobile.app.AlertDialog");
|
11 |
dojo.experimental("dojox.mobile.app.AlertDialog");
|
12 |
dojo.require("dijit._Widget");
|
13 |
dojo.declare("dojox.mobile.app.AlertDialog",dijit._Widget,{title:"",text:"",controller:null,buttons:null,defaultButtonLabel:"OK",onChoose:null,constructor:function(){ |
14 |
this.onClick=dojo.hitch(this,this.onClick); |
15 |
this._handleSelect=dojo.hitch(this,this._handleSelect); |
16 |
},buildRendering:function(){ |
17 |
this.domNode=dojo.create("div",{"class":"alertDialog"}); |
18 |
var _1=dojo.create("div",{"class":"alertDialogBody"},this.domNode); |
19 |
dojo.create("div",{"class":"alertTitle",innerHTML:this.title||""},_1); |
20 |
dojo.create("div",{"class":"alertText",innerHTML:this.text||""},_1); |
21 |
var _2=dojo.create("div",{"class":"alertBtns"},_1); |
22 |
if(!this.buttons||this.buttons.length==0){ |
23 |
this.buttons=[{label:this.defaultButtonLabel,value:"ok","class":"affirmative"}]; |
24 |
} |
25 |
var _3=this; |
26 |
dojo.forEach(this.buttons,function(_4){ |
27 |
var _5=new dojox.mobile.Button({btnClass:_4["class"]||"",label:_4.label}); |
28 |
_5._dialogValue=_4.value; |
29 |
dojo.place(_5.domNode,_2); |
30 |
_3.connect(_5,"onClick",_3._handleSelect);
|
31 |
}); |
32 |
var _6=this.controller.getWindowSize(); |
33 |
this.mask=dojo.create("div",{"class":"dialogUnderlayWrapper",innerHTML:"<div class=\"dialogUnderlay\"></div>",style:{width:_6.w+"px",height:_6.h+"px"}},this.controller.assistant.domNode); |
34 |
this.connect(this.mask,"onclick",function(){ |
35 |
_3.onChoose&&_3.onChoose(); |
36 |
_3.hide(); |
37 |
}); |
38 |
},postCreate:function(){ |
39 |
this.subscribe("/dojox/mobile/app/goback",this._handleSelect); |
40 |
},_handleSelect:function(_7){ |
41 |
var _8;
|
42 |
if(_7&&_7.target){
|
43 |
_8=_7.target; |
44 |
while(!dijit.byNode(_8)){
|
45 |
_8-_8.parentNode; |
46 |
} |
47 |
} |
48 |
if(this.onChoose){ |
49 |
this.onChoose(_8?dijit.byNode(_8)._dialogValue:undefined); |
50 |
} |
51 |
this.hide();
|
52 |
},show:function(){ |
53 |
this._doTransition(1); |
54 |
},hide:function(){ |
55 |
this._doTransition(-1); |
56 |
},_doTransition:function(_9){ |
57 |
var _a;
|
58 |
var h=dojo.marginBox(this.domNode.firstChild).h; |
59 |
var _b=this.controller.getWindowSize().h; |
60 |
var _c=_b-h;
|
61 |
var _d=_b;
|
62 |
var _e=dojo.fx.slideTo({node:this.domNode,duration:400,top:{start:_9<0?_c:_d,end:_9<0?_d:_c}}); |
63 |
var _f=dojo[_9<0?"fadeOut":"fadeIn"]({node:this.mask,duration:400}); |
64 |
var _a=dojo.fx.combine([_e,_f]);
|
65 |
var _10=this; |
66 |
dojo.connect(_a,"onEnd",this,function(){ |
67 |
if(_9<0){ |
68 |
_10.domNode.style.display="none";
|
69 |
dojo.destroy(_10.domNode); |
70 |
dojo.destroy(_10.mask); |
71 |
} |
72 |
}); |
73 |
_a.play(); |
74 |
},destroy:function(){ |
75 |
this.inherited(arguments); |
76 |
dojo.destroy(this.mask);
|
77 |
},onClick:function(){ |
78 |
}}); |
79 |
} |