2010-09-08 17:54:33 +00:00
|
|
|
(function( jQuery ) {
|
|
|
|
|
2011-06-07 00:16:14 +00:00
|
|
|
var rnamespaces = /\.(.*)$/,
|
2010-09-22 13:16:28 +00:00
|
|
|
rformElems = /^(?:textarea|input|select)$/i,
|
|
|
|
rperiod = /\./g,
|
2011-04-29 02:24:40 +00:00
|
|
|
rspaces = / /g,
|
2010-09-22 13:16:28 +00:00
|
|
|
rescape = /[^\w\s.|`]/g,
|
2011-07-29 00:43:23 +00:00
|
|
|
rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,
|
|
|
|
rhoverHack = /\bhover(\.\S+)?/,
|
2011-09-20 17:14:59 +00:00
|
|
|
rmouseEvent = /^(?:mouse|contextmenu)|click/,
|
2011-09-22 14:43:32 +00:00
|
|
|
rkeyEvent = /^(?:key)/,
|
2011-08-14 19:52:57 +00:00
|
|
|
rquickIs = /^([\w\-]+)?(?:#([\w\-]+))?(?:\.([\w\-]+))?(?:\[([\w+\-]+)=["']?([\w\-]*)["']?\])?(?::(first-child|last-child|empty))?$/,
|
2011-07-29 00:43:23 +00:00
|
|
|
quickPseudoMap = {
|
2011-08-14 19:52:57 +00:00
|
|
|
"empty": "firstChild",
|
|
|
|
"first-child": "previousSibling",
|
|
|
|
"last-child": "nextSibling"
|
|
|
|
},
|
|
|
|
quickParse = function( selector ) {
|
|
|
|
var quick = rquickIs.exec( selector );
|
|
|
|
if ( quick ) {
|
|
|
|
// 0 1 2 3 4 5 6
|
2011-09-07 03:20:48 +00:00
|
|
|
// [ _, tag, id, class, attrName, attrValue, :(empty first-child last-child) ]
|
2011-08-14 19:52:57 +00:00
|
|
|
quick[1] = ( quick[1] || "" ).toLowerCase();
|
|
|
|
quick[3] = quick[3] && new RegExp( "\\b" + quick[3] + "\\b" );
|
|
|
|
quick[6] = quickPseudoMap[ quick[6] ];
|
|
|
|
}
|
|
|
|
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-08-14 19:52:57 +00:00
|
|
|
(!m[3] || m[3].test( elem.className )) &&
|
|
|
|
(!m[4] || elem.getAttribute( m[4] ) == m[5]) &&
|
|
|
|
(!m[6] || !elem[ m[6] ])
|
|
|
|
);
|
2011-09-07 03:20:48 +00:00
|
|
|
},
|
|
|
|
useNativeMethod = function( event ) {
|
|
|
|
// IE throws error on focus/blur of a hidden element (#1486)
|
2011-09-10 18:46:58 +00:00
|
|
|
var type = event.type;
|
|
|
|
if ( !event.isDefaultPrevented() && this[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) ) {
|
|
|
|
this[ type ]();
|
2011-09-07 03:20:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
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) ?
|
2009-12-08 00:42:25 +00:00
|
|
|
jQuery.event.handle.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-08-02 02:30:11 +00:00
|
|
|
types = types.replace( rhoverHack, "mouseover$1 mouseout$1" ).split( " " );
|
2011-07-29 00:43:23 +00:00
|
|
|
for ( t = 0; t < types.length; t++ ) {
|
|
|
|
|
|
|
|
tns = rtypenamespace.exec( types[t] ) || [];
|
|
|
|
type = tns[1];
|
2011-08-02 02:30:11 +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 ] || {};
|
|
|
|
type = (selector? special.delegateType : special.bindType ) || 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,
|
|
|
|
namespace: namespaces.join(".")
|
|
|
|
}, handleObjIn);
|
2011-08-13 14:46:34 +00:00
|
|
|
|
2011-08-17 00:26:14 +00:00
|
|
|
// Delegated event; pre-analyze selector so it's processed quickly on event dispatch
|
2011-08-13 14:46:34 +00:00
|
|
|
if ( selector ) {
|
2011-08-14 19:52:57 +00:00
|
|
|
handleObj.quick = quickParse( selector );
|
|
|
|
if ( !handleObj.quick && jQuery.expr.match.POS.test( selector ) ) {
|
2011-08-13 14:46:34 +00:00
|
|
|
handleObj.isPositional = true;
|
|
|
|
}
|
|
|
|
}
|
2009-04-30 21:44:25 +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-09-07 03:20:48 +00:00
|
|
|
t, tns, type, 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
|
|
|
// For removal, types can be an Event object
|
|
|
|
if ( types && types.type && types.handler ) {
|
2010-02-04 05:20:52 +00:00
|
|
|
handler = types.handler;
|
|
|
|
types = types.type;
|
2011-07-29 00:43:23 +00:00
|
|
|
selector = types.selector;
|
2010-02-04 05:20:52 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
// Once for each type.namespace in types; type may be omitted
|
|
|
|
types = (types || "").replace( rhoverHack, "mouseover$1 mouseout$1" ).split(" ");
|
|
|
|
for ( t = 0; t < types.length; t++ ) {
|
|
|
|
tns = rtypenamespace.exec( types[t] ) || [];
|
|
|
|
type = tns[1];
|
|
|
|
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
|
|
|
|
if ( !type ) {
|
|
|
|
namespaces = namespaces? "." + namespaces : "";
|
|
|
|
for ( j in events ) {
|
|
|
|
jQuery.event.remove( elem, j + namespaces, handler, selector );
|
2010-02-04 05:20:52 +00:00
|
|
|
}
|
2011-07-29 00:43:23 +00:00
|
|
|
return;
|
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-08-13 14:46:34 +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-07-29 00:43:23 +00:00
|
|
|
namespaces = namespaces? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
// Only need to loop for special events or selective removal
|
|
|
|
if ( handler || namespaces || selector || special.remove ) {
|
|
|
|
for ( j = 0; j < eventType.length; j++ ) {
|
|
|
|
handleObj = eventType[ j ];
|
2010-02-04 05:20:52 +00:00
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
if ( !handler || handler.guid === handleObj.guid ) {
|
|
|
|
if ( !namespaces || namespaces.test( handleObj.namespace ) ) {
|
|
|
|
if ( !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
|
|
|
}
|
2011-07-29 00:43:23 +00:00
|
|
|
} else {
|
|
|
|
// Removing all events
|
|
|
|
eventType.length = 0;
|
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-09-08 00:57:37 +00:00
|
|
|
exclusive, i, cur, old, ontype, special, doc, eventPath, bubbleType,
|
|
|
|
addHandlers = function( elem, type ) {
|
2011-09-08 03:21:33 +00:00
|
|
|
// Defer getting handler so we don't waste time in case propagation is stopped
|
2011-09-08 00:57:37 +00:00
|
|
|
if ( (jQuery._data( elem, "events" ) || {})[ type ] ) {
|
|
|
|
eventPath.push({ elem: elem, type: type /*, handler: jQuery._data( elem, "handle" ) */ });
|
|
|
|
}
|
|
|
|
// IE doesn't like method names with a colon (#3533, #8272)
|
|
|
|
if ( ontype && jQuery.acceptData( elem ) && elem[ ontype ] ) {
|
|
|
|
eventPath.push({ elem: elem, type: type, handler: elem[ ontype ] });
|
|
|
|
}
|
|
|
|
};
|
2011-04-06 15:34:41 +00:00
|
|
|
|
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-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();
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
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-09-19 20:13:14 +00:00
|
|
|
var cache = jQuery.cache;
|
|
|
|
for ( i in cache ) {
|
|
|
|
if ( cache[ i ].events && cache[ i ].events[ type ] ) {
|
|
|
|
jQuery.event.trigger( event, data, cache[ i ].handle.elem );
|
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;
|
|
|
|
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)
|
|
|
|
// Always fire handlers for the target, even if prop is stopped in advance
|
|
|
|
eventPath = [];
|
|
|
|
addHandlers( elem, special.bindType || type );
|
|
|
|
doc = elem.ownerDocument;
|
|
|
|
if ( doc && !jQuery.isWindow( elem ) & !event.isPropagationStopped() ) {
|
|
|
|
bubbleType = special.delegateType || type;
|
|
|
|
for ( cur = elem.parentNode; cur; cur = cur.parentNode ) {
|
|
|
|
addHandlers( cur, bubbleType );
|
2011-04-06 15:34:41 +00:00
|
|
|
}
|
2011-09-08 00:57:37 +00:00
|
|
|
addHandlers( doc.defaultView || doc.parentWindow || window, bubbleType );
|
|
|
|
}
|
2011-09-20 16:54:34 +00:00
|
|
|
|
2011-09-08 00:57:37 +00:00
|
|
|
// Bubble up the DOM tree
|
|
|
|
for ( i = 0; i < eventPath.length; i++ ) {
|
|
|
|
cur = eventPath[ i ];
|
|
|
|
event.type = cur.type;
|
|
|
|
(cur.handler || jQuery._data( cur.elem, "handle" )).apply( cur.elem, data );
|
|
|
|
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-08-03 02:50:58 +00:00
|
|
|
if ( (!special._default || special._default.call( elem.ownerDocument, event, 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-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
|
|
|
},
|
|
|
|
|
2009-04-30 01:26:09 +00:00
|
|
|
handle: 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-09-22 15:12:42 +00:00
|
|
|
var propHook = jQuery.event.propHooks[ event.type ];
|
|
|
|
|
|
|
|
if ( propHook ) {
|
|
|
|
event = propHook( event );
|
2011-09-20 16:54:34 +00:00
|
|
|
}
|
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []),
|
|
|
|
delegateCount = handlers.delegateCount,
|
|
|
|
args = Array.prototype.slice.call( arguments, 0 ),
|
2011-07-31 15:53:15 +00:00
|
|
|
handlerQueue = [],
|
2011-08-13 14:46:34 +00:00
|
|
|
i, cur, selMatch, matches, handleObj, sel, hit, 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-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-07-31 15:53:15 +00:00
|
|
|
if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) {
|
2011-07-29 00:43:23 +00:00
|
|
|
|
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 = [];
|
|
|
|
for ( i = 0; i < delegateCount; i++ ) {
|
|
|
|
handleObj = handlers[ i ];
|
|
|
|
sel = handleObj.selector;
|
2011-08-13 14:46:34 +00:00
|
|
|
hit = selMatch[ sel ];
|
2011-07-29 00:43:23 +00:00
|
|
|
|
|
|
|
if ( handleObj.isPositional ) {
|
|
|
|
// Since .is() does not work for positionals; see http://jsfiddle.net/eJ4yd/3/
|
2011-08-13 14:46:34 +00:00
|
|
|
hit = (hit || (selMatch[ sel ] = jQuery( sel ))).index( cur ) >= 0;
|
2011-08-17 14:34:13 +00:00
|
|
|
} else if ( hit === undefined ) {
|
|
|
|
hit = selMatch[ sel ] = (handleObj.quick? quickIs( cur, handleObj.quick ) : jQuery( cur ).is( sel ));
|
2011-07-29 00:43:23 +00:00
|
|
|
}
|
2011-08-13 14:46:34 +00:00
|
|
|
if ( hit ) {
|
|
|
|
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-07-31 15:53:15 +00:00
|
|
|
// Copy the remaining (bound) handlers in case they're changed
|
|
|
|
handlers = handlers.slice( delegateCount );
|
|
|
|
|
|
|
|
// Run delegates first; they may want to stop propagation beneath us
|
|
|
|
event.delegateTarget = this;
|
2011-09-08 03:21:33 +00:00
|
|
|
for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
|
|
|
|
matched = handlerQueue[ i ];
|
2011-08-13 14:46:34 +00:00
|
|
|
dispatch( matched.elem, event, matched.matches, args );
|
2011-07-31 15:53:15 +00:00
|
|
|
}
|
|
|
|
delete event.delegateTarget;
|
2011-07-29 00:43:23 +00:00
|
|
|
|
|
|
|
// Run non-delegated handlers for this level
|
2011-07-31 15:53:15 +00:00
|
|
|
if ( handlers.length ) {
|
|
|
|
dispatch( this, event, handlers, args );
|
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-20 18:54:33 +00:00
|
|
|
props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
|
2008-05-28 20:43:13 +00:00
|
|
|
|
2011-09-20 16:54:34 +00:00
|
|
|
propHooks: {},
|
|
|
|
|
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
|
|
|
|
|
|
|
// store a copy of the original event object
|
2008-04-28 21:09:27 +00:00
|
|
|
// and "clone" to set read-only properties
|
2011-09-22 15:07:16 +00:00
|
|
|
var originalEvent = event,
|
|
|
|
propHook;
|
|
|
|
|
2008-12-29 21:57:29 +00:00
|
|
|
event = jQuery.Event( originalEvent );
|
2011-09-22 15:07:16 +00:00
|
|
|
propHook = jQuery.event.propHooks[ event.type ];
|
2008-05-28 20:43:13 +00:00
|
|
|
|
2009-04-30 01:26:09 +00:00
|
|
|
for ( var i = this.props.length, prop; i; ) {
|
2008-05-28 20:43:13 +00:00
|
|
|
prop = this.props[ --i ];
|
|
|
|
event[ prop ] = originalEvent[ prop ];
|
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
// Fix target property, if necessary
|
2011-09-22 14:52:29 +00:00
|
|
|
// Removal will crash IE6,7,8
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( !event.target ) {
|
2010-11-09 15:34:32 +00:00
|
|
|
// Fixes #1925 where srcElement might not be defined either
|
|
|
|
event.target = event.srcElement || document;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
// check if target is a textnode (safari)
|
2011-09-22 14:52:29 +00:00
|
|
|
// Removal will crash IE6,7,8
|
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
|
|
|
|
|
|
|
// Add relatedTarget, if necessary
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( !event.relatedTarget && event.fromElement ) {
|
|
|
|
event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
|
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2011-09-22 15:07:16 +00:00
|
|
|
if ( propHook ) {
|
|
|
|
event = propHook( event, originalEvent );
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
return event;
|
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2010-01-06 00:17:28 +00:00
|
|
|
// Deprecated, use jQuery.guid instead
|
|
|
|
guid: 1E8,
|
2009-12-22 00:58:13 +00:00
|
|
|
|
2010-01-06 00:17:28 +00:00
|
|
|
// Deprecated, use jQuery.proxy instead
|
2009-12-31 20:06:45 +00:00
|
|
|
proxy: jQuery.proxy,
|
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-08-13 14:46:34 +00:00
|
|
|
focus: {
|
|
|
|
delegateType: "focusin",
|
|
|
|
trigger: useNativeMethod
|
|
|
|
},
|
|
|
|
blur: {
|
|
|
|
delegateType: "focusout",
|
|
|
|
trigger: useNativeMethod
|
|
|
|
},
|
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
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-07-29 00:43:23 +00:00
|
|
|
// Run jQuery handler functions; called from jQuery.event.handle
|
2011-07-31 15:53:15 +00:00
|
|
|
function dispatch( target, event, handlers, args ) {
|
2011-08-13 14:46:34 +00:00
|
|
|
var run_all = !event.exclusive && !event.namespace,
|
|
|
|
specialHandle = (jQuery.event.special[event.type] || {}).handle,
|
|
|
|
j, handleObj, ret;
|
2011-07-29 00:43:23 +00:00
|
|
|
|
|
|
|
event.currentTarget = target;
|
2011-09-12 00:44:44 +00:00
|
|
|
for ( j = 0; j < handlers.length && !event.isImmediatePropagationStopped(); j++ ) {
|
2011-08-13 14:46:34 +00:00
|
|
|
handleObj = handlers[ j ];
|
2011-07-29 00:43:23 +00:00
|
|
|
|
|
|
|
// 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 ) ) {
|
2011-09-20 16:54:34 +00:00
|
|
|
|
2011-08-14 19:20:12 +00:00
|
|
|
// Pass in a reference to the handler function itself
|
|
|
|
// So that we can later remove it
|
|
|
|
event.handler = handleObj.handler;
|
|
|
|
event.data = handleObj.data;
|
|
|
|
event.handleObj = handleObj;
|
|
|
|
|
|
|
|
ret = (specialHandle || handleObj.handler).apply( target, args );
|
|
|
|
|
|
|
|
if ( ret !== undefined ) {
|
|
|
|
event.result = ret;
|
|
|
|
if ( ret === false ) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2011-07-29 00:43:23 +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 ) {
|
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-02-07 16:48:38 +00:00
|
|
|
this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
|
2010-12-27 19:30:05 +00:00
|
|
|
src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
|
|
|
|
|
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-08-13 14:46:34 +00:00
|
|
|
jQuery.event.special[ orig ] = jQuery.event.special[ fix ] = {
|
|
|
|
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,
|
|
|
|
oldType, ret;
|
2011-08-13 14:46:34 +00:00
|
|
|
|
2011-09-08 13:03:16 +00:00
|
|
|
// For a real mouseover/out, always call the handler; 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
|
|
|
|
if ( !related || handleObj.origType === event.type || (related !== target && !jQuery.contains( target, related )) ) {
|
2011-08-14 19:20:12 +00:00
|
|
|
oldType = event.type;
|
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 );
|
|
|
|
event.type = oldType;
|
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
|
|
|
|
2009-12-04 16:28:50 +00:00
|
|
|
// 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-08 03:21:33 +00:00
|
|
|
jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
|
2011-08-13 14:46:34 +00:00
|
|
|
var elem = e.target,
|
|
|
|
type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
|
|
|
|
|
2011-09-08 00:57:37 +00:00
|
|
|
// Do the elem.form check after type to avoid VML-related crash in IE (#9807)
|
2011-09-20 16:54:34 +00:00
|
|
|
if ( (e.type === "click" && (type === "submit" || type === "image") && elem.form) ||
|
2011-08-16 19:40:09 +00:00
|
|
|
(e.type === "keypress" && e.keyCode === 13 && (type === "text" || type === "password") && elem.form) ) {
|
2011-08-13 14:46:34 +00:00
|
|
|
simulate( "submit", this, e );
|
|
|
|
}
|
|
|
|
});
|
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-08-06 14:19:49 +00:00
|
|
|
jQuery.event.remove( this, "._submit" );
|
2010-02-09 04:28:15 +00:00
|
|
|
}
|
|
|
|
};
|
2009-12-04 16:28:50 +00:00
|
|
|
|
2009-12-07 02:20:08 +00:00
|
|
|
}
|
|
|
|
|
2009-12-04 16:28:50 +00:00
|
|
|
// change delegation, happens here so we have bind.
|
2009-12-07 02:20:08 +00:00
|
|
|
if ( !jQuery.support.changeBubbles ) {
|
|
|
|
|
2011-08-06 14:19:49 +00:00
|
|
|
var getVal = function( elem ) {
|
2011-07-15 20:21:44 +00:00
|
|
|
var type = jQuery.nodeName( elem, "input" ) ? elem.type : "",
|
|
|
|
val = elem.value;
|
2009-12-04 16:28:50 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
if ( type === "radio" || type === "checkbox" ) {
|
|
|
|
val = elem.checked;
|
2009-12-04 16:28:50 +00:00
|
|
|
|
2011-08-06 14:19:49 +00:00
|
|
|
} else if ( type === "select-one" ) {
|
|
|
|
val = elem.selectedIndex;
|
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
} else if ( type === "select-multiple" ) {
|
|
|
|
val = elem.selectedIndex > -1 ?
|
|
|
|
jQuery.map( elem.options, function( elem ) {
|
|
|
|
return elem.selected;
|
2011-09-08 03:21:33 +00:00
|
|
|
}).join( "-" ) :
|
2010-02-09 04:28:15 +00:00
|
|
|
"";
|
|
|
|
}
|
|
|
|
|
|
|
|
return val;
|
|
|
|
},
|
2009-12-21 20:32:32 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
testChange = function testChange( e ) {
|
2011-08-06 14:19:49 +00:00
|
|
|
var elem = e.target,
|
|
|
|
old, val;
|
2009-12-21 20:32:32 +00:00
|
|
|
|
2010-09-22 13:16:28 +00:00
|
|
|
if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
|
2009-12-21 20:32:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-08-06 14:19:49 +00:00
|
|
|
old = jQuery._data( elem, "_change_data" );
|
2011-09-08 03:21:33 +00:00
|
|
|
val = getVal( elem );
|
2009-12-04 16:28:50 +00:00
|
|
|
|
2009-12-21 20:32:32 +00:00
|
|
|
// the current data will be also retrieved by beforeactivate
|
|
|
|
if ( e.type !== "focusout" || elem.type !== "radio" ) {
|
2011-01-09 21:52:33 +00:00
|
|
|
jQuery._data( elem, "_change_data", val );
|
2009-12-21 20:32:32 +00:00
|
|
|
}
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2011-09-09 03:31:47 +00:00
|
|
|
if ( val !== old && old != null ) {
|
|
|
|
simulate( "change", elem, e, true );
|
2009-12-21 20:32:32 +00:00
|
|
|
}
|
2011-08-06 14:19:49 +00:00
|
|
|
},
|
2009-12-21 20:32:32 +00:00
|
|
|
|
2011-08-06 14:19:49 +00:00
|
|
|
changeFilters = {
|
2011-09-07 19:41:23 +00:00
|
|
|
focusout: testChange,
|
2009-12-21 20:32:32 +00:00
|
|
|
|
2011-09-07 19:41:23 +00:00
|
|
|
beforedeactivate: testChange,
|
2010-10-13 14:38:29 +00:00
|
|
|
|
2011-09-07 19:41:23 +00:00
|
|
|
click: function( e ) {
|
2011-09-08 03:21:33 +00:00
|
|
|
var elem = e.target,
|
|
|
|
name = elem.nodeName.toLowerCase(),
|
|
|
|
type = name === "input"? elem.type : "";
|
2009-12-21 20:32:32 +00:00
|
|
|
|
2011-09-08 03:21:33 +00:00
|
|
|
if ( type === "radio" || type === "checkbox" || name === "select" ) {
|
|
|
|
testChange.call( this, e );
|
2011-09-07 19:41:23 +00:00
|
|
|
}
|
|
|
|
},
|
2010-02-09 04:28:15 +00:00
|
|
|
|
2011-09-07 19:41:23 +00:00
|
|
|
// Change has to be called before submit
|
|
|
|
// Keydown will be called before keypress, which is used in submit-event delegation
|
|
|
|
keydown: function( e ) {
|
2011-09-08 03:21:33 +00:00
|
|
|
var elem = e.target,
|
|
|
|
name = elem.nodeName.toLowerCase(),
|
|
|
|
type = name === "input"? elem.type : "";
|
|
|
|
|
|
|
|
if ( (e.keyCode === 13 && name !== "textarea") ||
|
|
|
|
(e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
|
|
|
|
type === "select-multiple" ) {
|
|
|
|
testChange.call( this, e );
|
2011-09-07 19:41:23 +00:00
|
|
|
}
|
|
|
|
},
|
2009-12-04 16:28:50 +00:00
|
|
|
|
2011-09-07 19:41:23 +00:00
|
|
|
// Beforeactivate happens also before the previous element is blurred
|
2011-08-06 14:19:49 +00:00
|
|
|
// here, you can't trigger a change event, but you can store data
|
2011-09-08 03:21:33 +00:00
|
|
|
beforeactivate: function( e ) {
|
|
|
|
var elem = e.target;
|
|
|
|
jQuery._data( elem, "_change_data", getVal( elem ) );
|
2009-12-04 16:28:50 +00:00
|
|
|
},
|
|
|
|
|
2011-08-06 14:19:49 +00:00
|
|
|
// Update the current value if we're not re-focusing (#8157)
|
|
|
|
focus: function( e ) {
|
|
|
|
var elem = e.target;
|
|
|
|
if ( elem != document.activeElement ) {
|
2011-09-08 03:21:33 +00:00
|
|
|
jQuery._data( elem, "_change_data", getVal( elem ) );
|
2011-08-06 14:19:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
jQuery.event.special.change = {
|
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
setup: function( data, namespaces ) {
|
2011-09-12 01:18:32 +00:00
|
|
|
if ( this.type === "file" ) {
|
2010-02-13 09:40:26 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-09-12 01:18:32 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
for ( var type in changeFilters ) {
|
2011-09-08 03:21:33 +00:00
|
|
|
jQuery.event.add( this, type + "._change", changeFilters[ type ] );
|
2010-02-09 04:28:15 +00:00
|
|
|
}
|
2011-09-12 01:18:32 +00:00
|
|
|
|
|
|
|
return rformElems.test( this.nodeName );
|
2010-02-09 04:28:15 +00:00
|
|
|
},
|
2009-12-21 20:32:32 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
teardown: function( namespaces ) {
|
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
|
|
|
}
|
|
|
|
|
2011-08-13 14:46:34 +00:00
|
|
|
function simulate( type, elem, event, bubble ) {
|
2011-02-10 02:25:29 +00:00
|
|
|
// 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-09-08 19:59:23 +00:00
|
|
|
var e = jQuery.extend( new jQuery.Event(), event, { type: type, originalEvent: {} } );
|
2011-08-13 14:46:34 +00:00
|
|
|
if ( bubble ) {
|
|
|
|
jQuery.event.trigger( e, null, elem );
|
|
|
|
} else {
|
|
|
|
jQuery.event.handle.call( elem, e );
|
|
|
|
}
|
2011-08-06 14:19:49 +00:00
|
|
|
if ( e.isDefaultPrevented() ) {
|
|
|
|
event.preventDefault();
|
2011-02-10 02:25:29 +00:00
|
|
|
}
|
2009-12-04 16:28:50 +00:00
|
|
|
}
|
2009-09-16 08:33:00 +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 ) {
|
|
|
|
simulate( fix, event.target, jQuery.event.fix( event ), true );
|
|
|
|
};
|
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 ) {
|
|
|
|
jQuery.event.remove( event.delegateTarget || this, event );
|
|
|
|
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 ) {
|
|
|
|
if ( types && types.preventDefault ) {
|
|
|
|
// ( event ) native or jQuery.Event
|
|
|
|
return this.off( types.type, types.handler, types.selector );
|
|
|
|
}
|
|
|
|
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-07-29 00:43:23 +00:00
|
|
|
if ( typeof selector !== "string" ) {
|
|
|
|
// ( 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 ?
|
|
|
|
this.bind( name, 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
|
|
|
// Key Event property hooks
|
|
|
|
if ( rkeyEvent.test( name ) ) {
|
|
|
|
jQuery.event.propHooks[ name ] = function( event, original ) {
|
|
|
|
|
2011-09-22 15:22:56 +00:00
|
|
|
var charCode = event.charCode,
|
|
|
|
keyCode = event.keyCode,
|
|
|
|
ctrlKey = event.ctrlKey;
|
|
|
|
|
2011-09-22 14:43:32 +00:00
|
|
|
// Add which for key events
|
2011-09-22 15:22:56 +00:00
|
|
|
if ( event.which == null && (charCode != null || keyCode != null) ) {
|
|
|
|
event.which = charCode != null ? charCode : keyCode;
|
2011-09-22 14:43:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
|
2011-09-22 15:22:56 +00:00
|
|
|
if ( !event.metaKey && ctrlKey ) {
|
|
|
|
event.metaKey = ctrlKey;
|
2011-09-22 14:43:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return event;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mouse Event property hooks
|
|
|
|
if ( rmouseEvent.test( name ) ) {
|
2011-09-20 16:54:34 +00:00
|
|
|
jQuery.event.propHooks[ name ] = function( event, original ) {
|
|
|
|
|
2011-09-22 15:22:56 +00:00
|
|
|
var eventDoc, doc, body,
|
|
|
|
button = event.button;
|
2011-09-20 16:54:34 +00:00
|
|
|
|
|
|
|
// Calculate pageX/Y if missing and clientX/Y available
|
|
|
|
if ( event.pageX == null && event.clientX != null ) {
|
2011-09-22 15:22:56 +00:00
|
|
|
eventDoc = event.target.ownerDocument || document;
|
|
|
|
doc = eventDoc.documentElement;
|
|
|
|
body = eventDoc.body;
|
2011-09-20 16:54:34 +00:00
|
|
|
|
|
|
|
event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
|
|
|
|
event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add which for click: 1 === left; 2 === middle; 3 === right
|
|
|
|
// Note: button is not normalized, so don't use it
|
2011-09-22 15:22:56 +00:00
|
|
|
if ( !event.which && button !== undefined ) {
|
|
|
|
event.which = (button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ));
|
2011-09-20 16:54:34 +00:00
|
|
|
}
|
|
|
|
return event;
|
|
|
|
};
|
2011-09-22 14:43:32 +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
|
|
|
|