Revert "don't depend on mouseout. fixes #205"

This reverts commit b7601a2bd7ea12be17a433f0a0f003554bd60870.

Conflicts:

	4chan_x.user.js
	script.coffee
This commit is contained in:
Nicolas Stepien 2011-07-31 19:18:06 +02:00
parent 040cf69ec1
commit e994b8144c
2 changed files with 22 additions and 52 deletions

View File

@ -262,27 +262,14 @@
el.style.top = clientHeight < height || top < 0 ? 0 : top + height > clientHeight ? clientHeight - height : top;
if (clientX < clientWidth - 400) {
el.style.left = clientX + 45;
el.style.right = null;
return el.style.right = null;
} else {
el.style.left = null;
el.style.right = clientWidth - clientX + 45;
return el.style.right = clientWidth - clientX + 45;
}
/*
https://bugzilla.mozilla.org/show_bug.cgi?id=674955
`mouseout` does not fire when element removed
RESOLVED INVALID
god damn it mozzarella. when an element is removed (eg from un-inlining),
the `mouseout` event doesn't fire. we can't depend on `mouseout`, so we
simulate it by binding `mousemove` to the element and to the document. the
element binding stops the event from propogating; if the mouse has moved
off of the element, the event is not stopped, and mouseout happens.
*/
return e.stopPropagation();
},
hoverend: function(e) {
ui.el.parentNode.removeChild(ui.el);
return d.removeEventListener('mousemove', ui.hoverend, false);
return ui.el.parentNode.removeChild(ui.el);
}
};
/*
@ -2017,6 +2004,8 @@
});
if (conf['Quote Preview']) {
$.bind(link, 'mouseover', quotePreview.mouseover);
$.bind(link, 'mousemove', ui.hover);
$.bind(link, 'mouseout', quotePreview.mouseout);
}
if (conf['Quote Inline']) {
$.bind(link, 'click', quoteInline.toggle);
@ -2149,15 +2138,15 @@
if (!quote.hash) {
continue;
}
_results.push($.bind(quote, 'mouseover', quotePreview.mouseover));
$.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;
$.bind(this, 'mousemove', ui.hover);
$.bind(d, 'mousemove', quotePreview.mouseout);
qp = ui.el = $.el('div', {
id: 'qp',
className: 'replyhl'
@ -2168,7 +2157,6 @@
qp.innerHTML = el.innerHTML;
if (conf['Quote Highlighting']) {
$.addClass(el, 'qphl');
quotePreview.hl = el;
}
if (/backlink/.test(this.className)) {
replyID = $.x('ancestor::*[@id][1]', this).id.match(/\d+/)[0];
@ -2189,12 +2177,10 @@
}
},
mouseout: function() {
var hl;
hl = quotePreview.hl;
if (hl) {
$.removeClass(hl, 'qphl');
var el;
if (el = d.getElementById(this.hash.slice(1))) {
$.removeClass(el, 'qphl');
}
$.unbind(d, 'mousemove', quotePreview.mouseout);
return ui.hoverend();
},
parse: function(req, id, threadID) {
@ -2466,12 +2452,12 @@
if (!(thumb = $('img[md5]', root))) {
return;
}
return $.bind(thumb, 'mouseover', imgHover.mouseover);
$.bind(thumb, 'mouseover', imgHover.mouseover);
$.bind(thumb, 'mousemove', ui.hover);
return $.bind(thumb, 'mouseout', ui.hoverend);
});
},
mouseover: function(e) {
$.bind(this, 'mousemove', ui.hover);
$.bind(d, 'mousemove', ui.hoverend);
ui.el = $.el('img', {
id: 'iHover',
src: this.parentNode.href

View File

@ -183,22 +183,8 @@ ui =
el.style.left = null
el.style.right = clientWidth - clientX + 45
###
https://bugzilla.mozilla.org/show_bug.cgi?id=674955
`mouseout` does not fire when element removed
RESOLVED INVALID
god damn it mozzarella. when an element is removed (eg from un-inlining),
the `mouseout` event doesn't fire. we can't depend on `mouseout`, so we
simulate it by binding `mousemove` to the element and to the document. the
element binding stops the event from propogating; if the mouse has moved
off of the element, the event is not stopped, and mouseout happens.
###
e.stopPropagation()
hoverend: (e) ->
ui.el.parentNode.removeChild ui.el
d.removeEventListener 'mousemove', ui.hoverend, false
###
loosely follows the jquery api:
@ -1582,6 +1568,8 @@ quoteBacklink =
textContent: ">>#{id}"
if conf['Quote Preview']
$.bind link, 'mouseover', quotePreview.mouseover
$.bind link, 'mousemove', ui.hover
$.bind link, 'mouseout', quotePreview.mouseout
if conf['Quote Inline']
$.bind link, 'click', quoteInline.toggle
unless container = $ '.container', el
@ -1661,9 +1649,9 @@ quotePreview =
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) ->
$.bind @, 'mousemove', ui.hover
$.bind d, 'mousemove', quotePreview.mouseout
qp = ui.el = $.el 'div',
id: 'qp'
className: 'replyhl'
@ -1672,9 +1660,7 @@ quotePreview =
id = @hash[1..]
if el = d.getElementById id
qp.innerHTML = el.innerHTML
if conf['Quote Highlighting']
$.addClass el, 'qphl'
quotePreview.hl = el
$.addClass el, 'qphl' if conf['Quote Highlighting']
if /backlink/.test @className
replyID = $.x('ancestor::*[@id][1]', @).id.match(/\d+/)[0]
for quote in $$ 'a.quotelink', qp
@ -1685,9 +1671,7 @@ quotePreview =
threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', @).id
$.cache @pathname, (-> quotePreview.parse @, id, threadID)
mouseout: ->
{hl} = quotePreview
$.removeClass hl, 'qphl' if hl
$.unbind d, 'mousemove', quotePreview.mouseout
$.removeClass el, 'qphl' if el = d.getElementById @hash[1..]
ui.hoverend()
parse: (req, id, threadID) ->
return unless (qp = ui.el) and (qp.innerHTML is "Loading #{id}...")
@ -1857,9 +1841,9 @@ imgHover =
g.callbacks.push (root) ->
return unless thumb = $ 'img[md5]', root
$.bind thumb, 'mouseover', imgHover.mouseover
$.bind thumb, 'mousemove', ui.hover
$.bind thumb, 'mouseout', ui.hoverend
mouseover: (e) ->
$.bind @, 'mousemove', ui.hover
$.bind d, 'mousemove', ui.hoverend
ui.el = $.el 'img'
id: 'iHover'
src: @parentNode.href