Edit File by line
/home/zeestwma/richards.../wp-inclu.../js
File: hoverIntent.js
/*!
[0] Fix | Delete
* hoverIntent v1.10.2 // 2020.04.28 // jQuery v1.7.0+
[1] Fix | Delete
* http://briancherne.github.io/jquery-hoverIntent/
[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-2019 Brian Cherne
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* hoverIntent is similar to jQuery's built-in "hover" method except that
[10] Fix | Delete
* instead of firing the handlerIn function immediately, hoverIntent checks
[11] Fix | Delete
* to see if the user's mouse has slowed down (beneath the sensitivity
[12] Fix | Delete
* threshold) before firing the event. The handlerOut function is only
[13] Fix | Delete
* called after a matching handlerIn.
[14] Fix | Delete
*
[15] Fix | Delete
* // basic usage ... just like .hover()
[16] Fix | Delete
* .hoverIntent( handlerIn, handlerOut )
[17] Fix | Delete
* .hoverIntent( handlerInOut )
[18] Fix | Delete
*
[19] Fix | Delete
* // basic usage ... with event delegation!
[20] Fix | Delete
* .hoverIntent( handlerIn, handlerOut, selector )
[21] Fix | Delete
* .hoverIntent( handlerInOut, selector )
[22] Fix | Delete
*
[23] Fix | Delete
* // using a basic configuration object
[24] Fix | Delete
* .hoverIntent( config )
[25] Fix | Delete
*
[26] Fix | Delete
* @param handlerIn function OR configuration object
[27] Fix | Delete
* @param handlerOut function OR selector for delegation OR undefined
[28] Fix | Delete
* @param selector selector OR undefined
[29] Fix | Delete
* @author Brian Cherne <brian(at)cherne(dot)net>
[30] Fix | Delete
*/
[31] Fix | Delete
[32] Fix | Delete
;(function(factory) {
[33] Fix | Delete
'use strict';
[34] Fix | Delete
if (typeof define === 'function' && define.amd) {
[35] Fix | Delete
define(['jquery'], factory);
[36] Fix | Delete
} else if (typeof module === 'object' && module.exports) {
[37] Fix | Delete
module.exports = factory(require('jquery'));
[38] Fix | Delete
} else if (jQuery && !jQuery.fn.hoverIntent) {
[39] Fix | Delete
factory(jQuery);
[40] Fix | Delete
}
[41] Fix | Delete
})(function($) {
[42] Fix | Delete
'use strict';
[43] Fix | Delete
[44] Fix | Delete
// default configuration values
[45] Fix | Delete
var _cfg = {
[46] Fix | Delete
interval: 100,
[47] Fix | Delete
sensitivity: 6,
[48] Fix | Delete
timeout: 0
[49] Fix | Delete
};
[50] Fix | Delete
[51] Fix | Delete
// counter used to generate an ID for each instance
[52] Fix | Delete
var INSTANCE_COUNT = 0;
[53] Fix | Delete
[54] Fix | Delete
// current X and Y position of mouse, updated during mousemove tracking (shared across instances)
[55] Fix | Delete
var cX, cY;
[56] Fix | Delete
[57] Fix | Delete
// saves the current pointer position coordinates based on the given mousemove event
[58] Fix | Delete
var track = function(ev) {
[59] Fix | Delete
cX = ev.pageX;
[60] Fix | Delete
cY = ev.pageY;
[61] Fix | Delete
};
[62] Fix | Delete
[63] Fix | Delete
// compares current and previous mouse positions
[64] Fix | Delete
var compare = function(ev,$el,s,cfg) {
[65] Fix | Delete
// compare mouse positions to see if pointer has slowed enough to trigger `over` function
[66] Fix | Delete
if ( Math.sqrt( (s.pX-cX)*(s.pX-cX) + (s.pY-cY)*(s.pY-cY) ) < cfg.sensitivity ) {
[67] Fix | Delete
$el.off(s.event,track);
[68] Fix | Delete
delete s.timeoutId;
[69] Fix | Delete
// set hoverIntent state as active for this element (permits `out` handler to trigger)
[70] Fix | Delete
s.isActive = true;
[71] Fix | Delete
// overwrite old mouseenter event coordinates with most recent pointer position
[72] Fix | Delete
ev.pageX = cX; ev.pageY = cY;
[73] Fix | Delete
// clear coordinate data from state object
[74] Fix | Delete
delete s.pX; delete s.pY;
[75] Fix | Delete
return cfg.over.apply($el[0],[ev]);
[76] Fix | Delete
} else {
[77] Fix | Delete
// set previous coordinates for next comparison
[78] Fix | Delete
s.pX = cX; s.pY = cY;
[79] Fix | Delete
// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
[80] Fix | Delete
s.timeoutId = setTimeout( function(){compare(ev, $el, s, cfg);} , cfg.interval );
[81] Fix | Delete
}
[82] Fix | Delete
};
[83] Fix | Delete
[84] Fix | Delete
// triggers given `out` function at configured `timeout` after a mouseleave and clears state
[85] Fix | Delete
var delay = function(ev,$el,s,out) {
[86] Fix | Delete
var data = $el.data('hoverIntent');
[87] Fix | Delete
if (data) {
[88] Fix | Delete
delete data[s.id];
[89] Fix | Delete
}
[90] Fix | Delete
return out.apply($el[0],[ev]);
[91] Fix | Delete
};
[92] Fix | Delete
[93] Fix | Delete
// checks if `value` is a function
[94] Fix | Delete
var isFunction = function(value) {
[95] Fix | Delete
return typeof value === 'function';
[96] Fix | Delete
};
[97] Fix | Delete
[98] Fix | Delete
$.fn.hoverIntent = function(handlerIn,handlerOut,selector) {
[99] Fix | Delete
// instance ID, used as a key to store and retrieve state information on an element
[100] Fix | Delete
var instanceId = INSTANCE_COUNT++;
[101] Fix | Delete
[102] Fix | Delete
// extend the default configuration and parse parameters
[103] Fix | Delete
var cfg = $.extend({}, _cfg);
[104] Fix | Delete
if ( $.isPlainObject(handlerIn) ) {
[105] Fix | Delete
cfg = $.extend(cfg, handlerIn);
[106] Fix | Delete
if ( !isFunction(cfg.out) ) {
[107] Fix | Delete
cfg.out = cfg.over;
[108] Fix | Delete
}
[109] Fix | Delete
} else if ( isFunction(handlerOut) ) {
[110] Fix | Delete
cfg = $.extend(cfg, { over: handlerIn, out: handlerOut, selector: selector } );
[111] Fix | Delete
} else {
[112] Fix | Delete
cfg = $.extend(cfg, { over: handlerIn, out: handlerIn, selector: handlerOut } );
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
// A private function for handling mouse 'hovering'
[116] Fix | Delete
var handleHover = function(e) {
[117] Fix | Delete
// cloned event to pass to handlers (copy required for event object to be passed in IE)
[118] Fix | Delete
var ev = $.extend({},e);
[119] Fix | Delete
[120] Fix | Delete
// the current target of the mouse event, wrapped in a jQuery object
[121] Fix | Delete
var $el = $(this);
[122] Fix | Delete
[123] Fix | Delete
// read hoverIntent data from element (or initialize if not present)
[124] Fix | Delete
var hoverIntentData = $el.data('hoverIntent');
[125] Fix | Delete
if (!hoverIntentData) { $el.data('hoverIntent', (hoverIntentData = {})); }
[126] Fix | Delete
[127] Fix | Delete
// read per-instance state from element (or initialize if not present)
[128] Fix | Delete
var state = hoverIntentData[instanceId];
[129] Fix | Delete
if (!state) { hoverIntentData[instanceId] = state = { id: instanceId }; }
[130] Fix | Delete
[131] Fix | Delete
// state properties:
[132] Fix | Delete
// id = instance ID, used to clean up data
[133] Fix | Delete
// timeoutId = timeout ID, reused for tracking mouse position and delaying "out" handler
[134] Fix | Delete
// isActive = plugin state, true after `over` is called just until `out` is called
[135] Fix | Delete
// pX, pY = previously-measured pointer coordinates, updated at each polling interval
[136] Fix | Delete
// event = string representing the namespaced event used for mouse tracking
[137] Fix | Delete
[138] Fix | Delete
// clear any existing timeout
[139] Fix | Delete
if (state.timeoutId) { state.timeoutId = clearTimeout(state.timeoutId); }
[140] Fix | Delete
[141] Fix | Delete
// namespaced event used to register and unregister mousemove tracking
[142] Fix | Delete
var mousemove = state.event = 'mousemove.hoverIntent.hoverIntent'+instanceId;
[143] Fix | Delete
[144] Fix | Delete
// handle the event, based on its type
[145] Fix | Delete
if (e.type === 'mouseenter') {
[146] Fix | Delete
// do nothing if already active
[147] Fix | Delete
if (state.isActive) { return; }
[148] Fix | Delete
// set "previous" X and Y position based on initial entry point
[149] Fix | Delete
state.pX = ev.pageX; state.pY = ev.pageY;
[150] Fix | Delete
// update "current" X and Y position based on mousemove
[151] Fix | Delete
$el.off(mousemove,track).on(mousemove,track);
[152] Fix | Delete
// start polling interval (self-calling timeout) to compare mouse coordinates over time
[153] Fix | Delete
state.timeoutId = setTimeout( function(){compare(ev,$el,state,cfg);} , cfg.interval );
[154] Fix | Delete
} else { // "mouseleave"
[155] Fix | Delete
// do nothing if not already active
[156] Fix | Delete
if (!state.isActive) { return; }
[157] Fix | Delete
// unbind expensive mousemove event
[158] Fix | Delete
$el.off(mousemove,track);
[159] Fix | Delete
// if hoverIntent state is true, then call the mouseOut function after the specified delay
[160] Fix | Delete
state.timeoutId = setTimeout( function(){delay(ev,$el,state,cfg.out);} , cfg.timeout );
[161] Fix | Delete
}
[162] Fix | Delete
};
[163] Fix | Delete
[164] Fix | Delete
// listen for mouseenter and mouseleave
[165] Fix | Delete
return this.on({'mouseenter.hoverIntent':handleHover,'mouseleave.hoverIntent':handleHover}, cfg.selector);
[166] Fix | Delete
};
[167] Fix | Delete
});
[168] Fix | Delete
[169] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function