Make the Unread Line optional.

This commit is contained in:
Nicolas Stepien 2013-03-13 17:16:01 +01:00
parent e82e9b9f63
commit 2860471bd6
4 changed files with 20 additions and 12 deletions

View File

@ -92,6 +92,7 @@
'Thread Updater': [true, 'Fetch and insert new replies. Has more options in its own dialog.'],
'Unread Count': [true, 'Show the unread posts count in the tab title.'],
'Unread Tab Icon': [true, 'Show a different favicon when there are unread posts.'],
'Unread Line': [true, 'Show a line to distinguish read posts from unread ones.'],
'Thread Excerpt': [true, 'Show an excerpt of the thread in the tab title.'],
'Thread Stats': [true, 'Display reply and image count.'],
'Thread Watcher': [true, 'Bookmark threads.'],
@ -5243,14 +5244,16 @@
}
}
Unread.addPosts(posts);
if (Unread.hr.parentNode) {
Unread.hr.scrollIntoView(false);
} else if (posts.length && !Unread.posts.length) {
if (Unread.posts.length) {
$.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root).scrollIntoView(false);
} else if (posts.length) {
posts[posts.length - 1].nodes.root.scrollIntoView();
}
$.on(d, 'ThreadUpdate', Unread.onUpdate);
$.on(d, 'scroll visibilitychange', Unread.read);
return $.on(d, 'visibilitychange', Unread.setLine);
if (Conf['Unread Line']) {
return $.on(d, 'visibilitychange', Unread.setLine);
}
},
addPosts: function(newPosts) {
var ID, post, youInThisThread, yourPosts, _i, _len, _ref;
@ -5269,7 +5272,9 @@
Unread.addPostQuotingYou(post, yourPosts);
}
}
Unread.setLine((_ref = Unread.posts[0], __indexOf.call(newPosts, _ref) >= 0));
if (Conf['Unread Line']) {
Unread.setLine((_ref = Unread.posts[0], __indexOf.call(newPosts, _ref) >= 0));
}
Unread.read();
return Unread.update();
},

View File

@ -34,7 +34,7 @@ Thread Updater changes:
- Added a setting to always auto-scroll to the bottom instead of the first new post.
Unread posts changes:
- Added a line to distinguish read post from unread ones.
- Added a line to distinguish read posts from unread ones.
- Read posts won't be marked as unread after reloading a thread.
- The page will scroll to the last read post after reloading a thread.
- Visible posts will not be taken into account towards the unread count.

View File

@ -37,6 +37,7 @@ Config =
'Thread Updater': [true, 'Fetch and insert new replies. Has more options in its own dialog.']
'Unread Count': [true, 'Show the unread posts count in the tab title.']
'Unread Tab Icon': [true, 'Show a different favicon when there are unread posts.']
'Unread Line': [true, 'Show a line to distinguish read posts from unread ones.']
'Thread Excerpt': [true, 'Show an excerpt of the thread in the tab title.']
'Thread Stats': [true, 'Display reply and image count.']
'Thread Watcher': [true, 'Bookmark threads.']

View File

@ -3524,14 +3524,15 @@ Unread =
for ID, post of @posts
posts.push post if post.isReply
Unread.addPosts posts
if Unread.hr.parentNode
Unread.hr.scrollIntoView false
else if posts.length and !Unread.posts.length
if Unread.posts.length
# Scroll to before the first unread post.
$.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root).scrollIntoView false
else if posts.length
# Scroll to the last read post.
posts[posts.length - 1].nodes.root.scrollIntoView()
$.on d, 'ThreadUpdate', Unread.onUpdate
$.on d, 'scroll visibilitychange', Unread.read
$.on d, 'visibilitychange', Unread.setLine
$.on d, 'visibilitychange', Unread.setLine if Conf['Unread Line']
addPosts: (newPosts) ->
if Conf['Quick Reply']
@ -3543,8 +3544,9 @@ Unread =
continue
Unread.posts.push post
Unread.addPostQuotingYou post, yourPosts if yourPosts
# Force line on visible threads if there were no unread posts previously.
Unread.setLine Unread.posts[0] in newPosts
if Conf['Unread Line']
# Force line on visible threads if there were no unread posts previously.
Unread.setLine Unread.posts[0] in newPosts
Unread.read()
Unread.update()