1 |
efrain |
1 |
YUI.add('swfdetect', function (Y, NAME) {
|
|
|
2 |
|
|
|
3 |
/**
|
|
|
4 |
* Utility for Flash version detection
|
|
|
5 |
* @module swfdetect
|
|
|
6 |
*/
|
|
|
7 |
|
|
|
8 |
// Shortcuts and helper methods
|
|
|
9 |
var version = 0,
|
|
|
10 |
uA = Y.UA,
|
|
|
11 |
lG = Y.Lang,
|
|
|
12 |
sF = "ShockwaveFlash",
|
|
|
13 |
mF, eP, vS, ax6, ax;
|
|
|
14 |
|
|
|
15 |
function makeInt(n) {
|
|
|
16 |
return parseInt(n, 10);
|
|
|
17 |
}
|
|
|
18 |
|
|
|
19 |
function parseFlashVersion (flashVer) {
|
|
|
20 |
if (lG.isNumber(makeInt(flashVer[0]))) {
|
|
|
21 |
uA.flashMajor = flashVer[0];
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
if (lG.isNumber(makeInt(flashVer[1]))) {
|
|
|
25 |
uA.flashMinor = flashVer[1];
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
if (lG.isNumber(makeInt(flashVer[2]))) {
|
|
|
29 |
uA.flashRev = flashVer[2];
|
|
|
30 |
}
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
if (uA.gecko || uA.webkit || uA.opera) {
|
|
|
34 |
if ((mF = navigator.mimeTypes['application/x-shockwave-flash'])) {
|
|
|
35 |
if ((eP = mF.enabledPlugin)) {
|
|
|
36 |
vS = eP.description.replace(/\s[rd]/g, '.').replace(/[A-Za-z\s]+/g, '').split('.');
|
|
|
37 |
parseFlashVersion(vS);
|
|
|
38 |
}
|
|
|
39 |
}
|
|
|
40 |
}
|
|
|
41 |
else if(uA.ie) {
|
|
|
42 |
try
|
|
|
43 |
{
|
|
|
44 |
ax6 = new ActiveXObject(sF + "." + sF + ".6");
|
|
|
45 |
ax6.AllowScriptAccess = "always";
|
|
|
46 |
}
|
|
|
47 |
catch (e)
|
|
|
48 |
{
|
|
|
49 |
if(ax6 !== null)
|
|
|
50 |
{
|
|
|
51 |
version = 6.0;
|
|
|
52 |
}
|
|
|
53 |
}
|
|
|
54 |
if (version === 0) {
|
|
|
55 |
try
|
|
|
56 |
{
|
|
|
57 |
ax = new ActiveXObject(sF + "." + sF);
|
|
|
58 |
vS = ax.GetVariable("$version").replace(/[A-Za-z\s]+/g, '').split(',');
|
|
|
59 |
parseFlashVersion(vS);
|
|
|
60 |
} catch (e2) {}
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
/** Create a calendar view to represent a single or multiple
|
|
|
65 |
* month range of dates, rendered as a grid with date and
|
|
|
66 |
* weekday labels.
|
|
|
67 |
*
|
|
|
68 |
* @class SWFDetect
|
|
|
69 |
* @constructor
|
|
|
70 |
*/
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
Y.SWFDetect = {
|
|
|
74 |
|
|
|
75 |
/**
|
|
|
76 |
* Returns the version of either the Flash Player plugin (in Mozilla/WebKit/Opera browsers),
|
|
|
77 |
* or the Flash Player ActiveX control (in IE), as a String of the form "MM.mm.rr", where
|
|
|
78 |
* MM is the major version, mm is the minor version, and rr is the revision.
|
|
|
79 |
* @method getFlashVersion
|
|
|
80 |
*/
|
|
|
81 |
|
|
|
82 |
getFlashVersion : function () {
|
|
|
83 |
return (String(uA.flashMajor) + "." + String(uA.flashMinor) + "." + String(uA.flashRev));
|
|
|
84 |
},
|
|
|
85 |
|
|
|
86 |
/**
|
|
|
87 |
* Checks whether the version of the Flash player installed on the user's machine is greater
|
|
|
88 |
* than or equal to the one specified. If it is, this method returns true; it is false otherwise.
|
|
|
89 |
* @method isFlashVersionAtLeast
|
|
|
90 |
* @return {Boolean} Whether the Flash player version is greater than or equal to the one specified.
|
|
|
91 |
* @param flashMajor {Number} The Major version of the Flash player to compare against.
|
|
|
92 |
* @param flashMinor {Number} The Minor version of the Flash player to compare against.
|
|
|
93 |
* @param flashRev {Number} The Revision version of the Flash player to compare against.
|
|
|
94 |
*/
|
|
|
95 |
isFlashVersionAtLeast : function (flashMajor, flashMinor, flashRev) {
|
|
|
96 |
var uaMajor = makeInt(uA.flashMajor),
|
|
|
97 |
uaMinor = makeInt(uA.flashMinor),
|
|
|
98 |
uaRev = makeInt(uA.flashRev);
|
|
|
99 |
|
|
|
100 |
flashMajor = makeInt(flashMajor || 0);
|
|
|
101 |
flashMinor = makeInt(flashMinor || 0);
|
|
|
102 |
flashRev = makeInt(flashRev || 0);
|
|
|
103 |
|
|
|
104 |
if (flashMajor === uaMajor) {
|
|
|
105 |
if (flashMinor === uaMinor) {
|
|
|
106 |
return flashRev <= uaRev;
|
|
|
107 |
}
|
|
|
108 |
return flashMinor < uaMinor;
|
|
|
109 |
}
|
|
|
110 |
return flashMajor < uaMajor;
|
|
|
111 |
}
|
|
|
112 |
};
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
}, '3.18.1', {"requires": ["yui-base"]});
|