2
YUI 3.10.3 (build 2fb5187)
3
Copyright 2013 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
8
YUI.add('event-hover', function (Y, NAME) {
11
* Adds support for a "hover" event. The event provides a convenience wrapper
12
* for subscribing separately to mouseenter and mouseleave. The signature for
13
* subscribing to the event is</p>
15
* <pre><code>node.on("hover", overFn, outFn);
16
* node.delegate("hover", overFn, outFn, ".filterSelector");
17
* Y.on("hover", overFn, outFn, ".targetSelector");
18
* Y.delegate("hover", overFn, outFn, "#container", ".filterSelector");
21
* <p>Additionally, for compatibility with a more typical subscription
22
* signature, the following are also supported:</p>
24
* <pre><code>Y.on("hover", overFn, ".targetSelector", outFn);
25
* Y.delegate("hover", overFn, "#container", outFn, ".filterSelector");
29
* @submodule event-hover
31
var isFunction = Y.Lang.isFunction,
32
noop = function () {},
34
processArgs: function (args) {
35
// Y.delegate('hover', over, out, '#container', '.filter')
36
// comes in as ['hover', over, out, '#container', '.filter'], but
37
// node.delegate('hover', over, out, '.filter')
38
// comes in as ['hover', over, containerEl, out, '.filter']
39
var i = isFunction(args[2]) ? 2 : 3;
41
return (isFunction(args[i])) ? args.splice(i,1)[0] : noop;
44
on: function (node, sub, notifier, filter) {
45
var args = (sub.args) ? sub.args.slice() : [];
49
sub._detach = node[(filter) ? "delegate" : "on"]({
50
mouseenter: function (e) {
54
mouseleave: function (e) {
55
var thisObj = sub.context || this;
61
sub._extra.apply(thisObj, args);
66
detach: function (node, sub, notifier) {
71
conf.delegate = conf.on;
72
conf.detachDelegate = conf.detach;
74
Y.Event.define("hover", conf);
77
}, '3.10.3', {"requires": ["event-mouseenter"]});