codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
mouseenter: { setup: function() { if ( jQuery.browser.msie ) return false; jQuery(this).bind("mouseover", jQuery.event.special.mouseenter.handler); return true; }, teardown: function() { if ( jQuery.browser.msie ) return false; jQuery(this).unbind("mouseover", jQuery.event.special.mouseenter.handler); return true; }, handler: function(event) { // If we actually just moused on to a sub-element, ignore it if ( withinElement(event, this) ) return true; // Execute the right handlers by setting the event type to mouseenter event.type = "mouseenter"; return jQuery.event.handle.apply(this, arguments); } }, mouseleave: { setup: function() { if ( jQuery.browser.msie ) return false; jQuery(this).bind("mouseout", jQuery.event.special.mouseleave.handler); return true; }, teardown: function() { if ( jQuery.browser.msie ) return false; jQuery(this).unbind("mouseout", jQuery.event.special.mouseleave.handler); return true; }, handler: function(event) { // If we actually just moused on to a sub-element, ignore it if ( withinElement(event, this) ) return true; // Execute the right handlers by setting the event type to mouseleave event.type = "mouseleave"; return jQuery.event.handle.apply(this, arguments); } } // Checks if an event happened on an element within another element // Used in jQuery.event.special.mouseenter and mouseleave handlers var withinElement = function(event, elem) { // Check if mouse(over|out) are still within the same parent element var parent = event.relatedTarget; // Traverse up the tree while ( parent && parent != elem ) try { parent = parent.parentNode; } catch(error) { parent = elem; } // Return true if we actually just moused on to a sub-element return parent == elem; };
Private
[
?
]
Run code
Submit