Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / mobile / compat.js

History | View | Annotate | Download (8.12 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.compat"]){
9
dojo._hasResource["dojox.mobile.compat"]=true;
10
dojo.provide("dojox.mobile.compat");
11
dojo.require("dojo._base.fx");
12
dojo.require("dojo.fx");
13
dojo.require("dojox.fx.flip");
14
dojo.extend(dojox.mobile.View,{_doTransition:function(_1,_2,_3,_4){
15
var _5;
16
this.wakeUp(_2);
17
if(!_3||_3=="none"){
18
_2.style.display="";
19
_1.style.display="none";
20
_2.style.left="0px";
21
this.invokeCallback();
22
}else{
23
if(_3=="slide"){
24
var w=_1.offsetWidth;
25
var s1=dojo.fx.slideTo({node:_1,duration:400,left:-w*_4,top:_1.offsetTop});
26
var s2=dojo.fx.slideTo({node:_2,duration:400,left:0});
27
_2.style.position="absolute";
28
_2.style.left=w*_4+"px";
29
_2.style.display="";
30
_5=dojo.fx.combine([s1,s2]);
31
dojo.connect(_5,"onEnd",this,function(){
32
_1.style.display="none";
33
_2.style.position="relative";
34
this.invokeCallback();
35
});
36
_5.play();
37
}else{
38
if(_3=="flip"){
39
_5=dojox.fx.flip({node:_1,dir:"right",depth:0.5,duration:400});
40
_2.style.position="absolute";
41
_2.style.left="0px";
42
dojo.connect(_5,"onEnd",this,function(){
43
_1.style.display="none";
44
_2.style.position="relative";
45
_2.style.display="";
46
this.invokeCallback();
47
});
48
_5.play();
49
}else{
50
if(_3=="fade"){
51
_5=dojo.fx.chain([dojo.fadeOut({node:_1,duration:600}),dojo.fadeIn({node:_2,duration:600})]);
52
_2.style.position="absolute";
53
_2.style.left="0px";
54
_2.style.display="";
55
dojo.style(_2,"opacity",0);
56
dojo.connect(_5,"onEnd",this,function(){
57
_1.style.display="none";
58
_2.style.position="relative";
59
dojo.style(_1,"opacity",1);
60
this.invokeCallback();
61
});
62
_5.play();
63
}
64
}
65
}
66
}
67
},wakeUp:function(_6){
68
if(dojo.isIE&&!_6._wokeup){
69
_6._wokeup=true;
70
var _7=_6.style.display;
71
_6.style.display="";
72
var _8=_6.getElementsByTagName("*");
73
for(var i=0,_9=_8.length;i<_9;i++){
74
var _a=_8[i].style.display;
75
_8[i].style.display="none";
76
_8[i].style.display="";
77
_8[i].style.display=_a;
78
}
79
_6.style.display=_7;
80
}
81
}});
82
dojo.extend(dojox.mobile.Switch,{buildRendering:function(){
83
this.domNode=this.srcNodeRef||dojo.doc.createElement("DIV");
84
this.domNode.className="mblSwitch";
85
this.domNode.innerHTML="<div class=\"mblSwitchInner\">"+"<div class=\"mblSwitchBg mblSwitchBgLeft\">"+"<div class=\"mblSwitchCorner mblSwitchCorner1T\"></div>"+"<div class=\"mblSwitchCorner mblSwitchCorner2T\"></div>"+"<div class=\"mblSwitchCorner mblSwitchCorner3T\"></div>"+"<div class=\"mblSwitchText mblSwitchTextLeft\">"+this.leftLabel+"</div>"+"<div class=\"mblSwitchCorner mblSwitchCorner1B\"></div>"+"<div class=\"mblSwitchCorner mblSwitchCorner2B\"></div>"+"<div class=\"mblSwitchCorner mblSwitchCorner3B\"></div>"+"</div>"+"<div class=\"mblSwitchBg mblSwitchBgRight\">"+"<div class=\"mblSwitchCorner mblSwitchCorner1T\"></div>"+"<div class=\"mblSwitchCorner mblSwitchCorner2T\"></div>"+"<div class=\"mblSwitchCorner mblSwitchCorner3T\"></div>"+"<div class=\"mblSwitchText mblSwitchTextRight\">"+this.rightLabel+"</div>"+"<div class=\"mblSwitchCorner mblSwitchCorner1B\"></div>"+"<div class=\"mblSwitchCorner mblSwitchCorner2B\"></div>"+"<div class=\"mblSwitchCorner mblSwitchCorner3B\"></div>"+"</div>"+"<div class=\"mblSwitchKnobContainer\">"+"<div class=\"mblSwitchCorner mblSwitchCorner1T\"></div>"+"<div class=\"mblSwitchCorner mblSwitchCorner2T\"></div>"+"<div class=\"mblSwitchCorner mblSwitchCorner3T\"></div>"+"<div class=\"mblSwitchKnob\"></div>"+"<div class=\"mblSwitchCorner mblSwitchCorner1B\"></div>"+"<div class=\"mblSwitchCorner mblSwitchCorner2B\"></div>"+"<div class=\"mblSwitchCorner mblSwitchCorner3B\"></div>"+"</div>"+"</div>";
86
var n=this.inner=this.domNode.firstChild;
87
this.left=n.childNodes[0];
88
this.right=n.childNodes[1];
89
this.knob=n.childNodes[2];
90
dojo.addClass(this.domNode,(this.value=="on")?"mblSwitchOn":"mblSwitchOff");
91
this[this.value=="off"?"left":"right"].style.display="none";
92
},_changeState:function(_b){
93
if(!this.inner.parentNode||!this.inner.parentNode.tagName){
94
dojo.addClass(this.domNode,(_b=="on")?"mblSwitchOn":"mblSwitchOff");
95
return;
96
}
97
var _c;
98
if(this.inner.offsetLeft==0){
99
if(_b=="on"){
100
return;
101
}
102
_c=-53;
103
}else{
104
if(_b=="off"){
105
return;
106
}
107
_c=0;
108
}
109
var a=dojo.fx.slideTo({node:this.inner,duration:500,left:_c});
110
var _d=this;
111
dojo.connect(a,"onEnd",function(){
112
_d[_b=="off"?"left":"right"].style.display="none";
113
});
114
a.play();
115
}});
116
if(dojo.isIE){
117
dojo.extend(dojox.mobile.RoundRect,{buildRendering:function(){
118
dojox.mobile.createRoundRect(this);
119
this.domNode.className="mblRoundRect";
120
}});
121
dojox.mobile.RoundRectList._addChild=dojox.mobile.RoundRectList.prototype.addChild;
122
dojo.extend(dojox.mobile.RoundRectList,{buildRendering:function(){
123
dojox.mobile.createRoundRect(this,true);
124
this.domNode.className="mblRoundRectList";
125
},postCreate:function(){
126
this.redrawBorders();
127
},addChild:function(_e){
128
dojox.mobile.RoundRectList._addChild.apply(this,arguments);
129
this.redrawBorders();
130
if(dojox.mobile.applyPngFilter){
131
dojox.mobile.applyPngFilter(_e.domNode);
132
}
133
},redrawBorders:function(){
134
var _f=false;
135
for(var i=this.containerNode.childNodes.length-1;i>=0;i--){
136
var c=this.containerNode.childNodes[i];
137
if(c.tagName=="LI"){
138
c.style.borderBottomStyle=_f?"solid":"none";
139
_f=true;
140
}
141
}
142
}});
143
dojo.extend(dojox.mobile.EdgeToEdgeList,{buildRendering:function(){
144
this.domNode=this.containerNode=this.srcNodeRef||dojo.doc.createElement("UL");
145
this.domNode.className="mblEdgeToEdgeList";
146
}});
147
dojox.mobile.IconContainer._addChild=dojox.mobile.IconContainer.prototype.addChild;
148
dojo.extend(dojox.mobile.IconContainer,{addChild:function(_10){
149
dojox.mobile.IconContainer._addChild.apply(this,arguments);
150
if(dojox.mobile.applyPngFilter){
151
dojox.mobile.applyPngFilter(_10.domNode);
152
}
153
}});
154
dojo.mixin(dojox.mobile,{createRoundRect:function(_11,_12){
155
var i;
156
_11.domNode=dojo.doc.createElement("DIV");
157
_11.domNode.style.padding="0px";
158
_11.domNode.style.backgroundColor="transparent";
159
_11.domNode.style.borderStyle="none";
160
_11.containerNode=dojo.doc.createElement(_12?"UL":"DIV");
161
_11.containerNode.className="mblRoundRectContainer";
162
if(_11.srcNodeRef){
163
_11.srcNodeRef.parentNode.replaceChild(_11.domNode,_11.srcNodeRef);
164
for(i=0,len=_11.srcNodeRef.childNodes.length;i<len;i++){
165
_11.containerNode.appendChild(_11.srcNodeRef.removeChild(_11.srcNodeRef.firstChild));
166
}
167
_11.srcNodeRef=null;
168
}
169
_11.domNode.appendChild(_11.containerNode);
170
for(i=0;i<=5;i++){
171
var top=dojo.create("DIV");
172
top.className="mblRoundCorner mblRoundCorner"+i+"T";
173
_11.domNode.insertBefore(top,_11.containerNode);
174
var _13=dojo.create("DIV");
175
_13.className="mblRoundCorner mblRoundCorner"+i+"B";
176
_11.domNode.appendChild(_13);
177
}
178
}});
179
}
180
if(dojo.isIE<=6){
181
dojox.mobile.applyPngFilter=function(_14){
182
_14=_14||dojo.body();
183
var _15=_14.getElementsByTagName("IMG");
184
var _16=dojo.moduleUrl("dojo","resources/blank.gif");
185
for(var i=0,len=_15.length;i<len;i++){
186
var img=_15[i];
187
var w=img.offsetWidth;
188
var h=img.offsetHeight;
189
if(w===0||h===0){
190
return;
191
}
192
var src=img.src;
193
if(src.indexOf("resources/blank.gif")!=-1){
194
continue;
195
}
196
img.src=_16;
197
img.runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"')";
198
img.style.width=w+"px";
199
img.style.height=h+"px";
200
}
201
};
202
}
203
dojox.mobile.loadCss=function(_17){
204
if(!dojo.global._loadedCss){
205
var obj={};
206
dojo.forEach(dojo.doc.getElementsByTagName("link"),function(_18){
207
obj[_18.href]=true;
208
});
209
dojo.global._loadedCss=obj;
210
}
211
if(!dojo.isArray(_17)){
212
_17=[_17];
213
}
214
for(var i=0;i<_17.length;i++){
215
var _19=_17[i];
216
if(!dojo.global._loadedCss[_19]){
217
dojo.global._loadedCss[_19]=true;
218
if(dojo.doc.createStyleSheet){
219
setTimeout(function(_1a){
220
return function(){
221
dojo.doc.createStyleSheet(_1a);
222
};
223
}(_19),0);
224
}else{
225
var _1b=dojo.doc.createElement("link");
226
_1b.href=_19;
227
_1b.type="text/css";
228
_1b.rel="stylesheet";
229
var _1c=dojo.doc.getElementsByTagName("head")[0];
230
_1c.appendChild(_1b);
231
}
232
}
233
}
234
};
235
dojox.mobile.loadCompatCssFiles=function(){
236
var _1d=dojo.doc.getElementsByTagName("link");
237
for(var i=0,len=_1d.length;i<len;i++){
238
var _1e=_1d[i].href;
239
if((_1e.indexOf("/mobile/themes/")!=-1||location.href.indexOf("/mobile/tests/")!=-1)&&_1e.substring(_1e.length-4)==".css"){
240
var _1f=_1e.substring(0,_1e.length-4)+"-compat.css";
241
dojox.mobile.loadCss(_1f);
242
}
243
}
244
};
245
dojo.addOnLoad(function(){
246
dojox.mobile.loadCompatCssFiles();
247
if(dojox.mobile.applyPngFilter){
248
dojox.mobile.applyPngFilter();
249
}
250
});
251
}