Jump to page zero when starting to search.
Jump back to the previous page when clearing the search.
This commit is contained in:
parent
2248e4de16
commit
ac7b7661ca
@ -330,8 +330,13 @@ Index =
|
|||||||
Index.searchInput.focus()
|
Index.searchInput.focus()
|
||||||
onSearchInput: ->
|
onSearchInput: ->
|
||||||
if Index.isSearching = !!Index.searchInput.value.trim()
|
if Index.isSearching = !!Index.searchInput.value.trim()
|
||||||
Index.searchInput.dataset.searching = 1
|
unless Index.searchInput.dataset.searching
|
||||||
|
Index.searchInput.dataset.searching = 1
|
||||||
|
Index.pageBeforeSearch = Index.getCurrentPage()
|
||||||
|
pageNum = 0
|
||||||
else
|
else
|
||||||
|
pageNum = Index.pageBeforeSearch
|
||||||
|
delete Index.pageBeforeSearch
|
||||||
<% if (type === 'userscript') { %>
|
<% if (type === 'userscript') { %>
|
||||||
# XXX https://github.com/greasemonkey/greasemonkey/issues/1571
|
# XXX https://github.com/greasemonkey/greasemonkey/issues/1571
|
||||||
Index.searchInput.removeAttribute 'data-searching'
|
Index.searchInput.removeAttribute 'data-searching'
|
||||||
@ -339,7 +344,10 @@ Index =
|
|||||||
delete Index.searchInput.dataset.searching
|
delete Index.searchInput.dataset.searching
|
||||||
<% } %>
|
<% } %>
|
||||||
Index.sort()
|
Index.sort()
|
||||||
Index.buildIndex()
|
if Index.currentPage is pageNum
|
||||||
|
Index.buildIndex()
|
||||||
|
else
|
||||||
|
Index.pageNav pageNum
|
||||||
querySearch: (query) ->
|
querySearch: (query) ->
|
||||||
return unless keywords = query.toLowerCase().match /\S+/g
|
return unless keywords = query.toLowerCase().match /\S+/g
|
||||||
Index.search keywords
|
Index.search keywords
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user