]> git.wh0rd.org Git - tt-rss.git/blob - lib/dojo/sniff.js.uncompressed.js
4d52a43f34347a64d38487c867dc9568300b090e
[tt-rss.git] / lib / dojo / sniff.js.uncompressed.js
1 define("dojo/sniff", ["./has"], function(has){
2         // module:
3         //              dojo/sniff
4
5         /*=====
6         return function(){
7                 // summary:
8                 //              This module sets has() flags based on the current browser.
9                 //              It returns the has() function.
10         };
11         =====*/
12
13         if( 1 ){
14                 var n = navigator,
15                         dua = n.userAgent,
16                         dav = n.appVersion,
17                         tv = parseFloat(dav);
18
19                 has.add("air", dua.indexOf("AdobeAIR") >= 0),
20                 has.add("khtml", dav.indexOf("Konqueror") >= 0 ? tv : undefined);
21                 has.add("webkit", parseFloat(dua.split("WebKit/")[1]) || undefined);
22                 has.add("chrome", parseFloat(dua.split("Chrome/")[1]) || undefined);
23                 has.add("safari", dav.indexOf("Safari")>=0 && !has("chrome") ? parseFloat(dav.split("Version/")[1]) : undefined);
24                 has.add("mac", dav.indexOf("Macintosh") >= 0);
25                 has.add("quirks", document.compatMode == "BackCompat");
26                 has.add("ios", /iPhone|iPod|iPad/.test(dua));
27                 has.add("android", parseFloat(dua.split("Android ")[1]) || undefined);
28
29                 if(!has("webkit")){
30                         // Opera
31                         if(dua.indexOf("Opera") >= 0){
32                                 // see http://dev.opera.com/articles/view/opera-ua-string-changes and http://www.useragentstring.com/pages/Opera/
33                                 // 9.8 has both styles; <9.8, 9.9 only old style
34                                 has.add("opera", tv >= 9.8 ? parseFloat(dua.split("Version/")[1]) || tv : tv);
35                         }
36
37                         // Mozilla and firefox
38                         if(dua.indexOf("Gecko") >= 0 && !has("khtml") && !has("webkit")){
39                                 has.add("mozilla", tv);
40                         }
41                         if(has("mozilla")){
42                                 //We really need to get away from this. Consider a sane isGecko approach for the future.
43                                 has.add("ff", parseFloat(dua.split("Firefox/")[1] || dua.split("Minefield/")[1]) || undefined);
44                         }
45
46                         // IE
47                         if(document.all && !has("opera")){
48                                 var isIE = parseFloat(dav.split("MSIE ")[1]) || undefined;
49
50                                 //In cases where the page has an HTTP header or META tag with
51                                 //X-UA-Compatible, then it is in emulation mode.
52                                 //Make sure isIE reflects the desired version.
53                                 //document.documentMode of 5 means quirks mode.
54                                 //Only switch the value if documentMode's major version
55                                 //is different from isIE's major version.
56                                 var mode = document.documentMode;
57                                 if(mode && mode != 5 && Math.floor(isIE) != mode){
58                                         isIE = mode;
59                                 }
60
61                                 has.add("ie", isIE);
62                         }
63
64                         // Wii
65                         has.add("wii", typeof opera != "undefined" && opera.wiiremote);
66                 }
67         }
68
69         return has;
70 });