check for quote.hash before binding

ui.hover doesn't care if we `return`ed in the mouseover function
This commit is contained in:
James Campos 2011-05-22 13:21:50 -07:00
parent 696bb15b36
commit e6101a5efa
2 changed files with 12 additions and 8 deletions

View File

@ -1738,6 +1738,9 @@
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
quote = _ref[_i];
if (!quote.hash) {
continue;
}
quote.removeAttribute('onclick');
_results.push($.bind(quote, 'click', quoteInline.toggle));
}
@ -1745,9 +1748,7 @@
},
toggle: function(e) {
var el, id, inline, req, root, table, threadID;
if (!(id = this.hash.slice(1))) {
return;
}
id = this.hash.slice(1);
e.preventDefault();
root = $.x('ancestor::td[1]', this);
if (table = $("#i" + id, root)) {
@ -1837,6 +1838,9 @@
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
quote = _ref[_i];
if (!quote.hash) {
continue;
}
$.bind(quote, 'mouseover', quotePreview.mouseover);
$.bind(quote, 'mousemove', ui.hover);
$.bind(quote, 'mouseout', ui.hoverend);
@ -1853,9 +1857,7 @@
},
mouseover: function(e) {
var el, id, qp, quote, replyID, req, threadID, _i, _len, _ref;
if (!(id = this.hash.slice(1))) {
return;
}
id = this.hash.slice(1);
qp = $('#qp');
if (el = d.getElementById(id)) {
qp.innerHTML = el.innerHTML;

View File

@ -1394,10 +1394,11 @@ quoteInline =
g.callbacks.push quoteInline.node
node: (root) ->
for quote in $$ 'a.quotelink, a.backlink', root
continue unless quote.hash
quote.removeAttribute 'onclick'
$.bind quote, 'click', quoteInline.toggle
toggle: (e) ->
return unless id = @hash[1..]
id = @hash[1..]
e.preventDefault()
root = $.x 'ancestor::td[1]', @
if table = $ "#i#{id}", root
@ -1462,6 +1463,7 @@ quotePreview =
$.append d.body, preview
node: (root) ->
for quote in $$ 'a.quotelink, a.backlink', root
continue unless quote.hash
$.bind quote, 'mouseover', quotePreview.mouseover
$.bind quote, 'mousemove', ui.hover
$.bind quote, 'mouseout', ui.hoverend
@ -1470,7 +1472,7 @@ quotePreview =
return unless el = d.getElementById @hash[1..]
$.removeClass el, 'qphl'
mouseover: (e) ->
return unless id = @hash[1..]
id = @hash[1..]
qp = $ '#qp'
if el = d.getElementById id
qp.innerHTML = el.innerHTML