Slight performance improvement for the Anonymizer and ReportButton.

This commit is contained in:
Nicolas Stepien 2012-03-06 22:54:37 +01:00
parent f3e4c5b64a
commit 14d48f59b2
2 changed files with 23 additions and 26 deletions

View File

@ -2810,15 +2810,12 @@
return g.callbacks.push(this.node);
},
node: function(post) {
var name, trip;
var name, node;
name = $('.commentpostername, .postername', post.el);
name.textContent = 'Anonymous';
if (trip = $('.postertrip', post.el)) {
if (trip.parentNode.nodeName === 'A') {
return $.rm(trip.parentNode);
} else {
return $.rm(trip);
}
node = name.nextElementSibling;
if (node.className === 'postertrip' || node.nodeName === 'A') {
return $.rm(node);
}
}
};
@ -3412,16 +3409,17 @@
ReportButton = {
init: function() {
this.a = $.el('a', {
className: 'reportbutton',
innerHTML: '[ ! ]',
href: 'javascript:;'
});
return g.callbacks.push(this.node);
},
node: function(post) {
var a;
if (!(a = $('.reportbutton', post.el))) {
a = $.el('a', {
className: 'reportbutton',
innerHTML: '[ ! ]',
href: 'javascript:;'
});
a = ReportButton.a.cloneNode(true);
$.after($('span[id]', post.el), [$.tn(' '), a]);
}
return $.on(a, 'click', ReportButton.report);
@ -3506,7 +3504,7 @@
if (!g.REPLY) return;
count = this.replies.length;
if (conf['Unread Count']) d.title = "(" + count + ") " + this.title;
if (!(conf['Unread Favicon'] && count < 2 || forceUpdate)) return;
if (!(conf['Unread Favicon'] && (count < 2 || forceUpdate))) return;
Favicon.el.href = g.dead ? count ? Favicon.unreadDead : Favicon.dead : count ? Favicon.unread : Favicon["default"];
return $.add(d.head, Favicon.el);
}
@ -3679,7 +3677,7 @@
a = post.img.parentNode;
$.on(a, 'click', ImageExpand.cb.toggle);
if (ImageExpand.on && !post.root.hidden && post["class"] !== 'inline') {
return ImageExpand.expand(a.firstChild);
return ImageExpand.expand(post.img);
}
},
cb: {

View File

@ -2367,11 +2367,9 @@ Anonymize =
node: (post) ->
name = $ '.commentpostername, .postername', post.el
name.textContent = 'Anonymous'
if trip = $ '.postertrip', post.el
if trip.parentNode.nodeName is 'A'
$.rm trip.parentNode
else
$.rm trip
node = name.nextElementSibling
if node.className is 'postertrip' or node.nodeName is 'A'
$.rm node
Sauce =
init: ->
@ -2806,13 +2804,14 @@ QuoteCT =
ReportButton =
init: ->
@a = $.el 'a',
className: 'reportbutton'
innerHTML: '[&nbsp;!&nbsp;]'
href: 'javascript:;'
g.callbacks.push @node
node: (post) ->
if not a = $ '.reportbutton', post.el
a = $.el 'a',
className: 'reportbutton'
innerHTML: '[&nbsp;!&nbsp;]'
href: 'javascript:;'
unless a = $ '.reportbutton', post.el
a = ReportButton.a.cloneNode true
$.after $('span[id]', post.el), [$.tn(' '), a]
$.on a, 'click', ReportButton.report
report: ->
@ -2882,7 +2881,7 @@ Unread =
if conf['Unread Count']
d.title = "(#{count}) #{@title}"
unless conf['Unread Favicon'] and count < 2 or forceUpdate
unless conf['Unread Favicon'] and (count < 2 or forceUpdate)
return
Favicon.el.href =
@ -3012,7 +3011,7 @@ ImageExpand =
a = post.img.parentNode
$.on a, 'click', ImageExpand.cb.toggle
if ImageExpand.on and !post.root.hidden and post.class isnt 'inline'
ImageExpand.expand a.firstChild
ImageExpand.expand post.img
cb:
toggle: (e) ->
return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0