PageSourceSearch

https://www.msu.edu.my/theme-2023/assets/themes/msu-apply/jquery.hoverIntent.js?ver=1.10.1

js msu.edu.my collected 2026-10-02 11:16:14 UTC 7,213 bytes, 208 lines download raw bytes

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

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.