a1a3bc73
Luigi Serra
graphs updates
|
1
|
define( [
|
74249687
Luigi Serra
Cross browser con...
|
2
|
"./core",
|
a1a3bc73
Luigi Serra
graphs updates
|
3
|
"./var/document",
|
74249687
Luigi Serra
Cross browser con...
|
4
|
"./var/rnotwhite",
|
74249687
Luigi Serra
Cross browser con...
|
5
|
"./var/slice",
|
a1a3bc73
Luigi Serra
graphs updates
|
6
|
"./data/var/dataPriv",
|
74249687
Luigi Serra
Cross browser con...
|
7
8
|
"./core/init",
|
74249687
Luigi Serra
Cross browser con...
|
9
|
"./selector"
|
a1a3bc73
Luigi Serra
graphs updates
|
10
|
], function( jQuery, document, rnotwhite, slice, dataPriv ) {
|
74249687
Luigi Serra
Cross browser con...
|
11
12
13
|
var
rkeyEvent = /^key/,
|
a1a3bc73
Luigi Serra
graphs updates
|
14
15
|
rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
|
74249687
Luigi Serra
Cross browser con...
|
16
17
18
19
20
21
22
23
24
|
function returnTrue() {
return true;
}
function returnFalse() {
return false;
}
|
a1a3bc73
Luigi Serra
graphs updates
|
25
26
|
// Support: IE9
// See #13393 for more info
|
74249687
Luigi Serra
Cross browser con...
|
27
28
29
30
31
32
|
function safeActiveElement() {
try {
return document.activeElement;
} catch ( err ) { }
}
|
a1a3bc73
Luigi Serra
graphs updates
|
33
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 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 elem.each( function() {
jQuery.event.add( this, types, fn, data, selector );
} );
}
|
74249687
Luigi Serra
Cross browser con...
|
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/*
* 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,
|
a1a3bc73
Luigi Serra
graphs updates
|
107
|
elemData = dataPriv.get( elem );
|
74249687
Luigi Serra
Cross browser con...
|
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
// 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
|
a1a3bc73
Luigi Serra
graphs updates
|
127
|
if ( !( events = elemData.events ) ) {
|
74249687
Luigi Serra
Cross browser con...
|
128
129
|
events = elemData.events = {};
}
|
a1a3bc73
Luigi Serra
graphs updates
|
130
|
if ( !( eventHandle = elemData.handle ) ) {
|
74249687
Luigi Serra
Cross browser con...
|
131
|
eventHandle = elemData.handle = function( e ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
132
|
|
74249687
Luigi Serra
Cross browser con...
|
133
134
|
// Discard the second event of a jQuery.event.trigger() and
// when an event is called after a page has unloaded
|
a1a3bc73
Luigi Serra
graphs updates
|
135
|
return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
|
74249687
Luigi Serra
Cross browser con...
|
136
137
138
139
140
141
142
143
|
jQuery.event.dispatch.apply( elem, arguments ) : undefined;
};
}
// Handle multiple events separated by a space
types = ( types || "" ).match( rnotwhite ) || [ "" ];
t = types.length;
while ( t-- ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
144
145
146
|
tmp = rtypenamespace.exec( types[ t ] ) || [];
type = origType = tmp[ 1 ];
namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
|
74249687
Luigi Serra
Cross browser con...
|
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
// 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
|
a1a3bc73
Luigi Serra
graphs updates
|
163
|
handleObj = jQuery.extend( {
|
74249687
Luigi Serra
Cross browser con...
|
164
165
166
167
168
169
170
|
type: type,
origType: origType,
data: data,
handler: handler,
guid: handler.guid,
selector: selector,
needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
|
a1a3bc73
Luigi Serra
graphs updates
|
171
|
namespace: namespaces.join( "." )
|
74249687
Luigi Serra
Cross browser con...
|
172
173
174
|
}, handleObjIn );
// Init the event handler queue if we're the first
|
a1a3bc73
Luigi Serra
graphs updates
|
175
|
if ( !( handlers = events[ type ] ) ) {
|
74249687
Luigi Serra
Cross browser con...
|
176
177
178
179
|
handlers = events[ type ] = [];
handlers.delegateCount = 0;
// Only use addEventListener if the special events handler returns false
|
a1a3bc73
Luigi Serra
graphs updates
|
180
181
182
|
if ( !special.setup ||
special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
|
74249687
Luigi Serra
Cross browser con...
|
183
|
if ( elem.addEventListener ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
184
|
elem.addEventListener( type, eventHandle );
|
74249687
Luigi Serra
Cross browser con...
|
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
}
}
}
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,
|
a1a3bc73
Luigi Serra
graphs updates
|
216
|
elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
|
74249687
Luigi Serra
Cross browser con...
|
217
|
|
a1a3bc73
Luigi Serra
graphs updates
|
218
|
if ( !elemData || !( events = elemData.events ) ) {
|
74249687
Luigi Serra
Cross browser con...
|
219
220
221
222
223
224
225
|
return;
}
// Once for each type.namespace in types; type may be omitted
types = ( types || "" ).match( rnotwhite ) || [ "" ];
t = types.length;
while ( t-- ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
226
227
228
|
tmp = rtypenamespace.exec( types[ t ] ) || [];
type = origType = tmp[ 1 ];
namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
|
74249687
Luigi Serra
Cross browser con...
|
229
230
231
232
233
234
235
236
237
238
239
240
|
// 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 ] || [];
|
a1a3bc73
Luigi Serra
graphs updates
|
241
242
|
tmp = tmp[ 2 ] &&
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
|
74249687
Luigi Serra
Cross browser con...
|
243
244
245
246
247
248
249
250
251
|
// 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 ) ) &&
|
a1a3bc73
Luigi Serra
graphs updates
|
252
253
|
( !selector || selector === handleObj.selector ||
selector === "**" && handleObj.selector ) ) {
|
74249687
Luigi Serra
Cross browser con...
|
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
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 ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
268
269
270
|
if ( !special.teardown ||
special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
|
74249687
Luigi Serra
Cross browser con...
|
271
272
273
274
275
276
277
|
jQuery.removeEvent( elem, type, elemData.handle );
}
delete events[ type ];
}
}
|
a1a3bc73
Luigi Serra
graphs updates
|
278
|
// Remove data and the expando if it's no longer used
|
74249687
Luigi Serra
Cross browser con...
|
279
|
if ( jQuery.isEmptyObject( events ) ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
280
|
dataPriv.remove( elem, "handle events" );
|
74249687
Luigi Serra
Cross browser con...
|
281
|
}
|
74249687
Luigi Serra
Cross browser con...
|
282
283
284
285
286
287
288
289
290
291
|
},
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 ),
|
a1a3bc73
Luigi Serra
graphs updates
|
292
|
handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
|
74249687
Luigi Serra
Cross browser con...
|
293
294
295
|
special = jQuery.event.special[ event.type ] || {};
// Use the fix-ed jQuery.Event rather than the (read-only) native event
|
a1a3bc73
Luigi Serra
graphs updates
|
296
|
args[ 0 ] = event;
|
74249687
Luigi Serra
Cross browser con...
|
297
298
299
300
301
302
303
304
305
306
307
308
|
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;
|
a1a3bc73
Luigi Serra
graphs updates
|
309
|
while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
|
74249687
Luigi Serra
Cross browser con...
|
310
311
312
|
event.currentTarget = matched.elem;
j = 0;
|
a1a3bc73
Luigi Serra
graphs updates
|
313
314
|
while ( ( handleObj = matched.handlers[ j++ ] ) &&
!event.isImmediatePropagationStopped() ) {
|
74249687
Luigi Serra
Cross browser con...
|
315
316
317
|
// 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).
|
a1a3bc73
Luigi Serra
graphs updates
|
318
|
if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
|
74249687
Luigi Serra
Cross browser con...
|
319
320
321
322
|
event.handleObj = handleObj;
event.data = handleObj.data;
|
a1a3bc73
Luigi Serra
graphs updates
|
323
324
|
ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
handleObj.handler ).apply( matched.elem, args );
|
74249687
Luigi Serra
Cross browser con...
|
325
326
|
if ( ret !== undefined ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
327
|
if ( ( event.result = ret ) === false ) {
|
74249687
Luigi Serra
Cross browser con...
|
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
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;
|
a1a3bc73
Luigi Serra
graphs updates
|
350
|
// Support (at least): Chrome, IE9
|
74249687
Luigi Serra
Cross browser con...
|
351
352
|
// Find delegate handlers
// Black-hole SVG <use> instance trees (#13180)
|
a1a3bc73
Luigi Serra
graphs updates
|
353
354
355
356
357
|
//
// Support: Firefox<=42+
// Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343)
if ( delegateCount && cur.nodeType &&
( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) {
|
74249687
Luigi Serra
Cross browser con...
|
358
359
360
|
for ( ; cur !== this; cur = cur.parentNode || this ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
361
|
// Don't check non-elements (#13208)
|
74249687
Luigi Serra
Cross browser con...
|
362
|
// Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
|
a1a3bc73
Luigi Serra
graphs updates
|
363
|
if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) {
|
74249687
Luigi Serra
Cross browser con...
|
364
365
366
367
368
369
370
371
372
|
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 ?
|
a1a3bc73
Luigi Serra
graphs updates
|
373
|
jQuery( sel, this ).index( cur ) > -1 :
|
74249687
Luigi Serra
Cross browser con...
|
374
375
376
377
378
379
380
|
jQuery.find( sel, this, null, [ cur ] ).length;
}
if ( matches[ sel ] ) {
matches.push( handleObj );
}
}
if ( matches.length ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
381
|
handlerQueue.push( { elem: cur, handlers: matches } );
|
74249687
Luigi Serra
Cross browser con...
|
382
383
384
385
386
387
388
|
}
}
}
}
// Add the remaining (directly-bound) handlers
if ( delegateCount < handlers.length ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
389
|
handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } );
|
74249687
Luigi Serra
Cross browser con...
|
390
391
392
393
394
395
|
}
return handlerQueue;
},
// Includes some event props shared by KeyEvent and MouseEvent
|
a1a3bc73
Luigi Serra
graphs updates
|
396
397
|
props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
"metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ),
|
74249687
Luigi Serra
Cross browser con...
|
398
399
400
401
|
fixHooks: {},
keyHooks: {
|
a1a3bc73
Luigi Serra
graphs updates
|
402
|
props: "char charCode key keyCode".split( " " ),
|
74249687
Luigi Serra
Cross browser con...
|
403
404
405
406
407
408
409
410
411
412
413
414
|
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: {
|
a1a3bc73
Luigi Serra
graphs updates
|
415
416
|
props: ( "button buttons clientX clientY offsetX offsetY pageX pageY " +
"screenX screenY toElement" ).split( " " ),
|
74249687
Luigi Serra
Cross browser con...
|
417
418
419
420
421
422
423
424
425
426
|
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;
|
a1a3bc73
Luigi Serra
graphs updates
|
427
428
429
430
431
432
|
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...
|
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
|
}
// 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: {
|
a1a3bc73
Luigi Serra
graphs updates
|
489
|
|
74249687
Luigi Serra
Cross browser con...
|
490
491
492
493
|
// Prevent triggered image.load events from bubbling to window.load
noBubble: true
},
focus: {
|
a1a3bc73
Luigi Serra
graphs updates
|
494
|
|
74249687
Luigi Serra
Cross browser con...
|
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
|
// 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: {
|
a1a3bc73
Luigi Serra
graphs updates
|
514
|
|
74249687
Luigi Serra
Cross browser con...
|
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
|
// 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;
}
}
}
|
74249687
Luigi Serra
Cross browser con...
|
539
540
541
542
|
}
};
jQuery.removeEvent = function( elem, type, handle ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
543
544
|
// This "if" is needed for plain objects
|
74249687
Luigi Serra
Cross browser con...
|
545
|
if ( elem.removeEventListener ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
546
|
elem.removeEventListener( type, handle );
|
74249687
Luigi Serra
Cross browser con...
|
547
548
549
550
|
}
};
jQuery.Event = function( src, props ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
551
|
|
74249687
Luigi Serra
Cross browser con...
|
552
|
// Allow instantiation without the 'new' keyword
|
a1a3bc73
Luigi Serra
graphs updates
|
553
|
if ( !( this instanceof jQuery.Event ) ) {
|
74249687
Luigi Serra
Cross browser con...
|
554
555
556
557
558
559
560
561
562
563
564
565
|
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 &&
|
a1a3bc73
Luigi Serra
graphs updates
|
566
|
|
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
591
|
// 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 = {
|
a1a3bc73
Luigi Serra
graphs updates
|
592
|
constructor: jQuery.Event,
|
74249687
Luigi Serra
Cross browser con...
|
593
594
595
596
597
598
599
600
601
|
isDefaultPrevented: returnFalse,
isPropagationStopped: returnFalse,
isImmediatePropagationStopped: returnFalse,
preventDefault: function() {
var e = this.originalEvent;
this.isDefaultPrevented = returnTrue;
|
a1a3bc73
Luigi Serra
graphs updates
|
602
|
if ( e ) {
|
74249687
Luigi Serra
Cross browser con...
|
603
604
605
606
607
608
609
610
|
e.preventDefault();
}
},
stopPropagation: function() {
var e = this.originalEvent;
this.isPropagationStopped = returnTrue;
|
a1a3bc73
Luigi Serra
graphs updates
|
611
|
if ( e ) {
|
74249687
Luigi Serra
Cross browser con...
|
612
613
614
615
616
617
618
619
|
e.stopPropagation();
}
},
stopImmediatePropagation: function() {
var e = this.originalEvent;
this.isImmediatePropagationStopped = returnTrue;
|
a1a3bc73
Luigi Serra
graphs updates
|
620
|
if ( e ) {
|
74249687
Luigi Serra
Cross browser con...
|
621
622
623
624
625
626
627
628
|
e.stopImmediatePropagation();
}
this.stopPropagation();
}
};
// Create mouseenter/leave events using mouseover/out and event-time checks
|
a1a3bc73
Luigi Serra
graphs updates
|
629
630
631
632
633
634
635
636
|
// 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://code.google.com/p/chromium/issues/detail?id=470258
// for the description of the bug (it existed in older Chrome versions as well).
jQuery.each( {
|
74249687
Luigi Serra
Cross browser con...
|
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
|
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;
|
a1a3bc73
Luigi Serra
graphs updates
|
652
|
// For mouseenter/leave call the handler if related is outside the target.
|
74249687
Luigi Serra
Cross browser con...
|
653
|
// NB: No relatedTarget if the mouse left/entered the browser window
|
a1a3bc73
Luigi Serra
graphs updates
|
654
|
if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
|
74249687
Luigi Serra
Cross browser con...
|
655
656
657
658
659
660
661
|
event.type = handleObj.origType;
ret = handleObj.handler.apply( this, arguments );
event.type = fix;
}
return ret;
}
};
|
a1a3bc73
Luigi Serra
graphs updates
|
662
|
} );
|
74249687
Luigi Serra
Cross browser con...
|
663
|
|
a1a3bc73
Luigi Serra
graphs updates
|
664
665
666
|
jQuery.fn.extend( {
on: function( types, selector, data, fn ) {
return on( this, types, selector, data, fn );
|
74249687
Luigi Serra
Cross browser con...
|
667
668
|
},
one: function( types, selector, data, fn ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
669
|
return on( this, types, selector, data, fn, 1 );
|
74249687
Luigi Serra
Cross browser con...
|
670
671
672
673
|
},
off: function( types, selector, fn ) {
var handleObj, type;
if ( types && types.preventDefault && types.handleObj ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
674
|
|
74249687
Luigi Serra
Cross browser con...
|
675
676
677
|
// ( event ) dispatched jQuery.Event
handleObj = types.handleObj;
jQuery( types.delegateTarget ).off(
|
a1a3bc73
Luigi Serra
graphs updates
|
678
679
680
|
handleObj.namespace ?
handleObj.origType + "." + handleObj.namespace :
handleObj.origType,
|
74249687
Luigi Serra
Cross browser con...
|
681
682
683
684
685
686
|
handleObj.selector,
handleObj.handler
);
return this;
}
if ( typeof types === "object" ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
687
|
|
74249687
Luigi Serra
Cross browser con...
|
688
689
690
691
692
693
694
|
// ( types-object [, selector] )
for ( type in types ) {
this.off( type, selector, types[ type ] );
}
return this;
}
if ( selector === false || typeof selector === "function" ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
695
|
|
74249687
Luigi Serra
Cross browser con...
|
696
697
698
699
700
701
702
|
// ( types [, fn] )
fn = selector;
selector = undefined;
}
if ( fn === false ) {
fn = returnFalse;
}
|
a1a3bc73
Luigi Serra
graphs updates
|
703
|
return this.each( function() {
|
74249687
Luigi Serra
Cross browser con...
|
704
|
jQuery.event.remove( this, types, fn, selector );
|
a1a3bc73
Luigi Serra
graphs updates
|
705
|
} );
|
74249687
Luigi Serra
Cross browser con...
|
706
|
}
|
a1a3bc73
Luigi Serra
graphs updates
|
707
|
} );
|
74249687
Luigi Serra
Cross browser con...
|
708
709
|
return jQuery;
|
a1a3bc73
Luigi Serra
graphs updates
|
710
|
} );
|