2013-08-15 18:15:49 +00:00
|
|
|
define([
|
|
|
|
"./core",
|
|
|
|
"./var/strundefined",
|
|
|
|
"./var/rnotwhite",
|
|
|
|
"./var/hasOwn",
|
|
|
|
"./var/slice",
|
2013-09-02 17:21:09 +00:00
|
|
|
"./event/support",
|
2013-08-15 18:15:49 +00:00
|
|
|
"./data/accepts",
|
2013-09-02 17:21:09 +00:00
|
|
|
"./selector"
|
|
|
|
], function( jQuery, strundefined, rnotwhite, hasOwn, slice, support ) {
|
2013-08-15 18:15:49 +00:00
|
|
|
|
2012-11-26 08:20:43 +00:00
|
|
|
var rformElems = /^(?:input|select|textarea)$/i,
|
2011-09-25 23:56:34 +00:00
|
|
|
rkeyEvent = /^key/,
|
|
|
|
rmouseEvent = /^(?:mouse|contextmenu)|click/,
|
2012-11-26 08:20:43 +00:00
|
|
|
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
|
|
|
|
rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
|
2009-12-22 00:58:13 +00:00
|
|
|
|
2013-01-12 22:11:07 +00:00
|
|
|
function returnTrue() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function returnFalse() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-09 01:33:25 +00:00
|
|
|
function safeActiveElement() {
|
|
|
|
try {
|
|
|
|
return document.activeElement;
|
|
|
|
} catch ( err ) { }
|
|
|
|
}
|
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
/*
|
2011-09-08 03:21:33 +00:00
|
|
|
* Helper functions for managing events -- not part of the public interface.
|
|
|
|
* Props to Dean Edwards' addEvent library for many of the ideas.
|
2007-12-19 01:10:20 +00:00
|
|
|
*/
|
|
|
|
jQuery.event = {
|
|
|
|
|
2013-01-12 22:11:07 +00:00
|
|
|
global: {},
|
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
add: function( elem, types, handler, data, selector ) {
|
2013-01-29 00:04:58 +00:00
|
|
|
var tmp, events, t, handleObjIn,
|
|
|
|
special, eventHandle, handleObj,
|
|
|
|
handlers, type, namespaces, origType,
|
2013-01-16 19:36:24 +00:00
|
|
|
elemData = jQuery._data( elem );
|
2013-01-12 22:11:07 +00:00
|
|
|
|
2013-01-16 19:36:24 +00:00
|
|
|
// Don't attach events to noData or text/comment nodes (but allow plain objects)
|
2013-01-12 22:11:07 +00:00
|
|
|
if ( !elemData ) {
|
2011-02-15 21:03:23 +00:00
|
|
|
return;
|
2010-02-27 14:02:13 +00:00
|
|
|
}
|
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
// Caller can pass in an object of custom data in lieu of the handler
|
2010-02-05 02:36:32 +00:00
|
|
|
if ( handler.handler ) {
|
|
|
|
handleObjIn = handler;
|
|
|
|
handler = handleObjIn.handler;
|
2012-01-28 19:58:00 +00:00
|
|
|
selector = handleObjIn.selector;
|
2010-02-05 02:36:32 +00:00
|
|
|
}
|
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
// Make sure that the handler has a unique ID, used to find/remove it later
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( !handler.guid ) {
|
2009-12-31 20:06:45 +00:00
|
|
|
handler.guid = jQuery.guid++;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
// Init the element's event structure and main handler, if this is the first
|
2013-01-12 22:11:07 +00:00
|
|
|
if ( !(events = elemData.events) ) {
|
|
|
|
events = elemData.events = {};
|
2010-09-29 13:46:25 +00:00
|
|
|
}
|
2013-01-12 22:11:07 +00:00
|
|
|
if ( !(eventHandle = elemData.handle) ) {
|
|
|
|
eventHandle = elemData.handle = function( e ) {
|
2011-04-06 14:31:14 +00:00
|
|
|
// Discard the second event of a jQuery.event.trigger() and
|
|
|
|
// when an event is called after a page has unloaded
|
2013-08-15 18:15:49 +00:00
|
|
|
return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ?
|
2011-10-24 01:13:59 +00:00
|
|
|
jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
|
2008-12-19 04:36:28 +00:00
|
|
|
undefined;
|
2009-12-16 21:45:00 +00:00
|
|
|
};
|
2011-07-29 00:43:23 +00:00
|
|
|
// Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
|
|
|
|
eventHandle.elem = elem;
|
2010-01-13 16:24:54 +00:00
|
|
|
}
|
|
|
|
|
2008-04-29 23:34:50 +00:00
|
|
|
// Handle multiple events separated by a space
|
2013-08-15 18:15:49 +00:00
|
|
|
types = ( types || "" ).match( rnotwhite ) || [""];
|
2013-01-12 22:11:07 +00:00
|
|
|
t = types.length;
|
|
|
|
while ( t-- ) {
|
|
|
|
tmp = rtypenamespace.exec( types[t] ) || [];
|
|
|
|
type = origType = tmp[1];
|
|
|
|
namespaces = ( tmp[2] || "" ).split( "." ).sort();
|
2013-03-13 23:23:36 +00:00
|
|
|
|
2013-02-26 17:19:04 +00:00
|
|
|
// There *must* be a type, no attaching namespace-only handlers
|
|
|
|
if ( !type ) {
|
|
|
|
continue;
|
|
|
|
}
|
2011-08-17 00:26:14 +00:00
|
|
|
|
|
|
|
// If event changes its type, use the special event handlers for the changed type
|
2011-08-13 14:46:34 +00:00
|
|
|
special = jQuery.event.special[ type ] || {};
|
2011-10-06 14:12:05 +00:00
|
|
|
|
|
|
|
// 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
|
2011-08-17 00:26:14 +00:00
|
|
|
special = jQuery.event.special[ type ] || {};
|
|
|
|
|
|
|
|
// handleObj is passed to all event handlers
|
2011-07-29 00:43:23 +00:00
|
|
|
handleObj = jQuery.extend({
|
2011-08-13 14:46:34 +00:00
|
|
|
type: type,
|
2013-01-12 22:11:07 +00:00
|
|
|
origType: origType,
|
2011-09-20 16:54:34 +00:00
|
|
|
data: data,
|
2011-07-29 00:43:23 +00:00
|
|
|
handler: handler,
|
|
|
|
guid: handler.guid,
|
|
|
|
selector: selector,
|
2012-09-10 00:47:07 +00:00
|
|
|
needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
|
2011-07-29 00:43:23 +00:00
|
|
|
namespace: namespaces.join(".")
|
2011-10-06 14:12:05 +00:00
|
|
|
}, handleObjIn );
|
2011-08-13 14:46:34 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
// Init the event handler queue if we're the first
|
2013-01-12 22:11:07 +00:00
|
|
|
if ( !(handlers = events[ type ]) ) {
|
2010-02-04 05:20:52 +00:00
|
|
|
handlers = events[ type ] = [];
|
2011-07-29 00:43:23 +00:00
|
|
|
handlers.delegateCount = 0;
|
2011-09-20 16:54:34 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
// Only use addEventListener/attachEvent if the special events handler returns false
|
2010-02-05 16:02:56 +00:00
|
|
|
if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
|
2008-04-29 23:34:50 +00:00
|
|
|
// Bind the global event handler to the element
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( elem.addEventListener ) {
|
2010-02-04 05:20:52 +00:00
|
|
|
elem.addEventListener( type, eventHandle, false );
|
2010-01-28 19:12:44 +00:00
|
|
|
|
2009-04-30 01:26:09 +00:00
|
|
|
} else if ( elem.attachEvent ) {
|
2010-02-04 05:20:52 +00:00
|
|
|
elem.attachEvent( "on" + type, eventHandle );
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
2008-04-29 23:34:50 +00:00
|
|
|
}
|
2010-12-26 20:28:13 +00:00
|
|
|
|
|
|
|
if ( special.add ) {
|
|
|
|
special.add.call( elem, handleObj );
|
2010-02-13 11:10:43 +00:00
|
|
|
|
|
|
|
if ( !handleObj.handler.guid ) {
|
|
|
|
handleObj.handler.guid = handler.guid;
|
|
|
|
}
|
2010-02-04 05:20:52 +00:00
|
|
|
}
|
2010-02-05 02:36:32 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
// Add to the element's handler list, delegates in front
|
|
|
|
if ( selector ) {
|
|
|
|
handlers.splice( handlers.delegateCount++, 0, handleObj );
|
|
|
|
} else {
|
|
|
|
handlers.push( handleObj );
|
|
|
|
}
|
2011-09-20 16:54:34 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
// Keep track of which events have ever been used, for event optimization
|
2010-02-04 05:20:52 +00:00
|
|
|
jQuery.event.global[ type ] = true;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-12-21 04:53:33 +00:00
|
|
|
// Nullify elem to prevent memory leaks in IE
|
|
|
|
elem = null;
|
2007-12-19 01:10:20 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// Detach an event or set of events from an element
|
2011-11-15 16:38:55 +00:00
|
|
|
remove: function( elem, types, handler, selector, mappedTypes ) {
|
2013-01-29 00:04:58 +00:00
|
|
|
var j, handleObj, tmp,
|
|
|
|
origCount, t, events,
|
|
|
|
special, handlers, type,
|
|
|
|
namespaces, origType,
|
2012-07-10 01:38:11 +00:00
|
|
|
elemData = jQuery.hasData( elem ) && jQuery._data( elem );
|
2011-09-20 16:54:34 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
if ( !elemData || !(events = elemData.events) ) {
|
2010-01-28 19:12:44 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
// Once for each type.namespace in types; type may be omitted
|
2013-08-15 18:15:49 +00:00
|
|
|
types = ( types || "" ).match( rnotwhite ) || [""];
|
2013-01-12 22:11:07 +00:00
|
|
|
t = types.length;
|
|
|
|
while ( t-- ) {
|
|
|
|
tmp = rtypenamespace.exec( types[t] ) || [];
|
|
|
|
type = origType = tmp[1];
|
|
|
|
namespaces = ( tmp[2] || "" ).split( "." ).sort();
|
2010-01-28 19:12:44 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
// Unbind all events (on this namespace, if provided) for the element
|
2011-10-06 14:12:05 +00:00
|
|
|
if ( !type ) {
|
2011-11-15 16:38:55 +00:00
|
|
|
for ( type in events ) {
|
|
|
|
jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
|
2010-02-04 05:20:52 +00:00
|
|
|
}
|
2011-11-10 02:29:15 +00:00
|
|
|
continue;
|
2010-02-04 05:20:52 +00:00
|
|
|
}
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
special = jQuery.event.special[ type ] || {};
|
2013-01-12 22:11:07 +00:00
|
|
|
type = ( selector ? special.delegateType : special.bindType ) || type;
|
|
|
|
handlers = events[ type ] || [];
|
|
|
|
tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2011-11-14 01:50:36 +00:00
|
|
|
// Remove matching events
|
2013-01-12 22:11:07 +00:00
|
|
|
origCount = j = handlers.length;
|
|
|
|
while ( j-- ) {
|
|
|
|
handleObj = handlers[ j ];
|
2011-11-14 01:50:36 +00:00
|
|
|
|
2011-11-15 16:38:55 +00:00
|
|
|
if ( ( mappedTypes || origType === handleObj.origType ) &&
|
2012-10-22 17:28:51 +00:00
|
|
|
( !handler || handler.guid === handleObj.guid ) &&
|
2013-01-12 22:11:07 +00:00
|
|
|
( !tmp || tmp.test( handleObj.namespace ) ) &&
|
2012-10-22 17:28:51 +00:00
|
|
|
( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
|
2013-01-12 22:11:07 +00:00
|
|
|
handlers.splice( j, 1 );
|
2011-11-14 01:50:36 +00:00
|
|
|
|
|
|
|
if ( handleObj.selector ) {
|
2013-01-12 22:11:07 +00:00
|
|
|
handlers.delegateCount--;
|
2011-11-14 01:50:36 +00:00
|
|
|
}
|
|
|
|
if ( special.remove ) {
|
|
|
|
special.remove.call( elem, handleObj );
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
|
|
|
|
2011-09-07 03:20:48 +00:00
|
|
|
// Remove generic event handler if we removed something and no more handlers exist
|
|
|
|
// (avoids potential for endless recursion during removal of special event handlers)
|
2013-01-12 22:11:07 +00:00
|
|
|
if ( origCount && !handlers.length ) {
|
2012-06-18 02:42:24 +00:00
|
|
|
if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
|
2010-09-08 22:13:35 +00:00
|
|
|
jQuery.removeEvent( elem, type, elemData.handle );
|
2010-02-04 05:20:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete events[ type ];
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2011-09-20 01:16:20 +00:00
|
|
|
}
|
2010-01-28 19:12:44 +00:00
|
|
|
|
2011-09-20 01:16:20 +00:00
|
|
|
// Remove the expando if it's no longer used
|
|
|
|
if ( jQuery.isEmptyObject( events ) ) {
|
2012-04-05 01:17:01 +00:00
|
|
|
delete elemData.handle;
|
2011-09-20 01:16:20 +00:00
|
|
|
|
|
|
|
// removeData also checks for emptiness and clears the expando if empty
|
|
|
|
// so use it instead of delete
|
2012-10-16 15:15:41 +00:00
|
|
|
jQuery._removeData( elem, "events" );
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
|
|
|
},
|
2011-09-20 16:54:34 +00:00
|
|
|
|
2011-04-17 00:48:27 +00:00
|
|
|
trigger: function( event, data, elem, onlyHandlers ) {
|
2013-01-29 00:04:58 +00:00
|
|
|
var handle, ontype, cur,
|
|
|
|
bubbleType, special, tmp, i,
|
2013-01-12 22:11:07 +00:00
|
|
|
eventPath = [ elem || document ],
|
2013-08-15 18:15:49 +00:00
|
|
|
type = hasOwn.call( event, "type" ) ? event.type : event,
|
|
|
|
namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
|
2011-04-06 15:34:41 +00:00
|
|
|
|
2013-01-12 22:11:07 +00:00
|
|
|
cur = tmp = elem = elem || document;
|
2012-12-01 20:25:52 +00:00
|
|
|
|
|
|
|
// Don't do events on text and comment nodes
|
|
|
|
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-11-09 04:08:04 +00:00
|
|
|
// focus/blur morphs to focusin/out; ensure we're not firing them right now
|
|
|
|
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-12-01 20:25:52 +00:00
|
|
|
if ( type.indexOf(".") >= 0 ) {
|
2011-02-11 04:43:45 +00:00
|
|
|
// Namespaced trigger; create a regexp to match event type in handle()
|
|
|
|
namespaces = type.split(".");
|
2011-04-11 15:15:00 +00:00
|
|
|
type = namespaces.shift();
|
2011-02-11 04:43:45 +00:00
|
|
|
namespaces.sort();
|
|
|
|
}
|
2013-01-12 22:11:07 +00:00
|
|
|
ontype = type.indexOf(":") < 0 && "on" + type;
|
2011-04-07 03:41:47 +00:00
|
|
|
|
2013-01-12 22:11:07 +00:00
|
|
|
// 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 );
|
2011-04-12 18:58:55 +00:00
|
|
|
|
2013-02-02 02:20:15 +00:00
|
|
|
// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
|
|
|
|
event.isTrigger = onlyHandlers ? 2 : 3;
|
2012-12-01 20:25:52 +00:00
|
|
|
event.namespace = namespaces.join(".");
|
2013-01-12 22:11:07 +00:00
|
|
|
event.namespace_re = event.namespace ?
|
|
|
|
new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
|
|
|
|
null;
|
2009-01-02 23:07:16 +00:00
|
|
|
|
2011-03-16 03:40:25 +00:00
|
|
|
// Clean up the event in case it is being reused
|
2011-04-06 15:34:41 +00:00
|
|
|
event.result = undefined;
|
2011-09-20 02:50:29 +00:00
|
|
|
if ( !event.target ) {
|
|
|
|
event.target = elem;
|
|
|
|
}
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2011-03-16 03:40:25 +00:00
|
|
|
// Clone any incoming data and prepend the event, creating the handler arg list
|
2013-01-12 22:11:07 +00:00
|
|
|
data = data == null ?
|
|
|
|
[ event ] :
|
|
|
|
jQuery.makeArray( data, [ event ] );
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2011-08-13 14:46:34 +00:00
|
|
|
// Allow special events to draw outside the lines
|
|
|
|
special = jQuery.event.special[ type ] || {};
|
2012-11-21 03:31:33 +00:00
|
|
|
if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
|
2011-08-13 14:46:34 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-09-29 13:46:25 +00:00
|
|
|
|
2011-09-08 00:57:37 +00:00
|
|
|
// 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)
|
2011-10-13 20:30:40 +00:00
|
|
|
if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
|
|
|
|
|
2011-09-08 00:57:37 +00:00
|
|
|
bubbleType = special.delegateType || type;
|
2013-01-12 22:11:07 +00:00
|
|
|
if ( !rfocusMorph.test( bubbleType + type ) ) {
|
|
|
|
cur = cur.parentNode;
|
|
|
|
}
|
|
|
|
for ( ; cur; cur = cur.parentNode ) {
|
|
|
|
eventPath.push( cur );
|
|
|
|
tmp = cur;
|
2011-10-13 20:30:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Only add window if we got to document (e.g., not plain obj or detached DOM)
|
2013-01-12 22:11:07 +00:00
|
|
|
if ( tmp === (elem.ownerDocument || document) ) {
|
|
|
|
eventPath.push( tmp.defaultView || tmp.parentWindow || window );
|
2011-04-06 15:34:41 +00:00
|
|
|
}
|
2011-09-08 00:57:37 +00:00
|
|
|
}
|
2011-09-20 16:54:34 +00:00
|
|
|
|
2011-10-13 20:30:40 +00:00
|
|
|
// Fire handlers on the event path
|
2013-01-12 22:11:07 +00:00
|
|
|
i = 0;
|
|
|
|
while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
|
2011-10-13 20:30:40 +00:00
|
|
|
|
2013-01-12 22:11:07 +00:00
|
|
|
event.type = i > 1 ?
|
|
|
|
bubbleType :
|
|
|
|
special.bindType || type;
|
2011-10-13 20:30:40 +00:00
|
|
|
|
2013-01-12 22:11:07 +00:00
|
|
|
// jQuery handler
|
2011-10-27 19:31:35 +00:00
|
|
|
handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
|
2011-10-13 20:30:40 +00:00
|
|
|
if ( handle ) {
|
|
|
|
handle.apply( cur, data );
|
|
|
|
}
|
2013-01-12 22:11:07 +00:00
|
|
|
|
|
|
|
// Native handler
|
2011-10-13 20:30:40 +00:00
|
|
|
handle = ontype && cur[ ontype ];
|
2012-09-18 18:26:21 +00:00
|
|
|
if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
|
2011-11-07 16:07:36 +00:00
|
|
|
event.preventDefault();
|
2011-10-13 20:30:40 +00:00
|
|
|
}
|
2011-09-08 00:57:37 +00:00
|
|
|
}
|
|
|
|
event.type = type;
|
2009-12-05 04:18:05 +00:00
|
|
|
|
2011-02-11 04:43:45 +00:00
|
|
|
// If nobody prevented the default action, do it now
|
2011-11-15 15:22:32 +00:00
|
|
|
if ( !onlyHandlers && !event.isDefaultPrevented() ) {
|
2010-01-28 19:34:09 +00:00
|
|
|
|
2013-04-07 02:56:03 +00:00
|
|
|
if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
|
|
|
|
jQuery.acceptData( elem ) ) {
|
2009-12-05 04:18:05 +00:00
|
|
|
|
2011-03-16 03:40:25 +00:00
|
|
|
// Call a native DOM method on the target with the same name name as the event.
|
2011-09-10 18:46:58 +00:00
|
|
|
// Can't use an .isFunction() check here because IE6/7 fails that test.
|
2011-09-08 14:18:36 +00:00
|
|
|
// Don't do default actions on window, that's where global variables be (#6170)
|
2012-10-15 15:54:32 +00:00
|
|
|
if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
|
2011-10-06 14:12:05 +00:00
|
|
|
|
2011-09-08 01:02:13 +00:00
|
|
|
// Don't re-trigger an onFOO event when we call its FOO() method
|
2013-01-12 22:11:07 +00:00
|
|
|
tmp = elem[ ontype ];
|
2010-01-25 18:45:07 +00:00
|
|
|
|
2013-01-12 22:11:07 +00:00
|
|
|
if ( tmp ) {
|
2011-09-08 01:02:13 +00:00
|
|
|
elem[ ontype ] = null;
|
2010-01-25 18:45:07 +00:00
|
|
|
}
|
|
|
|
|
2011-09-08 14:18:36 +00:00
|
|
|
// Prevent re-triggering of the same event, since we already bubbled it above
|
2011-09-08 01:02:13 +00:00
|
|
|
jQuery.event.triggered = type;
|
2012-10-15 15:54:32 +00:00
|
|
|
try {
|
|
|
|
elem[ type ]();
|
|
|
|
} catch ( e ) {
|
|
|
|
// IE<9 dies on focus/blur to hidden element (#1486,#12518)
|
|
|
|
// only reproducible on winXP IE8 native, not IE9 in IE8 mode
|
|
|
|
}
|
2011-09-08 14:18:36 +00:00
|
|
|
jQuery.event.triggered = undefined;
|
2011-09-08 01:02:13 +00:00
|
|
|
|
2013-01-12 22:11:07 +00:00
|
|
|
if ( tmp ) {
|
|
|
|
elem[ ontype ] = tmp;
|
2011-09-08 01:02:13 +00:00
|
|
|
}
|
2010-01-25 18:45:07 +00:00
|
|
|
}
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
2011-09-20 16:54:34 +00:00
|
|
|
|
2011-04-17 00:48:27 +00:00
|
|
|
return event.result;
|
2007-12-19 01:10:20 +00:00
|
|
|
},
|
|
|
|
|
2011-10-24 01:13:59 +00:00
|
|
|
dispatch: function( event ) {
|
2011-07-29 00:43:23 +00:00
|
|
|
|
|
|
|
// Make a writable jQuery.Event from the native event object
|
2012-10-20 14:01:31 +00:00
|
|
|
event = jQuery.event.fix( event );
|
2011-09-20 16:54:34 +00:00
|
|
|
|
2013-01-29 00:04:58 +00:00
|
|
|
var i, ret, handleObj, matched, j,
|
2013-01-12 22:11:07 +00:00
|
|
|
handlerQueue = [],
|
2013-08-15 18:15:49 +00:00
|
|
|
args = slice.call( arguments ),
|
2013-01-12 22:11:07 +00:00
|
|
|
handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
|
|
|
|
special = jQuery.event.special[ event.type ] || {};
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
// Use the fix-ed jQuery.Event rather than the (read-only) native event
|
2011-02-11 04:43:45 +00:00
|
|
|
args[0] = event;
|
2011-10-24 15:17:24 +00:00
|
|
|
event.delegateTarget = this;
|
2011-07-29 00:43:23 +00:00
|
|
|
|
2012-03-05 02:11:50 +00:00
|
|
|
// Call the preDispatch hook for the mapped type, and let it bail if desired
|
|
|
|
if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-13 19:01:43 +00:00
|
|
|
// Determine handlers
|
2013-01-13 18:11:43 +00:00
|
|
|
handlerQueue = jQuery.event.handlers.call( this, event, handlers );
|
2011-07-31 15:53:15 +00:00
|
|
|
|
2011-10-24 15:17:24 +00:00
|
|
|
// Run delegates first; they may want to stop propagation beneath us
|
2013-01-12 22:11:07 +00:00
|
|
|
i = 0;
|
|
|
|
while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
|
2011-10-24 15:17:24 +00:00
|
|
|
event.currentTarget = matched.elem;
|
|
|
|
|
2013-01-12 22:11:07 +00:00
|
|
|
j = 0;
|
|
|
|
while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
|
2011-10-24 01:13:59 +00:00
|
|
|
|
2012-11-01 20:53:39 +00:00
|
|
|
// Triggered event must either 1) have no namespace, or
|
2011-10-24 01:13:59 +00:00
|
|
|
// 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
|
2013-01-12 22:11:07 +00:00
|
|
|
if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
|
2011-10-24 01:13:59 +00:00
|
|
|
|
|
|
|
event.handleObj = handleObj;
|
2013-01-12 22:11:07 +00:00
|
|
|
event.data = handleObj.data;
|
2011-10-24 01:13:59 +00:00
|
|
|
|
2011-11-10 02:51:55 +00:00
|
|
|
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
|
|
|
|
.apply( matched.elem, args );
|
2011-10-24 01:13:59 +00:00
|
|
|
|
|
|
|
if ( ret !== undefined ) {
|
2013-01-12 22:11:07 +00:00
|
|
|
if ( (event.result = ret) === false ) {
|
2011-10-24 01:13:59 +00:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-07-31 15:53:15 +00:00
|
|
|
}
|
2011-07-29 00:43:23 +00:00
|
|
|
|
2012-03-05 02:11:50 +00:00
|
|
|
// Call the postDispatch hook for the mapped type
|
|
|
|
if ( special.postDispatch ) {
|
|
|
|
special.postDispatch.call( this, event );
|
|
|
|
}
|
|
|
|
|
2009-12-07 00:55:08 +00:00
|
|
|
return event.result;
|
2007-12-19 01:10:20 +00:00
|
|
|
},
|
|
|
|
|
2013-01-13 18:11:43 +00:00
|
|
|
handlers: function( event, handlers ) {
|
2013-01-29 00:04:58 +00:00
|
|
|
var sel, handleObj, matches, i,
|
2013-01-13 18:11:43 +00:00
|
|
|
handlerQueue = [],
|
2013-01-13 19:01:43 +00:00
|
|
|
delegateCount = handlers.delegateCount,
|
|
|
|
cur = event.target;
|
2013-01-13 18:11:43 +00:00
|
|
|
|
2013-01-13 19:01:43 +00:00
|
|
|
// Find delegate handlers
|
2013-01-13 19:32:38 +00:00
|
|
|
// Black-hole SVG <use> instance trees (#13180)
|
2013-01-13 18:11:43 +00:00
|
|
|
// Avoid non-left-click bubbling in Firefox (#3861)
|
2013-01-13 19:32:38 +00:00
|
|
|
if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
|
2013-01-13 18:11:43 +00:00
|
|
|
|
2013-03-13 23:23:36 +00:00
|
|
|
/* jshint eqeqeq: false */
|
2013-01-13 19:01:43 +00:00
|
|
|
for ( ; cur != this; cur = cur.parentNode || this ) {
|
2013-03-13 23:23:36 +00:00
|
|
|
/* jshint eqeqeq: true */
|
2013-01-13 18:11:43 +00:00
|
|
|
|
2013-01-16 05:14:57 +00:00
|
|
|
// Don't check non-elements (#13208)
|
2013-01-13 19:01:43 +00:00
|
|
|
// Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
|
2013-01-16 05:14:57 +00:00
|
|
|
if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
|
2013-01-13 18:11:43 +00:00
|
|
|
matches = [];
|
2013-01-13 19:01:43 +00:00
|
|
|
for ( i = 0; i < delegateCount; i++ ) {
|
2013-01-13 18:11:43 +00:00
|
|
|
handleObj = handlers[ i ];
|
2013-01-14 02:38:40 +00:00
|
|
|
|
|
|
|
// Don't conflict with Object.prototype properties (#13203)
|
|
|
|
sel = handleObj.selector + " ";
|
2013-01-13 18:11:43 +00:00
|
|
|
|
2013-01-13 19:01:43 +00:00
|
|
|
if ( matches[ sel ] === undefined ) {
|
|
|
|
matches[ sel ] = handleObj.needsContext ?
|
2013-01-13 18:11:43 +00:00
|
|
|
jQuery( sel, this ).index( cur ) >= 0 :
|
|
|
|
jQuery.find( sel, this, null, [ cur ] ).length;
|
|
|
|
}
|
2013-01-13 19:01:43 +00:00
|
|
|
if ( matches[ sel ] ) {
|
2013-01-13 18:11:43 +00:00
|
|
|
matches.push( handleObj );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( matches.length ) {
|
|
|
|
handlerQueue.push({ elem: cur, handlers: matches });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the remaining (directly-bound) handlers
|
2013-01-13 19:01:43 +00:00
|
|
|
if ( delegateCount < handlers.length ) {
|
2013-01-13 18:11:43 +00:00
|
|
|
handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
|
|
|
|
}
|
|
|
|
|
|
|
|
return handlerQueue;
|
|
|
|
},
|
|
|
|
|
2013-01-12 22:11:07 +00:00
|
|
|
fix: function( event ) {
|
|
|
|
if ( event[ jQuery.expando ] ) {
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a writable copy of the event object and normalize some properties
|
2013-01-27 04:48:59 +00:00
|
|
|
var i, prop, copy,
|
|
|
|
type = event.type,
|
2013-01-12 22:11:07 +00:00
|
|
|
originalEvent = event,
|
2013-01-27 04:48:59 +00:00
|
|
|
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;
|
2013-01-12 22:11:07 +00:00
|
|
|
|
|
|
|
event = new jQuery.Event( originalEvent );
|
|
|
|
|
|
|
|
i = copy.length;
|
|
|
|
while ( i-- ) {
|
|
|
|
prop = copy[ i ];
|
|
|
|
event[ prop ] = originalEvent[ prop ];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Support: IE<9
|
|
|
|
// Fix target property (#1925)
|
|
|
|
if ( !event.target ) {
|
|
|
|
event.target = originalEvent.srcElement || document;
|
|
|
|
}
|
|
|
|
|
2013-01-14 01:05:43 +00:00
|
|
|
// Support: Chrome 23+, Safari?
|
|
|
|
// Target should not be a text node (#504, #13143)
|
2013-01-12 22:11:07 +00:00
|
|
|
if ( event.target.nodeType === 3 ) {
|
|
|
|
event.target = event.target.parentNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Support: IE<9
|
|
|
|
// For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
|
|
|
|
event.metaKey = !!event.metaKey;
|
|
|
|
|
|
|
|
return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
|
|
|
|
},
|
|
|
|
|
2011-09-25 23:56:34 +00:00
|
|
|
// Includes some event props shared by KeyEvent and MouseEvent
|
2012-11-01 21:51:34 +00:00
|
|
|
props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
|
2008-05-28 20:43:13 +00:00
|
|
|
|
2011-10-06 01:41:32 +00:00
|
|
|
fixHooks: {},
|
2008-05-28 20:43:13 +00:00
|
|
|
|
2011-09-25 23:56:34 +00:00
|
|
|
keyHooks: {
|
|
|
|
props: "char charCode key keyCode".split(" "),
|
|
|
|
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: {
|
2011-11-07 16:15:18 +00:00
|
|
|
props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
|
2011-09-25 23:56:34 +00:00
|
|
|
filter: function( event, original ) {
|
2013-01-29 00:04:58 +00:00
|
|
|
var body, eventDoc, doc,
|
2011-09-26 02:04:52 +00:00
|
|
|
button = original.button,
|
|
|
|
fromElement = original.fromElement;
|
2011-09-25 23:56:34 +00:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2011-10-27 19:31:35 +00:00
|
|
|
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 );
|
2011-09-25 23:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add relatedTarget, if necessary
|
2011-09-26 02:04:52 +00:00
|
|
|
if ( !event.relatedTarget && fromElement ) {
|
|
|
|
event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
|
2011-09-25 23:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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 ) {
|
2011-10-06 14:12:05 +00:00
|
|
|
event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
|
2011-09-25 23:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
special: {
|
2011-11-09 00:32:25 +00:00
|
|
|
load: {
|
|
|
|
// Prevent triggered image.load events from bubbling to window.load
|
|
|
|
noBubble: true
|
|
|
|
},
|
2011-08-13 14:46:34 +00:00
|
|
|
focus: {
|
2012-11-23 20:03:55 +00:00
|
|
|
// Fire native event if possible so blur/focus sequence is correct
|
|
|
|
trigger: function() {
|
2013-04-09 01:33:25 +00:00
|
|
|
if ( this !== safeActiveElement() && this.focus ) {
|
2012-11-23 20:03:55 +00:00
|
|
|
try {
|
|
|
|
this.focus();
|
|
|
|
return false;
|
|
|
|
} catch ( e ) {
|
2013-01-12 22:11:07 +00:00
|
|
|
// Support: IE<9
|
|
|
|
// If we error on focus to hidden element (#1486, #12518),
|
|
|
|
// let .trigger() run the handlers
|
2012-11-23 20:03:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2011-11-09 04:08:04 +00:00
|
|
|
delegateType: "focusin"
|
2011-08-13 14:46:34 +00:00
|
|
|
},
|
|
|
|
blur: {
|
2012-11-23 20:03:55 +00:00
|
|
|
trigger: function() {
|
2013-04-09 01:33:25 +00:00
|
|
|
if ( this === safeActiveElement() && this.blur ) {
|
2012-11-23 20:03:55 +00:00
|
|
|
this.blur();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
2011-11-09 04:08:04 +00:00
|
|
|
delegateType: "focusout"
|
2011-08-13 14:46:34 +00:00
|
|
|
},
|
2013-04-07 02:56:03 +00:00
|
|
|
click: {
|
|
|
|
// For checkbox, fire native event so checked state will be right
|
|
|
|
trigger: function() {
|
|
|
|
if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
|
|
|
|
this.click();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// For cross-browser consistency, don't fire native .click() on links
|
|
|
|
_default: function( event ) {
|
|
|
|
return jQuery.nodeName( event.target, "a" );
|
|
|
|
}
|
|
|
|
},
|
2010-02-05 02:36:32 +00:00
|
|
|
|
2009-12-07 00:55:08 +00:00
|
|
|
beforeunload: {
|
2012-08-14 20:10:10 +00:00
|
|
|
postDispatch: function( event ) {
|
2010-02-27 15:03:43 +00:00
|
|
|
|
2012-08-14 20:10:10 +00:00
|
|
|
// Even when returnValue equals to undefined Firefox will still show alert
|
|
|
|
if ( event.result !== undefined ) {
|
|
|
|
event.originalEvent.returnValue = event.result;
|
2009-12-07 00:55:08 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-22 04:59:34 +00:00
|
|
|
}
|
2011-09-28 16:04:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
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.
|
2011-10-06 14:12:05 +00:00
|
|
|
var e = jQuery.extend(
|
|
|
|
new jQuery.Event(),
|
|
|
|
event,
|
2013-02-26 18:06:58 +00:00
|
|
|
{
|
|
|
|
type: type,
|
2011-10-06 14:12:05 +00:00
|
|
|
isSimulated: true,
|
|
|
|
originalEvent: {}
|
|
|
|
}
|
2011-09-28 16:04:27 +00:00
|
|
|
);
|
|
|
|
if ( bubble ) {
|
|
|
|
jQuery.event.trigger( e, null, elem );
|
|
|
|
} else {
|
2011-10-24 01:13:59 +00:00
|
|
|
jQuery.event.dispatch.call( elem, e );
|
2011-09-28 16:04:27 +00:00
|
|
|
}
|
|
|
|
if ( e.isDefaultPrevented() ) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-09-08 22:13:35 +00:00
|
|
|
jQuery.removeEvent = document.removeEventListener ?
|
2010-01-28 20:25:52 +00:00
|
|
|
function( elem, type, handle ) {
|
2010-02-26 16:32:12 +00:00
|
|
|
if ( elem.removeEventListener ) {
|
|
|
|
elem.removeEventListener( type, handle, false );
|
|
|
|
}
|
2010-12-26 20:28:13 +00:00
|
|
|
} :
|
2010-01-28 20:25:52 +00:00
|
|
|
function( elem, type, handle ) {
|
2012-04-05 01:17:01 +00:00
|
|
|
var name = "on" + type;
|
|
|
|
|
2010-02-26 16:32:12 +00:00
|
|
|
if ( elem.detachEvent ) {
|
2012-04-05 01:17:01 +00:00
|
|
|
|
2012-10-10 17:00:45 +00:00
|
|
|
// #8545, #7054, preventing memory leaks for custom events in IE6-8
|
2012-04-05 01:17:01 +00:00
|
|
|
// detachEvent needed property on element, by name of that event, to properly expose it to GC
|
2013-08-15 18:15:49 +00:00
|
|
|
if ( typeof elem[ name ] === strundefined ) {
|
2012-04-05 01:17:01 +00:00
|
|
|
elem[ name ] = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
elem.detachEvent( name, handle );
|
2010-02-26 16:32:12 +00:00
|
|
|
}
|
2010-01-28 20:25:52 +00:00
|
|
|
};
|
|
|
|
|
2011-04-12 23:29:09 +00:00
|
|
|
jQuery.Event = function( src, props ) {
|
2008-12-29 21:57:29 +00:00
|
|
|
// Allow instantiation without the 'new' keyword
|
2011-07-29 00:43:23 +00:00
|
|
|
if ( !(this instanceof jQuery.Event) ) {
|
2011-04-12 23:29:09 +00:00
|
|
|
return new jQuery.Event( src, props );
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2008-12-25 21:44:54 +00:00
|
|
|
// Event object
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( src && src.type ) {
|
2008-12-25 21:44:54 +00:00
|
|
|
this.originalEvent = src;
|
2011-04-11 15:32:23 +00:00
|
|
|
this.type = src.type;
|
|
|
|
|
2010-12-27 19:30:05 +00:00
|
|
|
// Events bubbling up the document may have been marked as prevented
|
|
|
|
// by a handler lower down the tree; reflect the correct value.
|
2011-10-06 14:12:05 +00:00
|
|
|
this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
|
|
|
|
src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
|
2010-12-27 19:30:05 +00:00
|
|
|
|
2008-12-25 21:44:54 +00:00
|
|
|
// Event type
|
2009-04-30 01:26:09 +00:00
|
|
|
} else {
|
2008-12-25 21:44:54 +00:00
|
|
|
this.type = src;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2008-12-25 21:44:54 +00:00
|
|
|
|
2011-04-12 23:29:09 +00:00
|
|
|
// Put explicitly provided properties onto the event object
|
|
|
|
if ( props ) {
|
|
|
|
jQuery.extend( this, props );
|
|
|
|
}
|
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
// Create a timestamp if incoming event doesn't have one
|
2011-09-08 19:59:23 +00:00
|
|
|
this.timeStamp = src && src.timeStamp || jQuery.now();
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2008-12-25 21:44:54 +00:00
|
|
|
// Mark it as fixed
|
2010-04-24 21:15:45 +00:00
|
|
|
this[ jQuery.expando ] = true;
|
2008-12-25 21:44:54 +00:00
|
|
|
};
|
2008-10-18 22:46:04 +00:00
|
|
|
|
2008-12-31 02:58:13 +00:00
|
|
|
// 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
|
2008-12-25 21:44:54 +00:00
|
|
|
jQuery.Event.prototype = {
|
2013-01-12 22:11:07 +00:00
|
|
|
isDefaultPrevented: returnFalse,
|
|
|
|
isPropagationStopped: returnFalse,
|
|
|
|
isImmediatePropagationStopped: returnFalse,
|
2008-12-31 02:58:13 +00:00
|
|
|
|
2013-01-12 22:11:07 +00:00
|
|
|
preventDefault: function() {
|
2008-12-25 21:44:54 +00:00
|
|
|
var e = this.originalEvent;
|
2013-01-12 22:11:07 +00:00
|
|
|
|
|
|
|
this.isDefaultPrevented = returnTrue;
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( !e ) {
|
2008-12-25 21:44:54 +00:00
|
|
|
return;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2013-01-12 22:11:07 +00:00
|
|
|
// If preventDefault exists, run it on the original event
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( e.preventDefault ) {
|
2008-12-25 21:44:54 +00:00
|
|
|
e.preventDefault();
|
2010-09-20 14:16:36 +00:00
|
|
|
|
2013-01-12 22:11:07 +00:00
|
|
|
// Support: IE
|
|
|
|
// Otherwise set the returnValue property of the original event to false
|
2010-09-20 14:16:36 +00:00
|
|
|
} else {
|
|
|
|
e.returnValue = false;
|
|
|
|
}
|
2008-12-25 21:44:54 +00:00
|
|
|
},
|
|
|
|
stopPropagation: function() {
|
|
|
|
var e = this.originalEvent;
|
2013-01-12 22:11:07 +00:00
|
|
|
|
|
|
|
this.isPropagationStopped = returnTrue;
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( !e ) {
|
2008-12-25 21:44:54 +00:00
|
|
|
return;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2013-01-12 22:11:07 +00:00
|
|
|
// If stopPropagation exists, run it on the original event
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( e.stopPropagation ) {
|
2008-12-25 21:44:54 +00:00
|
|
|
e.stopPropagation();
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2013-01-12 22:11:07 +00:00
|
|
|
|
|
|
|
// Support: IE
|
|
|
|
// Set the cancelBubble property of the original event to true
|
2008-12-25 21:44:54 +00:00
|
|
|
e.cancelBubble = true;
|
|
|
|
},
|
2009-12-22 00:58:13 +00:00
|
|
|
stopImmediatePropagation: function() {
|
2008-12-31 02:58:13 +00:00
|
|
|
this.isImmediatePropagationStopped = returnTrue;
|
2008-12-25 21:44:54 +00:00
|
|
|
this.stopPropagation();
|
2013-01-12 22:11:07 +00:00
|
|
|
}
|
2008-12-25 21:44:54 +00:00
|
|
|
};
|
2009-12-21 23:06:23 +00:00
|
|
|
|
2011-09-08 13:03:16 +00:00
|
|
|
// Create mouseenter/leave events using mouseover/out and event-time checks
|
2009-03-23 01:55:17 +00:00
|
|
|
jQuery.each({
|
2009-11-30 20:04:55 +00:00
|
|
|
mouseenter: "mouseover",
|
|
|
|
mouseleave: "mouseout"
|
2009-04-30 01:26:09 +00:00
|
|
|
}, function( orig, fix ) {
|
2011-11-10 02:51:55 +00:00
|
|
|
jQuery.event.special[ orig ] = {
|
2011-08-13 14:46:34 +00:00
|
|
|
delegateType: fix,
|
|
|
|
bindType: fix,
|
|
|
|
|
2011-08-14 19:20:12 +00:00
|
|
|
handle: function( event ) {
|
2012-07-10 01:38:11 +00:00
|
|
|
var ret,
|
|
|
|
target = this,
|
2011-08-13 14:46:34 +00:00
|
|
|
related = event.relatedTarget,
|
2012-10-17 16:50:12 +00:00
|
|
|
handleObj = event.handleObj;
|
2011-08-13 14:46:34 +00:00
|
|
|
|
2011-11-10 02:51:55 +00:00
|
|
|
// For mousenter/leave call the handler if related is outside the target.
|
2011-09-08 02:49:32 +00:00
|
|
|
// NB: No relatedTarget if the mouse left/entered the browser window
|
2011-11-10 02:51:55 +00:00
|
|
|
if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
|
2011-08-13 14:46:34 +00:00
|
|
|
event.type = handleObj.origType;
|
2011-08-14 19:20:12 +00:00
|
|
|
ret = handleObj.handler.apply( this, arguments );
|
2011-11-10 02:51:55 +00:00
|
|
|
event.type = fix;
|
2011-08-13 14:46:34 +00:00
|
|
|
}
|
2011-08-14 19:20:12 +00:00
|
|
|
return ret;
|
2008-12-21 21:22:44 +00:00
|
|
|
}
|
2009-03-23 01:55:17 +00:00
|
|
|
};
|
2008-12-21 21:22:44 +00:00
|
|
|
});
|
2008-07-28 18:31:25 +00:00
|
|
|
|
2011-09-22 01:15:00 +00:00
|
|
|
// IE submit delegation
|
2013-09-02 17:21:09 +00:00
|
|
|
if ( !support.submitBubbles ) {
|
2009-12-07 02:20:08 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
jQuery.event.special.submit = {
|
2011-08-13 14:46:34 +00:00
|
|
|
setup: function() {
|
2011-08-16 19:40:09 +00:00
|
|
|
// Only need this for delegated form submit events
|
2011-08-13 14:46:34 +00:00
|
|
|
if ( jQuery.nodeName( this, "form" ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2011-09-22 01:15:00 +00:00
|
|
|
// Lazy-add a submit handler when a descendant form may potentially be submitted
|
2011-09-08 03:21:33 +00:00
|
|
|
jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
|
2011-09-22 01:15:00 +00:00
|
|
|
// Node name check avoids a VML-related crash in IE (#9807)
|
2011-08-13 14:46:34 +00:00
|
|
|
var elem = e.target,
|
2011-09-22 01:15:00 +00:00
|
|
|
form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
|
2013-01-12 22:11:07 +00:00
|
|
|
if ( form && !jQuery._data( form, "submitBubbles" ) ) {
|
2011-09-22 01:15:00 +00:00
|
|
|
jQuery.event.add( form, "submit._submit", function( event ) {
|
2012-03-05 02:11:50 +00:00
|
|
|
event._submit_bubble = true;
|
2011-09-22 01:15:00 +00:00
|
|
|
});
|
2013-01-12 22:11:07 +00:00
|
|
|
jQuery._data( form, "submitBubbles", true );
|
2011-08-13 14:46:34 +00:00
|
|
|
}
|
|
|
|
});
|
2011-09-22 01:15:00 +00:00
|
|
|
// return undefined since we don't need an event listener
|
2010-02-09 04:28:15 +00:00
|
|
|
},
|
2012-05-12 17:38:33 +00:00
|
|
|
|
2012-03-05 02:11:50 +00:00
|
|
|
postDispatch: function( event ) {
|
|
|
|
// If form was submitted by the user, bubble the event up the tree
|
|
|
|
if ( event._submit_bubble ) {
|
|
|
|
delete event._submit_bubble;
|
|
|
|
if ( this.parentNode && !event.isTrigger ) {
|
|
|
|
jQuery.event.simulate( "submit", this.parentNode, event, true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2009-12-04 16:28:50 +00:00
|
|
|
|
2011-08-13 14:46:34 +00:00
|
|
|
teardown: function() {
|
2011-09-22 01:15:00 +00:00
|
|
|
// Only need this for delegated form submit events
|
|
|
|
if ( jQuery.nodeName( this, "form" ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove delegated handlers; cleanData eventually reaps submit handlers attached above
|
2011-08-06 14:19:49 +00:00
|
|
|
jQuery.event.remove( this, "._submit" );
|
2010-02-09 04:28:15 +00:00
|
|
|
}
|
|
|
|
};
|
2009-12-07 02:20:08 +00:00
|
|
|
}
|
|
|
|
|
2011-09-20 02:50:29 +00:00
|
|
|
// IE change delegation and checkbox/radio fix
|
2013-09-02 17:21:09 +00:00
|
|
|
if ( !support.changeBubbles ) {
|
2009-12-07 02:20:08 +00:00
|
|
|
|
2011-08-06 14:19:49 +00:00
|
|
|
jQuery.event.special.change = {
|
|
|
|
|
2011-09-20 02:50:29 +00:00
|
|
|
setup: function() {
|
|
|
|
|
|
|
|
if ( rformElems.test( this.nodeName ) ) {
|
2011-09-21 02:18:34 +00:00
|
|
|
// IE doesn't fire change on a check/radio until blur; trigger it on click
|
|
|
|
// after a propertychange. Eat the blur-change in special.change.handle.
|
|
|
|
// This still fires onchange a second time for check/radio after blur.
|
2011-09-20 02:50:29 +00:00
|
|
|
if ( this.type === "checkbox" || this.type === "radio" ) {
|
2011-09-21 02:18:34 +00:00
|
|
|
jQuery.event.add( this, "propertychange._change", function( event ) {
|
|
|
|
if ( event.originalEvent.propertyName === "checked" ) {
|
|
|
|
this._just_changed = true;
|
|
|
|
}
|
|
|
|
});
|
2011-09-20 02:50:29 +00:00
|
|
|
jQuery.event.add( this, "click._change", function( event ) {
|
2011-11-16 02:06:53 +00:00
|
|
|
if ( this._just_changed && !event.isTrigger ) {
|
2011-09-21 02:18:34 +00:00
|
|
|
this._just_changed = false;
|
|
|
|
}
|
2012-04-11 01:54:07 +00:00
|
|
|
// Allow triggered, simulated change events (#11500)
|
|
|
|
jQuery.event.simulate( "change", this, event, true );
|
2011-09-20 02:50:29 +00:00
|
|
|
});
|
|
|
|
}
|
2010-02-13 09:40:26 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-09-20 02:50:29 +00:00
|
|
|
// Delegated event; lazy-add a change handler on descendant inputs
|
|
|
|
jQuery.event.add( this, "beforeactivate._change", function( e ) {
|
|
|
|
var elem = e.target;
|
|
|
|
|
2013-01-12 22:11:07 +00:00
|
|
|
if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
|
2011-09-20 02:50:29 +00:00
|
|
|
jQuery.event.add( elem, "change._change", function( event ) {
|
2011-11-16 02:06:53 +00:00
|
|
|
if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
|
2011-09-28 16:04:27 +00:00
|
|
|
jQuery.event.simulate( "change", this.parentNode, event, true );
|
2011-09-20 02:50:29 +00:00
|
|
|
}
|
|
|
|
});
|
2013-01-12 22:11:07 +00:00
|
|
|
jQuery._data( elem, "changeBubbles", true );
|
2011-09-20 02:50:29 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2011-10-06 14:12:05 +00:00
|
|
|
|
2011-09-20 02:50:29 +00:00
|
|
|
handle: function( event ) {
|
|
|
|
var elem = event.target;
|
2011-09-12 01:18:32 +00:00
|
|
|
|
2011-09-20 02:50:29 +00:00
|
|
|
// Swallow native change events from checkbox/radio, we already triggered them above
|
2011-09-21 03:01:07 +00:00
|
|
|
if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
|
2011-09-20 02:50:29 +00:00
|
|
|
return event.handleObj.handler.apply( this, arguments );
|
2010-02-09 04:28:15 +00:00
|
|
|
}
|
|
|
|
},
|
2009-12-21 20:32:32 +00:00
|
|
|
|
2011-09-20 02:50:29 +00:00
|
|
|
teardown: function() {
|
2011-08-06 14:19:49 +00:00
|
|
|
jQuery.event.remove( this, "._change" );
|
2011-09-12 01:18:32 +00:00
|
|
|
|
2012-08-20 00:19:44 +00:00
|
|
|
return !rformElems.test( this.nodeName );
|
2009-09-16 08:33:00 +00:00
|
|
|
}
|
2010-02-09 04:28:15 +00:00
|
|
|
};
|
2009-12-07 15:38:16 +00:00
|
|
|
}
|
|
|
|
|
2009-09-14 22:04:22 +00:00
|
|
|
// Create "bubbling" focus and blur events
|
2013-09-02 17:21:09 +00:00
|
|
|
if ( !support.focusinBubbles ) {
|
2009-12-22 00:58:13 +00:00
|
|
|
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
|
2011-04-05 19:55:40 +00:00
|
|
|
|
2011-03-05 02:16:40 +00:00
|
|
|
// Attach a single capturing handler while someone wants focusin/focusout
|
2011-08-17 00:26:14 +00:00
|
|
|
var attaches = 0,
|
|
|
|
handler = function( event ) {
|
2011-09-28 16:04:27 +00:00
|
|
|
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
|
2011-08-17 00:26:14 +00:00
|
|
|
};
|
2011-04-05 19:55:40 +00:00
|
|
|
|
2009-12-21 21:10:21 +00:00
|
|
|
jQuery.event.special[ fix ] = {
|
|
|
|
setup: function() {
|
2011-03-05 02:16:40 +00:00
|
|
|
if ( attaches++ === 0 ) {
|
|
|
|
document.addEventListener( orig, handler, true );
|
|
|
|
}
|
2011-02-07 16:48:38 +00:00
|
|
|
},
|
|
|
|
teardown: function() {
|
2011-03-05 02:16:40 +00:00
|
|
|
if ( --attaches === 0 ) {
|
|
|
|
document.removeEventListener( orig, handler, true );
|
|
|
|
}
|
2009-12-21 21:10:21 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
2009-12-07 02:02:58 +00:00
|
|
|
}
|
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
jQuery.fn.extend({
|
|
|
|
|
|
|
|
on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
|
2013-01-25 02:26:16 +00:00
|
|
|
var type, origFn;
|
2010-12-15 02:53:04 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
// Types can be a map of types/handlers
|
|
|
|
if ( typeof types === "object" ) {
|
|
|
|
// ( types-Object, selector, data )
|
2013-01-12 22:11:07 +00:00
|
|
|
if ( typeof selector !== "string" ) {
|
2011-07-29 00:43:23 +00:00
|
|
|
// ( types-Object, data )
|
2012-01-13 01:30:45 +00:00
|
|
|
data = data || selector;
|
2011-07-29 00:43:23 +00:00
|
|
|
selector = undefined;
|
|
|
|
}
|
|
|
|
for ( type in types ) {
|
2011-09-08 03:21:33 +00:00
|
|
|
this.on( type, selector, data, types[ type ], one );
|
2009-09-16 02:19:18 +00:00
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
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;
|
2009-05-07 00:50:28 +00:00
|
|
|
}
|
2009-12-31 05:37:23 +00:00
|
|
|
|
2011-09-01 21:52:13 +00:00
|
|
|
if ( one === 1 ) {
|
2011-07-29 00:43:23 +00:00
|
|
|
origFn = fn;
|
|
|
|
fn = function( event ) {
|
2011-10-24 02:25:13 +00:00
|
|
|
// Can use an empty set, since event contains the info
|
|
|
|
jQuery().off( event );
|
2011-07-29 00:43:23 +00:00
|
|
|
return origFn.apply( this, arguments );
|
2010-12-15 02:53:04 +00:00
|
|
|
};
|
2011-07-29 00:43:23 +00:00
|
|
|
// Use same guid so caller can remove using origFn
|
2011-09-08 03:21:33 +00:00
|
|
|
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
|
2010-12-15 02:53:04 +00:00
|
|
|
}
|
2011-07-29 00:43:23 +00:00
|
|
|
return this.each( function() {
|
|
|
|
jQuery.event.add( this, types, fn, data, selector );
|
|
|
|
});
|
|
|
|
},
|
|
|
|
one: function( types, selector, data, fn ) {
|
2011-11-17 19:28:22 +00:00
|
|
|
return this.on( types, selector, data, fn, 1 );
|
2011-07-29 00:43:23 +00:00
|
|
|
},
|
|
|
|
off: function( types, selector, fn ) {
|
2012-07-10 01:38:11 +00:00
|
|
|
var handleObj, type;
|
2011-10-24 02:25:13 +00:00
|
|
|
if ( types && types.preventDefault && types.handleObj ) {
|
|
|
|
// ( event ) dispatched jQuery.Event
|
2012-07-10 01:38:11 +00:00
|
|
|
handleObj = types.handleObj;
|
2011-10-27 19:31:35 +00:00
|
|
|
jQuery( types.delegateTarget ).off(
|
2011-12-14 02:40:59 +00:00
|
|
|
handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
|
2011-10-27 19:31:35 +00:00
|
|
|
handleObj.selector,
|
2011-10-24 02:25:13 +00:00
|
|
|
handleObj.handler
|
|
|
|
);
|
|
|
|
return this;
|
2011-07-29 00:43:23 +00:00
|
|
|
}
|
|
|
|
if ( typeof types === "object" ) {
|
|
|
|
// ( types-object [, selector] )
|
2012-07-10 01:38:11 +00:00
|
|
|
for ( type in types ) {
|
2011-09-08 03:21:33 +00:00
|
|
|
this.off( type, selector, types[ type ] );
|
2010-01-28 19:12:44 +00:00
|
|
|
}
|
2011-07-29 00:43:23 +00:00
|
|
|
return this;
|
2010-01-28 19:12:44 +00:00
|
|
|
}
|
2011-10-12 00:30:07 +00:00
|
|
|
if ( selector === false || typeof selector === "function" ) {
|
2011-07-29 00:43:23 +00:00
|
|
|
// ( types [, fn] )
|
|
|
|
fn = selector;
|
|
|
|
selector = undefined;
|
2009-09-16 02:19:18 +00:00
|
|
|
}
|
2011-07-29 00:43:23 +00:00
|
|
|
if ( fn === false ) {
|
|
|
|
fn = returnFalse;
|
|
|
|
}
|
|
|
|
return this.each(function() {
|
|
|
|
jQuery.event.remove( this, types, fn, selector );
|
|
|
|
});
|
|
|
|
},
|
2011-09-20 16:54:34 +00:00
|
|
|
|
2009-01-02 22:23:52 +00:00
|
|
|
trigger: function( type, data ) {
|
2010-01-11 18:48:40 +00:00
|
|
|
return this.each(function() {
|
2009-01-02 22:23:52 +00:00
|
|
|
jQuery.event.trigger( type, data, this );
|
2007-12-19 01:10:20 +00:00
|
|
|
});
|
|
|
|
},
|
2009-01-02 22:23:52 +00:00
|
|
|
triggerHandler: function( type, data ) {
|
2013-01-12 22:11:07 +00:00
|
|
|
var elem = this[0];
|
|
|
|
if ( elem ) {
|
|
|
|
return jQuery.event.trigger( type, data, elem, true );
|
2009-03-23 01:55:17 +00:00
|
|
|
}
|
2011-09-25 23:56:34 +00:00
|
|
|
}
|
|
|
|
});
|
2013-08-15 18:15:49 +00:00
|
|
|
|
|
|
|
});
|