Instantaneous index page navigation.
Also fix page navigation keybinds.
This commit is contained in:
parent
bc72f0f763
commit
0540dcf30f
13
CHANGELOG.md
13
CHANGELOG.md
@ -1,12 +1,13 @@
|
||||
Index navigation improvements:
|
||||
- You can now refresh the index page you are on with the icon in the header bar or the same keybind for refreshing threads.
|
||||
- You can now switch between single-page and all-pages navigation via the "Index Navigation" header sub-menu.
|
||||
- You can now switch between paged and all-threads index modes via the "Index Navigation" header sub-menu.
|
||||
- Threads in the index can now be sorted by:
|
||||
- bump order
|
||||
- creation date
|
||||
- reply count
|
||||
- file count
|
||||
- last reply
|
||||
- Bump order
|
||||
- Last reply
|
||||
- Creation date
|
||||
- Reply count
|
||||
- File count
|
||||
- Navigating across index pages is now instantaneous.
|
||||
|
||||
Added a keybind to open the catalog search field on index pages.
|
||||
|
||||
|
||||
@ -364,8 +364,7 @@ a[href="javascript:;"] {
|
||||
|
||||
/* Index */
|
||||
:root.index-loading .board,
|
||||
:root.index-loading .pagelist,
|
||||
:root.index-hide-pagelist .pagelist {
|
||||
:root.index-loading .pagelist {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
<div class="prev">
|
||||
<a>
|
||||
<button>Previous</button>
|
||||
<button disabled>Previous</button>
|
||||
</a>
|
||||
</div>
|
||||
<div class="pages"></div>
|
||||
<div class="next">
|
||||
<a>
|
||||
<button>Next</button>
|
||||
<button disabled>Next</button>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@ -2,12 +2,12 @@ Index =
|
||||
init: ->
|
||||
return if g.VIEW isnt 'index'
|
||||
|
||||
Index.button = $.el 'a',
|
||||
@button = $.el 'a',
|
||||
className: 'index-refresh-shortcut fa fa-refresh'
|
||||
title: 'Refresh Index'
|
||||
href: 'javascript:;'
|
||||
$.on Index.button, 'click', Index.update
|
||||
Header.addShortcut Index.button, 1
|
||||
$.on @button, 'click', @update
|
||||
Header.addShortcut @button, 1
|
||||
|
||||
modeEntry =
|
||||
el: $.el 'span', textContent: 'Index mode'
|
||||
@ -44,11 +44,15 @@ Index =
|
||||
subEntries: [modeEntry, sortEntry]
|
||||
|
||||
$.addClass doc, 'index-loading'
|
||||
Index.update()
|
||||
Index.root = $.el 'div', className: 'board'
|
||||
Index.pagelist = $.el 'div',
|
||||
@update()
|
||||
@root = $.el 'div', className: 'board'
|
||||
@pagelist = $.el 'div',
|
||||
className: 'pagelist'
|
||||
hidden: true
|
||||
innerHTML: <%= importHTML('General/Index-pagelist') %>
|
||||
Index.currentPage = +window.location.pathname.split('/')[2]
|
||||
$.on window, 'popstate', @cb.popstate
|
||||
$.on @pagelist, 'click', @cb.pageNav
|
||||
$.asap (-> $('.pagelist', doc) or d.readyState isnt 'loading'), ->
|
||||
$.replace $('.board'), Index.root
|
||||
$.replace $('.pagelist'), Index.pagelist
|
||||
@ -61,9 +65,38 @@ Index =
|
||||
sort: ->
|
||||
Index.sort()
|
||||
Index.buildIndex()
|
||||
popstate: (e) ->
|
||||
Index.currentPage = +window.location.pathname.split('/')[2]
|
||||
Index.pageLoad()
|
||||
pageNav: (e) ->
|
||||
return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0
|
||||
switch e.target.nodeName
|
||||
when 'BUTTON'
|
||||
a = e.target.parentNode
|
||||
when 'A'
|
||||
a = e.target
|
||||
else
|
||||
return
|
||||
e.preventDefault()
|
||||
Index.pageNav +a.pathname.split('/')[2]
|
||||
|
||||
scrollToIndex: ->
|
||||
Header.scrollTo Index.root if Index.root.getBoundingClientRect().top < 0
|
||||
|
||||
pageNav: (pageNum) ->
|
||||
return if Index.currentPage is pageNum
|
||||
history.pushState null, '', if pageNum is 0 then './' else pageNum
|
||||
Index.currentPage = pageNum
|
||||
Index.pageLoad()
|
||||
pageLoad: ->
|
||||
return unless 'currentPage' of Index # unnecessary popstate on page load
|
||||
return if Conf['Index Mode'] isnt 'paged'
|
||||
Index.buildIndex()
|
||||
Index.setPage()
|
||||
Index.scrollToIndex()
|
||||
|
||||
togglePagelist: ->
|
||||
(if Conf['Index Mode'] is 'paged' then $.rmClass else $.addClass) doc, 'index-hide-pagelist'
|
||||
Index.pagelist.hidden = Conf['Index Mode'] isnt 'paged'
|
||||
buildPagelist: ->
|
||||
pagesRoot = $ '.pages', Index.pagelist
|
||||
if pagesRoot.childElementCount isnt Index.pagesNum
|
||||
@ -76,6 +109,7 @@ Index =
|
||||
$.rmAll pagesRoot
|
||||
$.add pagesRoot, nodes
|
||||
Index.setPage()
|
||||
Index.togglePagelist()
|
||||
setPage: ->
|
||||
pageNum = +window.location.pathname.split('/')[2]
|
||||
pagesRoot = $ '.pages', Index.pagelist
|
||||
@ -134,7 +168,7 @@ Index =
|
||||
notice.el.lastElementChild.textContent = 'Index refreshed!'
|
||||
setTimeout notice.close, $.SECOND
|
||||
|
||||
Header.scrollTo Index.root if Index.root.getBoundingClientRect().top < 0
|
||||
Index.scrollToIndex()
|
||||
parse: (pages) ->
|
||||
Index.parseThreadList pages
|
||||
Index.buildAll()
|
||||
|
||||
@ -74,17 +74,18 @@ Keybinds =
|
||||
Keybinds.img threadRoot, true
|
||||
# Board Navigation
|
||||
when Conf['Front page']
|
||||
window.location = "/#{g.BOARD}/0#delform"
|
||||
if g.VIEW is 'index'
|
||||
Index.pageNav 0
|
||||
else
|
||||
window.location = "/#{g.BOARD}/"
|
||||
when Conf['Open front page']
|
||||
$.open "/#{g.BOARD}/#delform"
|
||||
$.open "/#{g.BOARD}/"
|
||||
when Conf['Next page']
|
||||
return if Conf['Index Mode'] isnt 'paged'
|
||||
if form = $ '.next form'
|
||||
window.location = form.action
|
||||
return unless g.VIEW is 'index' and Conf['Index Mode'] is 'paged'
|
||||
$('.next a', Index.pagelist).click()
|
||||
when Conf['Previous page']
|
||||
return if Conf['Index Mode'] isnt 'paged'
|
||||
if form = $ '.prev form'
|
||||
window.location = form.action
|
||||
return unless g.VIEW is 'index' and Conf['Index Mode'] is 'paged'
|
||||
$('.prev a', Index.pagelist).click()
|
||||
when Conf['Search form']
|
||||
$.id('search-btn').click()
|
||||
# Thread Navigation
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user