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-mouseenter', function (Y, NAME) {
11
* <p>Adds subscription and delegation support for mouseenter and mouseleave
12
* events. Unlike mouseover and mouseout, these events aren't fired from child
13
* elements of a subscribed node.</p>
15
* <p>This avoids receiving three mouseover notifications from a setup like</p>
17
* <pre><code>div#container > p > a[href]</code></pre>
21
* <pre><code>Y.one('#container').on('mouseover', callback)</code></pre>
23
* <p>When the mouse moves over the link, one mouseover event is fired from
24
* #container, then when the mouse moves over the p, another mouseover event is
25
* fired and bubbles to #container, causing a second notification, and finally
26
* when the mouse moves over the link, a third mouseover event is fired and
27
* bubbles to #container for a third notification.</p>
29
* <p>By contrast, using mouseenter instead of mouseover, the callback would be
30
* executed only once when the mouse moves over #container.</p>
33
* @submodule event-mouseenter
36
var domEventProxies = Y.Env.evt.dom_wrappers,
37
contains = Y.DOM.contains,
39
noop = function () {},
42
proxyType: "mouseover",
43
relProperty: "fromElement",
45
_notify: function (e, property, notifier) {
47
related = e.relatedTarget || e[property];
49
if (el !== related && !contains(el, related)) {
50
notifier.fire(new Y.DOMEventFacade(e, el,
51
domEventProxies['event:' + Y.stamp(el) + e.type]));
55
on: function (node, sub, notifier) {
56
var el = Y.Node.getDOMNode(node),
65
sub.handle = Y.Event._attach(args, { facade: false });
66
// node.on(this.proxyType, notify, null, notifier);
69
detach: function (node, sub) {
73
delegate: function (node, sub, notifier, filter) {
74
var el = Y.Node.getDOMNode(node),
83
sub.handle = Y.Event._attach(args, { facade: false });
84
sub.handle.sub.filter = filter;
85
sub.handle.sub.relProperty = this.relProperty;
86
sub.handle.sub._notify = this._filterNotify;
89
_filterNotify: function (thisObj, args, ce) {
92
args.push.apply(args, this.args);
95
var currentTarget = Y.delegate._applyFilter(this.filter, args, ce),
96
related = args[0].relatedTarget || args[0][this.relProperty],
100
currentTarget = toArray(currentTarget);
102
for (i = 0, len = currentTarget.length && (!e || !e.stopped); i < len; ++i) {
103
ct = currentTarget[0];
104
if (!contains(ct, related)) {
106
e = new Y.DOMEventFacade(args[0], ct, ce);
107
e.container = Y.one(ce.el);
109
e.currentTarget = Y.one(ct);
111
// TODO: where is notifier? args? this.notifier?
112
ret = args[1].fire(e);
124
detachDelegate: function (node, sub) {
129
Y.Event.define("mouseenter", config, true);
130
Y.Event.define("mouseleave", Y.merge(config, {
131
proxyType: "mouseout",
132
relProperty: "toElement"
136
}, '3.10.3', {"requires": ["event-synthetic"]});