Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
modernizr.environ.coffee
"use strict"
do ->
if !window.Modernizr
return
ua = new String(window.navigator.userAgent.toLowerCase())
ua.has = (cond) ->
@indexOf(cond) != -1
msie = ua.has('msie')
chrome = ua.has('chrome')
safari = ua.has('safari') && chrome
firefox = ua.has('firefox')
opera = ua.has('opera') || ua.has('opr/') #opera 15+
window.Modernizr.addTest {
'msie' : () ->
msie
'chrome' : () ->
chrome
'safari' : () ->
safari
'firefox' : () ->
firefox
'opera' : () ->
opera
}
iphone = ua.has('iphone')
ipod = ua.has('ipod')
ipad = ua.has('ipad')
macosx = ua.has('mac os x')
android = ua.has('android')
androidPhone = android && ua.has('mobile')
androidTablet = android && ! ua.has('mobile')
windows = ua.has('windows')
windowsPhone = windows && ua.has('phone')
windowsTablet = windows && ua.has('touch')
window.Modernizr.addTest {
'ios' : () ->
iphone || ipod || ipad
'iphone' : () ->
iphone
'ipod' : () ->
ipod
'ipad' : () ->
ipad
'macosx' : () ->
macosx
'android' : () ->
android
'androidPhone' : () ->
androidPhone
'androidTablet' : () ->
androidTablet
'windows' : () ->
windows
'windowsPhone' : () ->
windowsPhone
'windowsTablet' : () ->
windowsTablet
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.