History

Wrap app.isMobile in try/catch

Thibaut committed 11 years ago

Commit e21ac051 parent d570f781 file · +8 −5Browse files

Unified · Split

assets/javascripts/app/app.coffee+8−5
@@ -191,11 +191,14 @@ · 190 unmodified lines
191191 !!(@DOC or @doc)
192192
193193 isMobile: ->
194− # Need to sniff the user agent because some Android and Windows Phone devices don't take
195− # resolution (dpi) into account when reporting device width/height.
196− @_isMobile ?= (matchMedia('(max-device-width: 767px), (max-device-height: 767px)').matches) or
197− (navigator.userAgent.indexOf('Android') isnt -1 and navigator.userAgent.indexOf('Mobile') isnt -1) or
198− (navigator.userAgent.indexOf('IEMobile') isnt -1)
194+ try
195+ # Need to sniff the user agent because some Android and Windows Phone devices don't take
196+ # resolution (dpi) into account when reporting device width/height.
197+ @_isMobile ?= (window.matchMedia('(max-device-width: 767px), (max-device-height: 767px)').matches) or
198+ (navigator.userAgent.indexOf('Android') isnt -1 and navigator.userAgent.indexOf('Mobile') isnt -1) or
199+ (navigator.userAgent.indexOf('IEMobile') isnt -1)
200+ catch
201+ @_isMobile = false
199202
200203 isInvalidLocation: ->
201204 @config.env is 'production' and location.host.indexOf(app.config.production_host) isnt 0