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, "\\$&");
|
2010-10-13 14:35:28 +00:00
|
|
|
},
|
|
|
|
focusCounts = { focusin: 0, focusout: 0 };
|
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
|
|
|
|
|
|
|
// For whatever reason, IE has trouble passing the window object
|
|
|
|
// around, causing it to be cloned in the process
|
2010-09-22 20:41:51 +00:00
|
|
|
if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
|
2007-12-19 01:10:20 +00:00
|
|
|
elem = window;
|
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-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
|
2010-01-28 19:12:44 +00:00
|
|
|
var elemData = jQuery.data( elem );
|
|
|
|
|
|
|
|
// If no elemData is found then we must be trying to bind to one of the
|
|
|
|
// banned noData elements
|
|
|
|
if ( !elemData ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-10-12 04:35:18 +00:00
|
|
|
// Use a key less likely to result in collisions for plain JS objects.
|
|
|
|
// Fixes bug #7150.
|
|
|
|
var eventKey = elem.nodeType ? "events" : "__events__",
|
|
|
|
events = elemData[ eventKey ],
|
2010-03-01 17:44:56 +00:00
|
|
|
eventHandle = elemData.handle;
|
2010-09-29 13:46:25 +00:00
|
|
|
|
|
|
|
if ( typeof events === "function" ) {
|
|
|
|
// On plain objects events is a fn that holds the the data
|
|
|
|
// which prevents this data from being JSON serialized
|
|
|
|
// the function does not need to be called, it just contains the data
|
|
|
|
eventHandle = events.handle;
|
|
|
|
events = events.events;
|
|
|
|
|
|
|
|
} else if ( !events ) {
|
|
|
|
if ( !elem.nodeType ) {
|
|
|
|
// On plain objects, create a fn that acts as the holder
|
|
|
|
// of the values to avoid JSON serialization of event data
|
2010-10-12 04:35:18 +00:00
|
|
|
elemData[ eventKey ] = elemData = function(){};
|
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 ) {
|
|
|
|
elemData.handle = eventHandle = function() {
|
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
|
2008-12-19 04:36:28 +00:00
|
|
|
return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
|
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
|
|
|
}
|
2009-12-04 16:28:50 +00:00
|
|
|
|
|
|
|
if ( special.add ) {
|
2010-02-04 05:20:52 +00:00
|
|
|
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,
|
2010-10-12 04:35:18 +00:00
|
|
|
eventKey = elem.nodeType ? "events" : "__events__",
|
2010-02-04 05:20:52 +00:00
|
|
|
elemData = jQuery.data( elem ),
|
2010-10-12 04:35:18 +00:00
|
|
|
events = elemData && elemData[ eventKey ];
|
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-09-29 13:46:25 +00:00
|
|
|
|
|
|
|
if ( typeof events === "function" ) {
|
|
|
|
elemData = events;
|
|
|
|
events = events.events;
|
|
|
|
}
|
2010-01-28 19:12:44 +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-02-04 05:20:52 +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
|
|
|
|
2010-09-29 13:46:25 +00:00
|
|
|
if ( typeof elemData === "function" ) {
|
2010-10-12 23:49:37 +00:00
|
|
|
jQuery.removeData( elem, eventKey );
|
2010-09-29 13:46:25 +00:00
|
|
|
|
|
|
|
} else if ( jQuery.isEmptyObject( elemData ) ) {
|
2010-02-04 05:20:52 +00:00
|
|
|
jQuery.removeData( elem );
|
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 ] ) {
|
2009-05-01 00:59:27 +00:00
|
|
|
jQuery.each( jQuery.cache, function() {
|
|
|
|
if ( this.events && this.events[type] ) {
|
|
|
|
jQuery.event.trigger( event, data, this.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
|
2010-09-29 13:46:25 +00:00
|
|
|
var handle = elem.nodeType ?
|
|
|
|
jQuery.data( elem, "handle" ) :
|
2010-10-12 04:35:18 +00:00
|
|
|
(jQuery.data( elem, "__events__" ) || {}).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-09-22 13:16:28 +00:00
|
|
|
var target = event.target, old, targetType = type.replace(rnamespaces, ""),
|
2010-03-09 17:22:25 +00:00
|
|
|
isClick = jQuery.nodeName(target, "a") && targetType === "click",
|
|
|
|
special = jQuery.event.special[ targetType ] || {};
|
2010-01-28 19:34:09 +00:00
|
|
|
|
|
|
|
if ( (!special._default || special._default.call( elem, event ) === false) &&
|
|
|
|
!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
|
|
|
}
|
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
jQuery.event.triggered = true;
|
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
|
|
|
|
2010-02-04 05:20:52 +00:00
|
|
|
jQuery.event.triggered = false;
|
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-03-02 22:34:12 +00:00
|
|
|
var all, handlers, namespaces, namespace_sort = [], namespace_re, events, 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(".");
|
|
|
|
|
2010-10-12 04:35:18 +00:00
|
|
|
events = jQuery.data(this, this.nodeType ? "events" : "__events__");
|
2010-09-29 13:46:25 +00:00
|
|
|
|
|
|
|
if ( typeof events === "function" ) {
|
|
|
|
events = events.events;
|
|
|
|
}
|
|
|
|
|
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-02-04 05:20:52 +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 ) {
|
2007-12-19 01:10:20 +00:00
|
|
|
event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
|
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 ) {
|
|
|
|
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 ),
|
|
|
|
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-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;
|
|
|
|
// 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
|
|
|
}
|
2009-09-16 08:33:00 +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 {
|
|
|
|
// 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
|
|
|
|
2010-02-13 10:45:48 +00:00
|
|
|
if ( parent !== this ) {
|
|
|
|
// 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 ) {
|
|
|
|
if ( this.nodeName.toLowerCase() !== "form" ) {
|
|
|
|
jQuery.event.add(this, "click.specialSubmit", function( e ) {
|
|
|
|
var elem = e.target, type = elem.type;
|
|
|
|
|
|
|
|
if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
|
2010-09-30 17:46:36 +00:00
|
|
|
e.liveFired = undefined;
|
2010-02-09 04:28:15 +00:00
|
|
|
return trigger( "submit", this, arguments );
|
|
|
|
}
|
|
|
|
});
|
2009-12-04 16:28:50 +00:00
|
|
|
|
2010-02-09 04:28:15 +00:00
|
|
|
jQuery.event.add(this, "keypress.specialSubmit", 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 ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
|
2010-09-30 17:46:36 +00:00
|
|
|
e.liveFired = undefined;
|
2010-02-09 04:28:15 +00:00
|
|
|
return trigger( "submit", this, arguments );
|
|
|
|
}
|
|
|
|
});
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = jQuery.data( elem, "_change_data" );
|
|
|
|
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" ) {
|
|
|
|
jQuery.data( elem, "_change_data", val );
|
|
|
|
}
|
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;
|
2010-01-18 22:52:36 +00:00
|
|
|
return 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: {
|
|
|
|
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" ) {
|
|
|
|
return testChange.call( this, e );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// 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" ) {
|
|
|
|
return testChange.call( this, e );
|
|
|
|
}
|
|
|
|
},
|
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;
|
|
|
|
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 ) {
|
|
|
|
args[0].type = type;
|
|
|
|
return jQuery.event.handle.apply( elem, args );
|
|
|
|
}
|
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 ) {
|
2009-12-21 21:10:21 +00:00
|
|
|
jQuery.event.special[ fix ] = {
|
|
|
|
setup: function() {
|
2010-10-13 14:35:28 +00:00
|
|
|
if ( focusCounts[fix]++ === 0 ) {
|
|
|
|
document.addEventListener( orig, handler, true );
|
|
|
|
}
|
2009-12-21 21:10:21 +00:00
|
|
|
},
|
|
|
|
teardown: function() {
|
2010-10-13 14:35:28 +00:00
|
|
|
if ( --focusCounts[fix] === 0 ) {
|
|
|
|
document.removeEventListener( orig, handler, true );
|
|
|
|
}
|
2009-12-21 21:10:21 +00:00
|
|
|
}
|
|
|
|
};
|
2009-09-14 22:04:22 +00:00
|
|
|
|
2009-12-21 21:10:21 +00:00
|
|
|
function handler( e ) {
|
|
|
|
e = jQuery.event.fix( e );
|
|
|
|
e.type = fix;
|
2010-10-13 14:35:28 +00:00
|
|
|
return jQuery.event.trigger( e, null, e.target );
|
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-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-02-01 23:06:03 +00:00
|
|
|
|
|
|
|
delegate: function( selector, types, data, fn ) {
|
|
|
|
return this.live( types, data, fn, selector );
|
|
|
|
},
|
|
|
|
|
|
|
|
undelegate: function( selector, types, fn ) {
|
|
|
|
if ( arguments.length === 0 ) {
|
|
|
|
return this.unbind( "live" );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return this.die( types, null, fn, selector );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
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
|
2008-04-29 22:06:54 +00:00
|
|
|
var args = arguments, i = 1;
|
|
|
|
|
|
|
|
// 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
|
2009-12-22 01:13:16 +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-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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-02-26 14:26:14 +00:00
|
|
|
var stop, maxLevel, elems = [], selectors = [],
|
2010-09-22 20:56:48 +00:00
|
|
|
related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
|
2010-10-12 04:35:18 +00:00
|
|
|
events = jQuery.data( this, this.nodeType ? "events" : "__events__" );
|
2008-12-30 23:29:14 +00:00
|
|
|
|
2010-09-29 13:46:25 +00:00
|
|
|
if ( typeof events === "function" ) {
|
|
|
|
events = events.events;
|
|
|
|
}
|
|
|
|
|
2010-01-23 16:12:26 +00:00
|
|
|
// Make sure we avoid non-left-click bubbling in Firefox (#3861)
|
2010-02-13 00:38:57 +00:00
|
|
|
if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) {
|
2010-01-23 16:12:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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];
|
|
|
|
|
2010-03-02 22:34:12 +00:00
|
|
|
if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) {
|
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;
|
|
|
|
}
|
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
|
|
|
});
|
|
|
|
|
|
|
|
// Prevent memory leaks in IE
|
|
|
|
// Window isn't included so as not to unbind existing unload events
|
2009-03-19 15:16:02 +00:00
|
|
|
// More info:
|
|
|
|
// - http://isaacschlueter.com/2006/10/msie-memory-leaks/
|
2009-12-19 03:35:02 +00:00
|
|
|
if ( window.attachEvent && !window.addEventListener ) {
|
2010-10-10 22:01:59 +00:00
|
|
|
jQuery(window).bind("unload", function() {
|
2009-12-19 01:29:22 +00:00
|
|
|
for ( var id in jQuery.cache ) {
|
|
|
|
if ( jQuery.cache[ id ].handle ) {
|
|
|
|
// Try/Catch is to handle iframes being unloaded, see #4280
|
|
|
|
try {
|
|
|
|
jQuery.event.remove( jQuery.cache[ id ].handle.elem );
|
|
|
|
} catch(e) {}
|
|
|
|
}
|
2009-04-30 01:26:09 +00:00
|
|
|
}
|
2009-12-19 01:29:22 +00:00
|
|
|
});
|
|
|
|
}
|
2010-09-08 17:54:33 +00:00
|
|
|
|
|
|
|
})( jQuery );
|