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