History

Reset search field when browsing to index page in single doc mode

Thibaut Courouble committed 9 years ago

Commit 98a6eb51 parent 82743162 files · +6 −13Browse files

Showing the changes to assets/javascripts/views (1 of 2 files). Show all

Unified · Split

assets/javascripts/views/search/search.coffee+3−7
@@ -19,7 +19,6 @@ class app.views.Search extends app.View · 18 unmodified lines
19 altS: 'stackoverflow'19 altS: 'stackoverflow'
20 20
21 @routes:21 @routes:
22 root: 'onRoot'
23 after: 'afterRoute'22 after: 'afterRoute'
24 23
25 init: ->24 init: ->
@@ -77,9 +76,9 @@ class app.views.Search extends app.View · 51 unmodified lines
77 return76 return
78 77
79 searchUrl: =>78 searchUrl: =>
80 if app.router.isRoot()79 if location.pathname is '/'
81 @scope.searchUrl()80 @scope.searchUrl()
82 else if not app.router.isDocIndex()81 else if not app.router.isIndex()
83 return82 return
84 83
85 return unless value = @extractHashValue()84 return unless value = @extractHashValue()
@@ -129,11 +128,8 @@ class app.views.Search extends app.View · 43 unmodified lines
129 $.stopEvent(event)128 $.stopEvent(event)
130 return129 return
131 130
132 onRoot: (context) =>
133 @reset() unless context.init
134 return
135
136 afterRoute: (name, context) =>131 afterRoute: (name, context) =>
132 @reset() if not context.init and app.router.isIndex()
137 @delay @searchUrl if context.hash133 @delay @searchUrl if context.hash
138 @delay @autoFocus134 @delay @autoFocus
139 return135 return