diff --git a/assets/javascripts/app/router.coffee b/assets/javascripts/app/router.coffee index 3b167e1b..9a0e0b0a 100644 --- a/assets/javascripts/app/router.coffee +++ b/assets/javascripts/app/router.coffee @@ -112,18 +112,15 @@ class app.Router @triggerRoute 'notFound' return - isRoot: -> - location.pathname is '/' - - isDocIndex: -> - @context and @context.doc and @context.entry is @context.doc.toEntry() + isIndex: -> + @context.path is '/' or (app.isSingleDoc() and @context?.entry?.isIndex()) setInitialPath: -> # Remove superfluous forward slashes at the beginning of the path if (path = location.pathname.replace /^\/{2,}/g, '/') isnt location.pathname page.replace path + location.search + location.hash, null, true - if @isRoot() + if location.pathname is '/' if path = @getInitialPathFromHash() page.replace path + location.search, null, true else if path = @getInitialPathFromCookie() diff --git a/assets/javascripts/views/search/search.coffee b/assets/javascripts/views/search/search.coffee index e4f3900c..b9d72b6a 100644 --- a/assets/javascripts/views/search/search.coffee +++ b/assets/javascripts/views/search/search.coffee @@ -19,7 +19,6 @@ class app.views.Search extends app.View altS: 'stackoverflow' @routes: - root: 'onRoot' after: 'afterRoute' init: -> @@ -77,9 +76,9 @@ class app.views.Search extends app.View return searchUrl: => - if app.router.isRoot() + if location.pathname is '/' @scope.searchUrl() - else if not app.router.isDocIndex() + else if not app.router.isIndex() return return unless value = @extractHashValue() @@ -129,11 +128,8 @@ class app.views.Search extends app.View $.stopEvent(event) return - onRoot: (context) => - @reset() unless context.init - return - afterRoute: (name, context) => + @reset() if not context.init and app.router.isIndex() @delay @searchUrl if context.hash @delay @autoFocus return