Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / embed / Flash.js @ 13

History | View | Annotate | Download (6.42 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.embed.Flash"]){
9
dojo._hasResource["dojox.embed.Flash"]=true;
10
dojo.provide("dojox.embed.Flash");
11
(function(){
12
var _1,_2;
13
var _3=9;
14
var _4="dojox-embed-flash-",_5=0;
15
var _6={expressInstall:false,width:320,height:240,swLiveConnect:"true",allowScriptAccess:"sameDomain",allowNetworking:"all",style:null,redirect:null};
16
function _7(_8){
17
_8=dojo.delegate(_6,_8);
18
if(!("path" in _8)){
19
console.error("dojox.embed.Flash(ctor):: no path reference to a Flash movie was provided.");
20
return null;
21
}
22
if(!("id" in _8)){
23
_8.id=(_4+_5++);
24
}
25
return _8;
26
};
27
if(dojo.isIE){
28
_1=function(_9){
29
_9=_7(_9);
30
if(!_9){
31
return null;
32
}
33
var p;
34
var _a=_9.path;
35
if(_9.vars){
36
var a=[];
37
for(p in _9.vars){
38
a.push(p+"="+_9.vars[p]);
39
}
40
_9.params.FlashVars=a.join("&");
41
delete _9.vars;
42
}
43
var s="<object id=\""+_9.id+"\" "+"classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "+"width=\""+_9.width+"\" "+"height=\""+_9.height+"\""+((_9.style)?" style=\""+_9.style+"\"":"")+">"+"<param name=\"movie\" value=\""+_a+"\" />";
44
if(_9.params){
45
for(p in _9.params){
46
s+="<param name=\""+p+"\" value=\""+_9.params[p]+"\" />";
47
}
48
}
49
s+="</object>";
50
return {id:_9.id,markup:s};
51
};
52
_2=(function(){
53
var _b=10,_c=null;
54
while(!_c&&_b>7){
55
try{
56
_c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_b--);
57
}
58
catch(e){
59
}
60
}
61
if(_c){
62
var v=_c.GetVariable("$version").split(" ")[1].split(",");
63
return {major:(v[0]!=null)?parseInt(v[0]):0,minor:(v[1]!=null)?parseInt(v[1]):0,rev:(v[2]!=null)?parseInt(v[2]):0};
64
}
65
return {major:0,minor:0,rev:0};
66
})();
67
dojo.addOnUnload(function(){
68
var _d=function(){
69
};
70
var _e=dojo.query("object").reverse().style("display","none").forEach(function(i){
71
for(var p in i){
72
if((p!="FlashVars")&&dojo.isFunction(i[p])){
73
try{
74
i[p]=_d;
75
}
76
catch(e){
77
}
78
}
79
}
80
});
81
});
82
}else{
83
_1=function(_f){
84
_f=_7(_f);
85
if(!_f){
86
return null;
87
}
88
var p;
89
var _10=_f.path;
90
if(_f.vars){
91
var a=[];
92
for(p in _f.vars){
93
a.push(p+"="+_f.vars[p]);
94
}
95
_f.params.flashVars=a.join("&");
96
delete _f.vars;
97
}
98
var s="<embed type=\"application/x-shockwave-flash\" "+"src=\""+_10+"\" "+"id=\""+_f.id+"\" "+"width=\""+_f.width+"\" "+"height=\""+_f.height+"\""+((_f.style)?" style=\""+_f.style+"\" ":"")+"swLiveConnect=\""+_f.swLiveConnect+"\" "+"allowScriptAccess=\""+_f.allowScriptAccess+"\" "+"allowNetworking=\""+_f.allowNetworking+"\" "+"pluginspage=\""+window.location.protocol+"//www.adobe.com/go/getflashplayer\" ";
99
if(_f.params){
100
for(p in _f.params){
101
s+=" "+p+"=\""+_f.params[p]+"\"";
102
}
103
}
104
s+=" />";
105
return {id:_f.id,markup:s};
106
};
107
_2=(function(){
108
var _11=navigator.plugins["Shockwave Flash"];
109
if(_11&&_11.description){
110
var v=_11.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split(".");
111
return {major:(v[0]!=null)?parseInt(v[0]):0,minor:(v[1]!=null)?parseInt(v[1]):0,rev:(v[2]!=null)?parseInt(v[2]):0};
112
}
113
return {major:0,minor:0,rev:0};
114
})();
115
}
116
dojox.embed.Flash=function(_12,_13){
117
if(location.href.toLowerCase().indexOf("file://")>-1){
118
throw new Error("dojox.embed.Flash can't be run directly from a file. To instatiate the required SWF correctly it must be run from a server, like localHost.");
119
}
120
this.available=dojox.embed.Flash.available;
121
this.minimumVersion=_12.minimumVersion||_3;
122
this.id=null;
123
this.movie=null;
124
this.domNode=null;
125
if(_13){
126
_13=dojo.byId(_13);
127
}
128
setTimeout(dojo.hitch(this,function(){
129
if(_12.expressInstall||this.available&&this.available>=this.minimumVersion){
130
if(_12&&_13){
131
this.init(_12,_13);
132
}else{
133
this.onError("embed.Flash was not provided with the proper arguments.");
134
}
135
}else{
136
if(!this.available){
137
this.onError("Flash is not installed.");
138
}else{
139
this.onError("Flash version detected: "+this.available+" is out of date. Minimum required: "+this.minimumVersion);
140
}
141
}
142
}),100);
143
};
144
dojo.extend(dojox.embed.Flash,{onReady:function(_14){
145
console.warn("embed.Flash.movie.onReady:",_14);
146
},onLoad:function(_15){
147
console.warn("embed.Flash.movie.onLoad:",_15);
148
},onError:function(msg){
149
},_onload:function(){
150
clearInterval(this._poller);
151
delete this._poller;
152
delete this._pollCount;
153
delete this._pollMax;
154
this.onLoad(this.movie);
155
},init:function(_16,_17){
156
this.destroy();
157
_17=dojo.byId(_17||this.domNode);
158
if(!_17){
159
throw new Error("dojox.embed.Flash: no domNode reference has been passed.");
160
}
161
var p=0,_18=false;
162
this._poller=null;
163
this._pollCount=0;
164
this._pollMax=15;
165
this.pollTime=100;
166
if(dojox.embed.Flash.initialized){
167
this.id=dojox.embed.Flash.place(_16,_17);
168
this.domNode=_17;
169
setTimeout(dojo.hitch(this,function(){
170
this.movie=this.byId(this.id,_16.doc);
171
this.onReady(this.movie);
172
this._poller=setInterval(dojo.hitch(this,function(){
173
try{
174
p=this.movie.PercentLoaded();
175
}
176
catch(e){
177
console.warn("this.movie.PercentLoaded() failed");
178
}
179
if(p==100){
180
this._onload();
181
}else{
182
if(p==0&&this._pollCount++>this._pollMax){
183
clearInterval(this._poller);
184
throw new Error("Building SWF failed.");
185
}
186
}
187
}),this.pollTime);
188
}),1);
189
}
190
},_destroy:function(){
191
try{
192
this.domNode.removeChild(this.movie);
193
}
194
catch(e){
195
}
196
this.id=this.movie=this.domNode=null;
197
},destroy:function(){
198
if(!this.movie){
199
return;
200
}
201
var _19=dojo.delegate({id:true,movie:true,domNode:true,onReady:true,onLoad:true});
202
for(var p in this){
203
if(!_19[p]){
204
delete this[p];
205
}
206
}
207
if(this._poller){
208
dojo.connect(this,"onLoad",this,"_destroy");
209
}else{
210
this._destroy();
211
}
212
},byId:function(_1a,doc){
213
doc=doc||document;
214
if(doc.embeds[_1a]){
215
return doc.embeds[_1a];
216
}
217
if(doc[_1a]){
218
return doc[_1a];
219
}
220
if(window[_1a]){
221
return window[_1a];
222
}
223
if(document[_1a]){
224
return document[_1a];
225
}
226
return null;
227
}});
228
dojo.mixin(dojox.embed.Flash,{minSupported:8,available:_2.major,supported:(_2.major>=_2.required),minimumRequired:_2.required,version:_2,initialized:false,onInitialize:function(){
229
dojox.embed.Flash.initialized=true;
230
},__ie_markup__:function(_1b){
231
return _1(_1b);
232
},proxy:function(obj,_1c){
233
dojo.forEach((dojo.isArray(_1c)?_1c:[_1c]),function(_1d){
234
this[_1d]=dojo.hitch(this,function(){
235
return (function(){
236
return eval(this.movie.CallFunction("<invoke name=\""+_1d+"\" returntype=\"javascript\">"+"<arguments>"+dojo.map(arguments,function(_1e){
237
return __flash__toXML(_1e);
238
}).join("")+"</arguments>"+"</invoke>"));
239
}).apply(this,arguments||[]);
240
});
241
},obj);
242
}});
243
dojox.embed.Flash.place=function(_1f,_20){
244
var o=_1(_1f);
245
_20=dojo.byId(_20);
246
if(!_20){
247
_20=dojo.doc.createElement("div");
248
_20.id=o.id+"-container";
249
dojo.body().appendChild(_20);
250
}
251
if(o){
252
_20.innerHTML=o.markup;
253
return o.id;
254
}
255
return null;
256
};
257
dojox.embed.Flash.onInitialize();
258
})();
259
}