Blame view

app/bower_components/jquery/src/event.js 18.9 KB
87c93a029   Dang YoungWorld   add modal
1
  define( [
f986e111b   TRUONG   add libs
2
  	"./core",
87c93a029   Dang YoungWorld   add modal
3
4
5
  	"./var/document",
  	"./var/documentElement",
  	"./var/rnothtmlwhite",
f986e111b   TRUONG   add libs
6
  	"./var/slice",
87c93a029   Dang YoungWorld   add modal
7
  	"./data/var/dataPriv",
f986e111b   TRUONG   add libs
8
9
  
  	"./core/init",
f986e111b   TRUONG   add libs
10
  	"./selector"
87c93a029   Dang YoungWorld   add modal
11
  ], function( jQuery, document, documentElement, rnothtmlwhite, slice, dataPriv ) {
f986e111b   TRUONG   add libs
12

87c93a029   Dang YoungWorld   add modal
13
14
15
  "use strict";
  
  var
f986e111b   TRUONG   add libs
16
  	rkeyEvent = /^key/,
87c93a029   Dang YoungWorld   add modal
17
18
  	rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  	rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
f986e111b   TRUONG   add libs
19
20
21
22
23
24
25
26
  
  function returnTrue() {
  	return true;
  }
  
  function returnFalse() {
  	return false;
  }
87c93a029   Dang YoungWorld   add modal
27
28
  // Support: IE <=9 only
  // See #13393 for more info
f986e111b   TRUONG   add libs
29
30
31
32
33
  function safeActiveElement() {
  	try {
  		return document.activeElement;
  	} catch ( err ) { }
  }
87c93a029   Dang YoungWorld   add modal
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
  function on( elem, types, selector, data, fn, one ) {
  	var origFn, type;
  
  	// Types can be a map of types/handlers
  	if ( typeof types === "object" ) {
  
  		// ( types-Object, selector, data )
  		if ( typeof selector !== "string" ) {
  
  			// ( types-Object, data )
  			data = data || selector;
  			selector = undefined;
  		}
  		for ( type in types ) {
  			on( elem, type, selector, data, types[ type ], one );
  		}
  		return elem;
  	}
  
  	if ( data == null && fn == null ) {
  
  		// ( types, fn )
  		fn = selector;
  		data = selector = undefined;
  	} else if ( fn == null ) {
  		if ( typeof selector === "string" ) {
  
  			// ( types, selector, fn )
  			fn = data;
  			data = undefined;
  		} else {
  
  			// ( types, data, fn )
  			fn = data;
  			data = selector;
  			selector = undefined;
  		}
  	}
  	if ( fn === false ) {
  		fn = returnFalse;
  	} else if ( !fn ) {
  		return elem;
  	}
  
  	if ( one === 1 ) {
  		origFn = fn;
  		fn = function( event ) {
  
  			// Can use an empty set, since event contains the info
  			jQuery().off( event );
  			return origFn.apply( this, arguments );
  		};
  
  		// Use same guid so caller can remove using origFn
  		fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  	}
  	return elem.each( function() {
  		jQuery.event.add( this, types, fn, data, selector );
  	} );
  }
f986e111b   TRUONG   add libs
94
95
96
97
98
99
100
101
102
  /*
   * Helper functions for managing events -- not part of the public interface.
   * Props to Dean Edwards' addEvent library for many of the ideas.
   */
  jQuery.event = {
  
  	global: {},
  
  	add: function( elem, types, handler, data, selector ) {
87c93a029   Dang YoungWorld   add modal
103
104
105
106
107
  
  		var handleObjIn, eventHandle, tmp,
  			events, t, handleObj,
  			special, handlers, type, namespaces, origType,
  			elemData = dataPriv.get( elem );
f986e111b   TRUONG   add libs
108
109
110
111
112
113
114
115
116
117
118
119
  
  		// Don't attach events to noData or text/comment nodes (but allow plain objects)
  		if ( !elemData ) {
  			return;
  		}
  
  		// Caller can pass in an object of custom data in lieu of the handler
  		if ( handler.handler ) {
  			handleObjIn = handler;
  			handler = handleObjIn.handler;
  			selector = handleObjIn.selector;
  		}
87c93a029   Dang YoungWorld   add modal
120
121
122
123
124
  		// Ensure that invalid selectors throw exceptions at attach time
  		// Evaluate against documentElement in case elem is a non-element node (e.g., document)
  		if ( selector ) {
  			jQuery.find.matchesSelector( documentElement, selector );
  		}
f986e111b   TRUONG   add libs
125
126
127
128
129
130
  		// Make sure that the handler has a unique ID, used to find/remove it later
  		if ( !handler.guid ) {
  			handler.guid = jQuery.guid++;
  		}
  
  		// Init the element's event structure and main handler, if this is the first
87c93a029   Dang YoungWorld   add modal
131
  		if ( !( events = elemData.events ) ) {
f986e111b   TRUONG   add libs
132
133
  			events = elemData.events = {};
  		}
87c93a029   Dang YoungWorld   add modal
134
  		if ( !( eventHandle = elemData.handle ) ) {
f986e111b   TRUONG   add libs
135
  			eventHandle = elemData.handle = function( e ) {
87c93a029   Dang YoungWorld   add modal
136

f986e111b   TRUONG   add libs
137
138
  				// Discard the second event of a jQuery.event.trigger() and
  				// when an event is called after a page has unloaded
87c93a029   Dang YoungWorld   add modal
139
140
  				return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  					jQuery.event.dispatch.apply( elem, arguments ) : undefined;
f986e111b   TRUONG   add libs
141
  			};
f986e111b   TRUONG   add libs
142
143
144
  		}
  
  		// Handle multiple events separated by a space
87c93a029   Dang YoungWorld   add modal
145
  		types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
f986e111b   TRUONG   add libs
146
147
  		t = types.length;
  		while ( t-- ) {
87c93a029   Dang YoungWorld   add modal
148
149
150
  			tmp = rtypenamespace.exec( types[ t ] ) || [];
  			type = origType = tmp[ 1 ];
  			namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
f986e111b   TRUONG   add libs
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
  
  			// There *must* be a type, no attaching namespace-only handlers
  			if ( !type ) {
  				continue;
  			}
  
  			// If event changes its type, use the special event handlers for the changed type
  			special = jQuery.event.special[ type ] || {};
  
  			// If selector defined, determine special event api type, otherwise given type
  			type = ( selector ? special.delegateType : special.bindType ) || type;
  
  			// Update special based on newly reset type
  			special = jQuery.event.special[ type ] || {};
  
  			// handleObj is passed to all event handlers
87c93a029   Dang YoungWorld   add modal
167
  			handleObj = jQuery.extend( {
f986e111b   TRUONG   add libs
168
169
170
171
172
173
174
  				type: type,
  				origType: origType,
  				data: data,
  				handler: handler,
  				guid: handler.guid,
  				selector: selector,
  				needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
87c93a029   Dang YoungWorld   add modal
175
  				namespace: namespaces.join( "." )
f986e111b   TRUONG   add libs
176
177
178
  			}, handleObjIn );
  
  			// Init the event handler queue if we're the first
87c93a029   Dang YoungWorld   add modal
179
  			if ( !( handlers = events[ type ] ) ) {
f986e111b   TRUONG   add libs
180
181
  				handlers = events[ type ] = [];
  				handlers.delegateCount = 0;
87c93a029   Dang YoungWorld   add modal
182
183
184
  				// Only use addEventListener if the special events handler returns false
  				if ( !special.setup ||
  					special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
f986e111b   TRUONG   add libs
185

87c93a029   Dang YoungWorld   add modal
186
187
  					if ( elem.addEventListener ) {
  						elem.addEventListener( type, eventHandle );
f986e111b   TRUONG   add libs
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
  					}
  				}
  			}
  
  			if ( special.add ) {
  				special.add.call( elem, handleObj );
  
  				if ( !handleObj.handler.guid ) {
  					handleObj.handler.guid = handler.guid;
  				}
  			}
  
  			// Add to the element's handler list, delegates in front
  			if ( selector ) {
  				handlers.splice( handlers.delegateCount++, 0, handleObj );
  			} else {
  				handlers.push( handleObj );
  			}
  
  			// Keep track of which events have ever been used, for event optimization
  			jQuery.event.global[ type ] = true;
  		}
f986e111b   TRUONG   add libs
210
211
212
213
  	},
  
  	// Detach an event or set of events from an element
  	remove: function( elem, types, handler, selector, mappedTypes ) {
f986e111b   TRUONG   add libs
214

87c93a029   Dang YoungWorld   add modal
215
216
217
218
219
220
  		var j, origCount, tmp,
  			events, t, handleObj,
  			special, handlers, type, namespaces, origType,
  			elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  
  		if ( !elemData || !( events = elemData.events ) ) {
f986e111b   TRUONG   add libs
221
222
223
224
  			return;
  		}
  
  		// Once for each type.namespace in types; type may be omitted
87c93a029   Dang YoungWorld   add modal
225
  		types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
f986e111b   TRUONG   add libs
226
227
  		t = types.length;
  		while ( t-- ) {
87c93a029   Dang YoungWorld   add modal
228
229
230
  			tmp = rtypenamespace.exec( types[ t ] ) || [];
  			type = origType = tmp[ 1 ];
  			namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
f986e111b   TRUONG   add libs
231
232
233
234
235
236
237
238
239
240
241
242
  
  			// Unbind all events (on this namespace, if provided) for the element
  			if ( !type ) {
  				for ( type in events ) {
  					jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  				}
  				continue;
  			}
  
  			special = jQuery.event.special[ type ] || {};
  			type = ( selector ? special.delegateType : special.bindType ) || type;
  			handlers = events[ type ] || [];
87c93a029   Dang YoungWorld   add modal
243
244
  			tmp = tmp[ 2 ] &&
  				new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
f986e111b   TRUONG   add libs
245
246
247
248
249
250
251
252
253
  
  			// Remove matching events
  			origCount = j = handlers.length;
  			while ( j-- ) {
  				handleObj = handlers[ j ];
  
  				if ( ( mappedTypes || origType === handleObj.origType ) &&
  					( !handler || handler.guid === handleObj.guid ) &&
  					( !tmp || tmp.test( handleObj.namespace ) ) &&
87c93a029   Dang YoungWorld   add modal
254
255
  					( !selector || selector === handleObj.selector ||
  						selector === "**" && handleObj.selector ) ) {
f986e111b   TRUONG   add libs
256
257
258
259
260
261
262
263
264
265
266
267
268
269
  					handlers.splice( j, 1 );
  
  					if ( handleObj.selector ) {
  						handlers.delegateCount--;
  					}
  					if ( special.remove ) {
  						special.remove.call( elem, handleObj );
  					}
  				}
  			}
  
  			// Remove generic event handler if we removed something and no more handlers exist
  			// (avoids potential for endless recursion during removal of special event handlers)
  			if ( origCount && !handlers.length ) {
87c93a029   Dang YoungWorld   add modal
270
271
  				if ( !special.teardown ||
  					special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
f986e111b   TRUONG   add libs
272
273
274
275
276
277
  					jQuery.removeEvent( elem, type, elemData.handle );
  				}
  
  				delete events[ type ];
  			}
  		}
87c93a029   Dang YoungWorld   add modal
278
  		// Remove data and the expando if it's no longer used
f986e111b   TRUONG   add libs
279
  		if ( jQuery.isEmptyObject( events ) ) {
87c93a029   Dang YoungWorld   add modal
280
  			dataPriv.remove( elem, "handle events" );
f986e111b   TRUONG   add libs
281
  		}
f986e111b   TRUONG   add libs
282
  	},
87c93a029   Dang YoungWorld   add modal
283
  	dispatch: function( nativeEvent ) {
f986e111b   TRUONG   add libs
284
285
  
  		// Make a writable jQuery.Event from the native event object
87c93a029   Dang YoungWorld   add modal
286
  		var event = jQuery.event.fix( nativeEvent );
f986e111b   TRUONG   add libs
287

87c93a029   Dang YoungWorld   add modal
288
289
290
  		var i, j, ret, matched, handleObj, handlerQueue,
  			args = new Array( arguments.length ),
  			handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
f986e111b   TRUONG   add libs
291
292
293
  			special = jQuery.event.special[ event.type ] || {};
  
  		// Use the fix-ed jQuery.Event rather than the (read-only) native event
87c93a029   Dang YoungWorld   add modal
294
295
296
297
298
  		args[ 0 ] = event;
  
  		for ( i = 1; i < arguments.length; i++ ) {
  			args[ i ] = arguments[ i ];
  		}
f986e111b   TRUONG   add libs
299
300
301
302
303
304
305
306
307
308
309
310
  		event.delegateTarget = this;
  
  		// Call the preDispatch hook for the mapped type, and let it bail if desired
  		if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  			return;
  		}
  
  		// Determine handlers
  		handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  
  		// Run delegates first; they may want to stop propagation beneath us
  		i = 0;
87c93a029   Dang YoungWorld   add modal
311
  		while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
f986e111b   TRUONG   add libs
312
313
314
  			event.currentTarget = matched.elem;
  
  			j = 0;
87c93a029   Dang YoungWorld   add modal
315
316
  			while ( ( handleObj = matched.handlers[ j++ ] ) &&
  				!event.isImmediatePropagationStopped() ) {
f986e111b   TRUONG   add libs
317

87c93a029   Dang YoungWorld   add modal
318
319
320
  				// Triggered event must either 1) have no namespace, or 2) have namespace(s)
  				// a subset or equal to those in the bound event (both can have no namespace).
  				if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
f986e111b   TRUONG   add libs
321
322
323
  
  					event.handleObj = handleObj;
  					event.data = handleObj.data;
87c93a029   Dang YoungWorld   add modal
324
325
  					ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  						handleObj.handler ).apply( matched.elem, args );
f986e111b   TRUONG   add libs
326
327
  
  					if ( ret !== undefined ) {
87c93a029   Dang YoungWorld   add modal
328
  						if ( ( event.result = ret ) === false ) {
f986e111b   TRUONG   add libs
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
  							event.preventDefault();
  							event.stopPropagation();
  						}
  					}
  				}
  			}
  		}
  
  		// Call the postDispatch hook for the mapped type
  		if ( special.postDispatch ) {
  			special.postDispatch.call( this, event );
  		}
  
  		return event.result;
  	},
  
  	handlers: function( event, handlers ) {
87c93a029   Dang YoungWorld   add modal
346
  		var i, handleObj, sel, matchedHandlers, matchedSelectors,
f986e111b   TRUONG   add libs
347
348
349
350
351
  			handlerQueue = [],
  			delegateCount = handlers.delegateCount,
  			cur = event.target;
  
  		// Find delegate handlers
87c93a029   Dang YoungWorld   add modal
352
  		if ( delegateCount &&
f986e111b   TRUONG   add libs
353

87c93a029   Dang YoungWorld   add modal
354
355
356
357
358
359
360
361
362
363
364
365
  			// Support: IE <=9
  			// Black-hole SVG <use> instance trees (trac-13180)
  			cur.nodeType &&
  
  			// Support: Firefox <=42
  			// Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  			// https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  			// Support: IE 11 only
  			// ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  			!( event.type === "click" && event.button >= 1 ) ) {
  
  			for ( ; cur !== this; cur = cur.parentNode || this ) {
f986e111b   TRUONG   add libs
366
367
368
  
  				// Don't check non-elements (#13208)
  				// Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
87c93a029   Dang YoungWorld   add modal
369
370
371
  				if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  					matchedHandlers = [];
  					matchedSelectors = {};
f986e111b   TRUONG   add libs
372
373
374
375
376
  					for ( i = 0; i < delegateCount; i++ ) {
  						handleObj = handlers[ i ];
  
  						// Don't conflict with Object.prototype properties (#13203)
  						sel = handleObj.selector + " ";
87c93a029   Dang YoungWorld   add modal
377
378
379
  						if ( matchedSelectors[ sel ] === undefined ) {
  							matchedSelectors[ sel ] = handleObj.needsContext ?
  								jQuery( sel, this ).index( cur ) > -1 :
f986e111b   TRUONG   add libs
380
381
  								jQuery.find( sel, this, null, [ cur ] ).length;
  						}
87c93a029   Dang YoungWorld   add modal
382
383
  						if ( matchedSelectors[ sel ] ) {
  							matchedHandlers.push( handleObj );
f986e111b   TRUONG   add libs
384
385
  						}
  					}
87c93a029   Dang YoungWorld   add modal
386
387
  					if ( matchedHandlers.length ) {
  						handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
f986e111b   TRUONG   add libs
388
389
390
391
392
393
  					}
  				}
  			}
  		}
  
  		// Add the remaining (directly-bound) handlers
87c93a029   Dang YoungWorld   add modal
394
  		cur = this;
f986e111b   TRUONG   add libs
395
  		if ( delegateCount < handlers.length ) {
87c93a029   Dang YoungWorld   add modal
396
  			handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
f986e111b   TRUONG   add libs
397
398
399
400
  		}
  
  		return handlerQueue;
  	},
87c93a029   Dang YoungWorld   add modal
401
402
403
404
  	addProp: function( name, hook ) {
  		Object.defineProperty( jQuery.Event.prototype, name, {
  			enumerable: true,
  			configurable: true,
f986e111b   TRUONG   add libs
405

87c93a029   Dang YoungWorld   add modal
406
407
408
409
410
411
412
413
414
415
416
  			get: jQuery.isFunction( hook ) ?
  				function() {
  					if ( this.originalEvent ) {
  							return hook( this.originalEvent );
  					}
  				} :
  				function() {
  					if ( this.originalEvent ) {
  							return this.originalEvent[ name ];
  					}
  				},
f986e111b   TRUONG   add libs
417

87c93a029   Dang YoungWorld   add modal
418
419
420
421
422
423
424
  			set: function( value ) {
  				Object.defineProperty( this, name, {
  					enumerable: true,
  					configurable: true,
  					writable: true,
  					value: value
  				} );
f986e111b   TRUONG   add libs
425
  			}
87c93a029   Dang YoungWorld   add modal
426
  		} );
f986e111b   TRUONG   add libs
427
  	},
87c93a029   Dang YoungWorld   add modal
428
429
430
431
  	fix: function( originalEvent ) {
  		return originalEvent[ jQuery.expando ] ?
  			originalEvent :
  			new jQuery.Event( originalEvent );
f986e111b   TRUONG   add libs
432
433
434
435
  	},
  
  	special: {
  		load: {
87c93a029   Dang YoungWorld   add modal
436

f986e111b   TRUONG   add libs
437
438
439
440
  			// Prevent triggered image.load events from bubbling to window.load
  			noBubble: true
  		},
  		focus: {
87c93a029   Dang YoungWorld   add modal
441

f986e111b   TRUONG   add libs
442
443
444
  			// Fire native event if possible so blur/focus sequence is correct
  			trigger: function() {
  				if ( this !== safeActiveElement() && this.focus ) {
87c93a029   Dang YoungWorld   add modal
445
446
  					this.focus();
  					return false;
f986e111b   TRUONG   add libs
447
448
449
450
451
452
453
454
455
456
457
458
459
460
  				}
  			},
  			delegateType: "focusin"
  		},
  		blur: {
  			trigger: function() {
  				if ( this === safeActiveElement() && this.blur ) {
  					this.blur();
  					return false;
  				}
  			},
  			delegateType: "focusout"
  		},
  		click: {
87c93a029   Dang YoungWorld   add modal
461

f986e111b   TRUONG   add libs
462
463
  			// For checkbox, fire native event so checked state will be right
  			trigger: function() {
87c93a029   Dang YoungWorld   add modal
464
  				if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
f986e111b   TRUONG   add libs
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
  					this.click();
  					return false;
  				}
  			},
  
  			// For cross-browser consistency, don't fire native .click() on links
  			_default: function( event ) {
  				return jQuery.nodeName( event.target, "a" );
  			}
  		},
  
  		beforeunload: {
  			postDispatch: function( event ) {
  
  				// Support: Firefox 20+
  				// Firefox doesn't alert if the returnValue field is not set.
  				if ( event.result !== undefined && event.originalEvent ) {
  					event.originalEvent.returnValue = event.result;
  				}
  			}
  		}
f986e111b   TRUONG   add libs
486
487
  	}
  };
87c93a029   Dang YoungWorld   add modal
488
  jQuery.removeEvent = function( elem, type, handle ) {
f986e111b   TRUONG   add libs
489

87c93a029   Dang YoungWorld   add modal
490
491
492
493
494
  	// This "if" is needed for plain objects
  	if ( elem.removeEventListener ) {
  		elem.removeEventListener( type, handle );
  	}
  };
f986e111b   TRUONG   add libs
495
496
  
  jQuery.Event = function( src, props ) {
87c93a029   Dang YoungWorld   add modal
497

f986e111b   TRUONG   add libs
498
  	// Allow instantiation without the 'new' keyword
87c93a029   Dang YoungWorld   add modal
499
  	if ( !( this instanceof jQuery.Event ) ) {
f986e111b   TRUONG   add libs
500
501
502
503
504
505
506
507
508
509
510
511
  		return new jQuery.Event( src, props );
  	}
  
  	// Event object
  	if ( src && src.type ) {
  		this.originalEvent = src;
  		this.type = src.type;
  
  		// Events bubbling up the document may have been marked as prevented
  		// by a handler lower down the tree; reflect the correct value.
  		this.isDefaultPrevented = src.defaultPrevented ||
  				src.defaultPrevented === undefined &&
87c93a029   Dang YoungWorld   add modal
512
513
  
  				// Support: Android <=2.3 only
f986e111b   TRUONG   add libs
514
515
516
  				src.returnValue === false ?
  			returnTrue :
  			returnFalse;
87c93a029   Dang YoungWorld   add modal
517
518
519
520
521
522
523
524
525
  		// Create target properties
  		// Support: Safari <=6 - 7 only
  		// Target should not be a text node (#504, #13143)
  		this.target = ( src.target && src.target.nodeType === 3 ) ?
  			src.target.parentNode :
  			src.target;
  
  		this.currentTarget = src.currentTarget;
  		this.relatedTarget = src.relatedTarget;
f986e111b   TRUONG   add libs
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
  	// Event type
  	} else {
  		this.type = src;
  	}
  
  	// Put explicitly provided properties onto the event object
  	if ( props ) {
  		jQuery.extend( this, props );
  	}
  
  	// Create a timestamp if incoming event doesn't have one
  	this.timeStamp = src && src.timeStamp || jQuery.now();
  
  	// Mark it as fixed
  	this[ jQuery.expando ] = true;
  };
  
  // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
87c93a029   Dang YoungWorld   add modal
544
  // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
f986e111b   TRUONG   add libs
545
  jQuery.Event.prototype = {
87c93a029   Dang YoungWorld   add modal
546
  	constructor: jQuery.Event,
f986e111b   TRUONG   add libs
547
548
549
  	isDefaultPrevented: returnFalse,
  	isPropagationStopped: returnFalse,
  	isImmediatePropagationStopped: returnFalse,
87c93a029   Dang YoungWorld   add modal
550
  	isSimulated: false,
f986e111b   TRUONG   add libs
551
552
553
554
555
  
  	preventDefault: function() {
  		var e = this.originalEvent;
  
  		this.isDefaultPrevented = returnTrue;
f986e111b   TRUONG   add libs
556

87c93a029   Dang YoungWorld   add modal
557
  		if ( e && !this.isSimulated ) {
f986e111b   TRUONG   add libs
558
  			e.preventDefault();
f986e111b   TRUONG   add libs
559
560
561
562
563
564
  		}
  	},
  	stopPropagation: function() {
  		var e = this.originalEvent;
  
  		this.isPropagationStopped = returnTrue;
87c93a029   Dang YoungWorld   add modal
565
566
  
  		if ( e && !this.isSimulated ) {
f986e111b   TRUONG   add libs
567
568
  			e.stopPropagation();
  		}
f986e111b   TRUONG   add libs
569
570
571
572
573
  	},
  	stopImmediatePropagation: function() {
  		var e = this.originalEvent;
  
  		this.isImmediatePropagationStopped = returnTrue;
87c93a029   Dang YoungWorld   add modal
574
  		if ( e && !this.isSimulated ) {
f986e111b   TRUONG   add libs
575
576
577
578
579
580
  			e.stopImmediatePropagation();
  		}
  
  		this.stopPropagation();
  	}
  };
87c93a029   Dang YoungWorld   add modal
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
  // Includes all common event props including KeyEvent and MouseEvent specific props
  jQuery.each( {
  	altKey: true,
  	bubbles: true,
  	cancelable: true,
  	changedTouches: true,
  	ctrlKey: true,
  	detail: true,
  	eventPhase: true,
  	metaKey: true,
  	pageX: true,
  	pageY: true,
  	shiftKey: true,
  	view: true,
  	"char": true,
  	charCode: true,
  	key: true,
  	keyCode: true,
  	button: true,
  	buttons: true,
  	clientX: true,
  	clientY: true,
  	offsetX: true,
  	offsetY: true,
  	pointerId: true,
  	pointerType: true,
  	screenX: true,
  	screenY: true,
  	targetTouches: true,
  	toElement: true,
  	touches: true,
  
  	which: function( event ) {
  		var button = event.button;
  
  		// Add which for key events
  		if ( event.which == null && rkeyEvent.test( event.type ) ) {
  			return event.charCode != null ? event.charCode : event.keyCode;
  		}
  
  		// Add which for click: 1 === left; 2 === middle; 3 === right
  		if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  			if ( button & 1 ) {
  				return 1;
  			}
  
  			if ( button & 2 ) {
  				return 3;
  			}
  
  			if ( button & 4 ) {
  				return 2;
  			}
  
  			return 0;
  		}
  
  		return event.which;
  	}
  }, jQuery.event.addProp );
f986e111b   TRUONG   add libs
641
  // Create mouseenter/leave events using mouseover/out and event-time checks
87c93a029   Dang YoungWorld   add modal
642
643
644
645
646
647
648
649
  // so that event delegation works in jQuery.
  // Do the same for pointerenter/pointerleave and pointerover/pointerout
  //
  // Support: Safari 7 only
  // Safari sends mouseenter too often; see:
  // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  // for the description of the bug (it existed in older Chrome versions as well).
  jQuery.each( {
f986e111b   TRUONG   add libs
650
651
652
653
654
655
656
657
658
659
660
661
662
663
  	mouseenter: "mouseover",
  	mouseleave: "mouseout",
  	pointerenter: "pointerover",
  	pointerleave: "pointerout"
  }, function( orig, fix ) {
  	jQuery.event.special[ orig ] = {
  		delegateType: fix,
  		bindType: fix,
  
  		handle: function( event ) {
  			var ret,
  				target = this,
  				related = event.relatedTarget,
  				handleObj = event.handleObj;
87c93a029   Dang YoungWorld   add modal
664
  			// For mouseenter/leave call the handler if related is outside the target.
f986e111b   TRUONG   add libs
665
  			// NB: No relatedTarget if the mouse left/entered the browser window
87c93a029   Dang YoungWorld   add modal
666
  			if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
f986e111b   TRUONG   add libs
667
668
669
670
671
672
673
  				event.type = handleObj.origType;
  				ret = handleObj.handler.apply( this, arguments );
  				event.type = fix;
  			}
  			return ret;
  		}
  	};
87c93a029   Dang YoungWorld   add modal
674
  } );
f986e111b   TRUONG   add libs
675

87c93a029   Dang YoungWorld   add modal
676
  jQuery.fn.extend( {
f986e111b   TRUONG   add libs
677

87c93a029   Dang YoungWorld   add modal
678
679
  	on: function( types, selector, data, fn ) {
  		return on( this, types, selector, data, fn );
f986e111b   TRUONG   add libs
680
681
  	},
  	one: function( types, selector, data, fn ) {
87c93a029   Dang YoungWorld   add modal
682
  		return on( this, types, selector, data, fn, 1 );
f986e111b   TRUONG   add libs
683
684
685
686
  	},
  	off: function( types, selector, fn ) {
  		var handleObj, type;
  		if ( types && types.preventDefault && types.handleObj ) {
87c93a029   Dang YoungWorld   add modal
687

f986e111b   TRUONG   add libs
688
689
690
  			// ( event )  dispatched jQuery.Event
  			handleObj = types.handleObj;
  			jQuery( types.delegateTarget ).off(
87c93a029   Dang YoungWorld   add modal
691
692
693
  				handleObj.namespace ?
  					handleObj.origType + "." + handleObj.namespace :
  					handleObj.origType,
f986e111b   TRUONG   add libs
694
695
696
697
698
699
  				handleObj.selector,
  				handleObj.handler
  			);
  			return this;
  		}
  		if ( typeof types === "object" ) {
87c93a029   Dang YoungWorld   add modal
700

f986e111b   TRUONG   add libs
701
702
703
704
705
706
707
  			// ( types-object [, selector] )
  			for ( type in types ) {
  				this.off( type, selector, types[ type ] );
  			}
  			return this;
  		}
  		if ( selector === false || typeof selector === "function" ) {
87c93a029   Dang YoungWorld   add modal
708

f986e111b   TRUONG   add libs
709
710
711
712
713
714
715
  			// ( types [, fn] )
  			fn = selector;
  			selector = undefined;
  		}
  		if ( fn === false ) {
  			fn = returnFalse;
  		}
87c93a029   Dang YoungWorld   add modal
716
  		return this.each( function() {
f986e111b   TRUONG   add libs
717
  			jQuery.event.remove( this, types, fn, selector );
87c93a029   Dang YoungWorld   add modal
718
  		} );
f986e111b   TRUONG   add libs
719
  	}
87c93a029   Dang YoungWorld   add modal
720
  } );
f986e111b   TRUONG   add libs
721
722
  
  return jQuery;
87c93a029   Dang YoungWorld   add modal
723
  } );