mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
parent
4bc31ad41f
commit
48d85f1124
4 changed files with 17 additions and 7 deletions
|
@ -15,8 +15,10 @@
|
|||
@
|
||||
|
||||
trigger: (event, args...) ->
|
||||
@eventInProgress = { name: event, args: args }
|
||||
if callbacks = @_callbacks?[event]
|
||||
callback? args... for callback in callbacks.slice(0)
|
||||
@eventInProgress = null
|
||||
@trigger 'all', event, args... unless event is 'all'
|
||||
@
|
||||
|
||||
|
|
|
@ -44,7 +44,11 @@ class app.views.Search extends app.View
|
|||
@input.focus() unless document.activeElement?.tagName is 'INPUT'
|
||||
return
|
||||
|
||||
reset: ->
|
||||
getScopeDoc: ->
|
||||
@scope.getScope() if @scope.isActive()
|
||||
|
||||
reset: (force) ->
|
||||
@scope.reset() if force or not @input.value
|
||||
@el.reset()
|
||||
@onInput()
|
||||
@autoFocus()
|
||||
|
@ -129,7 +133,8 @@ class app.views.Search extends app.View
|
|||
return
|
||||
|
||||
afterRoute: (name, context) =>
|
||||
@reset() if not context.init and app.router.isIndex()
|
||||
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
|
||||
return
|
||||
|
|
|
@ -11,9 +11,6 @@ class app.views.SearchScope extends app.View
|
|||
@routes:
|
||||
after: 'afterRoute'
|
||||
|
||||
@shortcuts:
|
||||
escape: 'reset'
|
||||
|
||||
constructor: (@el) -> super
|
||||
|
||||
init: ->
|
||||
|
@ -29,6 +26,9 @@ class app.views.SearchScope extends app.View
|
|||
getScope: ->
|
||||
@doc or app
|
||||
|
||||
isActive: ->
|
||||
!!@doc
|
||||
|
||||
name: ->
|
||||
@doc?.name
|
||||
|
||||
|
|
|
@ -129,7 +129,8 @@ class app.views.Sidebar extends app.View
|
|||
|
||||
onEscape: =>
|
||||
@reset()
|
||||
@scrollToTop()
|
||||
@resetDisplay()
|
||||
if doc = @search.getScopeDoc() then @docList.reveal(doc.toEntry()) else @scrollToTop()
|
||||
return
|
||||
|
||||
onDocEnabled: ->
|
||||
|
@ -137,6 +138,8 @@ class app.views.Sidebar extends app.View
|
|||
@reset()
|
||||
return
|
||||
|
||||
afterRoute: =>
|
||||
afterRoute: (name, context) =>
|
||||
return if app.shortcuts.eventInProgress?.name is 'escape'
|
||||
@reset() if not context.init and app.router.isIndex()
|
||||
@resetDisplay()
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue