Changeset 19605
- Timestamp:
- 12/20/2011 08:54:54 PM (11 years ago)
- Location:
- trunk/wp-includes/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/hoverIntent.dev.js
r10291 r19605 5 5 * threshold) before firing the onMouseOver event. 6 6 * 7 * hoverIntent r 5 // 2007.03.27 // jQuery 1.1.2+7 * hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+ 8 8 * <http://cherne.net/brian/resources/jquery.hoverIntent.html> 9 9 * … … 26 26 * @param f onMouseOver function || An object with configuration options 27 27 * @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 29 29 */ 30 30 (function($) { … … 73 73 return cfg.out.apply(ob,[ev]); 74 74 }; 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/onMouseOut81 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 };97 75 98 76 // A private function for handling mouse 'hovering' 99 var doHover = function(e,ob) { 100 77 var handleHover = function(e) { 101 78 // copy objects to be passed into t (required for event object to be passed in IE) 102 79 var ev = jQuery.extend({},e); 80 var ob = this; 103 81 104 82 // cancel hoverIntent timer if it exists 105 83 if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } 106 84 107 // else e.type == "onmouseover"108 if (e.type == "mouse over") {85 // if e.type == "mouseenter" 86 if (e.type == "mouseenter") { 109 87 // set "previous" X and Y position based on initial entry point 110 88 pX = ev.pageX; pY = ev.pageY; … … 114 92 if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );} 115 93 116 // else e.type == " onmouseout"94 // else e.type == "mouseleave" 117 95 } else { 118 96 // unbind expensive mousemove event … … 124 102 125 103 // bind the function to the two event listeners 126 return this. mouseover(handleHover).mouseout(handleHover);104 return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover); 127 105 }; 128 106 })(jQuery); -
trunk/wp-includes/js/hoverIntent.js
r10291 r19605 1 (function( a){a.fn.hoverIntent=function(l,j){var m={sensitivity:7,interval:100,timeout:0};m=a.extend(m,j?{over:l,out:j}:l);var o,n,h,d;var e=function(f){o=f.pageX;n=f.pageY};var c=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);if((Math.abs(h-o)+Math.abs(d-n))<m.sensitivity){a(f).unbind("mousemove",e);f.hoverIntent_s=1;return m.over.apply(f,[g])}else{h=o;d=n;f.hoverIntent_t=setTimeout(function(){c(g,f)},m.interval)}};var i=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);f.hoverIntent_s=0;return m.out.apply(f,[g])};var b=function(q){var f=this;var g=(q.type=="mouseover"?q.fromElement:q.toElement)||q.relatedTarget;while(g&&g!=this){try{g=g.parentNode}catch(q){g=this}}if(g==this){if(a.browser.mozilla){if(q.type=="mouseout"){f.mtout=setTimeout(function(){k(q,f)},30)}else{if(f.mtout){f.mtout=clearTimeout(f.mtout)}}}return}else{if(f.mtout){f.mtout=clearTimeout(f.mtout)}k(q,f)}};var k=function(p,f){var g=jQuery.extend({},p);if(f.hoverIntent_t){f.hoverIntent_t=clearTimeout(f.hoverIntent_t)}if(p.type=="mouseover"){h=g.pageX;d=g.pageY;a(f).bind("mousemove",e);if(f.hoverIntent_s!=1){f.hoverIntent_t=setTimeout(function(){c(g,f)},m.interval)}}else{a(f).unbind("mousemove",e);if(f.hoverIntent_s==1){f.hoverIntent_t=setTimeout(function(){i(g,f)},m.timeout)}}};return this.mouseover(b).mouseout(b)}})(jQuery);1 (function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);
Note: See TracChangeset
for help on using the changeset viewer.