$.add the unread favicon only on Firefox and Oprah, as it sometimes impacts performances on Chrome for obscure reasons, and that bugs me. Fix the unread favicon on Opera by $.rming it, hopefully.

This commit is contained in:
Nicolas Stepien 2012-03-26 05:04:30 +02:00
parent cd8326a9c5
commit 784cc6a8ae
2 changed files with 18 additions and 13 deletions

View File

@ -3434,14 +3434,14 @@
replies: [], replies: [],
foresee: [], foresee: [],
node: function(post) { node: function(post) {
var index; var count, index;
if ((index = Unread.foresee.indexOf(post.id)) !== -1) { if ((index = Unread.foresee.indexOf(post.id)) !== -1) {
Unread.foresee.splice(index, 1); Unread.foresee.splice(index, 1);
return; return;
} }
if (post.root.hidden || post["class"]) return; if (post.root.hidden || post["class"]) return;
Unread.replies.push(post.root); count = Unread.replies.push(post.root);
return Unread.update(); return Unread.update(count === 1);
}, },
scroll: function() { scroll: function() {
var bottom, height, i, reply, _len, _ref; var bottom, height, i, reply, _len, _ref;
@ -3454,7 +3454,7 @@
} }
if (i === 0) return; if (i === 0) return;
Unread.replies = Unread.replies.slice(i); Unread.replies = Unread.replies.slice(i);
return Unread.update(); return Unread.update(Unread.replies.length === 0);
}, },
setTitle: function(count) { setTitle: function(count) {
if (this.scheduled) { if (this.scheduled) {
@ -3467,14 +3467,15 @@
return d.title = "(" + count + ") " + Unread.title; return d.title = "(" + count + ") " + Unread.title;
}), 5); }), 5);
}, },
update: function(forceUpdate) { update: function(updateFavicon) {
var count; var count;
if (!g.REPLY) return; if (!g.REPLY) return;
count = this.replies.length; count = this.replies.length;
if (Conf['Unread Count']) this.setTitle(count); if (Conf['Unread Count']) this.setTitle(count);
if (!(Conf['Unread Favicon'] && (count < 2 || forceUpdate))) return; if (!(Conf['Unread Favicon'] && updateFavicon)) return;
if ($.engine === 'presto') $.rm(Favicon.el);
Favicon.el.href = g.dead ? count ? Favicon.unreadDead : Favicon.dead : count ? Favicon.unread : Favicon["default"]; Favicon.el.href = g.dead ? count ? Favicon.unreadDead : Favicon.dead : count ? Favicon.unread : Favicon["default"];
return $.add(d.head, Favicon.el); if ($.engine !== 'webkit') return $.add(d.head, Favicon.el);
} }
}; };

View File

@ -2879,8 +2879,8 @@ Unread =
Unread.foresee.splice index, 1 Unread.foresee.splice index, 1
return return
return if post.root.hidden or post.class return if post.root.hidden or post.class
Unread.replies.push post.root count = Unread.replies.push post.root
Unread.update() Unread.update count is 1
scroll: -> scroll: ->
height = d.body.clientHeight height = d.body.clientHeight
@ -2891,7 +2891,7 @@ Unread =
return if i is 0 return if i is 0
Unread.replies = Unread.replies[i..] Unread.replies = Unread.replies[i..]
Unread.update() Unread.update Unread.replies.length is 0
setTitle: (count) -> setTitle: (count) ->
if @scheduled if @scheduled
@ -2903,7 +2903,7 @@ Unread =
d.title = "(#{count}) #{Unread.title}" d.title = "(#{count}) #{Unread.title}"
), 5 ), 5
update: (forceUpdate) -> update: (updateFavicon) ->
return unless g.REPLY return unless g.REPLY
count = @replies.length count = @replies.length
@ -2911,9 +2911,12 @@ Unread =
if Conf['Unread Count'] if Conf['Unread Count']
@setTitle count @setTitle count
unless Conf['Unread Favicon'] and (count < 2 or forceUpdate) unless Conf['Unread Favicon'] and updateFavicon
return return
if $.engine is 'presto'
$.rm Favicon.el
Favicon.el.href = Favicon.el.href =
if g.dead if g.dead
if count if count
@ -2929,7 +2932,8 @@ Unread =
#`favicon.href = href` doesn't work on Firefox #`favicon.href = href` doesn't work on Firefox
#`favicon.href = href` isn't enough on Opera #`favicon.href = href` isn't enough on Opera
#Opera won't always update the favicon if the href didn't not change #Opera won't always update the favicon if the href didn't not change
$.add d.head, Favicon.el unless $.engine is 'webkit'
$.add d.head, Favicon.el
Favicon = Favicon =
init: -> init: ->