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.'], '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 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 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 Excerpt': [true, 'Show an excerpt of the thread in the tab title.'],
'Thread Stats': [true, 'Display reply and image count.'], 'Thread Stats': [true, 'Display reply and image count.'],
'Thread Watcher': [true, 'Bookmark threads.'], 'Thread Watcher': [true, 'Bookmark threads.'],
@ -5243,14 +5244,16 @@
} }
} }
Unread.addPosts(posts); Unread.addPosts(posts);
if (Unread.hr.parentNode) { if (Unread.posts.length) {
Unread.hr.scrollIntoView(false); $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root).scrollIntoView(false);
} else if (posts.length && !Unread.posts.length) { } else if (posts.length) {
posts[posts.length - 1].nodes.root.scrollIntoView(); posts[posts.length - 1].nodes.root.scrollIntoView();
} }
$.on(d, 'ThreadUpdate', Unread.onUpdate); $.on(d, 'ThreadUpdate', Unread.onUpdate);
$.on(d, 'scroll visibilitychange', Unread.read); $.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) { addPosts: function(newPosts) {
var ID, post, youInThisThread, yourPosts, _i, _len, _ref; var ID, post, youInThisThread, yourPosts, _i, _len, _ref;
@ -5269,7 +5272,9 @@
Unread.addPostQuotingYou(post, yourPosts); 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(); Unread.read();
return Unread.update(); 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. - Added a setting to always auto-scroll to the bottom instead of the first new post.
Unread posts changes: 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. - 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. - 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. - 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.'] '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 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 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 Excerpt': [true, 'Show an excerpt of the thread in the tab title.']
'Thread Stats': [true, 'Display reply and image count.'] 'Thread Stats': [true, 'Display reply and image count.']
'Thread Watcher': [true, 'Bookmark threads.'] 'Thread Watcher': [true, 'Bookmark threads.']

View File

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