Edit File by line
/home/barbar84/public_h.../wp-inclu.../js
File: hoverIntent.js
/*!
[0] Fix | Delete
* hoverIntent v1.8.3 // 2014.08.11 // jQuery v1.9.1+
[1] Fix | Delete
* http://cherne.net/brian/resources/jquery.hoverIntent.html
[2] Fix | Delete
*
[3] Fix | Delete
* You may use hoverIntent under the terms of the MIT license. Basically that
[4] Fix | Delete
* means you are free to use hoverIntent as long as this header is left intact.
[5] Fix | Delete
* Copyright 2007, 2014 Brian Cherne
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/* hoverIntent is similar to jQuery's built-in "hover" method except that
[9] Fix | Delete
* instead of firing the handlerIn function immediately, hoverIntent checks
[10] Fix | Delete
* to see if the user's mouse has slowed down (beneath the sensitivity
[11] Fix | Delete
* threshold) before firing the event. The handlerOut function is only
[12] Fix | Delete
* called after a matching handlerIn.
[13] Fix | Delete
*
[14] Fix | Delete
* // basic usage ... just like .hover()
[15] Fix | Delete
* .hoverIntent( handlerIn, handlerOut )
[16] Fix | Delete
* .hoverIntent( handlerInOut )
[17] Fix | Delete
*
[18] Fix | Delete
* // basic usage ... with event delegation!
[19] Fix | Delete
* .hoverIntent( handlerIn, handlerOut, selector )
[20] Fix | Delete
* .hoverIntent( handlerInOut, selector )
[21] Fix | Delete
*
[22] Fix | Delete
* // using a basic configuration object
[23] Fix | Delete
* .hoverIntent( config )
[24] Fix | Delete
*
[25] Fix | Delete
* @param handlerIn function OR configuration object
[26] Fix | Delete
* @param handlerOut function OR selector for delegation OR undefined
[27] Fix | Delete
* @param selector selector OR undefined
[28] Fix | Delete
* @author Brian Cherne <brian(at)cherne(dot)net>
[29] Fix | Delete
*/
[30] Fix | Delete
(function($) {
[31] Fix | Delete
$.fn.hoverIntent = function(handlerIn,handlerOut,selector) {
[32] Fix | Delete
[33] Fix | Delete
// default configuration values
[34] Fix | Delete
var cfg = {
[35] Fix | Delete
interval: 100,
[36] Fix | Delete
sensitivity: 6,
[37] Fix | Delete
timeout: 0
[38] Fix | Delete
};
[39] Fix | Delete
[40] Fix | Delete
if ( typeof handlerIn === "object" ) {
[41] Fix | Delete
cfg = $.extend(cfg, handlerIn );
[42] Fix | Delete
} else if ($.isFunction(handlerOut)) {
[43] Fix | Delete
cfg = $.extend(cfg, { over: handlerIn, out: handlerOut, selector: selector } );
[44] Fix | Delete
} else {
[45] Fix | Delete
cfg = $.extend(cfg, { over: handlerIn, out: handlerIn, selector: handlerOut } );
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
// instantiate variables
[49] Fix | Delete
// cX, cY = current X and Y position of mouse, updated by mousemove event
[50] Fix | Delete
// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
[51] Fix | Delete
var cX, cY, pX, pY;
[52] Fix | Delete
[53] Fix | Delete
// A private function for getting mouse position
[54] Fix | Delete
var track = function(ev) {
[55] Fix | Delete
cX = ev.pageX;
[56] Fix | Delete
cY = ev.pageY;
[57] Fix | Delete
};
[58] Fix | Delete
[59] Fix | Delete
// A private function for comparing current and previous mouse position
[60] Fix | Delete
var compare = function(ev,ob) {
[61] Fix | Delete
ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
[62] Fix | Delete
// compare mouse positions to see if they've crossed the threshold
[63] Fix | Delete
if ( Math.sqrt( (pX-cX)*(pX-cX) + (pY-cY)*(pY-cY) ) < cfg.sensitivity ) {
[64] Fix | Delete
$(ob).off("mousemove.hoverIntent",track);
[65] Fix | Delete
// set hoverIntent state to true (so mouseOut can be called)
[66] Fix | Delete
ob.hoverIntent_s = true;
[67] Fix | Delete
return cfg.over.apply(ob,[ev]);
[68] Fix | Delete
} else {
[69] Fix | Delete
// set previous coordinates for next time
[70] Fix | Delete
pX = cX; pY = cY;
[71] Fix | Delete
// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
[72] Fix | Delete
ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
[73] Fix | Delete
}
[74] Fix | Delete
};
[75] Fix | Delete
[76] Fix | Delete
// A private function for delaying the mouseOut function
[77] Fix | Delete
var delay = function(ev,ob) {
[78] Fix | Delete
ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
[79] Fix | Delete
ob.hoverIntent_s = false;
[80] Fix | Delete
return cfg.out.apply(ob,[ev]);
[81] Fix | Delete
};
[82] Fix | Delete
[83] Fix | Delete
// A private function for handling mouse 'hovering'
[84] Fix | Delete
var handleHover = function(e) {
[85] Fix | Delete
// copy objects to be passed into t (required for event object to be passed in IE)
[86] Fix | Delete
var ev = $.extend({},e);
[87] Fix | Delete
var ob = this;
[88] Fix | Delete
[89] Fix | Delete
// cancel hoverIntent timer if it exists
[90] Fix | Delete
if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }
[91] Fix | Delete
[92] Fix | Delete
// if e.type === "mouseenter"
[93] Fix | Delete
if (e.type === "mouseenter") {
[94] Fix | Delete
// set "previous" X and Y position based on initial entry point
[95] Fix | Delete
pX = ev.pageX; pY = ev.pageY;
[96] Fix | Delete
// update "current" X and Y position based on mousemove
[97] Fix | Delete
$(ob).on("mousemove.hoverIntent",track);
[98] Fix | Delete
// start polling interval (self-calling timeout) to compare mouse coordinates over time
[99] Fix | Delete
if (!ob.hoverIntent_s) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}
[100] Fix | Delete
[101] Fix | Delete
// else e.type == "mouseleave"
[102] Fix | Delete
} else {
[103] Fix | Delete
// unbind expensive mousemove event
[104] Fix | Delete
$(ob).off("mousemove.hoverIntent",track);
[105] Fix | Delete
// if hoverIntent state is true, then call the mouseOut function after the specified delay
[106] Fix | Delete
if (ob.hoverIntent_s) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
[107] Fix | Delete
}
[108] Fix | Delete
};
[109] Fix | Delete
[110] Fix | Delete
// listen for mouseenter and mouseleave
[111] Fix | Delete
return this.on({'mouseenter.hoverIntent':handleHover,'mouseleave.hoverIntent':handleHover}, cfg.selector);
[112] Fix | Delete
};
[113] Fix | Delete
})(jQuery);
[114] Fix | Delete
[115] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function