Blame view

bower_components/jquery/src/event.js 23.9 KB
c5169e0e   Renato De Donato   a new hope
1
  define([
74249687   Luigi Serra   Cross browser con...
2
  	"./core",
c5169e0e   Renato De Donato   a new hope
3
  	"./var/strundefined",
74249687   Luigi Serra   Cross browser con...
4
  	"./var/rnotwhite",
c5169e0e   Renato De Donato   a new hope
5
  	"./var/hasOwn",
74249687   Luigi Serra   Cross browser con...
6
  	"./var/slice",
c5169e0e   Renato De Donato   a new hope
7
8
  	"./event/support",
  	"./data/var/data_priv",
74249687   Luigi Serra   Cross browser con...
9
10
  
  	"./core/init",
c5169e0e   Renato De Donato   a new hope
11
  	"./data/accepts",
74249687   Luigi Serra   Cross browser con...
12
  	"./selector"
c5169e0e   Renato De Donato   a new hope
13
  ], function( jQuery, strundefined, rnotwhite, hasOwn, slice, support, data_priv ) {
74249687   Luigi Serra   Cross browser con...
14
15
16
  
  var
  	rkeyEvent = /^key/,
c5169e0e   Renato De Donato   a new hope
17
18
19
  	rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
  	rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  	rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
74249687   Luigi Serra   Cross browser con...
20
21
22
23
24
25
26
27
28
  
  function returnTrue() {
  	return true;
  }
  
  function returnFalse() {
  	return false;
  }
  
74249687   Luigi Serra   Cross browser con...
29
30
31
32
33
34
  function safeActiveElement() {
  	try {
  		return document.activeElement;
  	} catch ( err ) { }
  }
  
74249687   Luigi Serra   Cross browser con...
35
36
37
38
39
40
41
42
43
44
45
46
47
  /*
   * 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 ) {
  
  		var handleObjIn, eventHandle, tmp,
  			events, t, handleObj,
  			special, handlers, type, namespaces, origType,
c5169e0e   Renato De Donato   a new hope
48
  			elemData = data_priv.get( elem );
74249687   Luigi Serra   Cross browser con...
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  
  		// 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;
  		}
  
  		// 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
c5169e0e   Renato De Donato   a new hope
68
  		if ( !(events = elemData.events) ) {
74249687   Luigi Serra   Cross browser con...
69
70
  			events = elemData.events = {};
  		}
c5169e0e   Renato De Donato   a new hope
71
  		if ( !(eventHandle = elemData.handle) ) {
74249687   Luigi Serra   Cross browser con...
72
  			eventHandle = elemData.handle = function( e ) {
74249687   Luigi Serra   Cross browser con...
73
74
  				// Discard the second event of a jQuery.event.trigger() and
  				// when an event is called after a page has unloaded
c5169e0e   Renato De Donato   a new hope
75
  				return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?
74249687   Luigi Serra   Cross browser con...
76
77
78
79
80
81
82
83
  					jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  			};
  		}
  
  		// Handle multiple events separated by a space
  		types = ( types || "" ).match( rnotwhite ) || [ "" ];
  		t = types.length;
  		while ( t-- ) {
c5169e0e   Renato De Donato   a new hope
84
85
86
  			tmp = rtypenamespace.exec( types[t] ) || [];
  			type = origType = tmp[1];
  			namespaces = ( tmp[2] || "" ).split( "." ).sort();
74249687   Luigi Serra   Cross browser con...
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
  
  			// 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
c5169e0e   Renato De Donato   a new hope
103
  			handleObj = jQuery.extend({
74249687   Luigi Serra   Cross browser con...
104
105
106
107
108
109
110
  				type: type,
  				origType: origType,
  				data: data,
  				handler: handler,
  				guid: handler.guid,
  				selector: selector,
  				needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
c5169e0e   Renato De Donato   a new hope
111
  				namespace: namespaces.join(".")
74249687   Luigi Serra   Cross browser con...
112
113
114
  			}, handleObjIn );
  
  			// Init the event handler queue if we're the first
c5169e0e   Renato De Donato   a new hope
115
  			if ( !(handlers = events[ type ]) ) {
74249687   Luigi Serra   Cross browser con...
116
117
118
119
  				handlers = events[ type ] = [];
  				handlers.delegateCount = 0;
  
  				// Only use addEventListener if the special events handler returns false
c5169e0e   Renato De Donato   a new hope
120
  				if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
74249687   Luigi Serra   Cross browser con...
121
  					if ( elem.addEventListener ) {
c5169e0e   Renato De Donato   a new hope
122
  						elem.addEventListener( type, eventHandle, false );
74249687   Luigi Serra   Cross browser con...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
  					}
  				}
  			}
  
  			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;
  		}
  
  	},
  
  	// Detach an event or set of events from an element
  	remove: function( elem, types, handler, selector, mappedTypes ) {
  
  		var j, origCount, tmp,
  			events, t, handleObj,
  			special, handlers, type, namespaces, origType,
c5169e0e   Renato De Donato   a new hope
154
  			elemData = data_priv.hasData( elem ) && data_priv.get( elem );
74249687   Luigi Serra   Cross browser con...
155
  
c5169e0e   Renato De Donato   a new hope
156
  		if ( !elemData || !(events = elemData.events) ) {
74249687   Luigi Serra   Cross browser con...
157
158
159
160
161
162
163
  			return;
  		}
  
  		// Once for each type.namespace in types; type may be omitted
  		types = ( types || "" ).match( rnotwhite ) || [ "" ];
  		t = types.length;
  		while ( t-- ) {
c5169e0e   Renato De Donato   a new hope
164
165
166
  			tmp = rtypenamespace.exec( types[t] ) || [];
  			type = origType = tmp[1];
  			namespaces = ( tmp[2] || "" ).split( "." ).sort();
74249687   Luigi Serra   Cross browser con...
167
168
169
170
171
172
173
174
175
176
177
178
  
  			// 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 ] || [];
c5169e0e   Renato De Donato   a new hope
179
  			tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
74249687   Luigi Serra   Cross browser con...
180
181
182
183
184
185
186
187
188
  
  			// 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 ) ) &&
c5169e0e   Renato De Donato   a new hope
189
  					( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
74249687   Luigi Serra   Cross browser con...
190
191
192
193
194
195
196
197
198
199
200
201
202
203
  					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 ) {
c5169e0e   Renato De Donato   a new hope
204
  				if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
74249687   Luigi Serra   Cross browser con...
205
206
207
208
209
210
211
  					jQuery.removeEvent( elem, type, elemData.handle );
  				}
  
  				delete events[ type ];
  			}
  		}
  
c5169e0e   Renato De Donato   a new hope
212
  		// Remove the expando if it's no longer used
74249687   Luigi Serra   Cross browser con...
213
  		if ( jQuery.isEmptyObject( events ) ) {
c5169e0e   Renato De Donato   a new hope
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
  			delete elemData.handle;
  			data_priv.remove( elem, "events" );
  		}
  	},
  
  	trigger: function( event, data, elem, onlyHandlers ) {
  
  		var i, cur, tmp, bubbleType, ontype, handle, special,
  			eventPath = [ elem || document ],
  			type = hasOwn.call( event, "type" ) ? event.type : event,
  			namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
  
  		cur = tmp = elem = elem || document;
  
  		// Don't do events on text and comment nodes
  		if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  			return;
  		}
  
  		// focus/blur morphs to focusin/out; ensure we're not firing them right now
  		if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  			return;
  		}
  
  		if ( type.indexOf(".") >= 0 ) {
  			// Namespaced trigger; create a regexp to match event type in handle()
  			namespaces = type.split(".");
  			type = namespaces.shift();
  			namespaces.sort();
  		}
  		ontype = type.indexOf(":") < 0 && "on" + type;
  
  		// Caller can pass in a jQuery.Event object, Object, or just an event type string
  		event = event[ jQuery.expando ] ?
  			event :
  			new jQuery.Event( type, typeof event === "object" && event );
  
  		// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  		event.isTrigger = onlyHandlers ? 2 : 3;
  		event.namespace = namespaces.join(".");
  		event.namespace_re = event.namespace ?
  			new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
  			null;
  
  		// Clean up the event in case it is being reused
  		event.result = undefined;
  		if ( !event.target ) {
  			event.target = elem;
  		}
  
  		// Clone any incoming data and prepend the event, creating the handler arg list
  		data = data == null ?
  			[ event ] :
  			jQuery.makeArray( data, [ event ] );
  
  		// Allow special events to draw outside the lines
  		special = jQuery.event.special[ type ] || {};
  		if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  			return;
  		}
  
  		// Determine event propagation path in advance, per W3C events spec (#9951)
  		// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  		if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
  
  			bubbleType = special.delegateType || type;
  			if ( !rfocusMorph.test( bubbleType + type ) ) {
  				cur = cur.parentNode;
  			}
  			for ( ; cur; cur = cur.parentNode ) {
  				eventPath.push( cur );
  				tmp = cur;
  			}
  
  			// Only add window if we got to document (e.g., not plain obj or detached DOM)
  			if ( tmp === (elem.ownerDocument || document) ) {
  				eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  			}
  		}
  
  		// Fire handlers on the event path
  		i = 0;
  		while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
  
  			event.type = i > 1 ?
  				bubbleType :
  				special.bindType || type;
  
  			// jQuery handler
  			handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" );
  			if ( handle ) {
  				handle.apply( cur, data );
  			}
  
  			// Native handler
  			handle = ontype && cur[ ontype ];
  			if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
  				event.result = handle.apply( cur, data );
  				if ( event.result === false ) {
  					event.preventDefault();
  				}
  			}
  		}
  		event.type = type;
  
  		// If nobody prevented the default action, do it now
  		if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  
  			if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
  				jQuery.acceptData( elem ) ) {
  
  				// Call a native DOM method on the target with the same name name as the event.
  				// Don't do default actions on window, that's where global variables be (#6170)
  				if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
  
  					// Don't re-trigger an onFOO event when we call its FOO() method
  					tmp = elem[ ontype ];
  
  					if ( tmp ) {
  						elem[ ontype ] = null;
  					}
  
  					// Prevent re-triggering of the same event, since we already bubbled it above
  					jQuery.event.triggered = type;
  					elem[ type ]();
  					jQuery.event.triggered = undefined;
  
  					if ( tmp ) {
  						elem[ ontype ] = tmp;
  					}
  				}
  			}
74249687   Luigi Serra   Cross browser con...
346
  		}
c5169e0e   Renato De Donato   a new hope
347
348
  
  		return event.result;
74249687   Luigi Serra   Cross browser con...
349
350
351
352
353
354
355
356
357
358
  	},
  
  	dispatch: function( event ) {
  
  		// Make a writable jQuery.Event from the native event object
  		event = jQuery.event.fix( event );
  
  		var i, j, ret, matched, handleObj,
  			handlerQueue = [],
  			args = slice.call( arguments ),
c5169e0e   Renato De Donato   a new hope
359
  			handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [],
74249687   Luigi Serra   Cross browser con...
360
361
362
  			special = jQuery.event.special[ event.type ] || {};
  
  		// Use the fix-ed jQuery.Event rather than the (read-only) native event
c5169e0e   Renato De Donato   a new hope
363
  		args[0] = event;
74249687   Luigi Serra   Cross browser con...
364
365
366
367
368
369
370
371
372
373
374
375
  		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;
c5169e0e   Renato De Donato   a new hope
376
  		while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
74249687   Luigi Serra   Cross browser con...
377
378
379
  			event.currentTarget = matched.elem;
  
  			j = 0;
c5169e0e   Renato De Donato   a new hope
380
  			while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
74249687   Luigi Serra   Cross browser con...
381
382
383
  
  				// 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).
c5169e0e   Renato De Donato   a new hope
384
  				if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
74249687   Luigi Serra   Cross browser con...
385
386
387
388
  
  					event.handleObj = handleObj;
  					event.data = handleObj.data;
  
c5169e0e   Renato De Donato   a new hope
389
390
  					ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
  							.apply( matched.elem, args );
74249687   Luigi Serra   Cross browser con...
391
392
  
  					if ( ret !== undefined ) {
c5169e0e   Renato De Donato   a new hope
393
  						if ( (event.result = ret) === false ) {
74249687   Luigi Serra   Cross browser con...
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
  							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 ) {
  		var i, matches, sel, handleObj,
  			handlerQueue = [],
  			delegateCount = handlers.delegateCount,
  			cur = event.target;
  
74249687   Luigi Serra   Cross browser con...
416
417
  		// Find delegate handlers
  		// Black-hole SVG <use> instance trees (#13180)
c5169e0e   Renato De Donato   a new hope
418
419
  		// Avoid non-left-click bubbling in Firefox (#3861)
  		if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
74249687   Luigi Serra   Cross browser con...
420
421
422
  
  			for ( ; cur !== this; cur = cur.parentNode || this ) {
  
74249687   Luigi Serra   Cross browser con...
423
  				// Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
c5169e0e   Renato De Donato   a new hope
424
  				if ( cur.disabled !== true || event.type !== "click" ) {
74249687   Luigi Serra   Cross browser con...
425
426
427
428
429
430
431
432
433
  					matches = [];
  					for ( i = 0; i < delegateCount; i++ ) {
  						handleObj = handlers[ i ];
  
  						// Don't conflict with Object.prototype properties (#13203)
  						sel = handleObj.selector + " ";
  
  						if ( matches[ sel ] === undefined ) {
  							matches[ sel ] = handleObj.needsContext ?
c5169e0e   Renato De Donato   a new hope
434
  								jQuery( sel, this ).index( cur ) >= 0 :
74249687   Luigi Serra   Cross browser con...
435
436
437
438
439
440
441
  								jQuery.find( sel, this, null, [ cur ] ).length;
  						}
  						if ( matches[ sel ] ) {
  							matches.push( handleObj );
  						}
  					}
  					if ( matches.length ) {
c5169e0e   Renato De Donato   a new hope
442
  						handlerQueue.push({ elem: cur, handlers: matches });
74249687   Luigi Serra   Cross browser con...
443
444
445
446
447
448
449
  					}
  				}
  			}
  		}
  
  		// Add the remaining (directly-bound) handlers
  		if ( delegateCount < handlers.length ) {
c5169e0e   Renato De Donato   a new hope
450
  			handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
74249687   Luigi Serra   Cross browser con...
451
452
453
454
455
456
  		}
  
  		return handlerQueue;
  	},
  
  	// Includes some event props shared by KeyEvent and MouseEvent
c5169e0e   Renato De Donato   a new hope
457
  	props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
74249687   Luigi Serra   Cross browser con...
458
459
460
461
  
  	fixHooks: {},
  
  	keyHooks: {
c5169e0e   Renato De Donato   a new hope
462
  		props: "char charCode key keyCode".split(" "),
74249687   Luigi Serra   Cross browser con...
463
464
465
466
467
468
469
470
471
472
473
474
  		filter: function( event, original ) {
  
  			// Add which for key events
  			if ( event.which == null ) {
  				event.which = original.charCode != null ? original.charCode : original.keyCode;
  			}
  
  			return event;
  		}
  	},
  
  	mouseHooks: {
c5169e0e   Renato De Donato   a new hope
475
  		props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
74249687   Luigi Serra   Cross browser con...
476
477
478
479
480
481
482
483
484
485
  		filter: function( event, original ) {
  			var eventDoc, doc, body,
  				button = original.button;
  
  			// Calculate pageX/Y if missing and clientX/Y available
  			if ( event.pageX == null && original.clientX != null ) {
  				eventDoc = event.target.ownerDocument || document;
  				doc = eventDoc.documentElement;
  				body = eventDoc.body;
  
c5169e0e   Renato De Donato   a new hope
486
487
  				event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
  				event.pageY = original.clientY + ( doc && doc.scrollTop  || body && body.scrollTop  || 0 ) - ( doc && doc.clientTop  || body && body.clientTop  || 0 );
74249687   Luigi Serra   Cross browser con...
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
  			}
  
  			// Add which for click: 1 === left; 2 === middle; 3 === right
  			// Note: button is not normalized, so don't use it
  			if ( !event.which && button !== undefined ) {
  				event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
  			}
  
  			return event;
  		}
  	},
  
  	fix: function( event ) {
  		if ( event[ jQuery.expando ] ) {
  			return event;
  		}
  
  		// Create a writable copy of the event object and normalize some properties
  		var i, prop, copy,
  			type = event.type,
  			originalEvent = event,
  			fixHook = this.fixHooks[ type ];
  
  		if ( !fixHook ) {
  			this.fixHooks[ type ] = fixHook =
  				rmouseEvent.test( type ) ? this.mouseHooks :
  				rkeyEvent.test( type ) ? this.keyHooks :
  				{};
  		}
  		copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
  
  		event = new jQuery.Event( originalEvent );
  
  		i = copy.length;
  		while ( i-- ) {
  			prop = copy[ i ];
  			event[ prop ] = originalEvent[ prop ];
  		}
  
  		// Support: Cordova 2.5 (WebKit) (#13255)
  		// All events should have a target; Cordova deviceready doesn't
  		if ( !event.target ) {
  			event.target = document;
  		}
  
  		// Support: Safari 6.0+, Chrome<28
  		// Target should not be a text node (#504, #13143)
  		if ( event.target.nodeType === 3 ) {
  			event.target = event.target.parentNode;
  		}
  
  		return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
  	},
  
  	special: {
  		load: {
74249687   Luigi Serra   Cross browser con...
544
545
546
547
  			// Prevent triggered image.load events from bubbling to window.load
  			noBubble: true
  		},
  		focus: {
74249687   Luigi Serra   Cross browser con...
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
  			// Fire native event if possible so blur/focus sequence is correct
  			trigger: function() {
  				if ( this !== safeActiveElement() && this.focus ) {
  					this.focus();
  					return false;
  				}
  			},
  			delegateType: "focusin"
  		},
  		blur: {
  			trigger: function() {
  				if ( this === safeActiveElement() && this.blur ) {
  					this.blur();
  					return false;
  				}
  			},
  			delegateType: "focusout"
  		},
  		click: {
74249687   Luigi Serra   Cross browser con...
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
  			// For checkbox, fire native event so checked state will be right
  			trigger: function() {
  				if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
  					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;
  				}
  			}
  		}
c5169e0e   Renato De Donato   a new hope
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
  	},
  
  	simulate: function( type, elem, event, bubble ) {
  		// Piggyback on a donor event to simulate a different one.
  		// Fake originalEvent to avoid donor's stopPropagation, but if the
  		// simulated event prevents default then we do the same on the donor.
  		var e = jQuery.extend(
  			new jQuery.Event(),
  			event,
  			{
  				type: type,
  				isSimulated: true,
  				originalEvent: {}
  			}
  		);
  		if ( bubble ) {
  			jQuery.event.trigger( e, null, elem );
  		} else {
  			jQuery.event.dispatch.call( elem, e );
  		}
  		if ( e.isDefaultPrevented() ) {
  			event.preventDefault();
  		}
74249687   Luigi Serra   Cross browser con...
614
615
616
617
  	}
  };
  
  jQuery.removeEvent = function( elem, type, handle ) {
74249687   Luigi Serra   Cross browser con...
618
  	if ( elem.removeEventListener ) {
c5169e0e   Renato De Donato   a new hope
619
  		elem.removeEventListener( type, handle, false );
74249687   Luigi Serra   Cross browser con...
620
621
622
623
  	}
  };
  
  jQuery.Event = function( src, props ) {
74249687   Luigi Serra   Cross browser con...
624
  	// Allow instantiation without the 'new' keyword
c5169e0e   Renato De Donato   a new hope
625
  	if ( !(this instanceof jQuery.Event) ) {
74249687   Luigi Serra   Cross browser con...
626
627
628
629
630
631
632
633
634
635
636
637
  		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 &&
74249687   Luigi Serra   Cross browser con...
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
  				// Support: Android<4.0
  				src.returnValue === false ?
  			returnTrue :
  			returnFalse;
  
  	// 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
  // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  jQuery.Event.prototype = {
74249687   Luigi Serra   Cross browser con...
663
664
665
666
667
668
669
670
671
  	isDefaultPrevented: returnFalse,
  	isPropagationStopped: returnFalse,
  	isImmediatePropagationStopped: returnFalse,
  
  	preventDefault: function() {
  		var e = this.originalEvent;
  
  		this.isDefaultPrevented = returnTrue;
  
c5169e0e   Renato De Donato   a new hope
672
  		if ( e && e.preventDefault ) {
74249687   Luigi Serra   Cross browser con...
673
674
675
676
677
678
679
680
  			e.preventDefault();
  		}
  	},
  	stopPropagation: function() {
  		var e = this.originalEvent;
  
  		this.isPropagationStopped = returnTrue;
  
c5169e0e   Renato De Donato   a new hope
681
  		if ( e && e.stopPropagation ) {
74249687   Luigi Serra   Cross browser con...
682
683
684
685
686
687
688
689
  			e.stopPropagation();
  		}
  	},
  	stopImmediatePropagation: function() {
  		var e = this.originalEvent;
  
  		this.isImmediatePropagationStopped = returnTrue;
  
c5169e0e   Renato De Donato   a new hope
690
  		if ( e && e.stopImmediatePropagation ) {
74249687   Luigi Serra   Cross browser con...
691
692
693
694
695
696
697
698
  			e.stopImmediatePropagation();
  		}
  
  		this.stopPropagation();
  	}
  };
  
  // Create mouseenter/leave events using mouseover/out and event-time checks
c5169e0e   Renato De Donato   a new hope
699
700
  // Support: Chrome 15+
  jQuery.each({
74249687   Luigi Serra   Cross browser con...
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
  	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;
  
c5169e0e   Renato De Donato   a new hope
716
  			// For mousenter/leave call the handler if related is outside the target.
74249687   Luigi Serra   Cross browser con...
717
  			// NB: No relatedTarget if the mouse left/entered the browser window
c5169e0e   Renato De Donato   a new hope
718
  			if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
74249687   Luigi Serra   Cross browser con...
719
720
721
722
723
724
725
  				event.type = handleObj.origType;
  				ret = handleObj.handler.apply( this, arguments );
  				event.type = fix;
  			}
  			return ret;
  		}
  	};
c5169e0e   Renato De Donato   a new hope
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
  });
  
  // Support: Firefox, Chrome, Safari
  // Create "bubbling" focus and blur events
  if ( !support.focusinBubbles ) {
  	jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  
  		// Attach a single capturing handler on the document while someone wants focusin/focusout
  		var handler = function( event ) {
  				jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
  			};
  
  		jQuery.event.special[ fix ] = {
  			setup: function() {
  				var doc = this.ownerDocument || this,
  					attaches = data_priv.access( doc, fix );
  
  				if ( !attaches ) {
  					doc.addEventListener( orig, handler, true );
  				}
  				data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
  			},
  			teardown: function() {
  				var doc = this.ownerDocument || this,
  					attaches = data_priv.access( doc, fix ) - 1;
  
  				if ( !attaches ) {
  					doc.removeEventListener( orig, handler, true );
  					data_priv.remove( doc, fix );
  
  				} else {
  					data_priv.access( doc, fix, attaches );
  				}
  			}
  		};
  	});
  }
  
  jQuery.fn.extend({
74249687   Luigi Serra   Cross browser con...
765
  
c5169e0e   Renato De Donato   a new hope
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
  	on: function( types, selector, data, fn, /*INTERNAL*/ 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 ) {
  				this.on( type, selector, data, types[ type ], one );
  			}
  			return this;
  		}
  
  		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 this;
  		}
  
  		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 this.each( function() {
  			jQuery.event.add( this, types, fn, data, selector );
  		});
74249687   Luigi Serra   Cross browser con...
818
819
  	},
  	one: function( types, selector, data, fn ) {
c5169e0e   Renato De Donato   a new hope
820
  		return this.on( types, selector, data, fn, 1 );
74249687   Luigi Serra   Cross browser con...
821
822
823
824
  	},
  	off: function( types, selector, fn ) {
  		var handleObj, type;
  		if ( types && types.preventDefault && types.handleObj ) {
74249687   Luigi Serra   Cross browser con...
825
826
827
  			// ( event )  dispatched jQuery.Event
  			handleObj = types.handleObj;
  			jQuery( types.delegateTarget ).off(
c5169e0e   Renato De Donato   a new hope
828
  				handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
74249687   Luigi Serra   Cross browser con...
829
830
831
832
833
834
  				handleObj.selector,
  				handleObj.handler
  			);
  			return this;
  		}
  		if ( typeof types === "object" ) {
74249687   Luigi Serra   Cross browser con...
835
836
837
838
839
840
841
  			// ( types-object [, selector] )
  			for ( type in types ) {
  				this.off( type, selector, types[ type ] );
  			}
  			return this;
  		}
  		if ( selector === false || typeof selector === "function" ) {
74249687   Luigi Serra   Cross browser con...
842
843
844
845
846
847
848
  			// ( types [, fn] )
  			fn = selector;
  			selector = undefined;
  		}
  		if ( fn === false ) {
  			fn = returnFalse;
  		}
c5169e0e   Renato De Donato   a new hope
849
  		return this.each(function() {
74249687   Luigi Serra   Cross browser con...
850
  			jQuery.event.remove( this, types, fn, selector );
c5169e0e   Renato De Donato   a new hope
851
852
853
854
855
856
857
858
859
860
861
862
863
  		});
  	},
  
  	trigger: function( type, data ) {
  		return this.each(function() {
  			jQuery.event.trigger( type, data, this );
  		});
  	},
  	triggerHandler: function( type, data ) {
  		var elem = this[0];
  		if ( elem ) {
  			return jQuery.event.trigger( type, data, elem, true );
  		}
74249687   Luigi Serra   Cross browser con...
864
  	}
c5169e0e   Renato De Donato   a new hope
865
  });
74249687   Luigi Serra   Cross browser con...
866
867
  
  return jQuery;
c5169e0e   Renato De Donato   a new hope
868
  });