3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
7 YUI.add('swfdetect', function(Y) {
10 * Utility for Flash version detection
14 // Shortcuts and helper methods
18 sF = "ShockwaveFlash",
22 return parseInt(n, 10);
25 function parseFlashVersion (flashVer) {
26 if (lG.isNumber(makeInt(flashVer[0]))) {
27 uA.flashMajor = flashVer[0];
30 if (lG.isNumber(makeInt(flashVer[1]))) {
31 uA.flashMinor = flashVer[1];
34 if (lG.isNumber(makeInt(flashVer[2]))) {
35 uA.flashRev = flashVer[2];
39 if (uA.gecko || uA.webkit || uA.opera) {
40 if ((mF = navigator.mimeTypes['application/x-shockwave-flash'])) {
41 if ((eP = mF.enabledPlugin)) {
42 vS = eP.description.replace(/\s[rd]/g, '.').replace(/[A-Za-z\s]+/g, '').split('.');
43 parseFlashVersion(vS);
50 ax6 = new ActiveXObject(sF + "." + sF + ".6");
51 ax6.AllowScriptAccess = "always";
63 ax = new ActiveXObject(sF + "." + sF);
64 vS = ax.GetVariable("$version").replace(/[A-Za-z\s]+/g, '').split(',');
65 parseFlashVersion(vS);
70 /** Create a calendar view to represent a single or multiple
71 * month range of dates, rendered as a grid with date and
82 * Returns the version of either the Flash Player plugin (in Mozilla/WebKit/Opera browsers),
83 * or the Flash Player ActiveX control (in IE), as a String of the form "MM.mm.rr", where
84 * MM is the major version, mm is the minor version, and rr is the revision.
85 * @method getFlashVersion
88 getFlashVersion : function () {
89 return (String(uA.flashMajor) + "." + String(uA.flashMinor) + "." + String(uA.flashRev));
93 * Checks whether the version of the Flash player installed on the user's machine is greater
94 * than or equal to the one specified. If it is, this method returns true; it is false otherwise.
95 * @method isFlashVersionAtLeast
96 * @return {Boolean} Whether the Flash player version is greater than or equal to the one specified.
97 * @param flashMajor {int} The Major version of the Flash player to compare against.
98 * @param flashMinor {int} The Minor version of the Flash player to compare against.
99 * @param flashRev {int} The Revision version of the Flash player to compare against.
101 isFlashVersionAtLeast : function (flashMajor, flashMinor, flashRev) {
102 var uaMajor = makeInt(uA.flashMajor),
103 uaMinor = makeInt(uA.flashMinor),
104 uaRev = makeInt(uA.flashRev);
106 flashMajor = makeInt(flashMajor || 0);
107 flashMinor = makeInt(flashMinor || 0);
108 flashRev = makeInt(flashRev || 0);
110 if (flashMajor === uaMajor) {
111 if (flashMinor === uaMinor) {
112 return flashRev <= uaRev;
114 return flashMinor < uaMinor;
116 return flashMajor < uaMajor;
121 }, '3.5.0' ,{requires:['yui-base']});