2010-09-08 17:54:33 +00:00
|
|
|
(function( jQuery ) {
|
|
|
|
|
2010-02-05 02:36:32 +00:00
|
|
|
var rnamespaces = /\.(.*)$/,
|
2010-09-22 13:16:28 +00:00
|
|
|
rformElems = /^(?:textarea|input|select)$/i,
|
|
|
|
rperiod = /\./g,
|
|
|
|
rspace = / /g,
|
|
|
|
rescape = /[^\w\s.|`]/g,
|
2010-02-05 02:36:32 +00:00
|
|
|
fcleanup = function( nm ) {
|
2010-09-22 13:16:28 +00:00
|
|
|
return nm.replace(rescape, "\\$&");
|
2011-02-07 16:48:38 +00:00
|
|
|
};
|
2009-12-22 00:58:13 +00:00
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
/*
|
|
|
|
* A number of helper functions used for managing events.
|
2008-06-27 14:17:28 +00:00
|
|
|
* Many of the ideas behind this code originated from
|
2007-12-19 01:10:20 +00:00
|
|
|
* Dean Edwards' addEvent library.
|
|
|
|
*/
|
|
|
|
jQuery.event = {
|
|
|
|
|
|
|
|
// Bind an event to an element
|
|
|
|
// Original by Dean Edwards
|
2009-04-30 01:26:09 +00:00
|
|
|
add: function( elem, types, handler, data ) {
|
|
|
|
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
|
2007-12-19 01:10:20 +00:00
|
|
|
return;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2011-02-18 00:01:30 +00:00
|
|
|
// TODO :: Use a try/catch until it's safe to pull this out (likely 1.6)
|
|
|
|
// Minor release fix for bug #8018
|
|
|
|
try {
|
|
|
|
// For whatever reason, IE has trouble passing the window object
|
|
|
|
// around, causing it to be cloned in the process
|
|
|
|
if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
|
|
|
|
elem = window;
|
|
|
|
}
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2011-02-18 00:01:30 +00:00
|
|
|
catch ( e ) {}
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2010-02-27 14:02:13 +00:00
|
|
|
if ( handler === false ) {
|
|
|
|
handler = returnFalse;
|
2010-10-24 16:18:33 +00:00
|
|
|
} else if ( !handler ) {
|
2010-11-09 15:34:32 +00:00
|
|
|
// Fixes bug #7229. Fix recommended by jdalton
|
2011-02-15 21:03:23 +00:00
|
|
|
return;
|
2010-02-27 14:02:13 +00:00
|
|
|
}
|
|
|
|
|
2010-02-05 02:36:32 +00:00
|
|
|
var handleObjIn, handleObj;
|
|
|
|
|
|
|
|
if ( handler.handler ) {
|
|
|
|
handleObjIn = handler;
|
|
|
|
handler = handleObjIn.handler;
|
|
|
|
}
|
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
// Make sure that the function being executed has a unique ID
|
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
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
// Init the element's event structure
|
2011-01-09 21:52:33 +00:00
|
|
|
var elemData = jQuery._data( elem );
|
2010-01-28 19:12:44 +00:00
|
|
|
|
|
|
|
// If no elemData is found then we must be trying to bind to one of the
|
|
|
|
// banned noData elements
|
|
|
|
if ( !elemData ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-07 16:48:38 +00:00
|
|
|
var events = elemData.events,
|
2010-03-01 17:44:56 +00:00
|
|
|
eventHandle = elemData.handle;
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2011-02-07 16:48:38 +00:00
|
|
|
if ( !events ) {
|
2010-09-29 13:46:25 +00:00
|
|
|
elemData.events = events = {};
|
|
|
|
}
|
2009-12-16 21:45:00 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
if ( !eventHandle ) {
|
2011-03-05 02:16:40 +00:00
|
|
|
elemData.handle = eventHandle = function( e ) {
|
2007-12-19 01:10:20 +00:00
|
|
|
// Handle the second event of a trigger and when
|
|
|
|
// an event is called after a page has unloaded
|
2011-03-05 02:16:40 +00:00
|
|
|
return typeof jQuery !== "undefined" && 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
|
|
|
};
|
2010-01-13 16:24:54 +00:00
|
|
|
}
|
|
|
|
|
2007-12-21 04:53:33 +00:00
|
|
|
// Add elem as a property of the handle function
|
2010-02-04 05:20:52 +00:00
|
|
|
// This is to prevent a memory leak with non-native events in IE.
|
|
|
|
eventHandle.elem = elem;
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2008-04-29 23:34:50 +00:00
|
|
|
// Handle multiple events separated by a space
|
|
|
|
// jQuery(...).bind("mouseover mouseout", fn);
|
2010-01-28 19:12:44 +00:00
|
|
|
types = types.split(" ");
|
2010-01-25 21:45:39 +00:00
|
|
|
|
2010-01-28 19:12:44 +00:00
|
|
|
var type, i = 0, namespaces;
|
2010-01-25 21:45:39 +00:00
|
|
|
|
2009-04-30 01:26:09 +00:00
|
|
|
while ( (type = types[ i++ ]) ) {
|
2010-02-05 02:36:32 +00:00
|
|
|
handleObj = handleObjIn ?
|
|
|
|
jQuery.extend({}, handleObjIn) :
|
|
|
|
{ handler: handler, data: data };
|
2010-01-25 21:45:39 +00:00
|
|
|
|
2010-01-28 19:12:44 +00:00
|
|
|
// Namespaced event handlers
|
|
|
|
if ( type.indexOf(".") > -1 ) {
|
|
|
|
namespaces = type.split(".");
|
|
|
|
type = namespaces.shift();
|
2010-02-04 05:20:52 +00:00
|
|
|
handleObj.namespace = namespaces.slice(0).sort().join(".");
|
2010-01-28 19:12:44 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
namespaces = [];
|
2010-02-05 02:36:32 +00:00
|
|
|
handleObj.namespace = "";
|
2010-01-28 19:12:44 +00:00
|
|
|
}
|
2008-04-29 23:34:50 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
handleObj.type = type;
|
2010-03-09 17:22:25 +00:00
|
|
|
if ( !handleObj.guid ) {
|
|
|
|
handleObj.guid = handler.guid;
|
|
|
|
}
|
2010-02-04 05:20:52 +00:00
|
|
|
|
2008-04-29 23:34:50 +00:00
|
|
|
// Get the current list of functions bound to this event
|
2009-04-30 21:44:25 +00:00
|
|
|
var handlers = events[ type ],
|
2010-02-04 05:20:52 +00:00
|
|
|
special = jQuery.event.special[ type ] || {};
|
2009-04-30 21:44:25 +00:00
|
|
|
|
2008-04-29 23:34:50 +00:00
|
|
|
// Init the event handler queue
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( !handlers ) {
|
2010-02-04 05:20:52 +00:00
|
|
|
handlers = events[ type ] = [];
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2008-04-29 23:34:50 +00:00
|
|
|
// Check for a special event handler
|
|
|
|
// 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
|
|
|
|
2008-04-29 23:34:50 +00:00
|
|
|
// Add the function to the element's handler list
|
2010-02-04 05:20:52 +00:00
|
|
|
handlers.push( handleObj );
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2008-04-29 23:34:50 +00:00
|
|
|
// Keep track of which events have been used, for global triggering
|
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
|
2010-02-04 05:20:52 +00:00
|
|
|
remove: function( elem, types, handler, pos ) {
|
2007-12-19 01:10:20 +00:00
|
|
|
// don't do events on text and comment nodes
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
|
2007-12-19 01:10:20 +00:00
|
|
|
return;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2010-02-27 14:02:13 +00:00
|
|
|
if ( handler === false ) {
|
|
|
|
handler = returnFalse;
|
|
|
|
}
|
|
|
|
|
2010-03-02 02:24:49 +00:00
|
|
|
var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
|
2011-01-09 21:52:33 +00:00
|
|
|
elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
|
2011-02-07 16:48:38 +00:00
|
|
|
events = elemData && elemData.events;
|
2010-01-28 19:12:44 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
if ( !elemData || !events ) {
|
2010-01-28 19:12:44 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
// types is actually an event object here
|
|
|
|
if ( types && types.type ) {
|
|
|
|
handler = types.handler;
|
|
|
|
types = types.type;
|
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
// Unbind all events for the element
|
|
|
|
if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
|
|
|
|
types = types || "";
|
2010-01-28 19:12:44 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
for ( type in events ) {
|
|
|
|
jQuery.event.remove( elem, type + types );
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
// Handle multiple events separated by a space
|
|
|
|
// jQuery(...).unbind("mouseover mouseout", fn);
|
|
|
|
types = types.split(" ");
|
|
|
|
|
|
|
|
while ( (type = types[ i++ ]) ) {
|
|
|
|
origType = type;
|
|
|
|
handleObj = null;
|
|
|
|
all = type.indexOf(".") < 0;
|
|
|
|
namespaces = [];
|
|
|
|
|
|
|
|
if ( !all ) {
|
|
|
|
// Namespaced event handlers
|
|
|
|
namespaces = type.split(".");
|
|
|
|
type = namespaces.shift();
|
2010-01-28 19:12:44 +00:00
|
|
|
|
2010-12-26 20:28:13 +00:00
|
|
|
namespace = new RegExp("(^|\\.)" +
|
2010-03-01 23:19:29 +00:00
|
|
|
jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
|
2010-02-04 05:20:52 +00:00
|
|
|
}
|
2010-01-28 19:12:44 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
eventType = events[ type ];
|
2010-01-28 19:12:44 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
if ( !eventType ) {
|
|
|
|
continue;
|
|
|
|
}
|
2010-01-28 19:12:44 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
if ( !handler ) {
|
2010-03-02 02:24:49 +00:00
|
|
|
for ( j = 0; j < eventType.length; j++ ) {
|
2010-02-04 05:20:52 +00:00
|
|
|
handleObj = eventType[ j ];
|
2010-01-28 19:16:52 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
if ( all || namespace.test( handleObj.namespace ) ) {
|
|
|
|
jQuery.event.remove( elem, origType, handleObj.handler, j );
|
|
|
|
eventType.splice( j--, 1 );
|
2010-01-28 19:12:44 +00:00
|
|
|
}
|
2010-02-04 05:20:52 +00:00
|
|
|
}
|
2010-01-28 19:12:44 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
continue;
|
|
|
|
}
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
special = jQuery.event.special[ type ] || {};
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2010-03-02 02:24:49 +00:00
|
|
|
for ( j = pos || 0; j < eventType.length; j++ ) {
|
2010-02-04 05:20:52 +00:00
|
|
|
handleObj = eventType[ j ];
|
2010-01-28 19:16:52 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
if ( handler.guid === handleObj.guid ) {
|
|
|
|
// remove the given handler for the given type
|
|
|
|
if ( all || namespace.test( handleObj.namespace ) ) {
|
|
|
|
if ( pos == null ) {
|
|
|
|
eventType.splice( j--, 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( special.remove ) {
|
2010-02-05 02:36:32 +00:00
|
|
|
special.remove.call( elem, handleObj );
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-04 05:20:52 +00:00
|
|
|
|
|
|
|
if ( pos != null ) {
|
|
|
|
break;
|
|
|
|
}
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
// remove generic event handler if no more handlers exist
|
2010-02-11 06:42:51 +00:00
|
|
|
if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
|
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
|
|
|
}
|
|
|
|
|
|
|
|
ret = null;
|
|
|
|
delete events[ type ];
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2010-02-04 05:20:52 +00:00
|
|
|
}
|
2010-01-28 19:12:44 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
// Remove the expando if it's no longer used
|
|
|
|
if ( jQuery.isEmptyObject( events ) ) {
|
|
|
|
var handle = elemData.handle;
|
|
|
|
if ( handle ) {
|
|
|
|
handle.elem = null;
|
|
|
|
}
|
2010-01-28 19:12:44 +00:00
|
|
|
|
2010-10-12 23:49:37 +00:00
|
|
|
delete elemData.events;
|
2010-02-04 05:20:52 +00:00
|
|
|
delete elemData.handle;
|
2010-01-28 19:12:44 +00:00
|
|
|
|
2011-02-07 16:48:38 +00:00
|
|
|
if ( jQuery.isEmptyObject( elemData ) ) {
|
2011-01-09 21:52:33 +00:00
|
|
|
jQuery.removeData( elem, undefined, true );
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-01-05 13:31:21 +00:00
|
|
|
// bubbling is internal
|
2009-05-10 14:38:35 +00:00
|
|
|
trigger: function( event, data, elem /*, bubbling */ ) {
|
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,
|
|
|
|
bubbling = arguments[3];
|
2008-12-31 02:58:13 +00:00
|
|
|
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( !bubbling ) {
|
2009-01-02 23:07:16 +00:00
|
|
|
event = typeof event === "object" ?
|
|
|
|
// jQuery.Event object
|
2010-04-24 21:15:45 +00:00
|
|
|
event[ jQuery.expando ] ? event :
|
2009-01-02 23:07:16 +00:00
|
|
|
// Object literal
|
|
|
|
jQuery.extend( jQuery.Event(type), event ) :
|
|
|
|
// Just the event type (string)
|
|
|
|
jQuery.Event(type);
|
|
|
|
|
|
|
|
if ( type.indexOf("!") >= 0 ) {
|
|
|
|
event.type = type = type.slice(0, -1);
|
|
|
|
event.exclusive = true;
|
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2009-01-02 23:07:16 +00:00
|
|
|
// Handle a global trigger
|
|
|
|
if ( !elem ) {
|
|
|
|
// Don't bubble custom events when global (to avoid too much overhead)
|
|
|
|
event.stopPropagation();
|
2009-12-22 01:13:16 +00:00
|
|
|
|
2009-01-02 23:07:16 +00:00
|
|
|
// Only trigger if we've ever bound an event for it
|
2010-02-04 05:20:52 +00:00
|
|
|
if ( jQuery.event.global[ type ] ) {
|
2011-01-09 21:52:33 +00:00
|
|
|
// XXX This code smells terrible. event.js should not be directly
|
|
|
|
// inspecting the data cache
|
2009-05-01 00:59:27 +00:00
|
|
|
jQuery.each( jQuery.cache, function() {
|
2011-01-09 21:52:33 +00:00
|
|
|
// internalKey variable is just used to make it easier to find
|
|
|
|
// and potentially change this stuff later; currently it just
|
|
|
|
// points to jQuery.expando
|
|
|
|
var internalKey = jQuery.expando,
|
|
|
|
internalCache = this[ internalKey ];
|
2011-02-07 16:48:38 +00:00
|
|
|
if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
|
2011-01-09 21:52:33 +00:00
|
|
|
jQuery.event.trigger( event, data, internalCache.handle.elem );
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2009-05-01 00:59:27 +00:00
|
|
|
});
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2009-01-02 23:07:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Handle triggering a single element
|
2008-12-25 21:44:54 +00:00
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
// don't do events on text and comment nodes
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
|
2007-12-19 01:10:20 +00:00
|
|
|
return undefined;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2009-01-05 13:31:21 +00:00
|
|
|
// Clean up in case it is reused
|
|
|
|
event.result = undefined;
|
|
|
|
event.target = elem;
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2009-01-05 13:31:21 +00:00
|
|
|
// Clone the incoming data, if any
|
2009-04-30 01:26:09 +00:00
|
|
|
data = jQuery.makeArray( data );
|
2009-01-05 13:31:21 +00:00
|
|
|
data.unshift( event );
|
2009-01-02 23:07:16 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2009-01-02 23:07:16 +00:00
|
|
|
event.currentTarget = elem;
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2009-01-02 23:07:16 +00:00
|
|
|
// Trigger the event, it is assumed that "handle" is a function
|
2011-02-07 16:48:38 +00:00
|
|
|
var handle = jQuery._data( elem, "handle" );
|
2010-09-29 13:46:25 +00:00
|
|
|
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( handle ) {
|
2009-01-02 23:07:16 +00:00
|
|
|
handle.apply( elem, data );
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2010-01-25 18:45:07 +00:00
|
|
|
var parent = elem.parentNode || elem.ownerDocument;
|
|
|
|
|
|
|
|
// Trigger an inline bound script
|
2009-06-17 02:31:45 +00:00
|
|
|
try {
|
2009-12-09 22:49:31 +00:00
|
|
|
if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
|
2010-01-25 18:45:07 +00:00
|
|
|
if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
|
|
|
|
event.result = false;
|
2010-09-24 22:02:31 +00:00
|
|
|
event.preventDefault();
|
2010-01-25 18:45:07 +00:00
|
|
|
}
|
2009-12-09 22:49:31 +00:00
|
|
|
}
|
2010-01-25 18:45:07 +00:00
|
|
|
|
2009-06-17 02:31:45 +00:00
|
|
|
// prevent IE from throwing an error for some elements with some event types, see #3533
|
2010-03-02 02:24:49 +00:00
|
|
|
} catch (inlineError) {}
|
2009-12-05 04:18:05 +00:00
|
|
|
|
2010-01-25 18:45:07 +00:00
|
|
|
if ( !event.isPropagationStopped() && parent ) {
|
|
|
|
jQuery.event.trigger( event, data, parent, true );
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2010-01-25 18:45:07 +00:00
|
|
|
} else if ( !event.isDefaultPrevented() ) {
|
2010-11-09 16:09:07 +00:00
|
|
|
var old,
|
|
|
|
target = event.target,
|
|
|
|
targetType = type.replace( rnamespaces, "" ),
|
|
|
|
isClick = jQuery.nodeName( target, "a" ) && targetType === "click",
|
2010-03-09 17:22:25 +00:00
|
|
|
special = jQuery.event.special[ targetType ] || {};
|
2010-01-28 19:34:09 +00:00
|
|
|
|
2010-12-26 20:28:13 +00:00
|
|
|
if ( (!special._default || special._default.call( elem, event ) === false) &&
|
2010-01-28 19:34:09 +00:00
|
|
|
!isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
|
2009-12-05 04:18:05 +00:00
|
|
|
|
2010-01-25 18:45:07 +00:00
|
|
|
try {
|
2010-03-09 17:22:25 +00:00
|
|
|
if ( target[ targetType ] ) {
|
2010-01-25 18:45:07 +00:00
|
|
|
// Make sure that we don't accidentally re-trigger the onFOO events
|
2010-03-09 17:22:25 +00:00
|
|
|
old = target[ "on" + targetType ];
|
2010-01-25 18:45:07 +00:00
|
|
|
|
|
|
|
if ( old ) {
|
2010-03-09 17:22:25 +00:00
|
|
|
target[ "on" + targetType ] = null;
|
2010-01-25 18:45:07 +00:00
|
|
|
}
|
|
|
|
|
2011-03-05 02:16:40 +00:00
|
|
|
jQuery.event.triggered = event.type;
|
2010-03-09 17:22:25 +00:00
|
|
|
target[ targetType ]();
|
2010-01-25 18:45:07 +00:00
|
|
|
}
|
2008-12-31 02:58:13 +00:00
|
|
|
|
2010-01-25 18:45:07 +00:00
|
|
|
// prevent IE from throwing an error for some elements with some event types, see #3533
|
2010-03-02 02:24:49 +00:00
|
|
|
} catch (triggerError) {}
|
2010-01-25 18:45:07 +00:00
|
|
|
|
|
|
|
if ( old ) {
|
2010-03-09 17:22:25 +00:00
|
|
|
target[ "on" + targetType ] = old;
|
2010-01-25 18:45:07 +00:00
|
|
|
}
|
2009-01-05 20:43:24 +00:00
|
|
|
|
2011-03-05 02:16:40 +00:00
|
|
|
jQuery.event.triggered = undefined;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-04-30 01:26:09 +00:00
|
|
|
handle: function( event ) {
|
2010-11-09 16:09:07 +00:00
|
|
|
var all, handlers, namespaces, namespace_re, events,
|
|
|
|
namespace_sort = [],
|
|
|
|
args = jQuery.makeArray( arguments );
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2010-03-02 02:24:49 +00:00
|
|
|
event = args[0] = jQuery.event.fix( event || window.event );
|
2009-02-17 12:38:16 +00:00
|
|
|
event.currentTarget = this;
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
// Namespaced event handlers
|
2010-02-08 16:31:01 +00:00
|
|
|
all = event.type.indexOf(".") < 0 && !event.exclusive;
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
if ( !all ) {
|
|
|
|
namespaces = event.type.split(".");
|
|
|
|
event.type = namespaces.shift();
|
2010-03-02 22:34:12 +00:00
|
|
|
namespace_sort = namespaces.slice(0).sort();
|
|
|
|
namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)");
|
2010-02-04 05:20:52 +00:00
|
|
|
}
|
2008-04-23 18:57:17 +00:00
|
|
|
|
2010-03-09 17:22:25 +00:00
|
|
|
event.namespace = event.namespace || namespace_sort.join(".");
|
|
|
|
|
2011-02-07 16:48:38 +00:00
|
|
|
events = jQuery._data(this, "events");
|
2010-09-29 13:46:25 +00:00
|
|
|
|
2010-02-27 07:31:33 +00:00
|
|
|
handlers = (events || {})[ event.type ];
|
2010-02-04 05:20:52 +00:00
|
|
|
|
|
|
|
if ( events && handlers ) {
|
|
|
|
// Clone the handlers to prevent manipulation
|
|
|
|
handlers = handlers.slice(0);
|
|
|
|
|
|
|
|
for ( var j = 0, l = handlers.length; j < l; j++ ) {
|
|
|
|
var handleObj = handlers[ j ];
|
|
|
|
|
|
|
|
// Filter the functions by class
|
2010-03-02 22:34:12 +00:00
|
|
|
if ( all || namespace_re.test( handleObj.namespace ) ) {
|
2010-02-04 05:20:52 +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;
|
2010-02-05 02:36:32 +00:00
|
|
|
event.handleObj = handleObj;
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2010-03-02 02:24:49 +00:00
|
|
|
var ret = handleObj.handler.apply( this, args );
|
2010-02-04 05:20:52 +00:00
|
|
|
|
|
|
|
if ( ret !== undefined ) {
|
|
|
|
event.result = ret;
|
|
|
|
if ( ret === false ) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
2008-12-31 02:58:13 +00:00
|
|
|
}
|
2008-10-18 22:46:04 +00:00
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
if ( event.isImmediatePropagationStopped() ) {
|
|
|
|
break;
|
|
|
|
}
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-07 00:55:08 +00:00
|
|
|
|
|
|
|
return event.result;
|
2007-12-19 01:10:20 +00:00
|
|
|
},
|
|
|
|
|
2010-06-29 03:21:59 +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 pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
|
2008-05-28 20:43:13 +00:00
|
|
|
|
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
|
2007-12-19 01:10:20 +00:00
|
|
|
var originalEvent = event;
|
2008-12-29 21:57:29 +00:00
|
|
|
event = jQuery.Event( originalEvent );
|
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
|
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)
|
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
|
|
|
|
|
|
|
// Calculate pageX/Y if missing and clientX/Y available
|
|
|
|
if ( event.pageX == null && event.clientX != null ) {
|
2010-11-09 16:09:07 +00:00
|
|
|
var doc = document.documentElement,
|
|
|
|
body = document.body;
|
|
|
|
|
2009-05-01 00:21:29 +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);
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
// Add which for key events
|
2010-09-29 03:13:40 +00:00
|
|
|
if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
|
2010-09-28 16:07:57 +00:00
|
|
|
event.which = event.charCode != null ? event.charCode : event.keyCode;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
// Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( !event.metaKey && event.ctrlKey ) {
|
2007-12-19 01:10:20 +00:00
|
|
|
event.metaKey = event.ctrlKey;
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2009-12-21 23:02:02 +00:00
|
|
|
// Add which for click: 1 === left; 2 === middle; 3 === right
|
2007-12-19 01:10:20 +00:00
|
|
|
// Note: button is not normalized, so don't use it
|
2009-06-17 02:31:45 +00:00
|
|
|
if ( !event.which && event.button !== undefined ) {
|
2007-12-19 01:10:20 +00:00
|
|
|
event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
|
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
|
2009-12-08 00:34:55 +00:00
|
|
|
setup: jQuery.bindReady,
|
2009-12-31 14:50:49 +00:00
|
|
|
teardown: jQuery.noop
|
2009-04-30 21:44:25 +00:00
|
|
|
},
|
2009-05-06 01:24:22 +00:00
|
|
|
|
2008-12-22 04:59:34 +00:00
|
|
|
live: {
|
2010-02-05 02:36:32 +00:00
|
|
|
add: function( handleObj ) {
|
2010-03-09 17:22:25 +00:00
|
|
|
jQuery.event.add( this,
|
|
|
|
liveConvert( handleObj.origType, handleObj.selector ),
|
2010-12-26 20:28:13 +00:00
|
|
|
jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
|
2008-12-22 04:59:34 +00:00
|
|
|
},
|
2009-05-06 01:24:22 +00:00
|
|
|
|
2010-02-05 02:36:32 +00:00
|
|
|
remove: function( handleObj ) {
|
2010-03-09 17:22:25 +00:00
|
|
|
jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
|
2010-02-05 02:36:32 +00:00
|
|
|
}
|
2009-12-07 00:55:08 +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
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-09-08 22:13:35 +00:00
|
|
|
jQuery.removeEvent = document.removeEventListener ?
|
2010-01-28 20:25:52 +00:00
|
|
|
function( elem, type, handle ) {
|
2010-02-26 16:32:12 +00:00
|
|
|
if ( elem.removeEventListener ) {
|
|
|
|
elem.removeEventListener( type, handle, false );
|
|
|
|
}
|
2010-12-26 20:28:13 +00:00
|
|
|
} :
|
2010-01-28 20:25:52 +00:00
|
|
|
function( elem, type, handle ) {
|
2010-02-26 16:32:12 +00:00
|
|
|
if ( elem.detachEvent ) {
|
|
|
|
elem.detachEvent( "on" + type, handle );
|
|
|
|
}
|
2010-01-28 20:25:52 +00:00
|
|
|
};
|
|
|
|
|
2009-12-22 00:58:13 +00:00
|
|
|
jQuery.Event = function( src ) {
|
2008-12-29 21:57:29 +00:00
|
|
|
// Allow instantiation without the 'new' keyword
|
2009-04-30 01:26:09 +00:00
|
|
|
if ( !this.preventDefault ) {
|
|
|
|
return new jQuery.Event( src );
|
|
|
|
}
|
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;
|
|
|
|
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
|
|
|
|
2009-01-19 22:20:25 +00:00
|
|
|
// timeStamp is buggy for some events on Firefox(#3843)
|
|
|
|
// So we won't rely on the native value
|
2010-03-23 16:12:16 +00:00
|
|
|
this.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
|
|
|
|
2008-12-21 21:22:44 +00:00
|
|
|
// Checks if an event happened on an element within another element
|
|
|
|
// Used in jQuery.event.special.mouseenter and mouseleave handlers
|
2009-04-30 01:26:09 +00:00
|
|
|
var withinElement = function( event ) {
|
2008-12-21 21:22:44 +00:00
|
|
|
// Check if mouse(over|out) are still within the same parent element
|
|
|
|
var parent = event.relatedTarget;
|
2009-12-21 23:06:23 +00:00
|
|
|
|
2010-02-13 10:45:48 +00:00
|
|
|
// Firefox sometimes assigns relatedTarget a XUL element
|
|
|
|
// which we cannot access the parentNode property of
|
|
|
|
try {
|
2011-02-08 16:15:55 +00:00
|
|
|
|
|
|
|
// Chrome does something similar, the parentNode property
|
|
|
|
// can be accessed but is null.
|
2011-03-10 03:38:26 +00:00
|
|
|
if ( parent && parent !== document && !parent.parentNode ) {
|
2011-02-08 16:15:55 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-02-13 10:45:48 +00:00
|
|
|
// Traverse up the tree
|
|
|
|
while ( parent && parent !== this ) {
|
2009-12-21 23:06:23 +00:00
|
|
|
parent = parent.parentNode;
|
|
|
|
}
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2011-02-08 16:08:25 +00:00
|
|
|
if ( parent !== this ) {
|
2010-02-13 10:45:48 +00:00
|
|
|
// set the correct event type
|
|
|
|
event.type = event.data;
|
2009-12-21 23:06:23 +00:00
|
|
|
|
2010-02-13 10:45:48 +00:00
|
|
|
// handle event if we actually just moused on to a non sub-element
|
|
|
|
jQuery.event.handle.apply( this, arguments );
|
|
|
|
}
|
2009-11-09 11:59:54 +00:00
|
|
|
|
2010-02-13 10:45:48 +00:00
|
|
|
// assuming we've left the element since we most likely mousedover a xul element
|
|
|
|
} catch(e) { }
|
2009-11-09 11:59:54 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// In case of event delegation, we only need to rename the event.type,
|
|
|
|
// liveHandler will take care of the rest.
|
|
|
|
delegate = function( event ) {
|
|
|
|
event.type = event.data;
|
|
|
|
jQuery.event.handle.apply( this, arguments );
|
2008-12-21 21:22:44 +00:00
|
|
|
};
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2009-09-14 22:04:22 +00:00
|
|
|
// Create mouseenter and mouseleave events
|
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 ) {
|
2009-11-30 20:04:55 +00:00
|
|
|
jQuery.event.special[ orig ] = {
|
2009-12-22 00:58:13 +00:00
|
|
|
setup: function( data ) {
|
2009-11-30 20:04:55 +00:00
|
|
|
jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
|
2008-12-21 21:22:44 +00:00
|
|
|
},
|
2009-12-22 00:58:13 +00:00
|
|
|
teardown: function( data ) {
|
2009-11-30 20:04:55 +00:00
|
|
|
jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
|
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 = {
|
|
|
|
setup: function( data, namespaces ) {
|
2010-11-21 03:31:04 +00:00
|
|
|
if ( this.nodeName && this.nodeName.toLowerCase() !== "form" ) {
|
2010-02-09 04:28:15 +00:00
|
|
|
jQuery.event.add(this, "click.specialSubmit", function( e ) {
|
2010-11-09 16:09:07 +00:00
|
|
|
var elem = e.target,
|
|
|
|
type = elem.type;
|
2010-02-09 04:28:15 +00:00
|
|
|
|
|
|
|
if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
|
2011-02-10 02:25:29 +00:00
|
|
|
trigger( "submit", this, arguments );
|
2010-02-09 04:28:15 +00:00
|
|
|
}
|
|
|
|
});
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
|
2010-11-09 16:09:07 +00:00
|
|
|
var elem = e.target,
|
|
|
|
type = elem.type;
|
2009-12-04 16:28:50 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
|
2011-02-10 02:25:29 +00:00
|
|
|
trigger( "submit", this, arguments );
|
2010-02-09 04:28:15 +00:00
|
|
|
}
|
|
|
|
});
|
2010-01-11 17:26:28 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
2009-12-04 16:28:50 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
teardown: function( namespaces ) {
|
2010-02-10 20:56:53 +00:00
|
|
|
jQuery.event.remove( this, ".specialSubmit" );
|
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 ) {
|
|
|
|
|
2010-09-22 13:16:28 +00:00
|
|
|
var changeFilters,
|
2009-12-04 16:28:50 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
getVal = function( elem ) {
|
|
|
|
var type = 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
|
|
|
|
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;
|
|
|
|
}).join("-") :
|
|
|
|
"";
|
2009-12-21 20:32:32 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
} else if ( elem.nodeName.toLowerCase() === "select" ) {
|
|
|
|
val = elem.selectedIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
return val;
|
|
|
|
},
|
2009-12-21 20:32:32 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
testChange = function testChange( e ) {
|
2009-12-21 20:32:32 +00:00
|
|
|
var elem = e.target, data, val;
|
|
|
|
|
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-01-09 21:52:33 +00:00
|
|
|
data = jQuery._data( elem, "_change_data" );
|
2009-12-21 20:32:32 +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
|
|
|
|
2010-01-23 17:52:32 +00:00
|
|
|
if ( data === undefined || val === data ) {
|
|
|
|
return;
|
|
|
|
}
|
2009-12-21 20:32:32 +00:00
|
|
|
|
2010-01-18 22:52:36 +00:00
|
|
|
if ( data != null || val ) {
|
2009-12-21 20:32:32 +00:00
|
|
|
e.type = "change";
|
2010-10-09 22:16:08 +00:00
|
|
|
e.liveFired = undefined;
|
2011-02-10 02:25:29 +00:00
|
|
|
jQuery.event.trigger( e, arguments[1], elem );
|
2009-12-21 20:32:32 +00:00
|
|
|
}
|
2010-02-09 04:28:15 +00:00
|
|
|
};
|
2009-12-21 20:32:32 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
jQuery.event.special.change = {
|
|
|
|
filters: {
|
2010-12-26 20:28:13 +00:00
|
|
|
focusout: testChange,
|
2009-12-21 20:32:32 +00:00
|
|
|
|
2010-10-13 14:38:29 +00:00
|
|
|
beforedeactivate: testChange,
|
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
click: function( e ) {
|
|
|
|
var elem = e.target, type = elem.type;
|
2009-12-21 20:32:32 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
|
2011-02-10 02:25:29 +00:00
|
|
|
testChange.call( this, e );
|
2010-02-09 04:28:15 +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 ) {
|
|
|
|
var elem = e.target, type = elem.type;
|
2009-12-04 16:28:50 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
|
|
|
|
(e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
|
|
|
|
type === "select-multiple" ) {
|
2011-02-10 02:25:29 +00:00
|
|
|
testChange.call( this, e );
|
2010-02-09 04:28:15 +00:00
|
|
|
}
|
|
|
|
},
|
2009-12-04 16:28:50 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
// Beforeactivate happens also before the previous element is blurred
|
|
|
|
// with this event you can't trigger a change event, but you can store
|
2010-10-09 23:04:15 +00:00
|
|
|
// information
|
2010-02-09 04:28:15 +00:00
|
|
|
beforeactivate: function( e ) {
|
|
|
|
var elem = e.target;
|
2011-01-09 21:52:33 +00:00
|
|
|
jQuery._data( elem, "_change_data", getVal(elem) );
|
2009-12-04 16:28:50 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
setup: function( data, namespaces ) {
|
2010-02-13 09:40:26 +00:00
|
|
|
if ( this.type === "file" ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
for ( var type in changeFilters ) {
|
|
|
|
jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
|
|
|
|
}
|
2010-02-05 16:02:56 +00:00
|
|
|
|
2010-09-22 13:16:28 +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 ) {
|
2010-02-10 20:56:53 +00:00
|
|
|
jQuery.event.remove( this, ".specialChange" );
|
2010-02-05 16:02:56 +00:00
|
|
|
|
2010-09-22 13:16:28 +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-21 20:32:32 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
changeFilters = jQuery.event.special.change.filters;
|
2010-10-09 23:04:15 +00:00
|
|
|
|
|
|
|
// Handle when the input is .focus()'d
|
|
|
|
changeFilters.focus = changeFilters.beforeactivate;
|
2009-12-07 15:38:16 +00:00
|
|
|
}
|
|
|
|
|
2009-12-04 16:28:50 +00:00
|
|
|
function trigger( type, elem, args ) {
|
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.
|
|
|
|
// Don't pass args or remember liveFired; they apply to the donor event.
|
|
|
|
var event = jQuery.extend( {}, args[ 0 ] );
|
|
|
|
event.type = type;
|
|
|
|
event.originalEvent = {};
|
|
|
|
event.liveFired = undefined;
|
|
|
|
jQuery.event.handle.call( elem, event );
|
|
|
|
if ( event.isDefaultPrevented() ) {
|
|
|
|
args[ 0 ].preventDefault();
|
|
|
|
}
|
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
|
2009-12-21 21:10:21 +00:00
|
|
|
if ( document.addEventListener ) {
|
2009-12-22 00:58:13 +00:00
|
|
|
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
|
2011-03-05 02:16:40 +00:00
|
|
|
|
|
|
|
// Attach a single capturing handler while someone wants focusin/focusout
|
|
|
|
var attaches = 0;
|
|
|
|
|
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-09-14 22:04:22 +00:00
|
|
|
|
2011-03-05 02:16:40 +00:00
|
|
|
function handler( donor ) {
|
|
|
|
// Donor event is always a native one; fix it and switch its type.
|
|
|
|
// Let focusin/out handler cancel the donor focus/blur event.
|
|
|
|
var e = jQuery.event.fix( donor );
|
2009-12-21 21:10:21 +00:00
|
|
|
e.type = fix;
|
2011-03-05 02:16:40 +00:00
|
|
|
e.originalEvent = {};
|
|
|
|
jQuery.event.trigger( e, null, e.target );
|
|
|
|
if ( e.isDefaultPrevented() ) {
|
|
|
|
donor.preventDefault();
|
|
|
|
}
|
2009-09-14 22:04:22 +00:00
|
|
|
}
|
2009-12-21 21:10:21 +00:00
|
|
|
});
|
2009-12-07 02:02:58 +00:00
|
|
|
}
|
|
|
|
|
2009-12-22 00:58:13 +00:00
|
|
|
jQuery.each(["bind", "one"], function( i, name ) {
|
2009-12-31 05:37:23 +00:00
|
|
|
jQuery.fn[ name ] = function( type, data, fn ) {
|
2009-09-16 02:19:18 +00:00
|
|
|
// Handle object literals
|
|
|
|
if ( typeof type === "object" ) {
|
|
|
|
for ( var key in type ) {
|
2009-12-10 22:44:30 +00:00
|
|
|
this[ name ](key, data, type[key], fn);
|
2009-09-16 02:19:18 +00:00
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2010-02-27 14:02:13 +00:00
|
|
|
if ( jQuery.isFunction( data ) || data === false ) {
|
2009-05-07 00:50:28 +00:00
|
|
|
fn = data;
|
|
|
|
data = undefined;
|
|
|
|
}
|
2009-12-31 05:37:23 +00:00
|
|
|
|
|
|
|
var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
|
2009-12-10 22:44:30 +00:00
|
|
|
jQuery( this ).unbind( event, handler );
|
2009-05-07 00:50:28 +00:00
|
|
|
return fn.apply( this, arguments );
|
2009-12-10 22:44:30 +00:00
|
|
|
}) : fn;
|
2009-12-31 05:37:23 +00:00
|
|
|
|
2010-01-28 19:12:44 +00:00
|
|
|
if ( type === "unload" && name !== "one" ) {
|
|
|
|
this.one( type, data, fn );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
for ( var i = 0, l = this.length; i < l; i++ ) {
|
|
|
|
jQuery.event.add( this[i], type, handler, data );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
2009-12-10 22:44:30 +00:00
|
|
|
};
|
|
|
|
});
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2009-12-10 22:44:30 +00:00
|
|
|
jQuery.fn.extend({
|
2007-12-19 01:10:20 +00:00
|
|
|
unbind: function( type, fn ) {
|
2009-09-16 02:19:18 +00:00
|
|
|
// Handle object literals
|
|
|
|
if ( typeof type === "object" && !type.preventDefault ) {
|
|
|
|
for ( var key in type ) {
|
|
|
|
this.unbind(key, type[key]);
|
|
|
|
}
|
2010-01-28 19:12:44 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
for ( var i = 0, l = this.length; i < l; i++ ) {
|
|
|
|
jQuery.event.remove( this[i], type, fn );
|
|
|
|
}
|
2009-09-16 02:19:18 +00:00
|
|
|
}
|
2009-12-10 22:44:30 +00:00
|
|
|
|
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 ) {
|
|
|
|
return this.live( types, data, fn, selector );
|
|
|
|
},
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2010-02-01 23:06:03 +00:00
|
|
|
undelegate: function( selector, types, fn ) {
|
|
|
|
if ( arguments.length === 0 ) {
|
|
|
|
return this.unbind( "live" );
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2010-02-01 23:06:03 +00:00
|
|
|
} else {
|
|
|
|
return this.die( types, null, fn, selector );
|
|
|
|
}
|
|
|
|
},
|
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] ) {
|
|
|
|
var event = jQuery.Event( type );
|
2008-12-31 02:58:13 +00:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2009-01-02 22:23:52 +00:00
|
|
|
jQuery.event.trigger( event, data, this[0] );
|
2008-12-31 02:58:13 +00:00
|
|
|
return event.result;
|
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,
|
|
|
|
i = 1;
|
2008-04-29 22:06:54 +00:00
|
|
|
|
|
|
|
// link all the functions, so any of them can unbind this click handler
|
2009-12-22 00:58:13 +00:00
|
|
|
while ( i < args.length ) {
|
2009-12-31 05:37:23 +00:00
|
|
|
jQuery.proxy( fn, args[ i++ ] );
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
|
2009-12-31 05:37:23 +00:00
|
|
|
return this.click( jQuery.proxy( fn, function( event ) {
|
2007-12-19 01:10:20 +00:00
|
|
|
// Figure out which function to execute
|
2011-01-09 21:52:33 +00:00
|
|
|
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
|
|
|
|
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
// Make sure that clicks stop
|
|
|
|
event.preventDefault();
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2007-12-19 01:10:20 +00:00
|
|
|
// and execute the function
|
2009-11-11 14:46:24 +00:00
|
|
|
return args[ lastToggle ].apply( this, arguments ) || false;
|
2008-04-29 22:06:54 +00:00
|
|
|
}));
|
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-02-11 21:50:26 +00:00
|
|
|
var liveMap = {
|
|
|
|
focus: "focusin",
|
|
|
|
blur: "focusout",
|
|
|
|
mouseenter: "mouseover",
|
|
|
|
mouseleave: "mouseout"
|
|
|
|
};
|
|
|
|
|
2010-01-23 16:56:24 +00:00
|
|
|
jQuery.each(["live", "die"], function( i, name ) {
|
2010-02-01 23:06:03 +00:00
|
|
|
jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
|
2010-02-11 21:50:26 +00:00
|
|
|
var type, i = 0, match, namespaces, preType,
|
2010-02-01 23:06:03 +00:00
|
|
|
selector = origSelector || this.selector,
|
|
|
|
context = origSelector ? this : jQuery( this.context );
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2010-03-14 11:34:32 +00:00
|
|
|
if ( typeof types === "object" && !types.preventDefault ) {
|
|
|
|
for ( var key in types ) {
|
|
|
|
context[ name ]( key, data, types[key], selector );
|
|
|
|
}
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2010-03-14 11:34:32 +00:00
|
|
|
return this;
|
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2009-05-07 00:50:28 +00:00
|
|
|
if ( jQuery.isFunction( data ) ) {
|
|
|
|
fn = data;
|
|
|
|
data = undefined;
|
|
|
|
}
|
2009-12-31 05:37:23 +00:00
|
|
|
|
2010-02-05 02:36:32 +00:00
|
|
|
types = (types || "").split(" ");
|
2009-12-31 05:37:23 +00:00
|
|
|
|
2010-01-23 21:37:12 +00:00
|
|
|
while ( (type = types[ i++ ]) != null ) {
|
2010-02-05 02:36:32 +00:00
|
|
|
match = rnamespaces.exec( type );
|
|
|
|
namespaces = "";
|
|
|
|
|
|
|
|
if ( match ) {
|
|
|
|
namespaces = match[0];
|
|
|
|
type = type.replace( rnamespaces, "" );
|
|
|
|
}
|
|
|
|
|
2010-02-11 21:50:26 +00:00
|
|
|
if ( type === "hover" ) {
|
|
|
|
types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
|
|
|
|
continue;
|
|
|
|
}
|
2010-02-05 02:36:32 +00:00
|
|
|
|
2010-02-11 21:50:26 +00:00
|
|
|
preType = type;
|
2010-02-13 10:37:17 +00:00
|
|
|
|
|
|
|
if ( type === "focus" || type === "blur" ) {
|
|
|
|
types.push( liveMap[ type ] + namespaces );
|
|
|
|
type = type + namespaces;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
type = (liveMap[ type ] || type) + namespaces;
|
|
|
|
}
|
2010-02-05 02:36:32 +00:00
|
|
|
|
2010-01-23 16:56:24 +00:00
|
|
|
if ( name === "live" ) {
|
|
|
|
// bind live handler
|
2010-03-01 17:44:56 +00:00
|
|
|
for ( var j = 0, l = context.length; j < l; j++ ) {
|
2010-03-09 17:22:25 +00:00
|
|
|
jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
|
2010-02-11 21:50:26 +00:00
|
|
|
{ data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
|
2010-03-01 17:44:56 +00:00
|
|
|
}
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2010-01-23 16:56:24 +00:00
|
|
|
} else {
|
|
|
|
// unbind live handler
|
2010-03-09 17:22:25 +00:00
|
|
|
context.unbind( "live." + liveConvert( type, selector ), fn );
|
2010-01-23 16:56:24 +00:00
|
|
|
}
|
|
|
|
}
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2008-12-22 04:59:34 +00:00
|
|
|
return this;
|
2010-03-01 17:44:56 +00:00
|
|
|
};
|
2007-12-19 01:10:20 +00:00
|
|
|
});
|
|
|
|
|
2009-04-30 01:26:09 +00:00
|
|
|
function liveHandler( event ) {
|
2010-11-09 16:09:07 +00:00
|
|
|
var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
|
|
|
|
elems = [],
|
|
|
|
selectors = [],
|
2011-02-07 16:48:38 +00:00
|
|
|
events = jQuery._data( this, "events" );
|
2010-09-29 13:46:25 +00:00
|
|
|
|
2010-11-22 00:54:56 +00:00
|
|
|
// Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
|
|
|
|
if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
|
2010-01-23 16:12:26 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-12-26 20:28:13 +00:00
|
|
|
|
2010-03-02 22:34:12 +00:00
|
|
|
if ( event.namespace ) {
|
|
|
|
namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
|
|
|
|
}
|
|
|
|
|
2010-02-05 02:36:32 +00:00
|
|
|
event.liveFired = this;
|
|
|
|
|
|
|
|
var live = events.live.slice(0);
|
|
|
|
|
|
|
|
for ( j = 0; j < live.length; j++ ) {
|
|
|
|
handleObj = live[j];
|
|
|
|
|
|
|
|
if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
|
|
|
|
selectors.push( handleObj.selector );
|
2009-12-04 16:28:50 +00:00
|
|
|
|
2009-12-03 16:15:26 +00:00
|
|
|
} else {
|
2010-02-05 02:36:32 +00:00
|
|
|
live.splice( j--, 1 );
|
2009-12-03 15:51:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
match = jQuery( event.target ).closest( selectors, event.currentTarget );
|
|
|
|
|
|
|
|
for ( i = 0, l = match.length; i < l; i++ ) {
|
2010-02-26 14:26:14 +00:00
|
|
|
close = match[i];
|
|
|
|
|
2010-02-05 02:36:32 +00:00
|
|
|
for ( j = 0; j < live.length; j++ ) {
|
|
|
|
handleObj = live[j];
|
|
|
|
|
2011-02-18 18:09:07 +00:00
|
|
|
if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
|
2010-02-26 14:26:14 +00:00
|
|
|
elem = close.elem;
|
2010-02-05 02:36:32 +00:00
|
|
|
related = null;
|
2009-12-03 15:51:04 +00:00
|
|
|
|
2009-11-09 11:59:54 +00:00
|
|
|
// Those two events require additional checking
|
2010-02-11 21:50:26 +00:00
|
|
|
if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
|
2010-02-26 16:23:49 +00:00
|
|
|
event.type = handleObj.preType;
|
2010-02-05 02:36:32 +00:00
|
|
|
related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
|
2009-11-09 11:59:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( !related || related !== elem ) {
|
2010-02-26 14:26:14 +00:00
|
|
|
elems.push({ elem: elem, handleObj: handleObj, level: close.level });
|
2009-11-09 11:59:54 +00:00
|
|
|
}
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2008-12-22 04:59:34 +00:00
|
|
|
}
|
2009-12-03 15:51:04 +00:00
|
|
|
}
|
2009-01-10 19:57:07 +00:00
|
|
|
|
2009-12-03 15:51:04 +00:00
|
|
|
for ( i = 0, l = elems.length; i < l; i++ ) {
|
|
|
|
match = elems[i];
|
2010-02-26 14:26:14 +00:00
|
|
|
|
|
|
|
if ( maxLevel && match.level > maxLevel ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-12-03 15:51:04 +00:00
|
|
|
event.currentTarget = match.elem;
|
2010-02-05 02:36:32 +00:00
|
|
|
event.data = match.handleObj.data;
|
|
|
|
event.handleObj = match.handleObj;
|
|
|
|
|
2010-02-26 14:26:14 +00:00
|
|
|
ret = match.handleObj.origHandler.apply( match.elem, arguments );
|
|
|
|
|
|
|
|
if ( ret === false || event.isPropagationStopped() ) {
|
|
|
|
maxLevel = match.level;
|
|
|
|
|
|
|
|
if ( ret === false ) {
|
|
|
|
stop = false;
|
|
|
|
}
|
2010-10-23 18:36:24 +00:00
|
|
|
if ( event.isImmediatePropagationStopped() ) {
|
|
|
|
break;
|
|
|
|
}
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2009-12-03 15:51:04 +00:00
|
|
|
}
|
2009-01-10 19:57:07 +00:00
|
|
|
|
2008-12-30 20:45:33 +00:00
|
|
|
return stop;
|
2008-12-22 04:59:34 +00:00
|
|
|
}
|
|
|
|
|
2009-04-30 01:26:09 +00:00
|
|
|
function liveConvert( type, selector ) {
|
2010-09-22 13:16:28 +00:00
|
|
|
return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&");
|
2008-12-22 04:59:34 +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 " +
|
|
|
|
"change select submit keydown keypress keyup error").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
|
|
|
}
|
2007-12-19 01:10:20 +00:00
|
|
|
});
|
|
|
|
|
2010-09-08 17:54:33 +00:00
|
|
|
})( jQuery );
|