event.js 1.1 KB

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