rm ui.el in ui.hoverend, use it

This commit is contained in:
James Campos 2011-07-20 14:42:12 -07:00
parent 889a18da0c
commit 5127ff9e9f
2 changed files with 50 additions and 59 deletions

View File

@ -268,7 +268,7 @@
} }
}, },
hoverend: function(e) { hoverend: function(e) {
return ui.el.style.top = '999%'; return ui.el.parentNode.removeChild(ui.el);
} }
}; };
/* /*
@ -2122,40 +2122,31 @@
}; };
quotePreview = { quotePreview = {
init: function() { init: function() {
var preview; return g.callbacks.push(function(root) {
g.callbacks.push(quotePreview.node); var quote, _i, _len, _ref, _results;
preview = $.el('div', { _ref = $$('a.quotelink, a.backlink', root);
_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);
_results.push($.bind(quote, 'mouseout', quotePreview.mouseout));
}
return _results;
});
},
mouseover: function(e) {
var el, id, qp, quote, replyID, threadID, _i, _len, _ref, _results;
qp = $.el('div', {
id: 'qp', id: 'qp',
className: 'replyhl' className: 'replyhl'
}); });
return $.append(d.body, preview); $.append(d.body, qp);
}, ui.el = qp;
node: function(root) {
var quote, _i, _len, _ref, _results;
_ref = $$('a.quotelink, a.backlink', root);
_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);
_results.push($.bind(quote, 'mouseout', quotePreview.mouseout));
}
return _results;
},
mouseout: function() {
var el;
if (el = d.getElementById(this.hash.slice(1))) {
$.removeClass(el, 'qphl');
}
return ui.hoverend();
},
mouseover: function(e) {
var el, id, qp, quote, replyID, threadID, _i, _len, _ref;
id = this.hash.slice(1); id = this.hash.slice(1);
qp = $('#qp');
if (el = d.getElementById(id)) { if (el = d.getElementById(id)) {
qp.innerHTML = el.innerHTML; qp.innerHTML = el.innerHTML;
if ($.config('Quote Highlighting')) { if ($.config('Quote Highlighting')) {
@ -2164,21 +2155,27 @@
if (/backlink/.test(this.className)) { if (/backlink/.test(this.className)) {
replyID = $.x('ancestor::*[@id][1]', this).id.match(/\d+/)[0]; replyID = $.x('ancestor::*[@id][1]', this).id.match(/\d+/)[0];
_ref = $$('a.quotelink', qp); _ref = $$('a.quotelink', qp);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
quote = _ref[_i]; quote = _ref[_i];
if (quote.hash.slice(1) === replyID) { _results.push(quote.hash.slice(1) === replyID ? quote.className = 'forwardlink' : void 0);
quote.className = 'forwardlink';
}
} }
return _results;
} }
} else { } else {
qp.innerHTML = "Loading " + id + "..."; qp.innerHTML = "Loading " + id + "...";
threadID = this.pathname.split('/').pop() || $.x('ancestor::div[@class="thread"]/div', this).id; threadID = this.pathname.split('/').pop() || $.x('ancestor::div[@class="thread"]/div', this).id;
$.cache(this.pathname, (function() { return $.cache(this.pathname, (function() {
return quotePreview.parse(this, id, threadID); return quotePreview.parse(this, id, threadID);
})); }));
} }
return ui.el = qp; },
mouseout: function() {
var el;
if (el = d.getElementById(this.hash.slice(1))) {
$.removeClass(el, 'qphl');
}
return ui.hoverend();
}, },
parse: function(req, id, threadID) { parse: function(req, id, threadID) {
var body, html, op, qp, reply, _i, _len, _ref; var body, html, op, qp, reply, _i, _len, _ref;
@ -2452,7 +2449,7 @@
} }
$.bind(thumb, 'mouseover', imgHover.mouseover); $.bind(thumb, 'mouseover', imgHover.mouseover);
$.bind(thumb, 'mousemove', ui.hover); $.bind(thumb, 'mousemove', ui.hover);
return $.bind(thumb, 'mouseout', imgHover.mouseout); return $.bind(thumb, 'mouseout', ui.hoverend);
}); });
}, },
mouseover: function(e) { mouseover: function(e) {
@ -2463,9 +2460,6 @@
}); });
ui.el = img; ui.el = img;
return $.append(d.body, img); return $.append(d.body, img);
},
mouseout: function(e) {
return $.rm(ui.el);
} }
}; };
imgPreloading = { imgPreloading = {

View File

@ -182,7 +182,7 @@ ui =
el.style.right = clientWidth - clientX + 45 el.style.right = clientWidth - clientX + 45
hoverend: (e) -> hoverend: (e) ->
ui.el.style.top = '999%' ui.el.parentNode.removeChild ui.el
### ###
loosely follows the jquery api: loosely follows the jquery api:
@ -1651,23 +1651,20 @@ quoteInline =
quotePreview = quotePreview =
init: -> init: ->
g.callbacks.push quotePreview.node g.callbacks.push (root) ->
preview = $.el 'div', 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', quotePreview.mouseout
mouseover: (e) ->
qp = $.el 'div',
id: 'qp' id: 'qp'
className: 'replyhl' className: 'replyhl'
$.append d.body, preview $.append d.body, qp
node: (root) -> ui.el = qp
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', quotePreview.mouseout
mouseout: ->
$.removeClass el, 'qphl' if el = d.getElementById @hash[1..]
ui.hoverend()
mouseover: (e) ->
id = @hash[1..] id = @hash[1..]
qp = $ '#qp'
if el = d.getElementById id if el = d.getElementById id
qp.innerHTML = el.innerHTML qp.innerHTML = el.innerHTML
$.addClass el, 'qphl' if $.config 'Quote Highlighting' $.addClass el, 'qphl' if $.config 'Quote Highlighting'
@ -1680,7 +1677,9 @@ quotePreview =
qp.innerHTML = "Loading #{id}..." qp.innerHTML = "Loading #{id}..."
threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', @).id threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', @).id
$.cache @pathname, (-> quotePreview.parse @, id, threadID) $.cache @pathname, (-> quotePreview.parse @, id, threadID)
ui.el = qp mouseout: ->
$.removeClass el, 'qphl' if el = d.getElementById @hash[1..]
ui.hoverend()
parse: (req, id, threadID) -> parse: (req, id, threadID) ->
qp = $ '#qp' qp = $ '#qp'
return unless qp.innerHTML is "Loading #{id}..." return unless qp.innerHTML is "Loading #{id}..."
@ -1851,15 +1850,13 @@ imgHover =
return unless thumb = $ 'img[md5]', root return unless thumb = $ 'img[md5]', root
$.bind thumb, 'mouseover', imgHover.mouseover $.bind thumb, 'mouseover', imgHover.mouseover
$.bind thumb, 'mousemove', ui.hover $.bind thumb, 'mousemove', ui.hover
$.bind thumb, 'mouseout', imgHover.mouseout $.bind thumb, 'mouseout', ui.hoverend
mouseover: (e) -> mouseover: (e) ->
img = $.el 'img' img = $.el 'img'
id: 'iHover' id: 'iHover'
src: @parentNode.href src: @parentNode.href
ui.el = img ui.el = img
$.append d.body, img $.append d.body, img
mouseout: (e) ->
$.rm ui.el
imgPreloading = imgPreloading =
init: -> init: ->