UNPKG

1.14 kBJavaScriptView Raw
1define( [
2 "../core",
3
4 "../event",
5 "../event/trigger"
6], function( jQuery ) {
7
8"use strict";
9
10jQuery.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.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
32 }
33} );
34
35jQuery.each(
36 ( "blur focus focusin focusout resize scroll click dblclick " +
37 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
38 "change select submit keydown keypress keyup contextmenu" ).split( " " ),
39 function( _i, name ) {
40
41 // Handle event binding
42 jQuery.fn[ name ] = function( data, fn ) {
43 return arguments.length > 0 ?
44 this.on( name, null, data, fn ) :
45 this.trigger( name );
46 };
47 }
48);
49
50} );