record index mode changes in history
This commit is contained in:
parent
295dabb756
commit
6bffe73450
@ -2,6 +2,7 @@ Index =
|
|||||||
showHiddenThreads: false
|
showHiddenThreads: false
|
||||||
init: ->
|
init: ->
|
||||||
return if g.BOARD.ID is 'f' or g.VIEW isnt 'index' or !Conf['JSON Navigation']
|
return if g.BOARD.ID is 'f' or g.VIEW isnt 'index' or !Conf['JSON Navigation']
|
||||||
|
@cb.popstate()
|
||||||
|
|
||||||
@board = "#{g.BOARD}"
|
@board = "#{g.BOARD}"
|
||||||
|
|
||||||
@ -230,13 +231,10 @@ Index =
|
|||||||
Index.sort()
|
Index.sort()
|
||||||
Index.buildIndex()
|
Index.buildIndex()
|
||||||
mode: ->
|
mode: ->
|
||||||
Index.cb.toggleCatalogMode()
|
|
||||||
Index.togglePagelist()
|
|
||||||
Index.buildIndex()
|
|
||||||
mode = Conf['Index Mode']
|
mode = Conf['Index Mode']
|
||||||
if mode not in ['catalog', Conf['Previous Index Mode']]
|
Index.currentPage = 1 if mode in ['all pages', 'catalog']
|
||||||
Conf['Previous Index Mode'] = mode
|
history.pushState {mode}, '', if Index.currentPage is 1 then './' else Index.currentPage
|
||||||
$.set 'Previous Index Mode', mode
|
Index.setMode()
|
||||||
sort: ->
|
sort: ->
|
||||||
Index.sort()
|
Index.sort()
|
||||||
Index.buildIndex()
|
Index.buildIndex()
|
||||||
@ -245,8 +243,16 @@ Index =
|
|||||||
Index.sort()
|
Index.sort()
|
||||||
Index.buildIndex()
|
Index.buildIndex()
|
||||||
popstate: (e) ->
|
popstate: (e) ->
|
||||||
|
unless e?.state
|
||||||
|
# page load or hash change
|
||||||
|
history.replaceState {mode: Conf['Index Mode']}, ''
|
||||||
|
return
|
||||||
|
{mode} = e.state
|
||||||
pageNum = Index.getCurrentPage()
|
pageNum = Index.getCurrentPage()
|
||||||
Index.pageLoad pageNum if Index.currentPage isnt pageNum
|
return if Conf['Index Mode'] is mode and Index.currentPage is pageNum
|
||||||
|
Conf['Index Mode'] = mode
|
||||||
|
Index.currentPage = pageNum
|
||||||
|
Index.setMode()
|
||||||
pageNav: (e) ->
|
pageNav: (e) ->
|
||||||
return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0
|
return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0
|
||||||
switch e.target.nodeName
|
switch e.target.nodeName
|
||||||
@ -267,7 +273,7 @@ Index =
|
|||||||
getCurrentPage: ->
|
getCurrentPage: ->
|
||||||
+window.location.pathname.split('/')[2] or 1
|
+window.location.pathname.split('/')[2] or 1
|
||||||
userPageNav: (pageNum) ->
|
userPageNav: (pageNum) ->
|
||||||
history.pushState null, '', if pageNum is 1 then './' else pageNum
|
history.pushState {mode: Conf['Index Mode']}, '', if pageNum is 1 then './' else pageNum
|
||||||
if Conf['Refreshed Navigation'] and Conf['Index Mode'] isnt 'all pages'
|
if Conf['Refreshed Navigation'] and Conf['Index Mode'] isnt 'all pages'
|
||||||
Index.update pageNum
|
Index.update pageNum
|
||||||
else
|
else
|
||||||
@ -279,6 +285,15 @@ Index =
|
|||||||
Index.buildIndex()
|
Index.buildIndex()
|
||||||
Index.setPage()
|
Index.setPage()
|
||||||
Index.scrollToIndex()
|
Index.scrollToIndex()
|
||||||
|
setMode: ->
|
||||||
|
Index.cb.toggleCatalogMode()
|
||||||
|
Index.togglePagelist()
|
||||||
|
Index.buildIndex()
|
||||||
|
Index.setPage()
|
||||||
|
mode = Conf['Index Mode']
|
||||||
|
if mode not in ['catalog', Conf['Previous Index Mode']]
|
||||||
|
Conf['Previous Index Mode'] = mode
|
||||||
|
$.set 'Previous Index Mode', mode
|
||||||
|
|
||||||
getPagesNum: ->
|
getPagesNum: ->
|
||||||
if Index.isSearching
|
if Index.isSearching
|
||||||
@ -590,7 +605,7 @@ Index =
|
|||||||
Index.buildIndex()
|
Index.buildIndex()
|
||||||
Index.setPage()
|
Index.setPage()
|
||||||
else
|
else
|
||||||
history.pushState null, '', if pageNum is 1 then './' else pageNum
|
history.pushState {mode: Conf['Index Mode']}, '', if pageNum is 1 then './' else pageNum
|
||||||
Index.pageLoad pageNum
|
Index.pageLoad pageNum
|
||||||
|
|
||||||
querySearch: (query) ->
|
querySearch: (query) ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user