From e5fd95158bff078b983cb2a0eeb05f6b6bb905fa Mon Sep 17 00:00:00 2001 From: seaweedchan Date: Sun, 12 Jan 2014 01:15:31 -0700 Subject: [PATCH] Start work on infinite scrolling --- src/General/Index.coffee | 13 +++++++------ src/Miscellaneous/Keybinds.coffee | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 6f0f1e77c..54263606a 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -14,6 +14,7 @@ Index = el: $.el 'span', textContent: 'Index mode' subEntries: [ { el: $.el 'label', innerHTML: ' Paged' } + { el: $.el 'label', innerHTML: ' Infinite scrolling' } { el: $.el 'label', innerHTML: ' 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() diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index d81814396..508eb61a8 100755 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -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()