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:
|
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 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:
|
- Threads in the index can now be sorted by:
|
||||||
- bump order
|
- Bump order
|
||||||
- creation date
|
- Last reply
|
||||||
- reply count
|
- Creation date
|
||||||
- file count
|
- Reply count
|
||||||
- last reply
|
- File count
|
||||||
|
- Navigating across index pages is now instantaneous.
|
||||||
|
|
||||||
Added a keybind to open the catalog search field on index pages.
|
Added a keybind to open the catalog search field on index pages.
|
||||||
|
|
||||||
|
|||||||
@ -364,8 +364,7 @@ a[href="javascript:;"] {
|
|||||||
|
|
||||||
/* Index */
|
/* Index */
|
||||||
:root.index-loading .board,
|
:root.index-loading .board,
|
||||||
:root.index-loading .pagelist,
|
:root.index-loading .pagelist {
|
||||||
:root.index-hide-pagelist .pagelist {
|
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
<div class="prev">
|
<div class="prev">
|
||||||
<a>
|
<a>
|
||||||
<button>Previous</button>
|
<button disabled>Previous</button>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="pages"></div>
|
<div class="pages"></div>
|
||||||
<div class="next">
|
<div class="next">
|
||||||
<a>
|
<a>
|
||||||
<button>Next</button>
|
<button disabled>Next</button>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -2,12 +2,12 @@ Index =
|
|||||||
init: ->
|
init: ->
|
||||||
return if g.VIEW isnt 'index'
|
return if g.VIEW isnt 'index'
|
||||||
|
|
||||||
Index.button = $.el 'a',
|
@button = $.el 'a',
|
||||||
className: 'index-refresh-shortcut fa fa-refresh'
|
className: 'index-refresh-shortcut fa fa-refresh'
|
||||||
title: 'Refresh Index'
|
title: 'Refresh Index'
|
||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
$.on Index.button, 'click', Index.update
|
$.on @button, 'click', @update
|
||||||
Header.addShortcut Index.button, 1
|
Header.addShortcut @button, 1
|
||||||
|
|
||||||
modeEntry =
|
modeEntry =
|
||||||
el: $.el 'span', textContent: 'Index mode'
|
el: $.el 'span', textContent: 'Index mode'
|
||||||
@ -44,11 +44,15 @@ Index =
|
|||||||
subEntries: [modeEntry, sortEntry]
|
subEntries: [modeEntry, sortEntry]
|
||||||
|
|
||||||
$.addClass doc, 'index-loading'
|
$.addClass doc, 'index-loading'
|
||||||
Index.update()
|
@update()
|
||||||
Index.root = $.el 'div', className: 'board'
|
@root = $.el 'div', className: 'board'
|
||||||
Index.pagelist = $.el 'div',
|
@pagelist = $.el 'div',
|
||||||
className: 'pagelist'
|
className: 'pagelist'
|
||||||
|
hidden: true
|
||||||
innerHTML: <%= importHTML('General/Index-pagelist') %>
|
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'), ->
|
$.asap (-> $('.pagelist', doc) or d.readyState isnt 'loading'), ->
|
||||||
$.replace $('.board'), Index.root
|
$.replace $('.board'), Index.root
|
||||||
$.replace $('.pagelist'), Index.pagelist
|
$.replace $('.pagelist'), Index.pagelist
|
||||||
@ -61,9 +65,38 @@ Index =
|
|||||||
sort: ->
|
sort: ->
|
||||||
Index.sort()
|
Index.sort()
|
||||||
Index.buildIndex()
|
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: ->
|
togglePagelist: ->
|
||||||
(if Conf['Index Mode'] is 'paged' then $.rmClass else $.addClass) doc, 'index-hide-pagelist'
|
Index.pagelist.hidden = Conf['Index Mode'] isnt 'paged'
|
||||||
buildPagelist: ->
|
buildPagelist: ->
|
||||||
pagesRoot = $ '.pages', Index.pagelist
|
pagesRoot = $ '.pages', Index.pagelist
|
||||||
if pagesRoot.childElementCount isnt Index.pagesNum
|
if pagesRoot.childElementCount isnt Index.pagesNum
|
||||||
@ -76,6 +109,7 @@ Index =
|
|||||||
$.rmAll pagesRoot
|
$.rmAll pagesRoot
|
||||||
$.add pagesRoot, nodes
|
$.add pagesRoot, nodes
|
||||||
Index.setPage()
|
Index.setPage()
|
||||||
|
Index.togglePagelist()
|
||||||
setPage: ->
|
setPage: ->
|
||||||
pageNum = +window.location.pathname.split('/')[2]
|
pageNum = +window.location.pathname.split('/')[2]
|
||||||
pagesRoot = $ '.pages', Index.pagelist
|
pagesRoot = $ '.pages', Index.pagelist
|
||||||
@ -134,7 +168,7 @@ Index =
|
|||||||
notice.el.lastElementChild.textContent = 'Index refreshed!'
|
notice.el.lastElementChild.textContent = 'Index refreshed!'
|
||||||
setTimeout notice.close, $.SECOND
|
setTimeout notice.close, $.SECOND
|
||||||
|
|
||||||
Header.scrollTo Index.root if Index.root.getBoundingClientRect().top < 0
|
Index.scrollToIndex()
|
||||||
parse: (pages) ->
|
parse: (pages) ->
|
||||||
Index.parseThreadList pages
|
Index.parseThreadList pages
|
||||||
Index.buildAll()
|
Index.buildAll()
|
||||||
|
|||||||
@ -74,17 +74,18 @@ Keybinds =
|
|||||||
Keybinds.img threadRoot, true
|
Keybinds.img threadRoot, true
|
||||||
# Board Navigation
|
# Board Navigation
|
||||||
when Conf['Front page']
|
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']
|
when Conf['Open front page']
|
||||||
$.open "/#{g.BOARD}/#delform"
|
$.open "/#{g.BOARD}/"
|
||||||
when Conf['Next page']
|
when Conf['Next page']
|
||||||
return if Conf['Index Mode'] isnt 'paged'
|
return unless g.VIEW is 'index' and Conf['Index Mode'] is 'paged'
|
||||||
if form = $ '.next form'
|
$('.next a', Index.pagelist).click()
|
||||||
window.location = form.action
|
|
||||||
when Conf['Previous page']
|
when Conf['Previous page']
|
||||||
return if Conf['Index Mode'] isnt 'paged'
|
return unless g.VIEW is 'index' and Conf['Index Mode'] is 'paged'
|
||||||
if form = $ '.prev form'
|
$('.prev a', Index.pagelist).click()
|
||||||
window.location = form.action
|
|
||||||
when Conf['Search form']
|
when Conf['Search form']
|
||||||
$.id('search-btn').click()
|
$.id('search-btn').click()
|
||||||
# Thread Navigation
|
# Thread Navigation
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user