mouseentermouseleave.js revision 9e0de5eced7fff5caf1e6125a65488d67eb066c2
/**
* Adds support for mouseenter/mouseleave events
* @module event
* @submodule event-mouseenter
*/
listeners = {},
getRelatedTarget = function (e) {
var target = e.relatedTarget;
if (!target) {
if (e.type == "mouseout") {
} else if (e.type == "mouseover") {
target = e.fromElement;
}
}
return target;
},
eventConfig = {
// Need to use Y.all because if el is a string it could be a
// selector that returns a NodeList
}, Event, true, false);
}
}
handles = [];
args[2] = v;
});
}
// At this point el will always be a Node instance
// The name of the custom event
// Bind an actual DOM event listener that will call the
// the custom event
if (!listener) {
domEventHandle = Event._attach([sDOMEvent, Y.rbind(Event._fireMouseEnter, Y, element, sEventName), element], { facade: false });
// Hook into the _delete method for the Custom Event wrapper of this
// DOM Event in order to clean up the 'listeners' map and unsubscribe
// the associated Custom Event listeners fired by this DOM event
// listeners of the Custom Event.
// Delete this event from the map of known mouseenter
// and mouseleave listeners
delete listeners[sEventName];
Y.log("DOM event listener associated with the " + sEventName + " Custom Event removed. Removing all " + sEventName + " listeners.", "info", "Event");
// Unsubscribe all listeners of the Custom Event fired
// by this DOM event.
Y.detachAll(sEventName);
}
listener = {};
}
// Remove the element from the args
// Subscribe to the custom event
// Hook into the detach method of the handle in order to clean up the
// 'listeners' map and remove the associated DOM event handler
// responsible for firing this Custom Event if all listener for this
// event have been removed.
Y.after(function () {
Y.log("No more listeners for the " + sEventName + " Custom Event. Removing its associated DOM event listener.", "info", "Event");
}
}, ceHandle, "detach");
return ceHandle;
}
};
var relatedTarget = getRelatedTarget(e),
if (currentTarget !== relatedTarget &&
contextFn: function() {
return eventFacade.currentTarget;
}
});
}
};
/**
* Sets up a "mouseenter" listener—a listener that is called the first time
* the user's mouse enters the specified element(s).
*
* @event mouseenter
* @param type {string} "mouseenter"
* @param fn {function} The method the event invokes.
* @param el {string|node} The element(s) to assign the listener to.
* @param spec {string} Optional. String representing a selector that must
* match the target of the event in order for the listener to be called.
* @return {EventHandle} the detach handle
* @for YUI
*/
/**
* Sets up a "mouseleave" listener—a listener that is called the first time
* the user's mouse leaves the specified element(s).
*
* @event mouseleave
* @param type {string} "mouseleave"
* @param fn {function} The method the event invokes.
* @param el {string|node} The element(s) to assign the listener to.
* @param spec {string} Optional. String representing a selector that must
* match the target of the event in order for the listener to be called.
* @return {EventHandle} the detach handle
* @for YUI
*/