diff --git a/assets/javascripts/app/app.coffee b/assets/javascripts/app/app.coffee index ec56e021..f16c821b 100644 --- a/assets/javascripts/app/app.coffee +++ b/assets/javascripts/app/app.coffee @@ -191,11 +191,14 @@ !!(@DOC or @doc) isMobile: -> - # Need to sniff the user agent because some Android and Windows Phone devices don't take - # resolution (dpi) into account when reporting device width/height. - @_isMobile ?= (matchMedia('(max-device-width: 767px), (max-device-height: 767px)').matches) or - (navigator.userAgent.indexOf('Android') isnt -1 and navigator.userAgent.indexOf('Mobile') isnt -1) or - (navigator.userAgent.indexOf('IEMobile') isnt -1) + try + # Need to sniff the user agent because some Android and Windows Phone devices don't take + # resolution (dpi) into account when reporting device width/height. + @_isMobile ?= (window.matchMedia('(max-device-width: 767px), (max-device-height: 767px)').matches) or + (navigator.userAgent.indexOf('Android') isnt -1 and navigator.userAgent.indexOf('Mobile') isnt -1) or + (navigator.userAgent.indexOf('IEMobile') isnt -1) + catch + @_isMobile = false isInvalidLocation: -> @config.env is 'production' and location.host.indexOf(app.config.production_host) isnt 0