2010-09-08 17:54:33 +00:00
|
|
|
(function( jQuery ) {
|
|
|
|
|
2011-11-06 19:49:31 +00:00
|
|
|
var rformElems = /^(?:textarea|input|select)$/i,
|
2011-07-29 00:43:23 +00:00
|
|
|
rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,
|
2011-11-10 23:05:58 +00:00
|
|
|
rhoverHack = /\bhover(\.\S+)?\b/,
|
2011-09-25 23:56:34 +00:00
|
|
|
rkeyEvent = /^key/,
|
|
|
|
rmouseEvent = /^(?:mouse|contextmenu)|click/,
|
2011-11-09 04:08:04 +00:00
|
|
|
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
|
2011-10-24 22:05:53 +00:00
|
|
|
rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
|
2011-08-14 19:52:57 +00:00
|
|
|
quickParse = function( selector ) {
|
|
|
|
var quick = rquickIs.exec( selector );
|
|
|
|
if ( quick ) {
|
2011-10-24 22:05:53 +00:00
|
|
|
// 0 1 2 3
|
|
|
|
// [ _, tag, id, class ]
|
2011-08-14 19:52:57 +00:00
|
|
|
quick[1] = ( quick[1] || "" ).toLowerCase();
|
2011-10-24 22:05:53 +00:00
|
|
|
quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" );
|
2011-08-14 19:52:57 +00:00
|
|
|
}
|
|
|
|
return quick;
|
|
|
|
},
|
|
|
|
quickIs = function( elem, m ) {
|
|
|
|
return (
|
2011-09-20 16:54:34 +00:00
|
|
|
(!m[1] || elem.nodeName.toLowerCase() === m[1]) &&
|
|
|
|
(!m[2] || elem.id === m[2]) &&
|
2011-10-24 22:05:53 +00:00
|
|
|
(!m[3] || m[3].test( elem.className ))
|
2011-08-14 19:52:57 +00:00
|
|
|
);
|
2011-10-27 21:11:40 +00:00
|
|
|
},
|
|
|
|
hoverHack = function( events ) {
|
|
|
|
return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
|
2011-08-16 19:40:09 +00:00
|
|
|
};
|
2009-12-22 00:58:13 +00:00
|
|
|
|
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 = {
|
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
add: function( elem, types, handler, data, selector ) {
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
var elemData, eventHandle, events,
|
|
|
|
t, tns, type, namespaces, handleObj,
|
|
|
|
handleObjIn, quick, handlers, special;
|
|
|
|
|
|
|
|
// Don't attach events to noData or text/comment nodes (allow plain objects tho)
|
|
|
|
if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
|
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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
events = elemData.events;
|
2011-02-07 16:48:38 +00:00
|
|
|
if ( !events ) {
|
2010-09-29 13:46:25 +00:00
|
|
|
elemData.events = events = {};
|
|
|
|
}
|
2011-07-29 00:43:23 +00:00
|
|
|
eventHandle = elemData.handle;
|
2010-02-04 05:20:52 +00:00
|
|
|
if ( !eventHandle ) {
|
2011-03-05 02:16:40 +00:00
|
|
|
elemData.handle = eventHandle = 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
|
2011-04-17 17:21:46 +00:00
|
|
|
return typeof jQuery !== "undefined" && (!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
|
|
|
|
// jQuery(...).bind("mouseover mouseout", fn);
|
2011-11-10 02:29:15 +00:00
|
|
|
types = jQuery.trim( hoverHack(types) ).split( " " );
|
2011-07-29 00:43:23 +00:00
|
|
|
for ( t = 0; t < types.length; t++ ) {
|
|
|
|
|
2011-10-06 14:12:05 +00:00
|
|
|
tns = rtypenamespace.exec( types[t] ) || [];
|
2011-07-29 00:43:23 +00:00
|
|
|
type = tns[1];
|
2011-10-27 19:31:35 +00:00
|
|
|
namespaces = ( tns[2] || "" ).split( "." ).sort();
|
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,
|
|
|
|
origType: tns[1],
|
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,
|
2011-11-07 01:12:00 +00:00
|
|
|
quick: quickParse( 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
|
|
|
|
handlers = events[ type ];
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( !handlers ) {
|
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
|
|
|
},
|
|
|
|
|
|
|
|
global: {},
|
|
|
|
|
|
|
|
// Detach an event or set of events from an element
|
2011-07-29 00:43:23 +00:00
|
|
|
remove: function( elem, types, handler, selector ) {
|
2010-01-28 19:12:44 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
var elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
|
2011-11-11 02:53:07 +00:00
|
|
|
t, tns, type, origType, namespaces, origCount,
|
2011-07-29 00:43:23 +00:00
|
|
|
j, events, special, handle, eventType, handleObj;
|
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
|
2011-11-10 02:29:15 +00:00
|
|
|
types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
|
2011-07-29 00:43:23 +00:00
|
|
|
for ( t = 0; t < types.length; t++ ) {
|
|
|
|
tns = rtypenamespace.exec( types[t] ) || [];
|
2011-11-11 02:53:07 +00:00
|
|
|
type = origType = tns[1];
|
2011-07-29 00:43:23 +00:00
|
|
|
namespaces = tns[2];
|
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-07-29 00:43:23 +00:00
|
|
|
namespaces = namespaces? "." + namespaces : "";
|
|
|
|
for ( j in events ) {
|
|
|
|
jQuery.event.remove( elem, j + namespaces, handler, selector );
|
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 ] || {};
|
2011-10-06 14:12:05 +00:00
|
|
|
type = ( selector? special.delegateType : special.bindType ) || type;
|
2011-07-29 00:43:23 +00:00
|
|
|
eventType = events[ type ] || [];
|
2011-09-07 03:20:48 +00:00
|
|
|
origCount = eventType.length;
|
2011-10-06 14:12:05 +00:00
|
|
|
namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2011-11-14 01:50:36 +00:00
|
|
|
// Remove matching events
|
|
|
|
for ( j = 0; j < eventType.length; j++ ) {
|
|
|
|
handleObj = eventType[ j ];
|
|
|
|
|
|
|
|
if ( origType === handleObj.origType &&
|
|
|
|
( !handler || handler.guid === handleObj.guid ) &&
|
|
|
|
( !namespaces || namespaces.test( handleObj.namespace ) ) &&
|
|
|
|
( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
|
|
|
|
eventType.splice( j--, 1 );
|
|
|
|
|
|
|
|
if ( handleObj.selector ) {
|
|
|
|
eventType.delegateCount--;
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
if ( eventType.length === 0 && origCount !== eventType.length ) {
|
2010-02-04 05:20:52 +00:00
|
|
|
if ( !special.teardown || special.teardown.call( elem, namespaces ) === 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 ) ) {
|
|
|
|
handle = elemData.handle;
|
|
|
|
if ( handle ) {
|
|
|
|
handle.elem = null;
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
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
|
|
|
|
jQuery.removeData( elem, [ "events", "handle" ], true );
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
|
|
|
},
|
2011-09-20 16:54:34 +00:00
|
|
|
|
2011-04-07 03:41:47 +00:00
|
|
|
// Events that are safe to short-circuit if no handlers are attached.
|
|
|
|
// Native DOM events should not be added, they may have inline handlers.
|
|
|
|
customEvent: {
|
|
|
|
"getData": true,
|
|
|
|
"setData": true,
|
|
|
|
"changeData": true
|
|
|
|
},
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2011-04-17 00:48:27 +00:00
|
|
|
trigger: function( event, data, elem, onlyHandlers ) {
|
2011-08-13 14:46:34 +00:00
|
|
|
// Don't do events on text and comment nodes
|
|
|
|
if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-25 21:44:54 +00:00
|
|
|
// Event object or event type
|
2009-05-10 14:38:35 +00:00
|
|
|
var type = event.type || event,
|
2011-04-11 15:15:00 +00:00
|
|
|
namespaces = [],
|
2011-10-13 20:30:40 +00:00
|
|
|
cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType;
|
2011-04-06 15:34:41 +00:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-09-08 03:21:33 +00:00
|
|
|
if ( type.indexOf( "!" ) >= 0 ) {
|
2011-04-11 15:15:00 +00:00
|
|
|
// Exclusive events trigger only for the exact event (no namespaces)
|
|
|
|
type = type.slice(0, -1);
|
|
|
|
exclusive = true;
|
2011-04-06 15:34:41 +00:00
|
|
|
}
|
2011-04-12 18:58:55 +00:00
|
|
|
|
2011-09-08 03:21:33 +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();
|
|
|
|
}
|
2011-04-07 03:41:47 +00:00
|
|
|
|
2011-04-17 00:48:27 +00:00
|
|
|
if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
|
2011-04-07 03:41:47 +00:00
|
|
|
// No jQuery handlers for this event type, and it can't have inline handlers
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-11 15:15:00 +00:00
|
|
|
// Caller can pass in an Event, Object, or just an event type string
|
|
|
|
event = typeof event === "object" ?
|
|
|
|
// jQuery.Event object
|
|
|
|
event[ jQuery.expando ] ? event :
|
|
|
|
// Object literal
|
2011-04-12 23:29:09 +00:00
|
|
|
new jQuery.Event( type, event ) :
|
2011-04-11 15:15:00 +00:00
|
|
|
// Just the event type (string)
|
2011-04-12 23:29:09 +00:00
|
|
|
new jQuery.Event( type );
|
2011-04-12 18:58:55 +00:00
|
|
|
|
2011-04-12 22:32:23 +00:00
|
|
|
event.type = type;
|
2011-09-21 03:01:07 +00:00
|
|
|
event.isTrigger = true;
|
2011-04-17 00:48:27 +00:00
|
|
|
event.exclusive = exclusive;
|
2011-09-08 03:21:33 +00:00
|
|
|
event.namespace = namespaces.join( "." );
|
2011-07-29 00:43:23 +00:00
|
|
|
event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
|
2011-09-08 00:57:37 +00:00
|
|
|
ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
|
|
|
|
|
2011-04-17 00:48:27 +00:00
|
|
|
// triggerHandler() and global events don't bubble or run the default action
|
|
|
|
if ( onlyHandlers || !elem ) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
2011-04-11 15:32:23 +00:00
|
|
|
|
2011-04-06 15:34:41 +00:00
|
|
|
// Handle a global trigger
|
|
|
|
if ( !elem ) {
|
2011-09-19 20:13:14 +00:00
|
|
|
|
2011-04-17 00:48:27 +00:00
|
|
|
// TODO: Stop taunting the data cache; remove global events and always attach to document
|
2011-10-06 14:12:05 +00:00
|
|
|
cache = jQuery.cache;
|
2011-09-19 20:13:14 +00:00
|
|
|
for ( i in cache ) {
|
|
|
|
if ( cache[ i ].events && cache[ i ].events[ type ] ) {
|
2011-10-24 03:03:00 +00:00
|
|
|
jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
|
2011-04-17 00:48:27 +00:00
|
|
|
}
|
2011-09-19 20:13:14 +00:00
|
|
|
}
|
2011-04-06 15:34:41 +00:00
|
|
|
return;
|
|
|
|
}
|
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
|
2011-05-16 14:38:36 +00:00
|
|
|
data = data != null ? jQuery.makeArray( data ) : [];
|
2011-04-06 15:34:41 +00:00
|
|
|
data.unshift( 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 ] || {};
|
|
|
|
if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
|
|
|
|
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
|
|
|
eventPath = [[ elem, special.bindType || type ]];
|
|
|
|
if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
|
|
|
|
|
2011-09-08 00:57:37 +00:00
|
|
|
bubbleType = special.delegateType || type;
|
2011-11-09 04:08:04 +00:00
|
|
|
cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
|
2011-10-13 20:30:40 +00:00
|
|
|
old = null;
|
2011-11-09 04:08:04 +00:00
|
|
|
for ( ; cur; cur = cur.parentNode ) {
|
2011-10-13 20:30:40 +00:00
|
|
|
eventPath.push([ cur, bubbleType ]);
|
|
|
|
old = cur;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only add window if we got to document (e.g., not plain obj or detached DOM)
|
|
|
|
if ( old && old === elem.ownerDocument ) {
|
|
|
|
eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
|
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
|
2011-09-08 00:57:37 +00:00
|
|
|
for ( i = 0; i < eventPath.length; i++ ) {
|
2011-10-13 20:30:40 +00:00
|
|
|
|
|
|
|
cur = eventPath[i][0];
|
|
|
|
event.type = eventPath[i][1];
|
|
|
|
|
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 );
|
|
|
|
}
|
2011-11-07 16:07:36 +00:00
|
|
|
// Note that this is a bare JS function and not a jQuery handler
|
2011-10-13 20:30:40 +00:00
|
|
|
handle = ontype && cur[ ontype ];
|
2011-11-07 16:07:36 +00:00
|
|
|
if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) {
|
|
|
|
event.preventDefault();
|
2011-10-13 20:30:40 +00:00
|
|
|
}
|
|
|
|
|
2011-09-08 00:57:37 +00:00
|
|
|
if ( event.isPropagationStopped() ) {
|
|
|
|
break;
|
2011-08-13 14:46:34 +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
|
|
|
|
if ( !event.isDefaultPrevented() ) {
|
2010-01-28 19:34:09 +00:00
|
|
|
|
2011-10-27 20:02:54 +00:00
|
|
|
if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
|
2011-02-11 04:43:45 +00:00
|
|
|
!(type === "click" && jQuery.nodeName( elem, "a" )) && 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)
|
2011-09-10 18:46:58 +00:00
|
|
|
// IE<9 dies on focus/blur to hidden element (#1486)
|
|
|
|
if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !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
|
|
|
|
old = elem[ ontype ];
|
2010-01-25 18:45:07 +00:00
|
|
|
|
2011-09-08 01:02:13 +00:00
|
|
|
if ( old ) {
|
|
|
|
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;
|
|
|
|
elem[ type ]();
|
2011-09-08 14:18:36 +00:00
|
|
|
jQuery.event.triggered = undefined;
|
2011-09-08 01:02:13 +00:00
|
|
|
|
|
|
|
if ( old ) {
|
|
|
|
elem[ ontype ] = old;
|
|
|
|
}
|
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
|
2011-02-11 04:43:45 +00:00
|
|
|
event = jQuery.event.fix( event || window.event );
|
2011-09-20 16:54:34 +00:00
|
|
|
|
2011-10-27 19:31:35 +00:00
|
|
|
var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
|
2011-07-29 00:43:23 +00:00
|
|
|
delegateCount = handlers.delegateCount,
|
2011-10-06 14:12:05 +00:00
|
|
|
args = [].slice.call( arguments, 0 ),
|
2011-10-24 01:13:59 +00:00
|
|
|
run_all = !event.exclusive && !event.namespace,
|
2011-07-31 15:53:15 +00:00
|
|
|
handlerQueue = [],
|
2011-11-07 01:12:00 +00:00
|
|
|
i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related;
|
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
|
|
|
|
2011-07-31 15:53:15 +00:00
|
|
|
// Determine handlers that should run if there are delegated events
|
2011-07-29 00:43:23 +00:00
|
|
|
// Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861)
|
2011-10-11 03:14:08 +00:00
|
|
|
if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) {
|
2011-07-29 00:43:23 +00:00
|
|
|
|
2011-11-07 01:12:00 +00:00
|
|
|
// Pregenerate a single jQuery object for reuse with .is()
|
|
|
|
jqcur = jQuery(this);
|
|
|
|
jqcur.context = this.ownerDocument || this;
|
|
|
|
|
2011-07-31 15:53:15 +00:00
|
|
|
for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
|
2011-07-29 00:43:23 +00:00
|
|
|
selMatch = {};
|
|
|
|
matches = [];
|
2011-11-07 01:12:00 +00:00
|
|
|
jqcur[0] = cur;
|
2011-07-29 00:43:23 +00:00
|
|
|
for ( i = 0; i < delegateCount; i++ ) {
|
|
|
|
handleObj = handlers[ i ];
|
|
|
|
sel = handleObj.selector;
|
|
|
|
|
2011-11-07 01:12:00 +00:00
|
|
|
if ( selMatch[ sel ] === undefined ) {
|
|
|
|
selMatch[ sel ] = (
|
|
|
|
handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel )
|
|
|
|
);
|
2011-07-29 00:43:23 +00:00
|
|
|
}
|
2011-11-07 01:12:00 +00:00
|
|
|
if ( selMatch[ sel ] ) {
|
2011-08-13 14:46:34 +00:00
|
|
|
matches.push( handleObj );
|
2008-12-31 02:58:13 +00:00
|
|
|
}
|
2011-04-06 15:34:41 +00:00
|
|
|
}
|
2011-07-29 00:43:23 +00:00
|
|
|
if ( matches.length ) {
|
2011-07-31 15:53:15 +00:00
|
|
|
handlerQueue.push({ elem: cur, matches: matches });
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
2011-04-06 15:34:41 +00:00
|
|
|
}
|
2011-09-20 16:54:34 +00:00
|
|
|
|
2011-10-21 15:16:27 +00:00
|
|
|
// Add the remaining (directly-bound) handlers
|
|
|
|
if ( handlers.length > delegateCount ) {
|
2011-10-21 15:11:36 +00:00
|
|
|
handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
|
|
|
|
}
|
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
|
2011-09-08 03:21:33 +00:00
|
|
|
for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
|
|
|
|
matched = handlerQueue[ i ];
|
2011-10-24 15:17:24 +00:00
|
|
|
event.currentTarget = matched.elem;
|
|
|
|
|
2011-10-24 01:13:59 +00:00
|
|
|
for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
|
|
|
|
handleObj = matched.matches[ j ];
|
|
|
|
|
|
|
|
// Triggered event must either 1) be non-exclusive and have no namespace, or
|
|
|
|
// 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
|
|
|
|
if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
|
|
|
|
|
|
|
|
event.data = handleObj.data;
|
|
|
|
event.handleObj = handleObj;
|
|
|
|
|
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 ) {
|
|
|
|
event.result = ret;
|
|
|
|
if ( ret === false ) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-07-31 15:53:15 +00:00
|
|
|
}
|
2011-07-29 00:43:23 +00:00
|
|
|
|
2009-12-07 00:55:08 +00:00
|
|
|
return event.result;
|
2007-12-19 01:10:20 +00:00
|
|
|
},
|
|
|
|
|
2011-09-25 23:56:34 +00:00
|
|
|
// Includes some event props shared by KeyEvent and MouseEvent
|
|
|
|
// *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
|
2011-09-29 14:34:40 +00:00
|
|
|
props: "attrChange attrName relatedNode srcElement 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 ) {
|
|
|
|
var eventDoc, doc, body,
|
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;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-04-30 01:26:09 +00:00
|
|
|
fix: function( event ) {
|
2010-04-24 21:15:45 +00:00
|
|
|
if ( event[ jQuery.expando ] ) {
|
2008-04-27 23:08:31 +00:00
|
|
|
return event;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2011-09-25 23:56:34 +00:00
|
|
|
// Create a writable copy of the event object and normalize some properties
|
2011-10-07 15:45:42 +00:00
|
|
|
var i, prop,
|
|
|
|
originalEvent = event,
|
2011-10-06 01:41:32 +00:00
|
|
|
fixHook = jQuery.event.fixHooks[ event.type ] || {},
|
2011-10-07 15:45:42 +00:00
|
|
|
copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
|
2011-09-22 15:07:16 +00:00
|
|
|
|
2008-12-29 21:57:29 +00:00
|
|
|
event = jQuery.Event( originalEvent );
|
2008-05-28 20:43:13 +00:00
|
|
|
|
2011-10-07 15:45:42 +00:00
|
|
|
for ( i = copy.length; i; ) {
|
2011-09-23 00:02:34 +00:00
|
|
|
prop = copy[ --i ];
|
2008-05-28 20:43:13 +00:00
|
|
|
event[ prop ] = originalEvent[ prop ];
|
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2011-09-25 23:56:34 +00:00
|
|
|
// Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( !event.target ) {
|
2011-09-25 23:56:34 +00:00
|
|
|
event.target = originalEvent.srcElement || document;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2011-09-25 23:56:34 +00:00
|
|
|
// Target should not be a text node (#504, Safari)
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( event.target.nodeType === 3 ) {
|
2008-04-28 21:09:27 +00:00
|
|
|
event.target = event.target.parentNode;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2011-09-25 23:56:34 +00:00
|
|
|
// For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8)
|
|
|
|
if ( event.metaKey === undefined ) {
|
|
|
|
event.metaKey = event.ctrlKey;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2011-10-06 01:41:32 +00:00
|
|
|
return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
|
2007-12-19 01:10:20 +00:00
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
special: {
|
|
|
|
ready: {
|
2008-07-28 18:31:25 +00:00
|
|
|
// Make sure the ready event is setup
|
2011-07-29 00:43:23 +00:00
|
|
|
setup: jQuery.bindReady
|
2009-12-07 00:55:08 +00:00
|
|
|
},
|
2011-09-20 16:54:34 +00:00
|
|
|
|
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: {
|
2011-11-09 04:08:04 +00:00
|
|
|
delegateType: "focusin"
|
2011-08-13 14:46:34 +00:00
|
|
|
},
|
|
|
|
blur: {
|
2011-11-09 04:08:04 +00:00
|
|
|
delegateType: "focusout"
|
2011-08-13 14:46:34 +00:00
|
|
|
},
|
2010-02-05 02:36:32 +00:00
|
|
|
|
2009-12-07 00:55:08 +00:00
|
|
|
beforeunload: {
|
2010-02-05 16:02:56 +00:00
|
|
|
setup: function( data, namespaces, eventHandle ) {
|
2009-12-07 00:55:08 +00:00
|
|
|
// We only want to do this special case on windows
|
2010-09-22 20:41:51 +00:00
|
|
|
if ( jQuery.isWindow( this ) ) {
|
2010-02-05 16:02:56 +00:00
|
|
|
this.onbeforeunload = eventHandle;
|
2009-12-07 00:55:08 +00:00
|
|
|
}
|
|
|
|
},
|
2010-02-27 15:03:43 +00:00
|
|
|
|
2010-02-05 16:02:56 +00:00
|
|
|
teardown: function( namespaces, eventHandle ) {
|
|
|
|
if ( this.onbeforeunload === eventHandle ) {
|
2009-12-07 00:55:08 +00:00
|
|
|
this.onbeforeunload = null;
|
|
|
|
}
|
|
|
|
}
|
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,
|
|
|
|
{ type: type,
|
|
|
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-10-26 20:02:20 +00:00
|
|
|
// Some plugins are using, but it's undocumented/deprecated and will be removed.
|
|
|
|
// The 1.7 special event interface should provide all the hooks needed now.
|
|
|
|
jQuery.event.handle = jQuery.event.dispatch;
|
|
|
|
|
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 ) {
|
2010-02-26 16:32:12 +00:00
|
|
|
if ( elem.detachEvent ) {
|
|
|
|
elem.detachEvent( "on" + type, handle );
|
|
|
|
}
|
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
|
|
|
|
2009-04-30 01:26:09 +00:00
|
|
|
function returnFalse() {
|
2008-12-31 02:58:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-04-30 01:26:09 +00:00
|
|
|
function returnTrue() {
|
2008-12-31 02:58:13 +00:00
|
|
|
return 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
|
2008-12-25 21:44:54 +00:00
|
|
|
jQuery.Event.prototype = {
|
|
|
|
preventDefault: function() {
|
2008-12-31 02:58:13 +00:00
|
|
|
this.isDefaultPrevented = returnTrue;
|
|
|
|
|
2008-12-25 21:44:54 +00:00
|
|
|
var e = this.originalEvent;
|
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
|
|
|
|
2008-12-25 21:44:54 +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
|
|
|
|
2008-12-25 21:44:54 +00:00
|
|
|
// otherwise set the returnValue property of the original event to false (IE)
|
2010-09-20 14:16:36 +00:00
|
|
|
} else {
|
|
|
|
e.returnValue = false;
|
|
|
|
}
|
2008-12-25 21:44:54 +00:00
|
|
|
},
|
|
|
|
stopPropagation: function() {
|
2008-12-31 02:58:13 +00:00
|
|
|
this.isPropagationStopped = returnTrue;
|
|
|
|
|
2008-12-25 21:44:54 +00:00
|
|
|
var e = this.originalEvent;
|
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
|
|
|
}
|
2008-12-25 21:44:54 +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
|
|
|
}
|
2008-12-25 21:44:54 +00:00
|
|
|
// otherwise set the cancelBubble property of the original event to true (IE)
|
|
|
|
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();
|
2008-12-31 02:58:13 +00:00
|
|
|
},
|
|
|
|
isDefaultPrevented: returnFalse,
|
|
|
|
isPropagationStopped: returnFalse,
|
|
|
|
isImmediatePropagationStopped: returnFalse
|
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 ) {
|
2011-08-13 14:46:34 +00:00
|
|
|
var target = this,
|
|
|
|
related = event.relatedTarget,
|
2011-08-14 19:20:12 +00:00
|
|
|
handleObj = event.handleObj,
|
|
|
|
selector = handleObj.selector,
|
2011-11-10 02:51:55 +00:00
|
|
|
ret;
|
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
|
2009-12-07 02:20:08 +00:00
|
|
|
if ( !jQuery.support.submitBubbles ) {
|
|
|
|
|
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;
|
|
|
|
if ( form && !form._submit_attached ) {
|
|
|
|
jQuery.event.add( form, "submit._submit", function( event ) {
|
|
|
|
// Form was submitted, bubble the event up the tree
|
|
|
|
if ( this.parentNode ) {
|
2011-09-28 16:04:27 +00:00
|
|
|
jQuery.event.simulate( "submit", this.parentNode, event, true );
|
2011-09-22 01:15:00 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
form._submit_attached = 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
|
|
|
},
|
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
|
2009-12-07 02:20:08 +00:00
|
|
|
if ( !jQuery.support.changeBubbles ) {
|
|
|
|
|
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-09-21 02:18:34 +00:00
|
|
|
if ( this._just_changed ) {
|
|
|
|
this._just_changed = false;
|
2011-09-28 16:04:27 +00:00
|
|
|
jQuery.event.simulate( "change", this, event, true );
|
2011-09-21 02:18:34 +00:00
|
|
|
}
|
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;
|
|
|
|
|
2011-10-06 14:12:05 +00:00
|
|
|
if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) {
|
2011-09-20 02:50:29 +00:00
|
|
|
jQuery.event.add( elem, "change._change", function( event ) {
|
|
|
|
if ( this.parentNode && !event.isSimulated ) {
|
2011-09-28 16:04:27 +00:00
|
|
|
jQuery.event.simulate( "change", this.parentNode, event, true );
|
2011-09-20 02:50:29 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
elem._change_attached = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
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
|
|
|
|
|
|
|
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
|
2011-04-04 14:27:31 +00:00
|
|
|
if ( !jQuery.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 ) {
|
|
|
|
var origFn, type;
|
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 )
|
|
|
|
if ( typeof selector !== "string" ) {
|
|
|
|
// ( types-Object, data )
|
|
|
|
data = selector;
|
|
|
|
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 ) {
|
|
|
|
return this.on.call( this, types, selector, data, fn, 1 );
|
|
|
|
},
|
|
|
|
off: function( types, selector, fn ) {
|
2011-10-24 02:25:13 +00:00
|
|
|
if ( types && types.preventDefault && types.handleObj ) {
|
|
|
|
// ( event ) dispatched jQuery.Event
|
|
|
|
var handleObj = types.handleObj;
|
2011-10-27 19:31:35 +00:00
|
|
|
jQuery( types.delegateTarget ).off(
|
|
|
|
handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type,
|
|
|
|
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] )
|
|
|
|
for ( var 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
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
bind: function( types, data, fn ) {
|
|
|
|
return this.on( types, null, data, fn );
|
|
|
|
},
|
|
|
|
unbind: function( types, fn ) {
|
|
|
|
return this.off( types, null, fn );
|
|
|
|
},
|
2009-12-10 22:44:30 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
live: function( types, data, fn ) {
|
|
|
|
jQuery( this.context ).on( types, this.selector, data, fn );
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
die: function( types, fn ) {
|
|
|
|
jQuery( this.context ).off( types, this.selector || "**", fn );
|
2010-01-28 19:12:44 +00:00
|
|
|
return this;
|
2007-12-19 01:10:20 +00:00
|
|
|
},
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2010-02-01 23:06:03 +00:00
|
|
|
delegate: function( selector, types, data, fn ) {
|
2011-07-29 00:43:23 +00:00
|
|
|
return this.on( types, selector, data, fn );
|
2010-02-01 23:06:03 +00:00
|
|
|
},
|
|
|
|
undelegate: function( selector, types, fn ) {
|
2011-07-29 00:43:23 +00:00
|
|
|
// ( namespace ) or ( selector, types [, fn] )
|
|
|
|
return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn );
|
2010-02-01 23:06:03 +00:00
|
|
|
},
|
2010-12-26 20:28:13 +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 ) {
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( this[0] ) {
|
2011-04-17 00:48:27 +00:00
|
|
|
return jQuery.event.trigger( type, data, this[0], true );
|
2009-03-23 01:55:17 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
},
|
|
|
|
|
2008-04-29 22:06:54 +00:00
|
|
|
toggle: function( fn ) {
|
2007-12-19 01:10:20 +00:00
|
|
|
// Save reference to arguments for access in closure
|
2010-11-09 16:09:07 +00:00
|
|
|
var args = arguments,
|
2010-12-15 02:53:04 +00:00
|
|
|
guid = fn.guid || jQuery.guid++,
|
|
|
|
i = 0,
|
|
|
|
toggler = function( event ) {
|
|
|
|
// Figure out which function to execute
|
2011-07-29 00:43:23 +00:00
|
|
|
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
|
|
|
|
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
|
2010-12-15 02:53:04 +00:00
|
|
|
|
|
|
|
// Make sure that clicks stop
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
// and execute the function
|
|
|
|
return args[ lastToggle ].apply( this, arguments ) || false;
|
|
|
|
};
|
2008-04-29 22:06:54 +00:00
|
|
|
|
|
|
|
// link all the functions, so any of them can unbind this click handler
|
2010-12-15 02:53:04 +00:00
|
|
|
toggler.guid = guid;
|
2009-12-22 00:58:13 +00:00
|
|
|
while ( i < args.length ) {
|
2010-12-15 02:53:04 +00:00
|
|
|
args[ i++ ].guid = guid;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2010-12-15 02:53:04 +00:00
|
|
|
return this.click( toggler );
|
2007-12-19 01:10:20 +00:00
|
|
|
},
|
|
|
|
|
2009-04-30 01:26:09 +00:00
|
|
|
hover: function( fnOver, fnOut ) {
|
2009-05-06 02:17:24 +00:00
|
|
|
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
|
2010-01-23 16:56:24 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2010-01-12 22:03:34 +00:00
|
|
|
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
|
2009-10-23 15:52:38 +00:00
|
|
|
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
|
2011-09-20 16:54:34 +00:00
|
|
|
"change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
// Handle event binding
|
2010-02-27 01:01:19 +00:00
|
|
|
jQuery.fn[ name ] = function( data, fn ) {
|
2010-03-02 02:24:49 +00:00
|
|
|
if ( fn == null ) {
|
2010-02-27 14:02:13 +00:00
|
|
|
fn = data;
|
|
|
|
data = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return arguments.length > 0 ?
|
2011-11-07 23:04:59 +00:00
|
|
|
this.on( name, null, data, fn ) :
|
2010-02-27 01:01:19 +00:00
|
|
|
this.trigger( name );
|
2007-12-19 01:10:20 +00:00
|
|
|
};
|
2009-12-10 05:28:33 +00:00
|
|
|
|
2010-01-13 02:54:06 +00:00
|
|
|
if ( jQuery.attrFn ) {
|
|
|
|
jQuery.attrFn[ name ] = true;
|
2009-12-10 05:28:33 +00:00
|
|
|
}
|
2011-09-20 16:54:34 +00:00
|
|
|
|
2011-09-22 14:43:32 +00:00
|
|
|
if ( rkeyEvent.test( name ) ) {
|
2011-10-06 01:41:32 +00:00
|
|
|
jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
|
2011-09-22 14:43:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( rmouseEvent.test( name ) ) {
|
2011-10-06 01:41:32 +00:00
|
|
|
jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
|
2011-09-25 23:56:34 +00:00
|
|
|
}
|
|
|
|
});
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2010-09-08 17:54:33 +00:00
|
|
|
})( jQuery );
|
2011-04-05 19:55:40 +00:00
|
|
|
|