Skip to content

Commit 1d235da

Browse files
committed
Tabbed js code. Code now uses 2 Spaces instead of Tabs. Fixes #26 (at least on my machine)
1 parent a13ec52 commit 1d235da

File tree

2 files changed

+190
-192
lines changed

2 files changed

+190
-192
lines changed

dist/jquery.browser.js

Lines changed: 95 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -14,100 +14,99 @@
1414
*/
1515

1616
(function( jQuery, window, undefined ) {
17-
"use strict";
18-
19-
var matched, browser;
20-
21-
jQuery.uaMatch = function( ua ) {
22-
ua = ua.toLowerCase();
23-
24-
var match = /(opr)[\/]([\w.]+)/.exec( ua ) ||
25-
/(chrome)[ \/]([\w.]+)/.exec( ua ) ||
26-
/(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) ||
27-
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
28-
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
29-
/(msie) ([\w.]+)/.exec( ua ) ||
30-
ua.indexOf("trident") >= 0 && /(rv)(?::| )([\w.]+)/.exec( ua ) ||
31-
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
32-
[];
33-
34-
var platform_match = /(ipad)/.exec( ua ) ||
35-
/(iphone)/.exec( ua ) ||
36-
/(android)/.exec( ua ) ||
37-
/(windows phone)/.exec( ua ) ||
38-
/(win)/.exec( ua ) ||
39-
/(mac)/.exec( ua ) ||
40-
/(linux)/.exec( ua ) ||
41-
/(cros)/i.exec( ua ) ||
42-
[];
43-
44-
return {
45-
browser: match[ 3 ] || match[ 1 ] || "",
46-
version: match[ 2 ] || "0",
47-
platform: platform_match[ 0 ] || ""
48-
};
49-
};
50-
51-
matched = jQuery.uaMatch( window.navigator.userAgent );
52-
browser = {};
53-
54-
if ( matched.browser ) {
55-
browser[ matched.browser ] = true;
56-
browser.version = matched.version;
57-
browser.versionNumber = parseInt(matched.version);
58-
}
59-
60-
if ( matched.platform ) {
61-
browser[ matched.platform ] = true;
62-
}
63-
64-
// These are all considered mobile platforms, meaning they run a mobile browser
65-
if ( browser.android || browser.ipad || browser.iphone || browser[ "windows phone" ] ) {
66-
browser.mobile = true;
67-
}
68-
69-
// These are all considered desktop platforms, meaning they run a desktop browser
70-
if ( browser.cros || browser.mac || browser.linux || browser.win ) {
71-
browser.desktop = true;
72-
}
73-
74-
// Chrome, Opera 15+ and Safari are webkit based browsers
75-
if ( browser.chrome || browser.opr || browser.safari ) {
76-
browser.webkit = true;
77-
}
78-
79-
// IE11 has a new token so we will assign it msie to avoid breaking changes
80-
if ( browser.rv )
81-
{
82-
var ie = "msie";
83-
84-
matched.browser = ie;
85-
browser[ie] = true;
86-
}
87-
88-
// Opera 15+ are identified as opr
89-
if ( browser.opr )
90-
{
91-
var opera = "opera";
92-
93-
matched.browser = opera;
94-
browser[opera] = true;
95-
}
96-
97-
// Stock Android browsers are marked as Safari on Android.
98-
if ( browser.safari && browser.android )
99-
{
100-
var android = "android";
101-
102-
matched.browser = android;
103-
browser[android] = true;
104-
}
105-
106-
// Assign the name and platform variable
107-
browser.name = matched.browser;
108-
browser.platform = matched.platform;
109-
110-
111-
jQuery.browser = browser;
112-
17+
"use strict";
18+
19+
var matched, browser;
20+
21+
jQuery.uaMatch = function( ua ) {
22+
ua = ua.toLowerCase();
23+
24+
var match = /(opr)[\/]([\w.]+)/.exec( ua ) ||
25+
/(chrome)[ \/]([\w.]+)/.exec( ua ) ||
26+
/(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) ||
27+
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
28+
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
29+
/(msie) ([\w.]+)/.exec( ua ) ||
30+
ua.indexOf("trident") >= 0 && /(rv)(?::| )([\w.]+)/.exec( ua ) ||
31+
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
32+
[];
33+
34+
var platform_match = /(ipad)/.exec( ua ) ||
35+
/(iphone)/.exec( ua ) ||
36+
/(android)/.exec( ua ) ||
37+
/(windows phone)/.exec( ua ) ||
38+
/(win)/.exec( ua ) ||
39+
/(mac)/.exec( ua ) ||
40+
/(linux)/.exec( ua ) ||
41+
/(cros)/i.exec( ua ) ||
42+
[];
43+
44+
return {
45+
browser: match[ 3 ] || match[ 1 ] || "",
46+
version: match[ 2 ] || "0",
47+
platform: platform_match[ 0 ] || ""
48+
};
49+
};
50+
51+
matched = jQuery.uaMatch( window.navigator.userAgent );
52+
browser = {};
53+
54+
if ( matched.browser ) {
55+
browser[ matched.browser ] = true;
56+
browser.version = matched.version;
57+
browser.versionNumber = parseInt(matched.version);
58+
}
59+
60+
if ( matched.platform ) {
61+
browser[ matched.platform ] = true;
62+
}
63+
64+
// These are all considered mobile platforms, meaning they run a mobile browser
65+
if ( browser.android || browser.ipad || browser.iphone || browser[ "windows phone" ] ) {
66+
browser.mobile = true;
67+
}
68+
69+
// These are all considered desktop platforms, meaning they run a desktop browser
70+
if ( browser.cros || browser.mac || browser.linux || browser.win ) {
71+
browser.desktop = true;
72+
}
73+
74+
// Chrome, Opera 15+ and Safari are webkit based browsers
75+
if ( browser.chrome || browser.opr || browser.safari ) {
76+
browser.webkit = true;
77+
}
78+
79+
// IE11 has a new token so we will assign it msie to avoid breaking changes
80+
if ( browser.rv )
81+
{
82+
var ie = "msie";
83+
84+
matched.browser = ie;
85+
browser[ie] = true;
86+
}
87+
88+
// Opera 15+ are identified as opr
89+
if ( browser.opr )
90+
{
91+
var opera = "opera";
92+
93+
matched.browser = opera;
94+
browser[opera] = true;
95+
}
96+
97+
// Stock Android browsers are marked as Safari on Android.
98+
if ( browser.safari && browser.android )
99+
{
100+
var android = "android";
101+
102+
matched.browser = android;
103+
browser[android] = true;
104+
}
105+
106+
// Assign the name and platform variable
107+
browser.name = matched.browser;
108+
browser.platform = matched.platform;
109+
110+
111+
jQuery.browser = browser;
113112
})( jQuery, window );

test/src/jquery.browser.js

Lines changed: 95 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -14,100 +14,99 @@
1414
*/
1515

1616
(function( jQuery, window, undefined ) {
17-
"use strict";
18-
19-
var matched, browser;
20-
21-
jQuery.uaMatch = function( ua ) {
22-
ua = ua.toLowerCase();
23-
24-
var match = /(opr)[\/]([\w.]+)/.exec( ua ) ||
25-
/(chrome)[ \/]([\w.]+)/.exec( ua ) ||
26-
/(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) ||
27-
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
28-
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
29-
/(msie) ([\w.]+)/.exec( ua ) ||
30-
ua.indexOf("trident") >= 0 && /(rv)(?::| )([\w.]+)/.exec( ua ) ||
31-
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
32-
[];
33-
34-
var platform_match = /(ipad)/.exec( ua ) ||
35-
/(iphone)/.exec( ua ) ||
36-
/(android)/.exec( ua ) ||
37-
/(windows phone)/.exec( ua ) ||
38-
/(win)/.exec( ua ) ||
39-
/(mac)/.exec( ua ) ||
40-
/(linux)/.exec( ua ) ||
41-
/(cros)/i.exec( ua ) ||
42-
[];
43-
44-
return {
45-
browser: match[ 3 ] || match[ 1 ] || "",
46-
version: match[ 2 ] || "0",
47-
platform: platform_match[ 0 ] || ""
48-
};
49-
};
50-
51-
matched = jQuery.uaMatch( window.navigator.userAgent );
52-
browser = {};
53-
54-
if ( matched.browser ) {
55-
browser[ matched.browser ] = true;
56-
browser.version = matched.version;
57-
browser.versionNumber = parseInt(matched.version);
58-
}
59-
60-
if ( matched.platform ) {
61-
browser[ matched.platform ] = true;
62-
}
63-
64-
// These are all considered mobile platforms, meaning they run a mobile browser
65-
if ( browser.android || browser.ipad || browser.iphone || browser[ "windows phone" ] ) {
66-
browser.mobile = true;
67-
}
68-
69-
// These are all considered desktop platforms, meaning they run a desktop browser
70-
if ( browser.cros || browser.mac || browser.linux || browser.win ) {
71-
browser.desktop = true;
72-
}
73-
74-
// Chrome, Opera 15+ and Safari are webkit based browsers
75-
if ( browser.chrome || browser.opr || browser.safari ) {
76-
browser.webkit = true;
77-
}
78-
79-
// IE11 has a new token so we will assign it msie to avoid breaking changes
80-
if ( browser.rv )
81-
{
82-
var ie = "msie";
83-
84-
matched.browser = ie;
85-
browser[ie] = true;
86-
}
87-
88-
// Opera 15+ are identified as opr
89-
if ( browser.opr )
90-
{
91-
var opera = "opera";
92-
93-
matched.browser = opera;
94-
browser[opera] = true;
95-
}
96-
97-
// Stock Android browsers are marked as Safari on Android.
98-
if ( browser.safari && browser.android )
99-
{
100-
var android = "android";
101-
102-
matched.browser = android;
103-
browser[android] = true;
104-
}
105-
106-
// Assign the name and platform variable
107-
browser.name = matched.browser;
108-
browser.platform = matched.platform;
109-
110-
111-
jQuery.browser = browser;
112-
17+
"use strict";
18+
19+
var matched, browser;
20+
21+
jQuery.uaMatch = function( ua ) {
22+
ua = ua.toLowerCase();
23+
24+
var match = /(opr)[\/]([\w.]+)/.exec( ua ) ||
25+
/(chrome)[ \/]([\w.]+)/.exec( ua ) ||
26+
/(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) ||
27+
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
28+
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
29+
/(msie) ([\w.]+)/.exec( ua ) ||
30+
ua.indexOf("trident") >= 0 && /(rv)(?::| )([\w.]+)/.exec( ua ) ||
31+
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
32+
[];
33+
34+
var platform_match = /(ipad)/.exec( ua ) ||
35+
/(iphone)/.exec( ua ) ||
36+
/(android)/.exec( ua ) ||
37+
/(windows phone)/.exec( ua ) ||
38+
/(win)/.exec( ua ) ||
39+
/(mac)/.exec( ua ) ||
40+
/(linux)/.exec( ua ) ||
41+
/(cros)/i.exec( ua ) ||
42+
[];
43+
44+
return {
45+
browser: match[ 3 ] || match[ 1 ] || "",
46+
version: match[ 2 ] || "0",
47+
platform: platform_match[ 0 ] || ""
48+
};
49+
};
50+
51+
matched = jQuery.uaMatch( window.navigator.userAgent );
52+
browser = {};
53+
54+
if ( matched.browser ) {
55+
browser[ matched.browser ] = true;
56+
browser.version = matched.version;
57+
browser.versionNumber = parseInt(matched.version);
58+
}
59+
60+
if ( matched.platform ) {
61+
browser[ matched.platform ] = true;
62+
}
63+
64+
// These are all considered mobile platforms, meaning they run a mobile browser
65+
if ( browser.android || browser.ipad || browser.iphone || browser[ "windows phone" ] ) {
66+
browser.mobile = true;
67+
}
68+
69+
// These are all considered desktop platforms, meaning they run a desktop browser
70+
if ( browser.cros || browser.mac || browser.linux || browser.win ) {
71+
browser.desktop = true;
72+
}
73+
74+
// Chrome, Opera 15+ and Safari are webkit based browsers
75+
if ( browser.chrome || browser.opr || browser.safari ) {
76+
browser.webkit = true;
77+
}
78+
79+
// IE11 has a new token so we will assign it msie to avoid breaking changes
80+
if ( browser.rv )
81+
{
82+
var ie = "msie";
83+
84+
matched.browser = ie;
85+
browser[ie] = true;
86+
}
87+
88+
// Opera 15+ are identified as opr
89+
if ( browser.opr )
90+
{
91+
var opera = "opera";
92+
93+
matched.browser = opera;
94+
browser[opera] = true;
95+
}
96+
97+
// Stock Android browsers are marked as Safari on Android.
98+
if ( browser.safari && browser.android )
99+
{
100+
var android = "android";
101+
102+
matched.browser = android;
103+
browser[android] = true;
104+
}
105+
106+
// Assign the name and platform variable
107+
browser.name = matched.browser;
108+
browser.platform = matched.platform;
109+
110+
111+
jQuery.browser = browser;
113112
})( jQuery, window );

0 commit comments

Comments
 (0)