Lets not push states for infinite scrolling. :)
This commit is contained in:
parent
6c1eef61c0
commit
d8154e8ae2
@ -2324,18 +2324,20 @@
|
|||||||
if (Index.req || Conf['Index Mode'] !== 'infinite' || (doc.scrollTop <= doc.scrollHeight - (300 + window.innerHeight)) || g.VIEW === 'thread') {
|
if (Index.req || Conf['Index Mode'] !== 'infinite' || (doc.scrollTop <= doc.scrollHeight - (300 + window.innerHeight)) || g.VIEW === 'thread') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pageNum = Index.getCurrentPage() + 1;
|
if (Index.pageNum == null) {
|
||||||
|
Index.pageNum = Index.getCurrentPage();
|
||||||
|
}
|
||||||
|
pageNum = Index.pageNum++;
|
||||||
if (pageNum >= Index.pagesNum) {
|
if (pageNum >= Index.pagesNum) {
|
||||||
return Index.endNotice();
|
return Index.endNotice();
|
||||||
}
|
}
|
||||||
nodesPerPage = Index.threadsNumPerPage * 2;
|
nodesPerPage = Index.threadsNumPerPage * 2;
|
||||||
history.pushState(null, '', "/" + g.BOARD + "/" + pageNum);
|
|
||||||
nodes = Index.sortedNodes.slice(nodesPerPage * pageNum, nodesPerPage * (pageNum + 1));
|
nodes = Index.sortedNodes.slice(nodesPerPage * pageNum, nodesPerPage * (pageNum + 1));
|
||||||
if (Conf['Show Replies']) {
|
if (Conf['Show Replies']) {
|
||||||
Index.buildReplies(nodes);
|
Index.buildReplies(nodes);
|
||||||
}
|
}
|
||||||
$.add(Index.root, nodes);
|
$.add(Index.root, nodes);
|
||||||
return Index.setPage();
|
return Index.setPage(pageNum);
|
||||||
}),
|
}),
|
||||||
endNotice: (function() {
|
endNotice: (function() {
|
||||||
var notify, reset;
|
var notify, reset;
|
||||||
@ -2386,14 +2388,6 @@
|
|||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return Index.userPageNav(+a.pathname.split('/')[2]);
|
return Index.userPageNav(+a.pathname.split('/')[2]);
|
||||||
},
|
|
||||||
link: function(e) {
|
|
||||||
if (g.VIEW !== 'index' || /catalog/.test(this.href)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
e.preventDefault();
|
|
||||||
history.pushState(null, '', this.pathname);
|
|
||||||
return Index.update();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scrollToIndex: function() {
|
scrollToIndex: function() {
|
||||||
@ -2456,9 +2450,9 @@
|
|||||||
}
|
}
|
||||||
return Index.togglePagelist();
|
return Index.togglePagelist();
|
||||||
},
|
},
|
||||||
setPage: function() {
|
setPage: function(pageNum) {
|
||||||
var a, href, maxPageNum, next, pageNum, pagesRoot, prev, strong;
|
var a, href, maxPageNum, next, pagesRoot, prev, strong;
|
||||||
pageNum = Index.getCurrentPage();
|
pageNum || (pageNum = Index.getCurrentPage());
|
||||||
maxPageNum = Index.getMaxPageNum();
|
maxPageNum = Index.getMaxPageNum();
|
||||||
pagesRoot = $('.pages', Index.pagelist);
|
pagesRoot = $('.pages', Index.pagelist);
|
||||||
prev = pagesRoot.previousSibling.firstChild;
|
prev = pagesRoot.previousSibling.firstChild;
|
||||||
@ -2495,6 +2489,7 @@
|
|||||||
if (!(d.readyState === 'loading' || Index.root.parentElement)) {
|
if (!(d.readyState === 'loading' || Index.root.parentElement)) {
|
||||||
$.replace($('.board'), Index.root);
|
$.replace($('.board'), Index.root);
|
||||||
}
|
}
|
||||||
|
delete Index.pageNum;
|
||||||
if ((_ref = Index.req) != null) {
|
if ((_ref = Index.req) != null) {
|
||||||
_ref.abort();
|
_ref.abort();
|
||||||
}
|
}
|
||||||
@ -12105,6 +12100,7 @@
|
|||||||
if (e) {
|
if (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
delete Index.pageNum;
|
||||||
path = this.pathname;
|
path = this.pathname;
|
||||||
if (this.hash) {
|
if (this.hash) {
|
||||||
path += this.hash;
|
path += this.hash;
|
||||||
|
|||||||
@ -2334,18 +2334,20 @@
|
|||||||
if (Index.req || Conf['Index Mode'] !== 'infinite' || (doc.scrollTop <= doc.scrollHeight - (300 + window.innerHeight)) || g.VIEW === 'thread') {
|
if (Index.req || Conf['Index Mode'] !== 'infinite' || (doc.scrollTop <= doc.scrollHeight - (300 + window.innerHeight)) || g.VIEW === 'thread') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pageNum = Index.getCurrentPage() + 1;
|
if (Index.pageNum == null) {
|
||||||
|
Index.pageNum = Index.getCurrentPage();
|
||||||
|
}
|
||||||
|
pageNum = Index.pageNum++;
|
||||||
if (pageNum >= Index.pagesNum) {
|
if (pageNum >= Index.pagesNum) {
|
||||||
return Index.endNotice();
|
return Index.endNotice();
|
||||||
}
|
}
|
||||||
nodesPerPage = Index.threadsNumPerPage * 2;
|
nodesPerPage = Index.threadsNumPerPage * 2;
|
||||||
history.pushState(null, '', "/" + g.BOARD + "/" + pageNum);
|
|
||||||
nodes = Index.sortedNodes.slice(nodesPerPage * pageNum, nodesPerPage * (pageNum + 1));
|
nodes = Index.sortedNodes.slice(nodesPerPage * pageNum, nodesPerPage * (pageNum + 1));
|
||||||
if (Conf['Show Replies']) {
|
if (Conf['Show Replies']) {
|
||||||
Index.buildReplies(nodes);
|
Index.buildReplies(nodes);
|
||||||
}
|
}
|
||||||
$.add(Index.root, nodes);
|
$.add(Index.root, nodes);
|
||||||
return Index.setPage();
|
return Index.setPage(pageNum);
|
||||||
}),
|
}),
|
||||||
endNotice: (function() {
|
endNotice: (function() {
|
||||||
var notify, reset;
|
var notify, reset;
|
||||||
@ -2396,14 +2398,6 @@
|
|||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return Index.userPageNav(+a.pathname.split('/')[2]);
|
return Index.userPageNav(+a.pathname.split('/')[2]);
|
||||||
},
|
|
||||||
link: function(e) {
|
|
||||||
if (g.VIEW !== 'index' || /catalog/.test(this.href)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
e.preventDefault();
|
|
||||||
history.pushState(null, '', this.pathname);
|
|
||||||
return Index.update();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scrollToIndex: function() {
|
scrollToIndex: function() {
|
||||||
@ -2466,9 +2460,9 @@
|
|||||||
}
|
}
|
||||||
return Index.togglePagelist();
|
return Index.togglePagelist();
|
||||||
},
|
},
|
||||||
setPage: function() {
|
setPage: function(pageNum) {
|
||||||
var a, href, maxPageNum, next, pageNum, pagesRoot, prev, strong;
|
var a, href, maxPageNum, next, pagesRoot, prev, strong;
|
||||||
pageNum = Index.getCurrentPage();
|
pageNum || (pageNum = Index.getCurrentPage());
|
||||||
maxPageNum = Index.getMaxPageNum();
|
maxPageNum = Index.getMaxPageNum();
|
||||||
pagesRoot = $('.pages', Index.pagelist);
|
pagesRoot = $('.pages', Index.pagelist);
|
||||||
prev = pagesRoot.previousSibling.firstChild;
|
prev = pagesRoot.previousSibling.firstChild;
|
||||||
@ -2505,6 +2499,7 @@
|
|||||||
if (!(d.readyState === 'loading' || Index.root.parentElement)) {
|
if (!(d.readyState === 'loading' || Index.root.parentElement)) {
|
||||||
$.replace($('.board'), Index.root);
|
$.replace($('.board'), Index.root);
|
||||||
}
|
}
|
||||||
|
delete Index.pageNum;
|
||||||
if ((_ref = Index.req) != null) {
|
if ((_ref = Index.req) != null) {
|
||||||
_ref.abort();
|
_ref.abort();
|
||||||
}
|
}
|
||||||
@ -12094,6 +12089,7 @@
|
|||||||
if (e) {
|
if (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
delete Index.pageNum;
|
||||||
path = this.pathname;
|
path = this.pathname;
|
||||||
if (this.hash) {
|
if (this.hash) {
|
||||||
path += this.hash;
|
path += this.hash;
|
||||||
|
|||||||
@ -112,14 +112,14 @@ Index =
|
|||||||
|
|
||||||
scroll: $.debounce 100, ->
|
scroll: $.debounce 100, ->
|
||||||
return if Index.req or Conf['Index Mode'] isnt 'infinite' or (doc.scrollTop <= doc.scrollHeight - (300 + window.innerHeight)) or g.VIEW is 'thread'
|
return if Index.req or Conf['Index Mode'] isnt 'infinite' or (doc.scrollTop <= doc.scrollHeight - (300 + window.innerHeight)) or g.VIEW is 'thread'
|
||||||
pageNum = Index.getCurrentPage() + 1
|
Index.pageNum = Index.getCurrentPage() unless Index.pageNum? # Avoid having to pushState to keep track of the current page
|
||||||
|
pageNum = Index.pageNum++
|
||||||
return Index.endNotice() if pageNum >= Index.pagesNum
|
return Index.endNotice() if pageNum >= Index.pagesNum
|
||||||
nodesPerPage = Index.threadsNumPerPage * 2
|
nodesPerPage = Index.threadsNumPerPage * 2
|
||||||
history.pushState null, '', "/#{g.BOARD}/#{pageNum}"
|
|
||||||
nodes = Index.sortedNodes[nodesPerPage * pageNum ... nodesPerPage * (pageNum + 1)]
|
nodes = Index.sortedNodes[nodesPerPage * pageNum ... nodesPerPage * (pageNum + 1)]
|
||||||
Index.buildReplies nodes if Conf['Show Replies']
|
Index.buildReplies nodes if Conf['Show Replies']
|
||||||
$.add Index.root, nodes
|
$.add Index.root, nodes
|
||||||
Index.setPage()
|
Index.setPage pageNum
|
||||||
|
|
||||||
endNotice: do ->
|
endNotice: do ->
|
||||||
notify = false
|
notify = false
|
||||||
@ -153,11 +153,6 @@ Index =
|
|||||||
return if a.textContent is 'Catalog'
|
return if a.textContent is 'Catalog'
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
Index.userPageNav +a.pathname.split('/')[2]
|
Index.userPageNav +a.pathname.split('/')[2]
|
||||||
link: (e) ->
|
|
||||||
return if g.VIEW isnt 'index' or /catalog/.test @href
|
|
||||||
e.preventDefault()
|
|
||||||
history.pushState null, '', @pathname
|
|
||||||
Index.update()
|
|
||||||
|
|
||||||
scrollToIndex: ->
|
scrollToIndex: ->
|
||||||
Header.scrollToIfNeeded Index.root
|
Header.scrollToIfNeeded Index.root
|
||||||
@ -202,8 +197,8 @@ Index =
|
|||||||
$.rmAll pagesRoot
|
$.rmAll pagesRoot
|
||||||
$.add pagesRoot, nodes
|
$.add pagesRoot, nodes
|
||||||
Index.togglePagelist()
|
Index.togglePagelist()
|
||||||
setPage: ->
|
setPage: (pageNum) ->
|
||||||
pageNum = Index.getCurrentPage()
|
pageNum or= Index.getCurrentPage()
|
||||||
maxPageNum = Index.getMaxPageNum()
|
maxPageNum = Index.getMaxPageNum()
|
||||||
pagesRoot = $ '.pages', Index.pagelist
|
pagesRoot = $ '.pages', Index.pagelist
|
||||||
# Previous/Next buttons
|
# Previous/Next buttons
|
||||||
@ -232,6 +227,7 @@ Index =
|
|||||||
return
|
return
|
||||||
unless d.readyState is 'loading' or Index.root.parentElement
|
unless d.readyState is 'loading' or Index.root.parentElement
|
||||||
$.replace $('.board'), Index.root
|
$.replace $('.board'), Index.root
|
||||||
|
delete Index.pageNum
|
||||||
Index.req?.abort()
|
Index.req?.abort()
|
||||||
Index.notice?.close()
|
Index.notice?.close()
|
||||||
|
|
||||||
|
|||||||
@ -184,6 +184,8 @@ Navigate =
|
|||||||
return if view is 'catalog' or 'f' in [boardID, g.BOARD.ID]
|
return if view is 'catalog' or 'f' in [boardID, g.BOARD.ID]
|
||||||
e.preventDefault() if e
|
e.preventDefault() if e
|
||||||
|
|
||||||
|
delete Index.pageNum
|
||||||
|
|
||||||
path = @pathname
|
path = @pathname
|
||||||
path += @hash if @hash
|
path += @hash if @hash
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user