Created
March 1, 2013 12:21
-
-
Save NARKOZ/5064290 to your computer and use it in GitHub Desktop.
jQuery.browser http://api.jquery.com/jQuery.browser/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Restores `$.browser` functionality removed in jQuery 1.9 | |
jQuery.uaMatch = (ua) -> | |
ua = ua.toLowerCase() | |
match = /(chrome)[ \/]([\w.]+)/.exec(ua) or | |
/(webkit)[ \/]([\w.]+)/.exec(ua) or | |
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) or | |
/(msie) ([\w.]+)/.exec(ua) or | |
ua.indexOf("compatible") < 0 and /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) or [] | |
browser: match[1] or '' | |
version: match[2] or '0' | |
matched = jQuery.uaMatch(navigator.userAgent) | |
browser = {} | |
if matched.browser | |
browser[matched.browser] = true | |
browser.version = matched.version | |
if browser.chrome | |
browser.webkit = true | |
else if browser.webkit | |
browser.safari = true | |
jQuery.browser = browser |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment