790be8cba411f071bbade4000bc5e1bf39496d0427cf2831742c9ff54c8c7c34aa65242a79c461cc355f89f91a530f7478be82b87782900816ced2bd7fdabc 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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
  25. .on( "mouseenter", fnOver )
  26. .on( "mouseleave", fnOut || fnOver );
  27. }
  28. } );
  29. jQuery.each(
  30. ( "blur focus focusin focusout resize scroll click dblclick " +
  31. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  32. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  33. function( _i, name ) {
  34. // Handle event binding
  35. jQuery.fn[ name ] = function( data, fn ) {
  36. return arguments.length > 0 ?
  37. this.on( name, null, data, fn ) :
  38. this.trigger( name );
  39. };
  40. }
  41. );
  42. } );