event.js (1160B)
1 define( [ 2 "../core", 3 4 "../event", 5 "../event/trigger" 6 ], function( jQuery ) { 7 8 "use strict"; 9 10 jQuery.fn.extend( { 11 12 bind: function( types, data, fn ) { 13 return this.on( types, null, data, fn ); 14 }, 15 unbind: function( types, fn ) { 16 return this.off( types, null, fn ); 17 }, 18 19 delegate: function( selector, types, data, fn ) { 20 return this.on( types, selector, data, fn ); 21 }, 22 undelegate: function( selector, types, fn ) { 23 24 // ( namespace ) or ( selector, types [, fn] ) 25 return arguments.length === 1 ? 26 this.off( selector, "**" ) : 27 this.off( types, selector || "**", fn ); 28 }, 29 30 hover: function( fnOver, fnOut ) { 31 return this 32 .on( "mouseenter", fnOver ) 33 .on( "mouseleave", fnOut || fnOver ); 34 } 35 } ); 36 37 jQuery.each( 38 ( "blur focus focusin focusout resize scroll click dblclick " + 39 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + 40 "change select submit keydown keypress keyup contextmenu" ).split( " " ), 41 function( _i, name ) { 42 43 // Handle event binding 44 jQuery.fn[ name ] = function( data, fn ) { 45 return arguments.length > 0 ? 46 this.on( name, null, data, fn ) : 47 this.trigger( name ); 48 }; 49 } 50 ); 51 52 } );