alias.js 1.1 KB

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