~bac/juju-gui/trunkcopy

« back to all changes in this revision

Viewing changes to lib/yui/build/swfdetect/swfdetect-debug.js

  • Committer: kapil.foss at gmail
  • Date: 2012-07-13 18:45:59 UTC
  • Revision ID: kapil.foss@gmail.com-20120713184559-2xl7be17egsrz0c9
reshape

Show diffs side-by-side

added added

removed removed

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