hoverIntent r7. props mjbanks. fixes #23752.
git-svn-id: http://core.svn.wordpress.org/trunk@24259 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6d0173ba11
commit
e6ebfdff1e
|
@ -2,7 +2,7 @@
|
||||||
if ( typeof(jQuery) != 'undefined' ) {
|
if ( typeof(jQuery) != 'undefined' ) {
|
||||||
if ( typeof(jQuery.fn.hoverIntent) == 'undefined' ) {
|
if ( typeof(jQuery.fn.hoverIntent) == 'undefined' ) {
|
||||||
// hoverIntent r6 - Copy of wp-includes/js/hoverIntent.min.js
|
// hoverIntent r6 - Copy of wp-includes/js/hoverIntent.min.js
|
||||||
(function(a){a.fn.hoverIntent=function(k,j){var l={sensitivity:7,interval:100,timeout:0};l=a.extend(l,j?{over:k,out:j}:k);var n,m,h,d;var e=function(f){n=f.pageX;m=f.pageY};var c=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);if((Math.abs(h-n)+Math.abs(d-m))<l.sensitivity){a(f).unbind("mousemove",e);f.hoverIntent_s=1;return l.over.apply(f,[g])}else{h=n;d=m;f.hoverIntent_t=setTimeout(function(){c(g,f)},l.interval)}};var i=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);f.hoverIntent_s=0;return l.out.apply(f,[g])};var b=function(o){var g=jQuery.extend({},o);var f=this;if(f.hoverIntent_t){f.hoverIntent_t=clearTimeout(f.hoverIntent_t)}if(o.type=="mouseenter"){h=g.pageX;d=g.pageY;a(f).bind("mousemove",e);if(f.hoverIntent_s!=1){f.hoverIntent_t=setTimeout(function(){c(g,f)},l.interval)}}else{a(f).unbind("mousemove",e);if(f.hoverIntent_s==1){f.hoverIntent_t=setTimeout(function(){i(g,f)},l.timeout)}}};return this.bind("mouseenter",b).bind("mouseleave",b)}})(jQuery);
|
(function(a){a.fn.hoverIntent=function(m,d,h){var j={interval:100,sensitivity:7,timeout:0};if(typeof m==="object"){j=a.extend(j,m)}else{if(a.isFunction(d)){j=a.extend(j,{over:m,out:d,selector:h})}else{j=a.extend(j,{over:m,out:m,selector:d})}}var l,k,g,f;var e=function(n){l=n.pageX;k=n.pageY};var c=function(o,n){n.hoverIntent_t=clearTimeout(n.hoverIntent_t);if((Math.abs(g-l)+Math.abs(f-k))<j.sensitivity){a(n).off("mousemove.hoverIntent",e);n.hoverIntent_s=1;return j.over.apply(n,[o])}else{g=l;f=k;n.hoverIntent_t=setTimeout(function(){c(o,n)},j.interval)}};var i=function(o,n){n.hoverIntent_t=clearTimeout(n.hoverIntent_t);n.hoverIntent_s=0;return j.out.apply(n,[o])};var b=function(p){var o=jQuery.extend({},p);var n=this;if(n.hoverIntent_t){n.hoverIntent_t=clearTimeout(n.hoverIntent_t)}if(p.type=="mouseenter"){g=o.pageX;f=o.pageY;a(n).on("mousemove.hoverIntent",e);if(n.hoverIntent_s!=1){n.hoverIntent_t=setTimeout(function(){c(o,n)},j.interval)}}else{a(n).off("mousemove.hoverIntent",e);if(n.hoverIntent_s==1){n.hoverIntent_t=setTimeout(function(){i(o,n)},j.timeout)}}};return this.on({"mouseenter.hoverIntent":b,"mouseleave.hoverIntent":b},j.selector)}})(jQuery);
|
||||||
}
|
}
|
||||||
jQuery(document).ready(function($){
|
jQuery(document).ready(function($){
|
||||||
var adminbar = $('#wpadminbar'), refresh, touchOpen, touchClose, disableHoverIntent = false;
|
var adminbar = $('#wpadminbar'), refresh, touchOpen, touchClose, disableHoverIntent = false;
|
||||||
|
|
|
@ -1,42 +1,51 @@
|
||||||
/**
|
/*!
|
||||||
* hoverIntent is similar to jQuery's built-in "hover" function except that
|
* hoverIntent r7 // 2013.03.11 // jQuery 1.9.1+
|
||||||
* instead of firing the onMouseOver event immediately, hoverIntent checks
|
* http://cherne.net/brian/resources/jquery.hoverIntent.html
|
||||||
|
*
|
||||||
|
* You may use hoverIntent under the terms of the MIT license. Basically that
|
||||||
|
* means you are free to use hoverIntent as long as this header is left intact.
|
||||||
|
* Copyright 2007, 2013 Brian Cherne
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* hoverIntent is similar to jQuery's built-in "hover" method except that
|
||||||
|
* instead of firing the handlerIn function immediately, hoverIntent checks
|
||||||
* to see if the user's mouse has slowed down (beneath the sensitivity
|
* to see if the user's mouse has slowed down (beneath the sensitivity
|
||||||
* threshold) before firing the onMouseOver event.
|
* threshold) before firing the event. The handlerOut function is only
|
||||||
|
* called after a matching handlerIn.
|
||||||
*
|
*
|
||||||
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
|
* // basic usage ... just like .hover()
|
||||||
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
|
* .hoverIntent( handlerIn, handlerOut )
|
||||||
|
* .hoverIntent( handlerInOut )
|
||||||
*
|
*
|
||||||
* hoverIntent is currently available for use in all personal or commercial
|
* // basic usage ... with event delegation!
|
||||||
* projects under both MIT and GPL licenses. This means that you can choose
|
* .hoverIntent( handlerIn, handlerOut, selector )
|
||||||
* the license that best suits your project, and use it accordingly.
|
* .hoverIntent( handlerInOut, selector )
|
||||||
*
|
*
|
||||||
* // basic usage (just like .hover) receives onMouseOver and onMouseOut functions
|
* // using a basic configuration object
|
||||||
* $("ul li").hoverIntent( showNav , hideNav );
|
* .hoverIntent( config )
|
||||||
*
|
*
|
||||||
* // advanced usage receives configuration object only
|
* @param handlerIn function OR configuration object
|
||||||
* $("ul li").hoverIntent({
|
* @param handlerOut function OR selector for delegation OR undefined
|
||||||
* sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
|
* @param selector selector OR undefined
|
||||||
* interval: 100, // number = milliseconds of polling interval
|
* @author Brian Cherne <brian(at)cherne(dot)net>
|
||||||
* over: showNav, // function = onMouseOver callback (required)
|
|
||||||
* timeout: 0, // number = milliseconds delay before onMouseOut function call
|
|
||||||
* out: hideNav // function = onMouseOut callback (required)
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* @param f onMouseOver function || An object with configuration options
|
|
||||||
* @param g onMouseOut function || Nothing (use configuration options object)
|
|
||||||
* @author Brian Cherne brian(at)cherne(dot)net
|
|
||||||
*/
|
*/
|
||||||
(function($) {
|
(function($) {
|
||||||
$.fn.hoverIntent = function(f,g) {
|
$.fn.hoverIntent = function(handlerIn,handlerOut,selector) {
|
||||||
// default configuration options
|
|
||||||
|
// default configuration values
|
||||||
var cfg = {
|
var cfg = {
|
||||||
sensitivity: 7,
|
|
||||||
interval: 100,
|
interval: 100,
|
||||||
|
sensitivity: 7,
|
||||||
timeout: 0
|
timeout: 0
|
||||||
};
|
};
|
||||||
// override configuration options with user supplied object
|
|
||||||
cfg = $.extend(cfg, g ? { over: f, out: g } : f );
|
if ( typeof handlerIn === "object" ) {
|
||||||
|
cfg = $.extend(cfg, handlerIn );
|
||||||
|
} else if ($.isFunction(handlerOut)) {
|
||||||
|
cfg = $.extend(cfg, { over: handlerIn, out: handlerOut, selector: selector } );
|
||||||
|
} else {
|
||||||
|
cfg = $.extend(cfg, { over: handlerIn, out: handlerIn, selector: handlerOut } );
|
||||||
|
}
|
||||||
|
|
||||||
// instantiate variables
|
// instantiate variables
|
||||||
// cX, cY = current X and Y position of mouse, updated by mousemove event
|
// cX, cY = current X and Y position of mouse, updated by mousemove event
|
||||||
|
@ -54,7 +63,7 @@
|
||||||
ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
|
ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
|
||||||
// compare mouse positions to see if they've crossed the threshold
|
// compare mouse positions to see if they've crossed the threshold
|
||||||
if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
|
if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
|
||||||
$(ob).unbind("mousemove",track);
|
$(ob).off("mousemove.hoverIntent",track);
|
||||||
// set hoverIntent state to true (so mouseOut can be called)
|
// set hoverIntent state to true (so mouseOut can be called)
|
||||||
ob.hoverIntent_s = 1;
|
ob.hoverIntent_s = 1;
|
||||||
return cfg.over.apply(ob,[ev]);
|
return cfg.over.apply(ob,[ev]);
|
||||||
|
@ -87,20 +96,20 @@
|
||||||
// set "previous" X and Y position based on initial entry point
|
// set "previous" X and Y position based on initial entry point
|
||||||
pX = ev.pageX; pY = ev.pageY;
|
pX = ev.pageX; pY = ev.pageY;
|
||||||
// update "current" X and Y position based on mousemove
|
// update "current" X and Y position based on mousemove
|
||||||
$(ob).bind("mousemove",track);
|
$(ob).on("mousemove.hoverIntent",track);
|
||||||
// start polling interval (self-calling timeout) to compare mouse coordinates over time
|
// start polling interval (self-calling timeout) to compare mouse coordinates over time
|
||||||
if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}
|
if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}
|
||||||
|
|
||||||
// else e.type == "mouseleave"
|
// else e.type == "mouseleave"
|
||||||
} else {
|
} else {
|
||||||
// unbind expensive mousemove event
|
// unbind expensive mousemove event
|
||||||
$(ob).unbind("mousemove",track);
|
$(ob).off("mousemove.hoverIntent",track);
|
||||||
// if hoverIntent state is true, then call the mouseOut function after the specified delay
|
// if hoverIntent state is true, then call the mouseOut function after the specified delay
|
||||||
if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
|
if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// bind the function to the two event listeners
|
// listen for mouseenter and mouseleave
|
||||||
return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover);
|
return this.on({'mouseenter.hoverIntent':handleHover,'mouseleave.hoverIntent':handleHover}, cfg.selector);
|
||||||
};
|
};
|
||||||
})(jQuery);
|
})(jQuery);
|
|
@ -321,7 +321,7 @@ function wp_default_scripts( &$scripts ) {
|
||||||
|
|
||||||
$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 );
|
$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 );
|
||||||
|
|
||||||
$scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), 'r6', 1 );
|
$scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), 'r7', 1 );
|
||||||
|
|
||||||
$scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2' ), false, 1 );
|
$scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2' ), false, 1 );
|
||||||
$scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 );
|
$scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 );
|
||||||
|
|
Loading…
Reference in New Issue