Start work on infinite scrolling
This commit is contained in:
parent
9a5ddc35d2
commit
e5fd95158b
@ -14,6 +14,7 @@ Index =
|
||||
el: $.el 'span', textContent: 'Index mode'
|
||||
subEntries: [
|
||||
{ el: $.el 'label', innerHTML: '<input type=radio name="Index Mode" value="paged"> Paged' }
|
||||
{ el: $.el 'label', innerHTML: '<input type=radio name="Index Mode" value="infinite"> Infinite scrolling' }
|
||||
{ el: $.el 'label', innerHTML: '<input type=radio name="Index Mode" value="all pages"> All threads' }
|
||||
]
|
||||
for label in modeEntry.subEntries
|
||||
@ -103,7 +104,7 @@ Index =
|
||||
$.replace $('.pagelist'), Index.pagelist
|
||||
|
||||
scroll: $.debounce 100, ->
|
||||
return if Conf['Index Mode'] isnt 'paged' or ((d.body.scrollTop or doc.scrollTop) <= doc.scrollHeight - (300 + window.innerHeight))
|
||||
return if Index.req or Conf['Index Mode'] isnt 'infinite' or ((d.body.scrollTop or doc.scrollTop) <= doc.scrollHeight - (300 + window.innerHeight))
|
||||
pageNum = Index.getCurrentPage() + 1
|
||||
return Index.endNotice() if pageNum >= Index.pagesNum
|
||||
nodesPerPage = Index.threadsNumPerPage * 2
|
||||
@ -160,7 +161,7 @@ Index =
|
||||
getCurrentPage: ->
|
||||
+window.location.pathname.split('/')[2]
|
||||
userPageNav: (pageNum) ->
|
||||
if Conf['Refreshed Navigation'] and Conf['Index Mode'] is 'paged'
|
||||
if Conf['Refreshed Navigation'] and Conf['Index Mode'] isnt 'all pages'
|
||||
Index.update pageNum
|
||||
else
|
||||
Index.pageNav pageNum
|
||||
@ -170,7 +171,7 @@ Index =
|
||||
Index.pageLoad pageNum
|
||||
pageLoad: (pageNum) ->
|
||||
Index.currentPage = pageNum
|
||||
return if Conf['Index Mode'] isnt 'paged'
|
||||
return if Conf['Index Mode'] is 'all pages'
|
||||
Index.buildIndex()
|
||||
Index.setPage()
|
||||
Index.scrollToIndex()
|
||||
@ -183,7 +184,7 @@ Index =
|
||||
getMaxPageNum: ->
|
||||
Math.max 0, Index.getPagesNum() - 1
|
||||
togglePagelist: ->
|
||||
Index.pagelist.hidden = Conf['Index Mode'] isnt 'paged'
|
||||
Index.pagelist.hidden = Conf['Index Mode'] is 'all pages'
|
||||
buildPagelist: ->
|
||||
pagesRoot = $ '.pages', Index.pagelist
|
||||
maxPageNum = Index.getMaxPageNum()
|
||||
@ -369,7 +370,7 @@ Index =
|
||||
Index.sortedNodes.splice offset++ * 2, 0, Index.sortedNodes.splice(i, 2)...
|
||||
return
|
||||
buildIndex: ->
|
||||
if Conf['Index Mode'] is 'paged'
|
||||
if Conf['Index Mode'] isnt 'all pages'
|
||||
pageNum = Index.getCurrentPage()
|
||||
nodesPerPage = Index.threadsNumPerPage * 2
|
||||
nodes = Index.sortedNodes[nodesPerPage * pageNum ... nodesPerPage * (pageNum + 1)]
|
||||
@ -405,7 +406,7 @@ Index =
|
||||
<% } %>
|
||||
Index.sort()
|
||||
# Go to the last available page if we were past the limit.
|
||||
pageNum = Math.min pageNum, Index.getMaxPageNum() if Conf['Index Mode'] is 'paged'
|
||||
pageNum = Math.min pageNum, Index.getMaxPageNum() if Conf['Index Mode'] isnt 'all pages'
|
||||
Index.buildPagelist()
|
||||
if Index.currentPage is pageNum
|
||||
Index.buildIndex()
|
||||
|
||||
@ -93,10 +93,10 @@ Keybinds =
|
||||
when Conf['Open front page']
|
||||
$.open "/#{g.BOARD}/"
|
||||
when Conf['Next page']
|
||||
return unless g.VIEW is 'index' and Conf['Index Mode'] is 'paged'
|
||||
return unless g.VIEW is 'index' and Conf['Index Mode'] isnt 'all pages'
|
||||
$('.next button', Index.pagelist).click()
|
||||
when Conf['Previous page']
|
||||
return unless g.VIEW is 'index' and Conf['Index Mode'] is 'paged'
|
||||
return unless g.VIEW is 'index' and Conf['Index Mode'] isnt 'all pages'
|
||||
$('.prev button', Index.pagelist).click()
|
||||
when Conf['Search form']
|
||||
Index.searchInput.focus()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user