Skip to content

Commit a8c9c39

Browse files
author
nacin
committed
hoverIntent r6. fixes #19311.
git-svn-id: http://core.svn.wordpress.org/trunk@19605 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent 0947168 commit a8c9c39

File tree

2 files changed

+9
-31
lines changed

2 files changed

+9
-31
lines changed

wp-includes/js/hoverIntent.dev.js

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* to see if the user's mouse has slowed down (beneath the sensitivity
55
* threshold) before firing the onMouseOver event.
66
*
7-
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
7+
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
88
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
99
*
1010
* hoverIntent is currently available for use in all personal or commercial
@@ -25,7 +25,7 @@
2525
*
2626
* @param f onMouseOver function || An object with configuration options
2727
* @param g onMouseOut function || Nothing (use configuration options object)
28-
* @author Brian Cherne <brian@cherne.net>
28+
* @author Brian Cherne brian(at)cherne(dot)net
2929
*/
3030
(function($) {
3131
$.fn.hoverIntent = function(f,g) {
@@ -72,48 +72,26 @@
7272
ob.hoverIntent_s = 0;
7373
return cfg.out.apply(ob,[ev]);
7474
};
75-
76-
// workaround for Mozilla bug: not firing mouseout/mouseleave on absolute positioned elements over textareas and input type="text"
77-
var handleHover = function(e) {
78-
var t = this;
79-
80-
// next two lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
81-
var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
82-
while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
83-
if ( p == this ) {
84-
if ( $.browser.mozilla ) {
85-
if ( e.type == "mouseout" ) {
86-
t.mtout = setTimeout( function(){doHover(e,t);}, 30 );
87-
} else {
88-
if (t.mtout) { t.mtout = clearTimeout(t.mtout); }
89-
}
90-
}
91-
return;
92-
} else {
93-
if (t.mtout) { t.mtout = clearTimeout(t.mtout); }
94-
doHover(e,t);
95-
}
96-
};
9775

9876
// A private function for handling mouse 'hovering'
99-
var doHover = function(e,ob) {
100-
77+
var handleHover = function(e) {
10178
// copy objects to be passed into t (required for event object to be passed in IE)
10279
var ev = jQuery.extend({},e);
80+
var ob = this;
10381

10482
// cancel hoverIntent timer if it exists
10583
if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }
10684

107-
// else e.type == "onmouseover"
108-
if (e.type == "mouseover") {
85+
// if e.type == "mouseenter"
86+
if (e.type == "mouseenter") {
10987
// set "previous" X and Y position based on initial entry point
11088
pX = ev.pageX; pY = ev.pageY;
11189
// update "current" X and Y position based on mousemove
11290
$(ob).bind("mousemove",track);
11391
// start polling interval (self-calling timeout) to compare mouse coordinates over time
11492
if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}
11593

116-
// else e.type == "onmouseout"
94+
// else e.type == "mouseleave"
11795
} else {
11896
// unbind expensive mousemove event
11997
$(ob).unbind("mousemove",track);
@@ -123,6 +101,6 @@
123101
};
124102

125103
// bind the function to the two event listeners
126-
return this.mouseover(handleHover).mouseout(handleHover);
104+
return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover);
127105
};
128106
})(jQuery);

wp-includes/js/hoverIntent.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)