mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
- adds graded support
- update readme - bump package
This commit is contained in:
parent
6d5a30df55
commit
6792081d03
29
README.md
29
README.md
@ -4,9 +4,11 @@ A Browser detector. Because sometimes, there is no other way, and not even good
|
||||
|
||||
So... it works like this:
|
||||
|
||||
if (bowser().msie && bowser().version <= 6) {
|
||||
alert('hello China');
|
||||
``` js
|
||||
if (bowser.msie && bowser.version <= 6) {
|
||||
alert('Hello China');
|
||||
}
|
||||
```
|
||||
|
||||
Detected Browsers
|
||||
-----
|
||||
@ -19,11 +21,13 @@ Detected Browsers
|
||||
|
||||
Notes
|
||||
----
|
||||
safari,chrome, and firefox will report that they have webkit|gecko engines
|
||||
Safari, Chrome, and Firefox will report that they have webkit|gecko engines
|
||||
|
||||
if (bowser().webkit) {
|
||||
``` js
|
||||
if (bowser.webkit) {
|
||||
// do stuff with safari & chrome
|
||||
}
|
||||
```
|
||||
|
||||
Ender installation
|
||||
-----
|
||||
@ -37,6 +41,23 @@ then add bowser to your module collection
|
||||
|
||||
use it like this:
|
||||
|
||||
``` js
|
||||
if ($.browser.chrome) {
|
||||
alert('Hello Silicon Valley');
|
||||
}
|
||||
```
|
||||
|
||||
Graded Browser Support
|
||||
---------
|
||||
One useful feature of Bowser is that aside from checking one browser from another -- it will keep up to date with [Yahoo's Graded Browser Support](http://developer.yahoo.com/yui/articles/gbs/) chart, giving you access to each grade on the bowser object
|
||||
|
||||
``` js
|
||||
if (bowser.a) {
|
||||
// support full feature set
|
||||
}
|
||||
else if (bowser.c) {
|
||||
// serve degraded version
|
||||
}
|
||||
else {
|
||||
// unsupported (bowser.x)
|
||||
}
|
32
bowser.js
32
bowser.js
@ -20,13 +20,7 @@
|
||||
safari = /safari/i.test(ua) && !chrome,
|
||||
opera = /opera/i.test(ua),
|
||||
firefox = /firefox/i.test(ua),
|
||||
gecko = /gecko\//i.test(ua),
|
||||
info;
|
||||
|
||||
function bowser() {
|
||||
info = info ? info : detect();
|
||||
return info;
|
||||
}
|
||||
gecko = /gecko\//i.test(ua);
|
||||
|
||||
function detect() {
|
||||
|
||||
@ -69,8 +63,30 @@
|
||||
|
||||
}
|
||||
|
||||
var bowser = detect();
|
||||
|
||||
// Graded Browser Support
|
||||
// http://developer.yahoo.com/yui/articles/gbs
|
||||
if ((bowser.msie && bowser.version >= 6) ||
|
||||
(bowser.chrome && bowser.version >= 8) ||
|
||||
(bowser.firefox && bowser.version >= 3.6) ||
|
||||
(bowser.safari && bowser.version >= 5) ||
|
||||
(bowser.opera && bowser.version >= 9.5)) {
|
||||
bowser.a = true;
|
||||
}
|
||||
|
||||
else if ((bowser.msie && bowser.version < 6) ||
|
||||
(bowser.chrome && bowser.version < 8) ||
|
||||
(bowser.firefox && bowser.version < 3.6) ||
|
||||
(bowser.safari && bowser.version < 5) ||
|
||||
(bowser.opera && bowser.version < 9.5)) {
|
||||
bowser.c = true;
|
||||
} else {
|
||||
bowser.x = true;
|
||||
}
|
||||
|
||||
typeof module !== 'undefined' && module.exports ?
|
||||
(module.exports.browser = bowser()) :
|
||||
(module.exports.browser = bowser) :
|
||||
(context.bowser = bowser);
|
||||
|
||||
}(this);
|
2
bowser.min.js
vendored
2
bowser.min.js
vendored
@ -4,4 +4,4 @@
|
||||
* https://github.com/ded/bowser
|
||||
* MIT License
|
||||
*/
|
||||
!function(a){function k(){if(c)return{msie:1,version:b.match(/msie ([\d\.]+);/i)[1]};if(d)return{webkit:1,chrome:1,version:b.match(/chrome\/([\d\.]+)/i)[1]};if(e)return{webkit:1,safari:1,version:b.match(/version\/([\d\.]+)/i)[1]};if(f)return{opera:1,version:b.match(/version\/([\d\.]+)/i)[1]};if(h){var a={gecko:1,version:b.match(/firefox\/([\d\.]+)/i)[1]};g&&(a.firefox=1);return a}}function j(){i=i?i:k();return i}var b=navigator.userAgent,c=/msie/i.test(b),d=/chrome/i.test(b),e=/safari/i.test(b)&&!d,f=/opera/i.test(b),g=/firefox/i.test(b),h=/gecko\//i.test(b),i;typeof module!="undefined"&&module.exports?module.exports.browser=j():a.bowser=j}(this)
|
||||
!function(a){function i(){if(c)return{msie:1,version:b.match(/msie ([\d\.]+);/i)[1]};if(d)return{webkit:1,chrome:1,version:b.match(/chrome\/([\d\.]+)/i)[1]};if(e)return{webkit:1,safari:1,version:b.match(/version\/([\d\.]+)/i)[1]};if(f)return{opera:1,version:b.match(/version\/([\d\.]+)/i)[1]};if(h){var a={gecko:1,version:b.match(/firefox\/([\d\.]+)/i)[1]};g&&(a.firefox=1);return a}}var b=navigator.userAgent,c=/msie/i.test(b),d=/chrome/i.test(b),e=/safari/i.test(b)&&!d,f=/opera/i.test(b),g=/firefox/i.test(b),h=/gecko\//i.test(b),j=i();j.msie&&j.version>=6||j.chrome&&j.version>=8||j.firefox&&j.version>=3.6||j.safari&&j.version>=5||j.opera&&j.version>=9.5?j.a=!0:j.msie&&j.version<6||j.chrome&&j.version<8||j.firefox&&j.version<3.6||j.safari&&j.version<5||j.opera&&j.version<9.5?j.c=!0:j.x=!0,typeof module!="undefined"&&module.exports?module.exports.browser=j:a.bowser=j}(this)
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "bowser",
|
||||
"description": "a browser detector",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.3",
|
||||
"homepage": "https://github.com/ded/bowser",
|
||||
"author": "Dustin Diaz <@ded>",
|
||||
"repository": {
|
||||
|
@ -14,13 +14,7 @@
|
||||
safari = /safari/i.test(ua) && !chrome,
|
||||
opera = /opera/i.test(ua),
|
||||
firefox = /firefox/i.test(ua),
|
||||
gecko = /gecko\//i.test(ua),
|
||||
info;
|
||||
|
||||
function bowser() {
|
||||
info = info ? info : detect();
|
||||
return info;
|
||||
}
|
||||
gecko = /gecko\//i.test(ua);
|
||||
|
||||
function detect() {
|
||||
|
||||
@ -63,8 +57,30 @@
|
||||
|
||||
}
|
||||
|
||||
var bowser = detect();
|
||||
|
||||
// Graded Browser Support
|
||||
// http://developer.yahoo.com/yui/articles/gbs
|
||||
if ((bowser.msie && bowser.version >= 6) ||
|
||||
(bowser.chrome && bowser.version >= 8) ||
|
||||
(bowser.firefox && bowser.version >= 3.6) ||
|
||||
(bowser.safari && bowser.version >= 5) ||
|
||||
(bowser.opera && bowser.version >= 9.5)) {
|
||||
bowser.a = true;
|
||||
}
|
||||
|
||||
else if ((bowser.msie && bowser.version < 6) ||
|
||||
(bowser.chrome && bowser.version < 8) ||
|
||||
(bowser.firefox && bowser.version < 3.6) ||
|
||||
(bowser.safari && bowser.version < 5) ||
|
||||
(bowser.opera && bowser.version < 9.5)) {
|
||||
bowser.c = true;
|
||||
} else {
|
||||
bowser.x = true;
|
||||
}
|
||||
|
||||
typeof module !== 'undefined' && module.exports ?
|
||||
(module.exports.browser = bowser()) :
|
||||
(module.exports.browser = bowser) :
|
||||
(context.bowser = bowser);
|
||||
|
||||
}(this);
|
Loading…
Reference in New Issue
Block a user