]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/javascript/yui/build/swfdetect/swfdetect.js
Release 6.5.0
[Github/sugarcrm.git] / include / javascript / yui / build / swfdetect / swfdetect.js
1 /*
2 Copyright (c) 2011, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
5 version: 2.9.0
6 */
7 /**
8  * Utility for Flash version detection
9  * @namespace YAHOO.util
10  * @module swfdetect
11  */
12 YAHOO.namespace("util");
13
14 /**
15  * Flafh detection utility.
16  * @class SWFDetect
17  * @static
18  */
19 (function () {
20         
21 var version = 0;
22 var uA = YAHOO.env.ua;
23 var sF = "ShockwaveFlash";
24 var mF, eP;
25
26         if (uA.gecko || uA.webkit || uA.opera) {
27                    if ((mF = navigator.mimeTypes['application/x-shockwave-flash'])) {
28                       if ((eP = mF.enabledPlugin)) {
29                                  var vS = [];
30                          vS = eP.description.replace(/\s[rd]/g, '.').replace(/[A-Za-z\s]+/g, '').split('.');
31                         version = vS[0] + '.';
32                                 switch((vS[2].toString()).length)
33                                 {
34                                         case 1:
35                                         version += "00";
36                                         break;
37                                         case 2: 
38                                         version += "0";
39                                         break;
40                                 }
41                                 version +=  vS[2];
42                                 version = parseFloat(version);
43                       }
44                    }
45                 }
46                 else if(uA.ie) {
47                     try
48                     {
49                         var ax6 = new ActiveXObject(sF + "." + sF + ".6");
50                         ax6.AllowScriptAccess = "always";
51                     }
52                     catch(e)
53                     {
54                         if(ax6 != null)
55                         {
56                             version = 6.0;
57                         }
58                     }
59                     if (version == 0) {
60                     try
61                     {
62                         var ax  = new ActiveXObject(sF + "." + sF);
63                         var vS = [];
64                         vS = ax.GetVariable("$version").replace(/[A-Za-z\s]+/g, '').split(',');
65                         version = vS[0] + '.';
66                                 switch((vS[2].toString()).length)
67                                 {
68                                         case 1:
69                                         version += "00";
70                                         break;
71                                         case 2: 
72                                         version += "0";
73                                         break;
74                                 }
75                                 version +=  vS[2];
76                                 version = parseFloat(version);
77                                 
78                     } catch (e) {}
79                     }
80                 }
81                 
82                 uA.flash = version;
83                 
84 YAHOO.util.SWFDetect = {                
85                 getFlashVersion : function () {
86                         return version;
87                 },
88                 
89                 isFlashVersionAtLeast : function (ver) {
90                         return version >= ver;
91                 },
92                 
93                 parseFlashVersion : function (ver)
94                 {
95                         var flashVersion = ver;
96                         if(YAHOO.lang.isString(ver))
97                         {
98                                 var verSplit = ver.split(".");
99                                 if(verSplit.length > 2)
100                                 {
101                                         flashVersion = parseInt(verSplit[0]);
102                                         flashVersion += parseInt(verSplit[2]) * .001;
103                                 }
104                                 else
105                                 {
106                                         flashVersion = parseFloat(ver);
107                                 }                                       
108                         }
109                         return YAHOO.lang.isNumber(flashVersion) ? flashVersion : null;
110                 }                       
111         };
112 })();
113 YAHOO.register("swfdetect", YAHOO.util.SWFDetect, {version: "2.9.0", build: "2800"});