Optimize search autofocus code

pull/647/merge
Thibaut Courouble 8 years ago
parent e2ad2e5117
commit 581e656fd2

@ -31,7 +31,7 @@ class app.views.Search extends app.View
app.on 'ready', @onReady
$.on window, 'hashchange', @searchUrl
$.on window, 'focus', @autoFocus
$.on window, 'focus', @onWindowFocus
return
focus: =>
@ -43,6 +43,9 @@ class app.views.Search extends app.View
@input.focus() unless document.activeElement?.tagName is 'INPUT'
return
onWindowFocus: (event) =>
@autoFocus() if event.target is window
getScopeDoc: ->
@scope.getScope() if @scope.isActive()
@ -135,7 +138,7 @@ class app.views.Search extends app.View
return if app.shortcuts.eventInProgress?.name is 'escape'
@reset(true) if not context.init and app.router.isIndex()
@delay @searchUrl if context.hash
@delay @autoFocus
$.requestAnimationFrame @autoFocus
return
extractHashValue: ->

Loading…
Cancel
Save