Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / flash / _base.js @ 12

History | View | Annotate | Download (8.43 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.flash._base"]){
9
dojo._hasResource["dojox.flash._base"]=true;
10
dojo.provide("dojox.flash._base");
11
dojo.experimental("dojox.flash");
12
dojo.require("dojo.window");
13
dojox.flash=function(){
14
};
15
dojox.flash={ready:false,url:null,_visible:true,_loadedListeners:[],_installingListeners:[],setSwf:function(_1,_2){
16
this.url=_1;
17
this._visible=true;
18
if(_2!==null&&_2!==undefined){
19
this._visible=_2;
20
}
21
this._initialize();
22
},addLoadedListener:function(_3){
23
this._loadedListeners.push(_3);
24
},addInstallingListener:function(_4){
25
this._installingListeners.push(_4);
26
},loaded:function(){
27
dojox.flash.ready=true;
28
if(dojox.flash._loadedListeners.length){
29
for(var i=0;i<dojox.flash._loadedListeners.length;i++){
30
dojox.flash._loadedListeners[i].call(null);
31
}
32
}
33
},installing:function(){
34
if(dojox.flash._installingListeners.length){
35
for(var i=0;i<dojox.flash._installingListeners.length;i++){
36
dojox.flash._installingListeners[i].call(null);
37
}
38
}
39
},_initialize:function(){
40
var _5=new dojox.flash.Install();
41
dojox.flash.installer=_5;
42
if(_5.needed()){
43
_5.install();
44
}else{
45
dojox.flash.obj=new dojox.flash.Embed(this._visible);
46
dojox.flash.obj.write();
47
dojox.flash.comm=new dojox.flash.Communicator();
48
}
49
}};
50
dojox.flash.Info=function(){
51
this._detectVersion();
52
};
53
dojox.flash.Info.prototype={version:-1,versionMajor:-1,versionMinor:-1,versionRevision:-1,capable:false,installing:false,isVersionOrAbove:function(_6,_7,_8){
54
_8=parseFloat("."+_8);
55
if(this.versionMajor>=_6&&this.versionMinor>=_7&&this.versionRevision>=_8){
56
return true;
57
}else{
58
return false;
59
}
60
},_detectVersion:function(){
61
var _9;
62
for(var _a=25;_a>0;_a--){
63
if(dojo.isIE){
64
var _b;
65
try{
66
if(_a>6){
67
_b=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_a);
68
}else{
69
_b=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
70
}
71
if(typeof _b=="object"){
72
if(_a==6){
73
_b.AllowScriptAccess="always";
74
}
75
_9=_b.GetVariable("$version");
76
}
77
}
78
catch(e){
79
continue;
80
}
81
}else{
82
_9=this._JSFlashInfo(_a);
83
}
84
if(_9==-1){
85
this.capable=false;
86
return;
87
}else{
88
if(_9!=0){
89
var _c;
90
if(dojo.isIE){
91
var _d=_9.split(" ");
92
var _e=_d[1];
93
_c=_e.split(",");
94
}else{
95
_c=_9.split(".");
96
}
97
this.versionMajor=_c[0];
98
this.versionMinor=_c[1];
99
this.versionRevision=_c[2];
100
var _f=this.versionMajor+"."+this.versionRevision;
101
this.version=parseFloat(_f);
102
this.capable=true;
103
break;
104
}
105
}
106
}
107
},_JSFlashInfo:function(_10){
108
if(navigator.plugins!=null&&navigator.plugins.length>0){
109
if(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]){
110
var _11=navigator.plugins["Shockwave Flash 2.0"]?" 2.0":"";
111
var _12=navigator.plugins["Shockwave Flash"+_11].description;
112
var _13=_12.split(" ");
113
var _14=_13[2].split(".");
114
var _15=_14[0];
115
var _16=_14[1];
116
var _17=(_13[3]||_13[4]).split("r");
117
var _18=_17[1]>0?_17[1]:0;
118
var _19=_15+"."+_16+"."+_18;
119
return _19;
120
}
121
}
122
return -1;
123
}};
124
dojox.flash.Embed=function(_1a){
125
this._visible=_1a;
126
};
127
dojox.flash.Embed.prototype={width:215,height:138,id:"flashObject",_visible:true,protocol:function(){
128
switch(window.location.protocol){
129
case "https:":
130
return "https";
131
break;
132
default:
133
return "http";
134
break;
135
}
136
},write:function(_1b){
137
var _1c;
138
var _1d=dojox.flash.url;
139
var _1e=_1d;
140
var _1f=_1d;
141
var _20=dojo.baseUrl;
142
var _21=document.location.protocol+"//"+document.location.host;
143
if(_1b){
144
var _22=escape(window.location);
145
document.title=document.title.slice(0,47)+" - Flash Player Installation";
146
var _23=escape(document.title);
147
_1e+="?MMredirectURL="+_22+"&MMplayerType=ActiveX"+"&MMdoctitle="+_23+"&baseUrl="+escape(_20)+"&xdomain="+escape(_21);
148
_1f+="?MMredirectURL="+_22+"&MMplayerType=PlugIn"+"&baseUrl="+escape(_20)+"&xdomain="+escape(_21);
149
}else{
150
_1e+="?cachebust="+new Date().getTime();
151
_1e+="&baseUrl="+escape(_20);
152
_1e+="&xdomain="+escape(_21);
153
}
154
if(_1f.indexOf("?")==-1){
155
_1f+="?baseUrl="+escape(_20);
156
}else{
157
_1f+="&baseUrl="+escape(_20);
158
}
159
_1f+="&xdomain="+escape(_21);
160
_1c="<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" "+"codebase=\""+this.protocol()+"://fpdownload.macromedia.com/pub/shockwave/cabs/flash/"+"swflash.cab#version=8,0,0,0\"\n "+"width=\""+this.width+"\"\n "+"height=\""+this.height+"\"\n "+"id=\""+this.id+"\"\n "+"name=\""+this.id+"\"\n "+"align=\"middle\">\n "+"<param name=\"allowScriptAccess\" value=\"always\"></param>\n "+"<param name=\"movie\" value=\""+_1e+"\"></param>\n "+"<param name=\"quality\" value=\"high\"></param>\n "+"<param name=\"bgcolor\" value=\"#ffffff\"></param>\n "+"<embed src=\""+_1f+"\" "+"quality=\"high\" "+"bgcolor=\"#ffffff\" "+"width=\""+this.width+"\" "+"height=\""+this.height+"\" "+"id=\""+this.id+"Embed"+"\" "+"name=\""+this.id+"\" "+"swLiveConnect=\"true\" "+"align=\"middle\" "+"allowScriptAccess=\"always\" "+"type=\"application/x-shockwave-flash\" "+"pluginspage=\""+this.protocol()+"://www.macromedia.com/go/getflashplayer\" "+"></embed>\n"+"</object>\n";
161
dojo.connect(dojo,"loaded",dojo.hitch(this,function(){
162
var _24=this.id+"Container";
163
if(dojo.byId(_24)){
164
return;
165
}
166
var div=document.createElement("div");
167
div.id=this.id+"Container";
168
div.style.width=this.width+"px";
169
div.style.height=this.height+"px";
170
if(!this._visible){
171
div.style.position="absolute";
172
div.style.zIndex="10000";
173
div.style.top="-1000px";
174
}
175
div.innerHTML=_1c;
176
var _25=document.getElementsByTagName("body");
177
if(!_25||!_25.length){
178
throw new Error("No body tag for this page");
179
}
180
_25=_25[0];
181
_25.appendChild(div);
182
}));
183
},get:function(){
184
if(dojo.isIE||dojo.isWebKit){
185
return dojo.byId(this.id);
186
}else{
187
return document[this.id+"Embed"];
188
}
189
},setVisible:function(_26){
190
var _27=dojo.byId(this.id+"Container");
191
if(_26){
192
_27.style.position="absolute";
193
_27.style.visibility="visible";
194
}else{
195
_27.style.position="absolute";
196
_27.style.y="-1000px";
197
_27.style.visibility="hidden";
198
}
199
},center:function(){
200
var _28=this.width;
201
var _29=this.height;
202
var _2a=dojo.window.getBox();
203
var x=_2a.l+(_2a.w-_28)/2;
204
var y=_2a.t+(_2a.h-_29)/2;
205
var _2b=dojo.byId(this.id+"Container");
206
_2b.style.top=y+"px";
207
_2b.style.left=x+"px";
208
}};
209
dojox.flash.Communicator=function(){
210
};
211
dojox.flash.Communicator.prototype={_addExternalInterfaceCallback:function(_2c){
212
var _2d=dojo.hitch(this,function(){
213
var _2e=new Array(arguments.length);
214
for(var i=0;i<arguments.length;i++){
215
_2e[i]=this._encodeData(arguments[i]);
216
}
217
var _2f=this._execFlash(_2c,_2e);
218
_2f=this._decodeData(_2f);
219
return _2f;
220
});
221
this[_2c]=_2d;
222
},_encodeData:function(_30){
223
if(!_30||typeof _30!="string"){
224
return _30;
225
}
226
_30=_30.replace("\\","&custom_backslash;");
227
_30=_30.replace(/\0/g,"&custom_null;");
228
return _30;
229
},_decodeData:function(_31){
230
if(_31&&_31.length&&typeof _31!="string"){
231
_31=_31[0];
232
}
233
if(!_31||typeof _31!="string"){
234
return _31;
235
}
236
_31=_31.replace(/\&custom_null\;/g,"\x00");
237
_31=_31.replace(/\&custom_lt\;/g,"<").replace(/\&custom_gt\;/g,">").replace(/\&custom_backslash\;/g,"\\");
238
return _31;
239
},_execFlash:function(_32,_33){
240
var _34=dojox.flash.obj.get();
241
_33=(_33)?_33:[];
242
for(var i=0;i<_33;i++){
243
if(typeof _33[i]=="string"){
244
_33[i]=this._encodeData(_33[i]);
245
}
246
}
247
var _35=function(){
248
return eval(_34.CallFunction("<invoke name=\""+_32+"\" returntype=\"javascript\">"+__flash__argumentsToXML(_33,0)+"</invoke>"));
249
};
250
var _36=_35.call(_33);
251
if(typeof _36=="string"){
252
_36=this._decodeData(_36);
253
}
254
return _36;
255
}};
256
dojox.flash.Install=function(){
257
};
258
dojox.flash.Install.prototype={needed:function(){
259
if(!dojox.flash.info.capable){
260
return true;
261
}
262
if(!dojox.flash.info.isVersionOrAbove(8,0,0)){
263
return true;
264
}
265
return false;
266
},install:function(){
267
var _37;
268
dojox.flash.info.installing=true;
269
dojox.flash.installing();
270
if(dojox.flash.info.capable==false){
271
_37=new dojox.flash.Embed(false);
272
_37.write();
273
}else{
274
if(dojox.flash.info.isVersionOrAbove(6,0,65)){
275
_37=new dojox.flash.Embed(false);
276
_37.write(true);
277
_37.setVisible(true);
278
_37.center();
279
}else{
280
alert("This content requires a more recent version of the Macromedia "+" Flash Player.");
281
window.location.href=+dojox.flash.Embed.protocol()+"://www.macromedia.com/go/getflashplayer";
282
}
283
}
284
},_onInstallStatus:function(msg){
285
if(msg=="Download.Complete"){
286
dojox.flash._initialize();
287
}else{
288
if(msg=="Download.Cancelled"){
289
alert("This content requires a more recent version of the Macromedia "+" Flash Player.");
290
window.location.href=dojox.flash.Embed.protocol()+"://www.macromedia.com/go/getflashplayer";
291
}else{
292
if(msg=="Download.Failed"){
293
alert("There was an error downloading the Flash Player update. "+"Please try again later, or visit macromedia.com to download "+"the latest version of the Flash plugin.");
294
}
295
}
296
}
297
}};
298
dojox.flash.info=new dojox.flash.Info();
299
}