|
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 Y.log(vS[0]); |
|
38 parseFlashVersion(vS); |
|
39 } |
|
40 } |
|
41 } |
|
42 else if(uA.ie) { |
|
43 try |
|
44 { |
|
45 ax6 = new ActiveXObject(sF + "." + sF + ".6"); |
|
46 ax6.AllowScriptAccess = "always"; |
|
47 } |
|
48 catch (e) |
|
49 { |
|
50 if(ax6 !== null) |
|
51 { |
|
52 version = 6.0; |
|
53 } |
|
54 } |
|
55 if (version === 0) { |
|
56 try |
|
57 { |
|
58 ax = new ActiveXObject(sF + "." + sF); |
|
59 vS = ax.GetVariable("$version").replace(/[A-Za-z\s]+/g, '').split(','); |
|
60 parseFlashVersion(vS); |
|
61 } catch (e2) {} |
|
62 } |
|
63 } |
|
64 |
|
65 /** Create a calendar view to represent a single or multiple |
|
66 * month range of dates, rendered as a grid with date and |
|
67 * weekday labels. |
|
68 * |
|
69 * @class SWFDetect |
|
70 * @constructor |
|
71 */ |
|
72 |
|
73 |
|
74 Y.SWFDetect = { |
|
75 |
|
76 /** |
|
77 * Returns the version of either the Flash Player plugin (in Mozilla/WebKit/Opera browsers), |
|
78 * or the Flash Player ActiveX control (in IE), as a String of the form "MM.mm.rr", where |
|
79 * MM is the major version, mm is the minor version, and rr is the revision. |
|
80 * @method getFlashVersion |
|
81 */ |
|
82 |
|
83 getFlashVersion : function () { |
|
84 return (String(uA.flashMajor) + "." + String(uA.flashMinor) + "." + String(uA.flashRev)); |
|
85 }, |
|
86 |
|
87 /** |
|
88 * Checks whether the version of the Flash player installed on the user's machine is greater |
|
89 * than or equal to the one specified. If it is, this method returns true; it is false otherwise. |
|
90 * @method isFlashVersionAtLeast |
|
91 * @return {Boolean} Whether the Flash player version is greater than or equal to the one specified. |
|
92 * @param flashMajor {Number} The Major version of the Flash player to compare against. |
|
93 * @param flashMinor {Number} The Minor version of the Flash player to compare against. |
|
94 * @param flashRev {Number} The Revision version of the Flash player to compare against. |
|
95 */ |
|
96 isFlashVersionAtLeast : function (flashMajor, flashMinor, flashRev) { |
|
97 var uaMajor = makeInt(uA.flashMajor), |
|
98 uaMinor = makeInt(uA.flashMinor), |
|
99 uaRev = makeInt(uA.flashRev); |
|
100 |
|
101 flashMajor = makeInt(flashMajor || 0); |
|
102 flashMinor = makeInt(flashMinor || 0); |
|
103 flashRev = makeInt(flashRev || 0); |
|
104 |
|
105 if (flashMajor === uaMajor) { |
|
106 if (flashMinor === uaMinor) { |
|
107 return flashRev <= uaRev; |
|
108 } |
|
109 return flashMinor < uaMinor; |
|
110 } |
|
111 return flashMajor < uaMajor; |
|
112 } |
|
113 }; |
|
114 |
|
115 |
|
116 }, '@VERSION@', {"requires": ["yui-base"]}); |