Mayhem's unread scroll fixes
This commit is contained in:
parent
867ba2bf0e
commit
eb0386c82f
@ -6585,29 +6585,27 @@
|
|||||||
if (Conf['Unread Line']) {
|
if (Conf['Unread Line']) {
|
||||||
$.on(d, 'visibilitychange', Unread.setLine);
|
$.on(d, 'visibilitychange', Unread.setLine);
|
||||||
}
|
}
|
||||||
if (!Conf['Scroll to Last Read Post']) {
|
if (Conf['Scroll to Last Read Post']) {
|
||||||
|
return $.on(window, 'load', Unread.scroll);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scroll: function() {
|
||||||
|
var hash, posts, root;
|
||||||
|
|
||||||
|
if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return $.on(window, 'load', function() {
|
if (Unread.posts.length) {
|
||||||
var hash, root;
|
while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) {
|
||||||
|
if (!(Get.postFromRoot(root)).isHidden) {
|
||||||
if ((hash = location.hash.match(/\d+/)) && hash[0] in this.posts) {
|
break;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Unread.posts.length) {
|
|
||||||
while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) {
|
|
||||||
if (!(Get.postFromRoot(root)).isHidden) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!root) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return root.scrollIntoView(false);
|
|
||||||
} else if (posts.length) {
|
|
||||||
return Header.scrollToPost(posts[posts.length - 1].nodes.root);
|
|
||||||
}
|
}
|
||||||
});
|
root.scrollIntoView(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
posts = Object.keys(Unread.thread.posts);
|
||||||
|
return Header.scrollToPost(Unread.thread.posts[posts[posts.length - 1]].nodes.root);
|
||||||
},
|
},
|
||||||
sync: function() {
|
sync: function() {
|
||||||
var lastReadPost;
|
var lastReadPost;
|
||||||
|
|||||||
@ -6576,29 +6576,27 @@
|
|||||||
if (Conf['Unread Line']) {
|
if (Conf['Unread Line']) {
|
||||||
$.on(d, 'visibilitychange', Unread.setLine);
|
$.on(d, 'visibilitychange', Unread.setLine);
|
||||||
}
|
}
|
||||||
if (!Conf['Scroll to Last Read Post']) {
|
if (Conf['Scroll to Last Read Post']) {
|
||||||
|
return $.on(window, 'load', Unread.scroll);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scroll: function() {
|
||||||
|
var hash, posts, root;
|
||||||
|
|
||||||
|
if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return $.on(window, 'load', function() {
|
if (Unread.posts.length) {
|
||||||
var hash, root;
|
while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) {
|
||||||
|
if (!(Get.postFromRoot(root)).isHidden) {
|
||||||
if ((hash = location.hash.match(/\d+/)) && hash[0] in this.posts) {
|
break;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Unread.posts.length) {
|
|
||||||
while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) {
|
|
||||||
if (!(Get.postFromRoot(root)).isHidden) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!root) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return root.scrollIntoView(false);
|
|
||||||
} else if (posts.length) {
|
|
||||||
return Header.scrollToPost(posts[posts.length - 1].nodes.root);
|
|
||||||
}
|
}
|
||||||
});
|
root.scrollIntoView(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
posts = Object.keys(Unread.thread.posts);
|
||||||
|
return Header.scrollToPost(Unread.thread.posts[posts[posts.length - 1]].nodes.root);
|
||||||
},
|
},
|
||||||
sync: function() {
|
sync: function() {
|
||||||
var lastReadPost;
|
var lastReadPost;
|
||||||
|
|||||||
@ -6440,29 +6440,27 @@
|
|||||||
if (Conf['Unread Line']) {
|
if (Conf['Unread Line']) {
|
||||||
$.on(d, 'visibilitychange', Unread.setLine);
|
$.on(d, 'visibilitychange', Unread.setLine);
|
||||||
}
|
}
|
||||||
if (!Conf['Scroll to Last Read Post']) {
|
if (Conf['Scroll to Last Read Post']) {
|
||||||
|
return $.on(window, 'load', Unread.scroll);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scroll: function() {
|
||||||
|
var hash, posts, root;
|
||||||
|
|
||||||
|
if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return $.on(window, 'load', function() {
|
if (Unread.posts.length) {
|
||||||
var hash, root;
|
while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) {
|
||||||
|
if (!(Get.postFromRoot(root)).isHidden) {
|
||||||
if ((hash = location.hash.match(/\d+/)) && hash[0] in this.posts) {
|
break;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Unread.posts.length) {
|
|
||||||
while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) {
|
|
||||||
if (!(Get.postFromRoot(root)).isHidden) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!root) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return root.scrollIntoView(false);
|
|
||||||
} else if (posts.length) {
|
|
||||||
return Header.scrollToPost(posts[posts.length - 1].nodes.root);
|
|
||||||
}
|
}
|
||||||
});
|
root.scrollIntoView(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
posts = Object.keys(Unread.thread.posts);
|
||||||
|
return Header.scrollToPost(Unread.thread.posts[posts[posts.length - 1]].nodes.root);
|
||||||
},
|
},
|
||||||
sync: function() {
|
sync: function() {
|
||||||
var lastReadPost;
|
var lastReadPost;
|
||||||
|
|||||||
@ -26,21 +26,20 @@ Unread =
|
|||||||
$.on d, 'ThreadUpdate', Unread.onUpdate
|
$.on d, 'ThreadUpdate', Unread.onUpdate
|
||||||
$.on d, 'scroll visibilitychange', Unread.read
|
$.on d, 'scroll visibilitychange', Unread.read
|
||||||
$.on d, 'visibilitychange', Unread.setLine if Conf['Unread Line']
|
$.on d, 'visibilitychange', Unread.setLine if Conf['Unread Line']
|
||||||
|
$.on window, 'load', Unread.scroll if Conf['Scroll to Last Read Post']
|
||||||
|
|
||||||
return unless Conf['Scroll to Last Read Post']
|
scroll: ->
|
||||||
|
# Let the header's onload callback handle it.
|
||||||
$.on window, 'load', ->
|
return if (hash = location.hash.match /\d+/) and hash[0] of Unread.thread.posts
|
||||||
# Let the header's onload callback handle it.
|
if Unread.posts.length
|
||||||
return if (hash = location.hash.match /\d+/) and hash[0] of @posts
|
# Scroll to before the first unread post.
|
||||||
if Unread.posts.length
|
while root = $.x 'preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root
|
||||||
# Scroll to before the first unread post.
|
break unless (Get.postFromRoot root).isHidden
|
||||||
while root = $.x 'preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root
|
root.scrollIntoView false
|
||||||
break unless (Get.postFromRoot root).isHidden
|
return
|
||||||
return unless root
|
# Scroll to the last read post.
|
||||||
root.scrollIntoView false
|
posts = Object.keys Unread.thread.posts
|
||||||
else if posts.length
|
Header.scrollToPost Unread.thread.posts[posts[posts.length - 1]].nodes.root
|
||||||
# Scroll to the last read post.
|
|
||||||
Header.scrollToPost (posts[posts.length - 1]).nodes.root
|
|
||||||
|
|
||||||
sync: ->
|
sync: ->
|
||||||
lastReadPost = Unread.db.get
|
lastReadPost = Unread.db.get
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user