|
|
|
@ -32,19 +32,23 @@ class app.views.SearchScope extends app.View
|
|
|
|
|
name: ->
|
|
|
|
|
@doc?.name
|
|
|
|
|
|
|
|
|
|
search: (value) ->
|
|
|
|
|
unless @doc
|
|
|
|
|
@searcher.find app.docs.all(), 'text', value
|
|
|
|
|
search: (value, searchDisabled = false) ->
|
|
|
|
|
return if @doc
|
|
|
|
|
@searcher.find app.docs.all(), 'text', value
|
|
|
|
|
@searcher.find app.disabledDocs.all(), 'text', value if not @doc and searchDisabled
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
searchUrl: ->
|
|
|
|
|
if value = @extractHashValue()
|
|
|
|
|
@search value
|
|
|
|
|
@search value, true
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
onResults: (results) =>
|
|
|
|
|
if results.length
|
|
|
|
|
@selectDoc results[0]
|
|
|
|
|
return unless doc = results[0]
|
|
|
|
|
if app.docs.contains(doc)
|
|
|
|
|
@selectDoc(doc)
|
|
|
|
|
else
|
|
|
|
|
@redirectToDoc(doc)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
selectDoc: (doc) ->
|
|
|
|
@ -63,6 +67,12 @@ class app.views.SearchScope extends app.View
|
|
|
|
|
@trigger 'change', @doc, previousDoc
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
redirectToDoc: (doc) ->
|
|
|
|
|
hash = location.hash
|
|
|
|
|
app.router.replaceHash('')
|
|
|
|
|
window.location = doc.fullPath() + hash
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
reset: =>
|
|
|
|
|
return unless @doc
|
|
|
|
|
previousDoc = @doc
|
|
|
|
@ -97,8 +107,10 @@ class app.views.SearchScope extends app.View
|
|
|
|
|
app.router.replaceHash(newHash)
|
|
|
|
|
value
|
|
|
|
|
|
|
|
|
|
HASH_RGX = new RegExp "^##{SEARCH_PARAM}=(.+?) ."
|
|
|
|
|
|
|
|
|
|
getHashValue: ->
|
|
|
|
|
try (new RegExp "^##{SEARCH_PARAM}=(.+?) .").exec($.urlDecode location.hash)?[1] catch
|
|
|
|
|
try HASH_RGX.exec($.urlDecode location.hash)?[1] catch
|
|
|
|
|
|
|
|
|
|
afterRoute: (name, context) =>
|
|
|
|
|
if !app.isSingleDoc() and context.init and context.doc
|
|
|
|
|