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
191 !!(@DOC or @doc)191 !!(@DOC or @doc)
192 192
193 isMobile: ->193 isMobile: ->
194 # Need to sniff the user agent because some Android and Windows Phone devices don't take194 try
195 # resolution (dpi) into account when reporting device width/height.195 # Need to sniff the user agent because some Android and Windows Phone devices don't take
196 @_isMobile ?= (matchMedia('(max-device-width: 767px), (max-device-height: 767px)').matches) or196 # resolution (dpi) into account when reporting device width/height.
197 (navigator.userAgent.indexOf('Android') isnt -1 and navigator.userAgent.indexOf('Mobile') isnt -1) or197 @_isMobile ?= (window.matchMedia('(max-device-width: 767px), (max-device-height: 767px)').matches) or
198 (navigator.userAgent.indexOf('IEMobile') isnt -1)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
199 202
200 isInvalidLocation: ->203 isInvalidLocation: ->
201 @config.env is 'production' and location.host.indexOf(app.config.production_host) isnt 0204 @config.env is 'production' and location.host.indexOf(app.config.production_host) isnt 0