ajaxlibs 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -1
- data/VERSION +1 -1
- data/lib/ajaxlibs/libraries/dojo.rb +2 -1
- data/lib/ajaxlibs/libraries/jqueryui.rb +2 -1
- data/lib/ajaxlibs/libraries/jrails.rb +0 -1
- data/lib/ajaxlibs/libraries/swfobject.rb +8 -0
- data/lib/ajaxlibs/libraries/yui.rb +14 -0
- data/lib/ajaxlibs.rb +1 -0
- data/public/dojo/1.4.3/dojo.xd.js +16 -0
- data/public/dojo/1.4.3/dojo.xd.js.uncompressed.js +12129 -0
- data/public/jqueryui/1.8.1/jquery-ui.js +11003 -0
- data/public/jqueryui/1.8.1/jquery-ui.min.js +392 -0
- data/public/swfobject/2.1/swfobject.js +5 -0
- data/public/swfobject/2.1/swfobject_src.js +731 -0
- data/public/swfobject/2.2/swfobject.js +4 -0
- data/public/swfobject/2.2/swfobject_src.js +777 -0
- data/spec/library_spec.rb +19 -7
- metadata +21 -4
@@ -0,0 +1,731 @@
|
|
1
|
+
/*! SWFObject v2.1 <http://code.google.com/p/swfobject/>
|
2
|
+
Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
|
3
|
+
This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
|
4
|
+
*/
|
5
|
+
|
6
|
+
var swfobject = function() {
|
7
|
+
|
8
|
+
var UNDEF = "undefined",
|
9
|
+
OBJECT = "object",
|
10
|
+
SHOCKWAVE_FLASH = "Shockwave Flash",
|
11
|
+
SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
|
12
|
+
FLASH_MIME_TYPE = "application/x-shockwave-flash",
|
13
|
+
EXPRESS_INSTALL_ID = "SWFObjectExprInst",
|
14
|
+
|
15
|
+
win = window,
|
16
|
+
doc = document,
|
17
|
+
nav = navigator,
|
18
|
+
|
19
|
+
domLoadFnArr = [],
|
20
|
+
regObjArr = [],
|
21
|
+
objIdArr = [],
|
22
|
+
listenersArr = [],
|
23
|
+
script,
|
24
|
+
timer = null,
|
25
|
+
storedAltContent = null,
|
26
|
+
storedAltContentId = null,
|
27
|
+
isDomLoaded = false,
|
28
|
+
isExpressInstallActive = false;
|
29
|
+
|
30
|
+
/* Centralized function for browser feature detection
|
31
|
+
- Proprietary feature detection (conditional compiling) is used to detect Internet Explorer's features
|
32
|
+
- User agent string detection is only used when no alternative is possible
|
33
|
+
- Is executed directly for optimal performance
|
34
|
+
*/
|
35
|
+
var ua = function() {
|
36
|
+
var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
|
37
|
+
playerVersion = [0,0,0],
|
38
|
+
d = null;
|
39
|
+
if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
|
40
|
+
d = nav.plugins[SHOCKWAVE_FLASH].description;
|
41
|
+
if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
|
42
|
+
d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
|
43
|
+
playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
|
44
|
+
playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
|
45
|
+
playerVersion[2] = /r/.test(d) ? parseInt(d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
else if (typeof win.ActiveXObject != UNDEF) {
|
49
|
+
var a = null, fp6Crash = false;
|
50
|
+
try {
|
51
|
+
a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".7");
|
52
|
+
}
|
53
|
+
catch(e) {
|
54
|
+
try {
|
55
|
+
a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".6");
|
56
|
+
playerVersion = [6,0,21];
|
57
|
+
a.AllowScriptAccess = "always"; // Introduced in fp6.0.47
|
58
|
+
}
|
59
|
+
catch(e) {
|
60
|
+
if (playerVersion[0] == 6) {
|
61
|
+
fp6Crash = true;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
if (!fp6Crash) {
|
65
|
+
try {
|
66
|
+
a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
|
67
|
+
}
|
68
|
+
catch(e) {}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
if (!fp6Crash && a) { // a will return null when ActiveX is disabled
|
72
|
+
try {
|
73
|
+
d = a.GetVariable("$version"); // Will crash fp6.0.21/23/29
|
74
|
+
if (d) {
|
75
|
+
d = d.split(" ")[1].split(",");
|
76
|
+
playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
|
77
|
+
}
|
78
|
+
}
|
79
|
+
catch(e) {}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
var u = nav.userAgent.toLowerCase(),
|
83
|
+
p = nav.platform.toLowerCase(),
|
84
|
+
webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
|
85
|
+
ie = false,
|
86
|
+
windows = p ? /win/.test(p) : /win/.test(u),
|
87
|
+
mac = p ? /mac/.test(p) : /mac/.test(u);
|
88
|
+
/*@cc_on
|
89
|
+
ie = true;
|
90
|
+
@if (@_win32)
|
91
|
+
windows = true;
|
92
|
+
@elif (@_mac)
|
93
|
+
mac = true;
|
94
|
+
@end
|
95
|
+
@*/
|
96
|
+
return { w3cdom:w3cdom, pv:playerVersion, webkit:webkit, ie:ie, win:windows, mac:mac };
|
97
|
+
}();
|
98
|
+
|
99
|
+
/* Cross-browser onDomLoad
|
100
|
+
- Based on Dean Edwards' solution: http://dean.edwards.name/weblog/2006/06/again/
|
101
|
+
- Will fire an event as soon as the DOM of a page is loaded (supported by Gecko based browsers - like Firefox -, IE, Opera9+, Safari)
|
102
|
+
*/
|
103
|
+
var onDomLoad = function() {
|
104
|
+
if (!ua.w3cdom) {
|
105
|
+
return;
|
106
|
+
}
|
107
|
+
addDomLoadEvent(main);
|
108
|
+
if (ua.ie && ua.win) {
|
109
|
+
try { // Avoid a possible Operation Aborted error
|
110
|
+
doc.write("<scr" + "ipt id=__ie_ondomload defer=true src=//:></scr" + "ipt>"); // String is split into pieces to avoid Norton AV to add code that can cause errors
|
111
|
+
script = getElementById("__ie_ondomload");
|
112
|
+
if (script) {
|
113
|
+
addListener(script, "onreadystatechange", checkReadyState);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
catch(e) {}
|
117
|
+
}
|
118
|
+
if (ua.webkit && typeof doc.readyState != UNDEF) {
|
119
|
+
timer = setInterval(function() { if (/loaded|complete/.test(doc.readyState)) { callDomLoadFunctions(); }}, 10);
|
120
|
+
}
|
121
|
+
if (typeof doc.addEventListener != UNDEF) {
|
122
|
+
doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, null);
|
123
|
+
}
|
124
|
+
addLoadEvent(callDomLoadFunctions);
|
125
|
+
}();
|
126
|
+
|
127
|
+
function checkReadyState() {
|
128
|
+
if (script.readyState == "complete") {
|
129
|
+
script.parentNode.removeChild(script);
|
130
|
+
callDomLoadFunctions();
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
function callDomLoadFunctions() {
|
135
|
+
if (isDomLoaded) {
|
136
|
+
return;
|
137
|
+
}
|
138
|
+
if (ua.ie && ua.win) { // Test if we can really add elements to the DOM; we don't want to fire it too early
|
139
|
+
var s = createElement("span");
|
140
|
+
try { // Avoid a possible Operation Aborted error
|
141
|
+
var t = doc.getElementsByTagName("body")[0].appendChild(s);
|
142
|
+
t.parentNode.removeChild(t);
|
143
|
+
}
|
144
|
+
catch (e) {
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
isDomLoaded = true;
|
149
|
+
if (timer) {
|
150
|
+
clearInterval(timer);
|
151
|
+
timer = null;
|
152
|
+
}
|
153
|
+
var dl = domLoadFnArr.length;
|
154
|
+
for (var i = 0; i < dl; i++) {
|
155
|
+
domLoadFnArr[i]();
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
function addDomLoadEvent(fn) {
|
160
|
+
if (isDomLoaded) {
|
161
|
+
fn();
|
162
|
+
}
|
163
|
+
else {
|
164
|
+
domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
/* Cross-browser onload
|
169
|
+
- Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
|
170
|
+
- Will fire an event as soon as a web page including all of its assets are loaded
|
171
|
+
*/
|
172
|
+
function addLoadEvent(fn) {
|
173
|
+
if (typeof win.addEventListener != UNDEF) {
|
174
|
+
win.addEventListener("load", fn, false);
|
175
|
+
}
|
176
|
+
else if (typeof doc.addEventListener != UNDEF) {
|
177
|
+
doc.addEventListener("load", fn, false);
|
178
|
+
}
|
179
|
+
else if (typeof win.attachEvent != UNDEF) {
|
180
|
+
addListener(win, "onload", fn);
|
181
|
+
}
|
182
|
+
else if (typeof win.onload == "function") {
|
183
|
+
var fnOld = win.onload;
|
184
|
+
win.onload = function() {
|
185
|
+
fnOld();
|
186
|
+
fn();
|
187
|
+
};
|
188
|
+
}
|
189
|
+
else {
|
190
|
+
win.onload = fn;
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
/* Main function
|
195
|
+
- Will preferably execute onDomLoad, otherwise onload (as a fallback)
|
196
|
+
*/
|
197
|
+
function main() { // Static publishing only
|
198
|
+
var rl = regObjArr.length;
|
199
|
+
for (var i = 0; i < rl; i++) { // For each registered object element
|
200
|
+
var id = regObjArr[i].id;
|
201
|
+
if (ua.pv[0] > 0) {
|
202
|
+
var obj = getElementById(id);
|
203
|
+
if (obj) {
|
204
|
+
regObjArr[i].width = obj.getAttribute("width") ? obj.getAttribute("width") : "0";
|
205
|
+
regObjArr[i].height = obj.getAttribute("height") ? obj.getAttribute("height") : "0";
|
206
|
+
if (hasPlayerVersion(regObjArr[i].swfVersion)) { // Flash plug-in version >= Flash content version: Houston, we have a match!
|
207
|
+
if (ua.webkit && ua.webkit < 312) { // Older webkit engines ignore the object element's nested param elements
|
208
|
+
fixParams(obj);
|
209
|
+
}
|
210
|
+
setVisibility(id, true);
|
211
|
+
}
|
212
|
+
else if (regObjArr[i].expressInstall && !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac)) { // Show the Adobe Express Install dialog if set by the web page author and if supported (fp6.0.65+ on Win/Mac OS only)
|
213
|
+
showExpressInstall(regObjArr[i]);
|
214
|
+
}
|
215
|
+
else { // Flash plug-in and Flash content version mismatch: display alternative content instead of Flash content
|
216
|
+
displayAltContent(obj);
|
217
|
+
}
|
218
|
+
}
|
219
|
+
}
|
220
|
+
else { // If no fp is installed, we let the object element do its job (show alternative content)
|
221
|
+
setVisibility(id, true);
|
222
|
+
}
|
223
|
+
}
|
224
|
+
}
|
225
|
+
|
226
|
+
/* Fix nested param elements, which are ignored by older webkit engines
|
227
|
+
- This includes Safari up to and including version 1.2.2 on Mac OS 10.3
|
228
|
+
- Fall back to the proprietary embed element
|
229
|
+
*/
|
230
|
+
function fixParams(obj) {
|
231
|
+
var nestedObj = obj.getElementsByTagName(OBJECT)[0];
|
232
|
+
if (nestedObj) {
|
233
|
+
var e = createElement("embed"), a = nestedObj.attributes;
|
234
|
+
if (a) {
|
235
|
+
var al = a.length;
|
236
|
+
for (var i = 0; i < al; i++) {
|
237
|
+
if (a[i].nodeName == "DATA") {
|
238
|
+
e.setAttribute("src", a[i].nodeValue);
|
239
|
+
}
|
240
|
+
else {
|
241
|
+
e.setAttribute(a[i].nodeName, a[i].nodeValue);
|
242
|
+
}
|
243
|
+
}
|
244
|
+
}
|
245
|
+
var c = nestedObj.childNodes;
|
246
|
+
if (c) {
|
247
|
+
var cl = c.length;
|
248
|
+
for (var j = 0; j < cl; j++) {
|
249
|
+
if (c[j].nodeType == 1 && c[j].nodeName == "PARAM") {
|
250
|
+
e.setAttribute(c[j].getAttribute("name"), c[j].getAttribute("value"));
|
251
|
+
}
|
252
|
+
}
|
253
|
+
}
|
254
|
+
obj.parentNode.replaceChild(e, obj);
|
255
|
+
}
|
256
|
+
}
|
257
|
+
|
258
|
+
/* Show the Adobe Express Install dialog
|
259
|
+
- Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75
|
260
|
+
*/
|
261
|
+
function showExpressInstall(regObj) {
|
262
|
+
isExpressInstallActive = true;
|
263
|
+
var obj = getElementById(regObj.id);
|
264
|
+
if (obj) {
|
265
|
+
if (regObj.altContentId) {
|
266
|
+
var ac = getElementById(regObj.altContentId);
|
267
|
+
if (ac) {
|
268
|
+
storedAltContent = ac;
|
269
|
+
storedAltContentId = regObj.altContentId;
|
270
|
+
}
|
271
|
+
}
|
272
|
+
else {
|
273
|
+
storedAltContent = abstractAltContent(obj);
|
274
|
+
}
|
275
|
+
if (!(/%$/.test(regObj.width)) && parseInt(regObj.width, 10) < 310) {
|
276
|
+
regObj.width = "310";
|
277
|
+
}
|
278
|
+
if (!(/%$/.test(regObj.height)) && parseInt(regObj.height, 10) < 137) {
|
279
|
+
regObj.height = "137";
|
280
|
+
}
|
281
|
+
doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
|
282
|
+
var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
|
283
|
+
dt = doc.title,
|
284
|
+
fv = "MMredirectURL=" + win.location + "&MMplayerType=" + pt + "&MMdoctitle=" + dt,
|
285
|
+
replaceId = regObj.id;
|
286
|
+
// For IE when a SWF is loading (AND: not available in cache) wait for the onload event to fire to remove the original object element
|
287
|
+
// In IE you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
|
288
|
+
if (ua.ie && ua.win && obj.readyState != 4) {
|
289
|
+
var newObj = createElement("div");
|
290
|
+
replaceId += "SWFObjectNew";
|
291
|
+
newObj.setAttribute("id", replaceId);
|
292
|
+
obj.parentNode.insertBefore(newObj, obj); // Insert placeholder div that will be replaced by the object element that loads expressinstall.swf
|
293
|
+
obj.style.display = "none";
|
294
|
+
var fn = function() {
|
295
|
+
obj.parentNode.removeChild(obj);
|
296
|
+
};
|
297
|
+
addListener(win, "onload", fn);
|
298
|
+
}
|
299
|
+
createSWF({ data:regObj.expressInstall, id:EXPRESS_INSTALL_ID, width:regObj.width, height:regObj.height }, { flashvars:fv }, replaceId);
|
300
|
+
}
|
301
|
+
}
|
302
|
+
|
303
|
+
/* Functions to abstract and display alternative content
|
304
|
+
*/
|
305
|
+
function displayAltContent(obj) {
|
306
|
+
if (ua.ie && ua.win && obj.readyState != 4) {
|
307
|
+
// For IE when a SWF is loading (AND: not available in cache) wait for the onload event to fire to remove the original object element
|
308
|
+
// In IE you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
|
309
|
+
var el = createElement("div");
|
310
|
+
obj.parentNode.insertBefore(el, obj); // Insert placeholder div that will be replaced by the alternative content
|
311
|
+
el.parentNode.replaceChild(abstractAltContent(obj), el);
|
312
|
+
obj.style.display = "none";
|
313
|
+
var fn = function() {
|
314
|
+
obj.parentNode.removeChild(obj);
|
315
|
+
};
|
316
|
+
addListener(win, "onload", fn);
|
317
|
+
}
|
318
|
+
else {
|
319
|
+
obj.parentNode.replaceChild(abstractAltContent(obj), obj);
|
320
|
+
}
|
321
|
+
}
|
322
|
+
|
323
|
+
function abstractAltContent(obj) {
|
324
|
+
var ac = createElement("div");
|
325
|
+
if (ua.win && ua.ie) {
|
326
|
+
ac.innerHTML = obj.innerHTML;
|
327
|
+
}
|
328
|
+
else {
|
329
|
+
var nestedObj = obj.getElementsByTagName(OBJECT)[0];
|
330
|
+
if (nestedObj) {
|
331
|
+
var c = nestedObj.childNodes;
|
332
|
+
if (c) {
|
333
|
+
var cl = c.length;
|
334
|
+
for (var i = 0; i < cl; i++) {
|
335
|
+
if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
|
336
|
+
ac.appendChild(c[i].cloneNode(true));
|
337
|
+
}
|
338
|
+
}
|
339
|
+
}
|
340
|
+
}
|
341
|
+
}
|
342
|
+
return ac;
|
343
|
+
}
|
344
|
+
|
345
|
+
/* Cross-browser dynamic SWF creation
|
346
|
+
*/
|
347
|
+
function createSWF(attObj, parObj, id) {
|
348
|
+
var r, el = getElementById(id);
|
349
|
+
if (el) {
|
350
|
+
if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
|
351
|
+
attObj.id = id;
|
352
|
+
}
|
353
|
+
if (ua.ie && ua.win) { // IE, the object element and W3C DOM methods do not combine: fall back to outerHTML
|
354
|
+
var att = "";
|
355
|
+
for (var i in attObj) {
|
356
|
+
if (attObj[i] != Object.prototype[i]) { // Filter out prototype additions from other potential libraries, like Object.prototype.toJSONString = function() {}
|
357
|
+
if (i.toLowerCase() == "data") {
|
358
|
+
parObj.movie = attObj[i];
|
359
|
+
}
|
360
|
+
else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
|
361
|
+
att += ' class="' + attObj[i] + '"';
|
362
|
+
}
|
363
|
+
else if (i.toLowerCase() != "classid") {
|
364
|
+
att += ' ' + i + '="' + attObj[i] + '"';
|
365
|
+
}
|
366
|
+
}
|
367
|
+
}
|
368
|
+
var par = "";
|
369
|
+
for (var j in parObj) {
|
370
|
+
if (parObj[j] != Object.prototype[j]) { // Filter out prototype additions from other potential libraries
|
371
|
+
par += '<param name="' + j + '" value="' + parObj[j] + '" />';
|
372
|
+
}
|
373
|
+
}
|
374
|
+
el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
|
375
|
+
objIdArr[objIdArr.length] = attObj.id; // Stored to fix object 'leaks' on unload (dynamic publishing only)
|
376
|
+
r = getElementById(attObj.id);
|
377
|
+
}
|
378
|
+
else if (ua.webkit && ua.webkit < 312) { // Older webkit engines ignore the object element's nested param elements: fall back to the proprietary embed element
|
379
|
+
var e = createElement("embed");
|
380
|
+
e.setAttribute("type", FLASH_MIME_TYPE);
|
381
|
+
for (var k in attObj) {
|
382
|
+
if (attObj[k] != Object.prototype[k]) { // Filter out prototype additions from other potential libraries
|
383
|
+
if (k.toLowerCase() == "data") {
|
384
|
+
e.setAttribute("src", attObj[k]);
|
385
|
+
}
|
386
|
+
else if (k.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
|
387
|
+
e.setAttribute("class", attObj[k]);
|
388
|
+
}
|
389
|
+
else if (k.toLowerCase() != "classid") { // Filter out IE specific attribute
|
390
|
+
e.setAttribute(k, attObj[k]);
|
391
|
+
}
|
392
|
+
}
|
393
|
+
}
|
394
|
+
for (var l in parObj) {
|
395
|
+
if (parObj[l] != Object.prototype[l]) { // Filter out prototype additions from other potential libraries
|
396
|
+
if (l.toLowerCase() != "movie") { // Filter out IE specific param element
|
397
|
+
e.setAttribute(l, parObj[l]);
|
398
|
+
}
|
399
|
+
}
|
400
|
+
}
|
401
|
+
el.parentNode.replaceChild(e, el);
|
402
|
+
r = e;
|
403
|
+
}
|
404
|
+
else { // Well-behaving browsers
|
405
|
+
var o = createElement(OBJECT);
|
406
|
+
o.setAttribute("type", FLASH_MIME_TYPE);
|
407
|
+
for (var m in attObj) {
|
408
|
+
if (attObj[m] != Object.prototype[m]) { // Filter out prototype additions from other potential libraries
|
409
|
+
if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
|
410
|
+
o.setAttribute("class", attObj[m]);
|
411
|
+
}
|
412
|
+
else if (m.toLowerCase() != "classid") { // Filter out IE specific attribute
|
413
|
+
o.setAttribute(m, attObj[m]);
|
414
|
+
}
|
415
|
+
}
|
416
|
+
}
|
417
|
+
for (var n in parObj) {
|
418
|
+
if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // Filter out prototype additions from other potential libraries and IE specific param element
|
419
|
+
createObjParam(o, n, parObj[n]);
|
420
|
+
}
|
421
|
+
}
|
422
|
+
el.parentNode.replaceChild(o, el);
|
423
|
+
r = o;
|
424
|
+
}
|
425
|
+
}
|
426
|
+
return r;
|
427
|
+
}
|
428
|
+
|
429
|
+
function createObjParam(el, pName, pValue) {
|
430
|
+
var p = createElement("param");
|
431
|
+
p.setAttribute("name", pName);
|
432
|
+
p.setAttribute("value", pValue);
|
433
|
+
el.appendChild(p);
|
434
|
+
}
|
435
|
+
|
436
|
+
/* Cross-browser SWF removal
|
437
|
+
- Especially needed to safely and completely remove a SWF in Internet Explorer
|
438
|
+
*/
|
439
|
+
function removeSWF(id) {
|
440
|
+
var obj = getElementById(id);
|
441
|
+
if (obj && (obj.nodeName == "OBJECT" || obj.nodeName == "EMBED")) {
|
442
|
+
if (ua.ie && ua.win) {
|
443
|
+
if (obj.readyState == 4) {
|
444
|
+
removeObjectInIE(id);
|
445
|
+
}
|
446
|
+
else {
|
447
|
+
win.attachEvent("onload", function() {
|
448
|
+
removeObjectInIE(id);
|
449
|
+
});
|
450
|
+
}
|
451
|
+
}
|
452
|
+
else {
|
453
|
+
obj.parentNode.removeChild(obj);
|
454
|
+
}
|
455
|
+
}
|
456
|
+
}
|
457
|
+
|
458
|
+
function removeObjectInIE(id) {
|
459
|
+
var obj = getElementById(id);
|
460
|
+
if (obj) {
|
461
|
+
for (var i in obj) {
|
462
|
+
if (typeof obj[i] == "function") {
|
463
|
+
obj[i] = null;
|
464
|
+
}
|
465
|
+
}
|
466
|
+
obj.parentNode.removeChild(obj);
|
467
|
+
}
|
468
|
+
}
|
469
|
+
|
470
|
+
/* Functions to optimize JavaScript compression
|
471
|
+
*/
|
472
|
+
function getElementById(id) {
|
473
|
+
var el = null;
|
474
|
+
try {
|
475
|
+
el = doc.getElementById(id);
|
476
|
+
}
|
477
|
+
catch (e) {}
|
478
|
+
return el;
|
479
|
+
}
|
480
|
+
|
481
|
+
function createElement(el) {
|
482
|
+
return doc.createElement(el);
|
483
|
+
}
|
484
|
+
|
485
|
+
/* Updated attachEvent function for Internet Explorer
|
486
|
+
- Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks
|
487
|
+
*/
|
488
|
+
function addListener(target, eventType, fn) {
|
489
|
+
target.attachEvent(eventType, fn);
|
490
|
+
listenersArr[listenersArr.length] = [target, eventType, fn];
|
491
|
+
}
|
492
|
+
|
493
|
+
/* Flash Player and SWF content version matching
|
494
|
+
*/
|
495
|
+
function hasPlayerVersion(rv) {
|
496
|
+
var pv = ua.pv, v = rv.split(".");
|
497
|
+
v[0] = parseInt(v[0], 10);
|
498
|
+
v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
|
499
|
+
v[2] = parseInt(v[2], 10) || 0;
|
500
|
+
return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
|
501
|
+
}
|
502
|
+
|
503
|
+
/* Cross-browser dynamic CSS creation
|
504
|
+
- Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php
|
505
|
+
*/
|
506
|
+
function createCSS(sel, decl) {
|
507
|
+
if (ua.ie && ua.mac) {
|
508
|
+
return;
|
509
|
+
}
|
510
|
+
var h = doc.getElementsByTagName("head")[0], s = createElement("style");
|
511
|
+
s.setAttribute("type", "text/css");
|
512
|
+
s.setAttribute("media", "screen");
|
513
|
+
if (!(ua.ie && ua.win) && typeof doc.createTextNode != UNDEF) {
|
514
|
+
s.appendChild(doc.createTextNode(sel + " {" + decl + "}"));
|
515
|
+
}
|
516
|
+
h.appendChild(s);
|
517
|
+
if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) {
|
518
|
+
var ls = doc.styleSheets[doc.styleSheets.length - 1];
|
519
|
+
if (typeof ls.addRule == OBJECT) {
|
520
|
+
ls.addRule(sel, decl);
|
521
|
+
}
|
522
|
+
}
|
523
|
+
}
|
524
|
+
|
525
|
+
function setVisibility(id, isVisible) {
|
526
|
+
var v = isVisible ? "visible" : "hidden";
|
527
|
+
if (isDomLoaded && getElementById(id)) {
|
528
|
+
getElementById(id).style.visibility = v;
|
529
|
+
}
|
530
|
+
else {
|
531
|
+
createCSS("#" + id, "visibility:" + v);
|
532
|
+
}
|
533
|
+
}
|
534
|
+
|
535
|
+
/* Filter to avoid XSS attacks
|
536
|
+
*/
|
537
|
+
function urlEncodeIfNecessary(s) {
|
538
|
+
var regex = /[\\\"<>\.;]/;
|
539
|
+
var hasBadChars = regex.exec(s) != null;
|
540
|
+
return hasBadChars ? encodeURIComponent(s) : s;
|
541
|
+
}
|
542
|
+
|
543
|
+
/* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only)
|
544
|
+
*/
|
545
|
+
var cleanup = function() {
|
546
|
+
if (ua.ie && ua.win) {
|
547
|
+
window.attachEvent("onunload", function() {
|
548
|
+
// remove listeners to avoid memory leaks
|
549
|
+
var ll = listenersArr.length;
|
550
|
+
for (var i = 0; i < ll; i++) {
|
551
|
+
listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]);
|
552
|
+
}
|
553
|
+
// cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect
|
554
|
+
var il = objIdArr.length;
|
555
|
+
for (var j = 0; j < il; j++) {
|
556
|
+
removeSWF(objIdArr[j]);
|
557
|
+
}
|
558
|
+
// cleanup library's main closures to avoid memory leaks
|
559
|
+
for (var k in ua) {
|
560
|
+
ua[k] = null;
|
561
|
+
}
|
562
|
+
ua = null;
|
563
|
+
for (var l in swfobject) {
|
564
|
+
swfobject[l] = null;
|
565
|
+
}
|
566
|
+
swfobject = null;
|
567
|
+
});
|
568
|
+
}
|
569
|
+
}();
|
570
|
+
|
571
|
+
|
572
|
+
return {
|
573
|
+
/* Public API
|
574
|
+
- Reference: http://code.google.com/p/swfobject/wiki/SWFObject_2_0_documentation
|
575
|
+
*/
|
576
|
+
registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr) {
|
577
|
+
if (!ua.w3cdom || !objectIdStr || !swfVersionStr) {
|
578
|
+
return;
|
579
|
+
}
|
580
|
+
var regObj = {};
|
581
|
+
regObj.id = objectIdStr;
|
582
|
+
regObj.swfVersion = swfVersionStr;
|
583
|
+
regObj.expressInstall = xiSwfUrlStr ? xiSwfUrlStr : false;
|
584
|
+
regObjArr[regObjArr.length] = regObj;
|
585
|
+
setVisibility(objectIdStr, false);
|
586
|
+
},
|
587
|
+
|
588
|
+
getObjectById: function(objectIdStr) {
|
589
|
+
var r = null;
|
590
|
+
if (ua.w3cdom) {
|
591
|
+
var o = getElementById(objectIdStr);
|
592
|
+
if (o) {
|
593
|
+
var n = o.getElementsByTagName(OBJECT)[0];
|
594
|
+
if (!n || (n && typeof o.SetVariable != UNDEF)) {
|
595
|
+
r = o;
|
596
|
+
}
|
597
|
+
else if (typeof n.SetVariable != UNDEF) {
|
598
|
+
r = n;
|
599
|
+
}
|
600
|
+
}
|
601
|
+
}
|
602
|
+
return r;
|
603
|
+
},
|
604
|
+
|
605
|
+
embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj) {
|
606
|
+
if (!ua.w3cdom || !swfUrlStr || !replaceElemIdStr || !widthStr || !heightStr || !swfVersionStr) {
|
607
|
+
return;
|
608
|
+
}
|
609
|
+
widthStr += ""; // Auto-convert to string
|
610
|
+
heightStr += "";
|
611
|
+
if (hasPlayerVersion(swfVersionStr)) {
|
612
|
+
setVisibility(replaceElemIdStr, false);
|
613
|
+
var att = {};
|
614
|
+
if (attObj && typeof attObj === OBJECT) {
|
615
|
+
for (var i in attObj) {
|
616
|
+
if (attObj[i] != Object.prototype[i]) { // Filter out prototype additions from other potential libraries
|
617
|
+
att[i] = attObj[i];
|
618
|
+
}
|
619
|
+
}
|
620
|
+
}
|
621
|
+
att.data = swfUrlStr;
|
622
|
+
att.width = widthStr;
|
623
|
+
att.height = heightStr;
|
624
|
+
var par = {};
|
625
|
+
if (parObj && typeof parObj === OBJECT) {
|
626
|
+
for (var j in parObj) {
|
627
|
+
if (parObj[j] != Object.prototype[j]) { // Filter out prototype additions from other potential libraries
|
628
|
+
par[j] = parObj[j];
|
629
|
+
}
|
630
|
+
}
|
631
|
+
}
|
632
|
+
if (flashvarsObj && typeof flashvarsObj === OBJECT) {
|
633
|
+
for (var k in flashvarsObj) {
|
634
|
+
if (flashvarsObj[k] != Object.prototype[k]) { // Filter out prototype additions from other potential libraries
|
635
|
+
if (typeof par.flashvars != UNDEF) {
|
636
|
+
par.flashvars += "&" + k + "=" + flashvarsObj[k];
|
637
|
+
}
|
638
|
+
else {
|
639
|
+
par.flashvars = k + "=" + flashvarsObj[k];
|
640
|
+
}
|
641
|
+
}
|
642
|
+
}
|
643
|
+
}
|
644
|
+
addDomLoadEvent(function() {
|
645
|
+
createSWF(att, par, replaceElemIdStr);
|
646
|
+
if (att.id == replaceElemIdStr) {
|
647
|
+
setVisibility(replaceElemIdStr, true);
|
648
|
+
}
|
649
|
+
});
|
650
|
+
}
|
651
|
+
else if (xiSwfUrlStr && !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac)) {
|
652
|
+
isExpressInstallActive = true; // deferred execution
|
653
|
+
setVisibility(replaceElemIdStr, false);
|
654
|
+
addDomLoadEvent(function() {
|
655
|
+
var regObj = {};
|
656
|
+
regObj.id = regObj.altContentId = replaceElemIdStr;
|
657
|
+
regObj.width = widthStr;
|
658
|
+
regObj.height = heightStr;
|
659
|
+
regObj.expressInstall = xiSwfUrlStr;
|
660
|
+
showExpressInstall(regObj);
|
661
|
+
});
|
662
|
+
}
|
663
|
+
},
|
664
|
+
|
665
|
+
getFlashPlayerVersion: function() {
|
666
|
+
return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
|
667
|
+
},
|
668
|
+
|
669
|
+
hasFlashPlayerVersion: hasPlayerVersion,
|
670
|
+
|
671
|
+
createSWF: function(attObj, parObj, replaceElemIdStr) {
|
672
|
+
if (ua.w3cdom) {
|
673
|
+
return createSWF(attObj, parObj, replaceElemIdStr);
|
674
|
+
}
|
675
|
+
else {
|
676
|
+
return undefined;
|
677
|
+
}
|
678
|
+
},
|
679
|
+
|
680
|
+
removeSWF: function(objElemIdStr) {
|
681
|
+
if (ua.w3cdom) {
|
682
|
+
removeSWF(objElemIdStr);
|
683
|
+
}
|
684
|
+
},
|
685
|
+
|
686
|
+
createCSS: function(sel, decl) {
|
687
|
+
if (ua.w3cdom) {
|
688
|
+
createCSS(sel, decl);
|
689
|
+
}
|
690
|
+
},
|
691
|
+
|
692
|
+
addDomLoadEvent: addDomLoadEvent,
|
693
|
+
|
694
|
+
addLoadEvent: addLoadEvent,
|
695
|
+
|
696
|
+
getQueryParamValue: function(param) {
|
697
|
+
var q = doc.location.search || doc.location.hash;
|
698
|
+
if (param == null) {
|
699
|
+
return urlEncodeIfNecessary(q);
|
700
|
+
}
|
701
|
+
if (q) {
|
702
|
+
var pairs = q.substring(1).split("&");
|
703
|
+
for (var i = 0; i < pairs.length; i++) {
|
704
|
+
if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
|
705
|
+
return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1)));
|
706
|
+
}
|
707
|
+
}
|
708
|
+
}
|
709
|
+
return "";
|
710
|
+
},
|
711
|
+
|
712
|
+
// For internal usage only
|
713
|
+
expressInstallCallback: function() {
|
714
|
+
if (isExpressInstallActive && storedAltContent) {
|
715
|
+
var obj = getElementById(EXPRESS_INSTALL_ID);
|
716
|
+
if (obj) {
|
717
|
+
obj.parentNode.replaceChild(storedAltContent, obj);
|
718
|
+
if (storedAltContentId) {
|
719
|
+
setVisibility(storedAltContentId, true);
|
720
|
+
if (ua.ie && ua.win) {
|
721
|
+
storedAltContent.style.display = "block";
|
722
|
+
}
|
723
|
+
}
|
724
|
+
storedAltContent = null;
|
725
|
+
storedAltContentId = null;
|
726
|
+
isExpressInstallActive = false;
|
727
|
+
}
|
728
|
+
}
|
729
|
+
}
|
730
|
+
};
|
731
|
+
}();
|