2010-09-08 19:54:33 +02:00
|
|
|
(function( jQuery ) {
|
|
|
|
|
2010-02-05 03:36:32 +01:00
|
|
|
var rnamespaces = /\.(.*)$/,
|
2010-09-22 15:16:28 +02:00
|
|
|
rformElems = /^(?:textarea|input|select)$/i,
|
|
|
|
rperiod = /\./g,
|
|
|
|
rspace = / /g,
|
|
|
|
rescape = /[^\w\s.|`]/g,
|
2010-02-05 03:36:32 +01:00
|
|
|
fcleanup = function( nm ) {
|
2010-09-22 15:16:28 +02:00
|
|
|
return nm.replace(rescape, "\\$&");
|
2010-10-13 16:35:28 +02:00
|
|
|
},
|
2011-01-09 22:52:33 +01:00
|
|
|
eventKey = "events";
|
2009-12-22 01:58:13 +01:00
|
|
|
|
2007-12-19 02:10:20 +01:00
|
|
|
/*
|
|
|
|
* A number of helper functions used for managing events.
|
2008-06-27 16:17:28 +02:00
|
|
|
* Many of the ideas behind this code originated from
|
2007-12-19 02:10:20 +01:00
|
|
|
* Dean Edwards' addEvent library.
|
|
|
|
*/
|
|
|
|
jQuery.event = {
|
|
|
|
|
|
|
|
// Bind an event to an element
|
|
|
|
// Original by Dean Edwards
|
2009-04-30 03:26:09 +02:00
|
|
|
add: function( elem, types, handler, data ) {
|
|
|
|
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
|
2007-12-19 02:10:20 +01:00
|
|
|
return;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
|
|
|
|
// For whatever reason, IE has trouble passing the window object
|
|
|
|
// around, causing it to be cloned in the process
|
2010-09-22 22:41:51 +02:00
|
|
|
if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
|
2007-12-19 02:10:20 +01:00
|
|
|
elem = window;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2010-02-27 15:02:13 +01:00
|
|
|
if ( handler === false ) {
|
|
|
|
handler = returnFalse;
|
2010-10-24 18:18:33 +02:00
|
|
|
} else if ( !handler ) {
|
2010-11-09 16:34:32 +01:00
|
|
|
// Fixes bug #7229. Fix recommended by jdalton
|
2010-10-24 18:18:33 +02:00
|
|
|
return;
|
2010-02-27 15:02:13 +01:00
|
|
|
}
|
|
|
|
|
2010-02-05 03:36:32 +01:00
|
|
|
var handleObjIn, handleObj;
|
|
|
|
|
|
|
|
if ( handler.handler ) {
|
|
|
|
handleObjIn = handler;
|
|
|
|
handler = handleObjIn.handler;
|
|
|
|
}
|
|
|
|
|
2007-12-19 02:10:20 +01:00
|
|
|
// Make sure that the function being executed has a unique ID
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( !handler.guid ) {
|
2009-12-31 21:06:45 +01:00
|
|
|
handler.guid = jQuery.guid++;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-12-19 02:10:20 +01:00
|
|
|
// Init the element's event structure
|
2011-01-09 22:52:33 +01:00
|
|
|
var elemData = jQuery._data( elem );
|
2010-01-28 20:12:44 +01:00
|
|
|
|
|
|
|
// If no elemData is found then we must be trying to bind to one of the
|
|
|
|
// banned noData elements
|
|
|
|
if ( !elemData ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-09 22:52:33 +01:00
|
|
|
var events = elemData[ eventKey ],
|
2010-03-01 18:44:56 +01:00
|
|
|
eventHandle = elemData.handle;
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2010-09-29 15:46:25 +02: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 06:35:18 +02:00
|
|
|
elemData[ eventKey ] = elemData = function(){};
|
2010-09-29 15:46:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
elemData.events = events = {};
|
|
|
|
}
|
2009-12-16 22:45:00 +01:00
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
if ( !eventHandle ) {
|
|
|
|
elemData.handle = eventHandle = function() {
|
2007-12-19 02:10:20 +01:00
|
|
|
// Handle the second event of a trigger and when
|
|
|
|
// an event is called after a page has unloaded
|
2008-12-19 05:36:28 +01:00
|
|
|
return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
|
2009-12-08 01:42:25 +01:00
|
|
|
jQuery.event.handle.apply( eventHandle.elem, arguments ) :
|
2008-12-19 05:36:28 +01:00
|
|
|
undefined;
|
2009-12-16 22:45:00 +01:00
|
|
|
};
|
2010-01-13 17:24:54 +01:00
|
|
|
}
|
|
|
|
|
2007-12-21 05:53:33 +01:00
|
|
|
// Add elem as a property of the handle function
|
2010-02-04 06:20:52 +01:00
|
|
|
// This is to prevent a memory leak with non-native events in IE.
|
|
|
|
eventHandle.elem = elem;
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2008-04-30 01:34:50 +02:00
|
|
|
// Handle multiple events separated by a space
|
|
|
|
// jQuery(...).bind("mouseover mouseout", fn);
|
2010-01-28 20:12:44 +01:00
|
|
|
types = types.split(" ");
|
2010-01-25 22:45:39 +01:00
|
|
|
|
2010-01-28 20:12:44 +01:00
|
|
|
var type, i = 0, namespaces;
|
2010-01-25 22:45:39 +01:00
|
|
|
|
2009-04-30 03:26:09 +02:00
|
|
|
while ( (type = types[ i++ ]) ) {
|
2010-02-05 03:36:32 +01:00
|
|
|
handleObj = handleObjIn ?
|
|
|
|
jQuery.extend({}, handleObjIn) :
|
|
|
|
{ handler: handler, data: data };
|
2010-01-25 22:45:39 +01:00
|
|
|
|
2010-01-28 20:12:44 +01:00
|
|
|
// Namespaced event handlers
|
|
|
|
if ( type.indexOf(".") > -1 ) {
|
|
|
|
namespaces = type.split(".");
|
|
|
|
type = namespaces.shift();
|
2010-02-04 06:20:52 +01:00
|
|
|
handleObj.namespace = namespaces.slice(0).sort().join(".");
|
2010-01-28 20:12:44 +01:00
|
|
|
|
|
|
|
} else {
|
|
|
|
namespaces = [];
|
2010-02-05 03:36:32 +01:00
|
|
|
handleObj.namespace = "";
|
2010-01-28 20:12:44 +01:00
|
|
|
}
|
2008-04-30 01:34:50 +02:00
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
handleObj.type = type;
|
2010-03-09 18:22:25 +01:00
|
|
|
if ( !handleObj.guid ) {
|
|
|
|
handleObj.guid = handler.guid;
|
|
|
|
}
|
2010-02-04 06:20:52 +01:00
|
|
|
|
2008-04-30 01:34:50 +02:00
|
|
|
// Get the current list of functions bound to this event
|
2009-04-30 23:44:25 +02:00
|
|
|
var handlers = events[ type ],
|
2010-02-04 06:20:52 +01:00
|
|
|
special = jQuery.event.special[ type ] || {};
|
2009-04-30 23:44:25 +02:00
|
|
|
|
2008-04-30 01:34:50 +02:00
|
|
|
// Init the event handler queue
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( !handlers ) {
|
2010-02-04 06:20:52 +01:00
|
|
|
handlers = events[ type ] = [];
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2008-04-30 01:34:50 +02:00
|
|
|
// Check for a special event handler
|
|
|
|
// Only use addEventListener/attachEvent if the special
|
|
|
|
// events handler returns false
|
2010-02-05 17:02:56 +01:00
|
|
|
if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
|
2008-04-30 01:34:50 +02:00
|
|
|
// Bind the global event handler to the element
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( elem.addEventListener ) {
|
2010-02-04 06:20:52 +01:00
|
|
|
elem.addEventListener( type, eventHandle, false );
|
2010-01-28 20:12:44 +01:00
|
|
|
|
2009-04-30 03:26:09 +02:00
|
|
|
} else if ( elem.attachEvent ) {
|
2010-02-04 06:20:52 +01:00
|
|
|
elem.attachEvent( "on" + type, eventHandle );
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
}
|
2008-04-30 01:34:50 +02:00
|
|
|
}
|
2010-12-26 21:28:13 +01:00
|
|
|
|
|
|
|
if ( special.add ) {
|
|
|
|
special.add.call( elem, handleObj );
|
2010-02-13 12:10:43 +01:00
|
|
|
|
|
|
|
if ( !handleObj.handler.guid ) {
|
|
|
|
handleObj.handler.guid = handler.guid;
|
|
|
|
}
|
2010-02-04 06:20:52 +01:00
|
|
|
}
|
2010-02-05 03:36:32 +01:00
|
|
|
|
2008-04-30 01:34:50 +02:00
|
|
|
// Add the function to the element's handler list
|
2010-02-04 06:20:52 +01:00
|
|
|
handlers.push( handleObj );
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2008-04-30 01:34:50 +02:00
|
|
|
// Keep track of which events have been used, for global triggering
|
2010-02-04 06:20:52 +01:00
|
|
|
jQuery.event.global[ type ] = true;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-12-21 05:53:33 +01:00
|
|
|
// Nullify elem to prevent memory leaks in IE
|
|
|
|
elem = null;
|
2007-12-19 02:10:20 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
global: {},
|
|
|
|
|
|
|
|
// Detach an event or set of events from an element
|
2010-02-04 06:20:52 +01:00
|
|
|
remove: function( elem, types, handler, pos ) {
|
2007-12-19 02:10:20 +01:00
|
|
|
// don't do events on text and comment nodes
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
|
2007-12-19 02:10:20 +01:00
|
|
|
return;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2010-02-27 15:02:13 +01:00
|
|
|
if ( handler === false ) {
|
|
|
|
handler = returnFalse;
|
|
|
|
}
|
|
|
|
|
2010-03-02 03:24:49 +01:00
|
|
|
var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
|
2011-01-09 22:52:33 +01:00
|
|
|
elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
|
2010-10-12 06:35:18 +02:00
|
|
|
events = elemData && elemData[ eventKey ];
|
2010-01-28 20:12:44 +01:00
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
if ( !elemData || !events ) {
|
2010-01-28 20:12:44 +01:00
|
|
|
return;
|
|
|
|
}
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2010-09-29 15:46:25 +02:00
|
|
|
if ( typeof events === "function" ) {
|
|
|
|
elemData = events;
|
|
|
|
events = events.events;
|
|
|
|
}
|
2010-01-28 20:12:44 +01:00
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
// types is actually an event object here
|
|
|
|
if ( types && types.type ) {
|
|
|
|
handler = types.handler;
|
|
|
|
types = types.type;
|
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
// Unbind all events for the element
|
|
|
|
if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
|
|
|
|
types = types || "";
|
2010-01-28 20:12:44 +01:00
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
for ( type in events ) {
|
|
|
|
jQuery.event.remove( elem, type + types );
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2010-02-04 06:20:52 +01: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 20:12:44 +01:00
|
|
|
|
2010-12-26 21:28:13 +01:00
|
|
|
namespace = new RegExp("(^|\\.)" +
|
2010-03-02 00:19:29 +01:00
|
|
|
jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
|
2010-02-04 06:20:52 +01:00
|
|
|
}
|
2010-01-28 20:12:44 +01:00
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
eventType = events[ type ];
|
2010-01-28 20:12:44 +01:00
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
if ( !eventType ) {
|
|
|
|
continue;
|
|
|
|
}
|
2010-01-28 20:12:44 +01:00
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
if ( !handler ) {
|
2010-03-02 03:24:49 +01:00
|
|
|
for ( j = 0; j < eventType.length; j++ ) {
|
2010-02-04 06:20:52 +01:00
|
|
|
handleObj = eventType[ j ];
|
2010-01-28 20:16:52 +01:00
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
if ( all || namespace.test( handleObj.namespace ) ) {
|
|
|
|
jQuery.event.remove( elem, origType, handleObj.handler, j );
|
|
|
|
eventType.splice( j--, 1 );
|
2010-01-28 20:12:44 +01:00
|
|
|
}
|
2010-02-04 06:20:52 +01:00
|
|
|
}
|
2010-01-28 20:12:44 +01:00
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
continue;
|
|
|
|
}
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
special = jQuery.event.special[ type ] || {};
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2010-03-02 03:24:49 +01:00
|
|
|
for ( j = pos || 0; j < eventType.length; j++ ) {
|
2010-02-04 06:20:52 +01:00
|
|
|
handleObj = eventType[ j ];
|
2010-01-28 20:16:52 +01:00
|
|
|
|
2010-02-04 06:20:52 +01: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 03:36:32 +01:00
|
|
|
special.remove.call( elem, handleObj );
|
2007-12-19 02:10:20 +01:00
|
|
|
}
|
|
|
|
}
|
2010-02-04 06:20:52 +01:00
|
|
|
|
|
|
|
if ( pos != null ) {
|
|
|
|
break;
|
|
|
|
}
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
}
|
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
// remove generic event handler if no more handlers exist
|
2010-02-11 07:42:51 +01:00
|
|
|
if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
|
2010-02-04 06:20:52 +01:00
|
|
|
if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
|
2010-09-09 00:13:35 +02:00
|
|
|
jQuery.removeEvent( elem, type, elemData.handle );
|
2010-02-04 06:20:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = null;
|
|
|
|
delete events[ type ];
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2010-02-04 06:20:52 +01:00
|
|
|
}
|
2010-01-28 20:12:44 +01:00
|
|
|
|
2010-02-04 06:20:52 +01: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 20:12:44 +01:00
|
|
|
|
2010-10-13 01:49:37 +02:00
|
|
|
delete elemData.events;
|
2010-02-04 06:20:52 +01:00
|
|
|
delete elemData.handle;
|
2010-01-28 20:12:44 +01:00
|
|
|
|
2010-09-29 15:46:25 +02:00
|
|
|
if ( typeof elemData === "function" ) {
|
2011-01-09 22:52:33 +01:00
|
|
|
jQuery.removeData( elem, eventKey, true );
|
2010-09-29 15:46:25 +02:00
|
|
|
|
|
|
|
} else if ( jQuery.isEmptyObject( elemData ) ) {
|
2011-01-09 22:52:33 +01:00
|
|
|
jQuery.removeData( elem, undefined, true );
|
2007-12-19 02:10:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-01-05 14:31:21 +01:00
|
|
|
// bubbling is internal
|
2009-05-10 16:38:35 +02:00
|
|
|
trigger: function( event, data, elem /*, bubbling */ ) {
|
2008-12-25 22:44:54 +01:00
|
|
|
// Event object or event type
|
2009-05-10 16:38:35 +02:00
|
|
|
var type = event.type || event,
|
|
|
|
bubbling = arguments[3];
|
2008-12-31 03:58:13 +01:00
|
|
|
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( !bubbling ) {
|
2009-01-03 00:07:16 +01:00
|
|
|
event = typeof event === "object" ?
|
|
|
|
// jQuery.Event object
|
2010-04-24 23:15:45 +02:00
|
|
|
event[ jQuery.expando ] ? event :
|
2009-01-03 00:07:16 +01: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 02:10:20 +01:00
|
|
|
|
2009-01-03 00:07:16 +01:00
|
|
|
// Handle a global trigger
|
|
|
|
if ( !elem ) {
|
|
|
|
// Don't bubble custom events when global (to avoid too much overhead)
|
|
|
|
event.stopPropagation();
|
2009-12-22 02:13:16 +01:00
|
|
|
|
2009-01-03 00:07:16 +01:00
|
|
|
// Only trigger if we've ever bound an event for it
|
2010-02-04 06:20:52 +01:00
|
|
|
if ( jQuery.event.global[ type ] ) {
|
2011-01-09 22:52:33 +01:00
|
|
|
// XXX This code smells terrible. event.js should not be directly
|
|
|
|
// inspecting the data cache
|
2009-05-01 02:59:27 +02:00
|
|
|
jQuery.each( jQuery.cache, function() {
|
2011-01-09 22:52:33 +01: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 ];
|
|
|
|
if ( internalCache && internalCache.events && internalCache.events[type] ) {
|
|
|
|
jQuery.event.trigger( event, data, internalCache.handle.elem );
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2009-05-01 02:59:27 +02:00
|
|
|
});
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2009-01-03 00:07:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Handle triggering a single element
|
2008-12-25 22:44:54 +01:00
|
|
|
|
2007-12-19 02:10:20 +01:00
|
|
|
// don't do events on text and comment nodes
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
|
2007-12-19 02:10:20 +01:00
|
|
|
return undefined;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2009-01-05 14:31:21 +01:00
|
|
|
// Clean up in case it is reused
|
|
|
|
event.result = undefined;
|
|
|
|
event.target = elem;
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2009-01-05 14:31:21 +01:00
|
|
|
// Clone the incoming data, if any
|
2009-04-30 03:26:09 +02:00
|
|
|
data = jQuery.makeArray( data );
|
2009-01-05 14:31:21 +01:00
|
|
|
data.unshift( event );
|
2009-01-03 00:07:16 +01:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2009-01-03 00:07:16 +01:00
|
|
|
event.currentTarget = elem;
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2009-01-03 00:07:16 +01:00
|
|
|
// Trigger the event, it is assumed that "handle" is a function
|
2010-09-29 15:46:25 +02:00
|
|
|
var handle = elem.nodeType ?
|
2011-01-09 22:52:33 +01:00
|
|
|
jQuery._data( elem, "handle" ) :
|
|
|
|
(jQuery._data( elem, eventKey ) || {}).handle;
|
2010-09-29 15:46:25 +02:00
|
|
|
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( handle ) {
|
2009-01-03 00:07:16 +01:00
|
|
|
handle.apply( elem, data );
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2010-01-25 19:45:07 +01:00
|
|
|
var parent = elem.parentNode || elem.ownerDocument;
|
|
|
|
|
|
|
|
// Trigger an inline bound script
|
2009-06-17 04:31:45 +02:00
|
|
|
try {
|
2009-12-09 23:49:31 +01:00
|
|
|
if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
|
2010-01-25 19:45:07 +01:00
|
|
|
if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
|
|
|
|
event.result = false;
|
2010-09-25 00:02:31 +02:00
|
|
|
event.preventDefault();
|
2010-01-25 19:45:07 +01:00
|
|
|
}
|
2009-12-09 23:49:31 +01:00
|
|
|
}
|
2010-01-25 19:45:07 +01:00
|
|
|
|
2009-06-17 04:31:45 +02:00
|
|
|
// prevent IE from throwing an error for some elements with some event types, see #3533
|
2010-03-02 03:24:49 +01:00
|
|
|
} catch (inlineError) {}
|
2009-12-05 05:18:05 +01:00
|
|
|
|
2010-01-25 19:45:07 +01:00
|
|
|
if ( !event.isPropagationStopped() && parent ) {
|
|
|
|
jQuery.event.trigger( event, data, parent, true );
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2010-01-25 19:45:07 +01:00
|
|
|
} else if ( !event.isDefaultPrevented() ) {
|
2010-11-09 17:09:07 +01:00
|
|
|
var old,
|
|
|
|
target = event.target,
|
|
|
|
targetType = type.replace( rnamespaces, "" ),
|
|
|
|
isClick = jQuery.nodeName( target, "a" ) && targetType === "click",
|
2010-03-09 18:22:25 +01:00
|
|
|
special = jQuery.event.special[ targetType ] || {};
|
2010-01-28 20:34:09 +01:00
|
|
|
|
2010-12-26 21:28:13 +01:00
|
|
|
if ( (!special._default || special._default.call( elem, event ) === false) &&
|
2010-01-28 20:34:09 +01:00
|
|
|
!isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
|
2009-12-05 05:18:05 +01:00
|
|
|
|
2010-01-25 19:45:07 +01:00
|
|
|
try {
|
2010-03-09 18:22:25 +01:00
|
|
|
if ( target[ targetType ] ) {
|
2010-01-25 19:45:07 +01:00
|
|
|
// Make sure that we don't accidentally re-trigger the onFOO events
|
2010-03-09 18:22:25 +01:00
|
|
|
old = target[ "on" + targetType ];
|
2010-01-25 19:45:07 +01:00
|
|
|
|
|
|
|
if ( old ) {
|
2010-03-09 18:22:25 +01:00
|
|
|
target[ "on" + targetType ] = null;
|
2010-01-25 19:45:07 +01:00
|
|
|
}
|
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
jQuery.event.triggered = true;
|
2010-03-09 18:22:25 +01:00
|
|
|
target[ targetType ]();
|
2010-01-25 19:45:07 +01:00
|
|
|
}
|
2008-12-31 03:58:13 +01:00
|
|
|
|
2010-01-25 19:45:07 +01:00
|
|
|
// prevent IE from throwing an error for some elements with some event types, see #3533
|
2010-03-02 03:24:49 +01:00
|
|
|
} catch (triggerError) {}
|
2010-01-25 19:45:07 +01:00
|
|
|
|
|
|
|
if ( old ) {
|
2010-03-09 18:22:25 +01:00
|
|
|
target[ "on" + targetType ] = old;
|
2010-01-25 19:45:07 +01:00
|
|
|
}
|
2009-01-05 21:43:24 +01:00
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
jQuery.event.triggered = false;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-04-30 03:26:09 +02:00
|
|
|
handle: function( event ) {
|
2010-11-09 17:09:07 +01:00
|
|
|
var all, handlers, namespaces, namespace_re, events,
|
|
|
|
namespace_sort = [],
|
|
|
|
args = jQuery.makeArray( arguments );
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2010-03-02 03:24:49 +01:00
|
|
|
event = args[0] = jQuery.event.fix( event || window.event );
|
2009-02-17 13:38:16 +01:00
|
|
|
event.currentTarget = this;
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2007-12-19 02:10:20 +01:00
|
|
|
// Namespaced event handlers
|
2010-02-08 17:31:01 +01:00
|
|
|
all = event.type.indexOf(".") < 0 && !event.exclusive;
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
if ( !all ) {
|
|
|
|
namespaces = event.type.split(".");
|
|
|
|
event.type = namespaces.shift();
|
2010-03-02 23:34:12 +01:00
|
|
|
namespace_sort = namespaces.slice(0).sort();
|
|
|
|
namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)");
|
2010-02-04 06:20:52 +01:00
|
|
|
}
|
2008-04-23 20:57:17 +02:00
|
|
|
|
2010-03-09 18:22:25 +01:00
|
|
|
event.namespace = event.namespace || namespace_sort.join(".");
|
|
|
|
|
2011-01-09 22:52:33 +01:00
|
|
|
events = jQuery._data(this, eventKey);
|
2010-09-29 15:46:25 +02:00
|
|
|
|
|
|
|
if ( typeof events === "function" ) {
|
|
|
|
events = events.events;
|
|
|
|
}
|
|
|
|
|
2010-02-27 08:31:33 +01:00
|
|
|
handlers = (events || {})[ event.type ];
|
2010-02-04 06:20:52 +01: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 23:34:12 +01:00
|
|
|
if ( all || namespace_re.test( handleObj.namespace ) ) {
|
2010-02-04 06:20:52 +01: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 03:36:32 +01:00
|
|
|
event.handleObj = handleObj;
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2010-03-02 03:24:49 +01:00
|
|
|
var ret = handleObj.handler.apply( this, args );
|
2010-02-04 06:20:52 +01:00
|
|
|
|
|
|
|
if ( ret !== undefined ) {
|
|
|
|
event.result = ret;
|
|
|
|
if ( ret === false ) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
2008-12-31 03:58:13 +01:00
|
|
|
}
|
2008-10-19 00:46:04 +02:00
|
|
|
|
2010-02-04 06:20:52 +01:00
|
|
|
if ( event.isImmediatePropagationStopped() ) {
|
|
|
|
break;
|
|
|
|
}
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
}
|
|
|
|
}
|
2009-12-07 01:55:08 +01:00
|
|
|
|
|
|
|
return event.result;
|
2007-12-19 02:10:20 +01:00
|
|
|
},
|
|
|
|
|
2010-06-29 05:21:59 +02: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 22:43:13 +02:00
|
|
|
|
2009-04-30 03:26:09 +02:00
|
|
|
fix: function( event ) {
|
2010-04-24 23:15:45 +02:00
|
|
|
if ( event[ jQuery.expando ] ) {
|
2008-04-28 01:08:31 +02:00
|
|
|
return event;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2008-05-13 03:45:58 +02:00
|
|
|
|
|
|
|
// store a copy of the original event object
|
2008-04-28 23:09:27 +02:00
|
|
|
// and "clone" to set read-only properties
|
2007-12-19 02:10:20 +01:00
|
|
|
var originalEvent = event;
|
2008-12-29 22:57:29 +01:00
|
|
|
event = jQuery.Event( originalEvent );
|
2008-05-28 22:43:13 +02:00
|
|
|
|
2009-04-30 03:26:09 +02:00
|
|
|
for ( var i = this.props.length, prop; i; ) {
|
2008-05-28 22:43:13 +02:00
|
|
|
prop = this.props[ --i ];
|
|
|
|
event[ prop ] = originalEvent[ prop ];
|
|
|
|
}
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-12-19 02:10:20 +01:00
|
|
|
// Fix target property, if necessary
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( !event.target ) {
|
2010-11-09 16:34:32 +01:00
|
|
|
// Fixes #1925 where srcElement might not be defined either
|
|
|
|
event.target = event.srcElement || document;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-12-19 02:10:20 +01:00
|
|
|
// check if target is a textnode (safari)
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( event.target.nodeType === 3 ) {
|
2008-04-28 23:09:27 +02:00
|
|
|
event.target = event.target.parentNode;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
|
|
|
|
// Add relatedTarget, if necessary
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( !event.relatedTarget && event.fromElement ) {
|
|
|
|
event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
|
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
|
|
|
|
// Calculate pageX/Y if missing and clientX/Y available
|
|
|
|
if ( event.pageX == null && event.clientX != null ) {
|
2010-11-09 17:09:07 +01:00
|
|
|
var doc = document.documentElement,
|
|
|
|
body = document.body;
|
|
|
|
|
2009-05-01 02:21:29 +02: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 02:10:20 +01:00
|
|
|
}
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-12-19 02:10:20 +01:00
|
|
|
// Add which for key events
|
2010-09-29 05:13:40 +02:00
|
|
|
if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
|
2010-09-28 18:07:57 +02:00
|
|
|
event.which = event.charCode != null ? event.charCode : event.keyCode;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-12-19 02:10:20 +01:00
|
|
|
// Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( !event.metaKey && event.ctrlKey ) {
|
2007-12-19 02:10:20 +01:00
|
|
|
event.metaKey = event.ctrlKey;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2009-12-22 00:02:02 +01:00
|
|
|
// Add which for click: 1 === left; 2 === middle; 3 === right
|
2007-12-19 02:10:20 +01:00
|
|
|
// Note: button is not normalized, so don't use it
|
2009-06-17 04:31:45 +02:00
|
|
|
if ( !event.which && event.button !== undefined ) {
|
2007-12-19 02:10:20 +01:00
|
|
|
event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-12-19 02:10:20 +01:00
|
|
|
return event;
|
|
|
|
},
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2010-01-06 01:17:28 +01:00
|
|
|
// Deprecated, use jQuery.guid instead
|
|
|
|
guid: 1E8,
|
2009-12-22 01:58:13 +01:00
|
|
|
|
2010-01-06 01:17:28 +01:00
|
|
|
// Deprecated, use jQuery.proxy instead
|
2009-12-31 21:06:45 +01:00
|
|
|
proxy: jQuery.proxy,
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-12-19 02:10:20 +01:00
|
|
|
special: {
|
|
|
|
ready: {
|
2008-07-28 20:31:25 +02:00
|
|
|
// Make sure the ready event is setup
|
2009-12-08 01:34:55 +01:00
|
|
|
setup: jQuery.bindReady,
|
2009-12-31 15:50:49 +01:00
|
|
|
teardown: jQuery.noop
|
2009-04-30 23:44:25 +02:00
|
|
|
},
|
2009-05-06 03:24:22 +02:00
|
|
|
|
2008-12-22 05:59:34 +01:00
|
|
|
live: {
|
2010-02-05 03:36:32 +01:00
|
|
|
add: function( handleObj ) {
|
2010-03-09 18:22:25 +01:00
|
|
|
jQuery.event.add( this,
|
|
|
|
liveConvert( handleObj.origType, handleObj.selector ),
|
2010-12-26 21:28:13 +01:00
|
|
|
jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
|
2008-12-22 05:59:34 +01:00
|
|
|
},
|
2009-05-06 03:24:22 +02:00
|
|
|
|
2010-02-05 03:36:32 +01:00
|
|
|
remove: function( handleObj ) {
|
2010-03-09 18:22:25 +01:00
|
|
|
jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
|
2010-02-05 03:36:32 +01:00
|
|
|
}
|
2009-12-07 01:55:08 +01:00
|
|
|
},
|
2010-02-05 03:36:32 +01:00
|
|
|
|
2009-12-07 01:55:08 +01:00
|
|
|
beforeunload: {
|
2010-02-05 17:02:56 +01:00
|
|
|
setup: function( data, namespaces, eventHandle ) {
|
2009-12-07 01:55:08 +01:00
|
|
|
// We only want to do this special case on windows
|
2010-09-22 22:41:51 +02:00
|
|
|
if ( jQuery.isWindow( this ) ) {
|
2010-02-05 17:02:56 +01:00
|
|
|
this.onbeforeunload = eventHandle;
|
2009-12-07 01:55:08 +01:00
|
|
|
}
|
|
|
|
},
|
2010-02-27 16:03:43 +01:00
|
|
|
|
2010-02-05 17:02:56 +01:00
|
|
|
teardown: function( namespaces, eventHandle ) {
|
|
|
|
if ( this.onbeforeunload === eventHandle ) {
|
2009-12-07 01:55:08 +01:00
|
|
|
this.onbeforeunload = null;
|
|
|
|
}
|
|
|
|
}
|
2008-12-22 05:59:34 +01:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-09-09 00:13:35 +02:00
|
|
|
jQuery.removeEvent = document.removeEventListener ?
|
2010-01-28 21:25:52 +01:00
|
|
|
function( elem, type, handle ) {
|
2010-02-26 17:32:12 +01:00
|
|
|
if ( elem.removeEventListener ) {
|
|
|
|
elem.removeEventListener( type, handle, false );
|
|
|
|
}
|
2010-12-26 21:28:13 +01:00
|
|
|
} :
|
2010-01-28 21:25:52 +01:00
|
|
|
function( elem, type, handle ) {
|
2010-02-26 17:32:12 +01:00
|
|
|
if ( elem.detachEvent ) {
|
|
|
|
elem.detachEvent( "on" + type, handle );
|
|
|
|
}
|
2010-01-28 21:25:52 +01:00
|
|
|
};
|
|
|
|
|
2009-12-22 01:58:13 +01:00
|
|
|
jQuery.Event = function( src ) {
|
2008-12-29 22:57:29 +01:00
|
|
|
// Allow instantiation without the 'new' keyword
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( !this.preventDefault ) {
|
|
|
|
return new jQuery.Event( src );
|
|
|
|
}
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2008-12-25 22:44:54 +01:00
|
|
|
// Event object
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( src && src.type ) {
|
2008-12-25 22:44:54 +01:00
|
|
|
this.originalEvent = src;
|
|
|
|
this.type = src.type;
|
2010-12-27 20:30:05 +01:00
|
|
|
|
|
|
|
// Events bubbling up the document may have been marked as prevented
|
|
|
|
// by a handler lower down the tree; reflect the correct value.
|
2010-12-24 15:53:39 +01:00
|
|
|
this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
|
2010-12-27 20:30:05 +01:00
|
|
|
src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
|
|
|
|
|
2008-12-25 22:44:54 +01:00
|
|
|
// Event type
|
2009-04-30 03:26:09 +02:00
|
|
|
} else {
|
2008-12-25 22:44:54 +01:00
|
|
|
this.type = src;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2008-12-25 22:44:54 +01:00
|
|
|
|
2009-01-19 23:20:25 +01:00
|
|
|
// timeStamp is buggy for some events on Firefox(#3843)
|
|
|
|
// So we won't rely on the native value
|
2010-03-23 17:12:16 +01:00
|
|
|
this.timeStamp = jQuery.now();
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2008-12-25 22:44:54 +01:00
|
|
|
// Mark it as fixed
|
2010-04-24 23:15:45 +02:00
|
|
|
this[ jQuery.expando ] = true;
|
2008-12-25 22:44:54 +01:00
|
|
|
};
|
2008-10-19 00:46:04 +02:00
|
|
|
|
2009-04-30 03:26:09 +02:00
|
|
|
function returnFalse() {
|
2008-12-31 03:58:13 +01:00
|
|
|
return false;
|
|
|
|
}
|
2009-04-30 03:26:09 +02:00
|
|
|
function returnTrue() {
|
2008-12-31 03:58:13 +01: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 22:44:54 +01:00
|
|
|
jQuery.Event.prototype = {
|
|
|
|
preventDefault: function() {
|
2008-12-31 03:58:13 +01:00
|
|
|
this.isDefaultPrevented = returnTrue;
|
|
|
|
|
2008-12-25 22:44:54 +01:00
|
|
|
var e = this.originalEvent;
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( !e ) {
|
2008-12-25 22:44:54 +01:00
|
|
|
return;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2008-12-25 22:44:54 +01:00
|
|
|
// if preventDefault exists run it on the original event
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( e.preventDefault ) {
|
2008-12-25 22:44:54 +01:00
|
|
|
e.preventDefault();
|
2010-09-20 16:16:36 +02:00
|
|
|
|
2008-12-25 22:44:54 +01:00
|
|
|
// otherwise set the returnValue property of the original event to false (IE)
|
2010-09-20 16:16:36 +02:00
|
|
|
} else {
|
|
|
|
e.returnValue = false;
|
|
|
|
}
|
2008-12-25 22:44:54 +01:00
|
|
|
},
|
|
|
|
stopPropagation: function() {
|
2008-12-31 03:58:13 +01:00
|
|
|
this.isPropagationStopped = returnTrue;
|
|
|
|
|
2008-12-25 22:44:54 +01:00
|
|
|
var e = this.originalEvent;
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( !e ) {
|
2008-12-25 22:44:54 +01:00
|
|
|
return;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2008-12-25 22:44:54 +01:00
|
|
|
// if stopPropagation exists run it on the original event
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( e.stopPropagation ) {
|
2008-12-25 22:44:54 +01:00
|
|
|
e.stopPropagation();
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2008-12-25 22:44:54 +01:00
|
|
|
// otherwise set the cancelBubble property of the original event to true (IE)
|
|
|
|
e.cancelBubble = true;
|
|
|
|
},
|
2009-12-22 01:58:13 +01:00
|
|
|
stopImmediatePropagation: function() {
|
2008-12-31 03:58:13 +01:00
|
|
|
this.isImmediatePropagationStopped = returnTrue;
|
2008-12-25 22:44:54 +01:00
|
|
|
this.stopPropagation();
|
2008-12-31 03:58:13 +01:00
|
|
|
},
|
|
|
|
isDefaultPrevented: returnFalse,
|
|
|
|
isPropagationStopped: returnFalse,
|
|
|
|
isImmediatePropagationStopped: returnFalse
|
2008-12-25 22:44:54 +01:00
|
|
|
};
|
2009-12-22 00:06:23 +01:00
|
|
|
|
2008-12-21 22:22:44 +01:00
|
|
|
// Checks if an event happened on an element within another element
|
|
|
|
// Used in jQuery.event.special.mouseenter and mouseleave handlers
|
2009-04-30 03:26:09 +02:00
|
|
|
var withinElement = function( event ) {
|
2008-12-21 22:22:44 +01:00
|
|
|
// Check if mouse(over|out) are still within the same parent element
|
|
|
|
var parent = event.relatedTarget;
|
2009-12-22 00:06:23 +01:00
|
|
|
|
2010-02-13 11:45:48 +01: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-22 00:06:23 +01:00
|
|
|
parent = parent.parentNode;
|
|
|
|
}
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2010-02-13 11:45:48 +01:00
|
|
|
if ( parent !== this ) {
|
|
|
|
// set the correct event type
|
|
|
|
event.type = event.data;
|
2009-12-22 00:06:23 +01:00
|
|
|
|
2010-02-13 11:45:48 +01:00
|
|
|
// handle event if we actually just moused on to a non sub-element
|
|
|
|
jQuery.event.handle.apply( this, arguments );
|
|
|
|
}
|
2009-11-09 12:59:54 +01:00
|
|
|
|
2010-02-13 11:45:48 +01:00
|
|
|
// assuming we've left the element since we most likely mousedover a xul element
|
|
|
|
} catch(e) { }
|
2009-11-09 12:59:54 +01: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 22:22:44 +01:00
|
|
|
};
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2009-09-15 00:04:22 +02:00
|
|
|
// Create mouseenter and mouseleave events
|
2009-03-23 02:55:17 +01:00
|
|
|
jQuery.each({
|
2009-11-30 21:04:55 +01:00
|
|
|
mouseenter: "mouseover",
|
|
|
|
mouseleave: "mouseout"
|
2009-04-30 03:26:09 +02:00
|
|
|
}, function( orig, fix ) {
|
2009-11-30 21:04:55 +01:00
|
|
|
jQuery.event.special[ orig ] = {
|
2009-12-22 01:58:13 +01:00
|
|
|
setup: function( data ) {
|
2009-11-30 21:04:55 +01:00
|
|
|
jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
|
2008-12-21 22:22:44 +01:00
|
|
|
},
|
2009-12-22 01:58:13 +01:00
|
|
|
teardown: function( data ) {
|
2009-11-30 21:04:55 +01:00
|
|
|
jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
|
2008-12-21 22:22:44 +01:00
|
|
|
}
|
2009-03-23 02:55:17 +01:00
|
|
|
};
|
2008-12-21 22:22:44 +01:00
|
|
|
});
|
2008-07-28 20:31:25 +02:00
|
|
|
|
2009-12-04 17:28:50 +01:00
|
|
|
// submit delegation
|
2009-12-07 03:20:08 +01:00
|
|
|
if ( !jQuery.support.submitBubbles ) {
|
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
jQuery.event.special.submit = {
|
|
|
|
setup: function( data, namespaces ) {
|
2010-11-21 04:31:04 +01:00
|
|
|
if ( this.nodeName && this.nodeName.toLowerCase() !== "form" ) {
|
2010-02-09 05:28:15 +01:00
|
|
|
jQuery.event.add(this, "click.specialSubmit", function( e ) {
|
2010-11-09 17:09:07 +01:00
|
|
|
var elem = e.target,
|
|
|
|
type = elem.type;
|
2010-02-09 05:28:15 +01:00
|
|
|
|
|
|
|
if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
|
2010-09-30 19:46:36 +02:00
|
|
|
e.liveFired = undefined;
|
2010-02-09 05:28:15 +01:00
|
|
|
return trigger( "submit", this, arguments );
|
|
|
|
}
|
|
|
|
});
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
|
2010-11-09 17:09:07 +01:00
|
|
|
var elem = e.target,
|
|
|
|
type = elem.type;
|
2009-12-04 17:28:50 +01:00
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
|
2010-09-30 19:46:36 +02:00
|
|
|
e.liveFired = undefined;
|
2010-02-09 05:28:15 +01:00
|
|
|
return trigger( "submit", this, arguments );
|
|
|
|
}
|
|
|
|
});
|
2010-01-11 18:26:28 +01:00
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
2009-12-04 17:28:50 +01:00
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
teardown: function( namespaces ) {
|
2010-02-10 21:56:53 +01:00
|
|
|
jQuery.event.remove( this, ".specialSubmit" );
|
2010-02-09 05:28:15 +01:00
|
|
|
}
|
|
|
|
};
|
2009-12-04 17:28:50 +01:00
|
|
|
|
2009-12-07 03:20:08 +01:00
|
|
|
}
|
|
|
|
|
2009-12-04 17:28:50 +01:00
|
|
|
// change delegation, happens here so we have bind.
|
2009-12-07 03:20:08 +01:00
|
|
|
if ( !jQuery.support.changeBubbles ) {
|
|
|
|
|
2010-09-22 15:16:28 +02:00
|
|
|
var changeFilters,
|
2009-12-04 17:28:50 +01:00
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
getVal = function( elem ) {
|
|
|
|
var type = elem.type, val = elem.value;
|
2009-12-04 17:28:50 +01:00
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
if ( type === "radio" || type === "checkbox" ) {
|
|
|
|
val = elem.checked;
|
2009-12-04 17:28:50 +01:00
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
} else if ( type === "select-multiple" ) {
|
|
|
|
val = elem.selectedIndex > -1 ?
|
|
|
|
jQuery.map( elem.options, function( elem ) {
|
|
|
|
return elem.selected;
|
|
|
|
}).join("-") :
|
|
|
|
"";
|
2009-12-21 21:32:32 +01:00
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
} else if ( elem.nodeName.toLowerCase() === "select" ) {
|
|
|
|
val = elem.selectedIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
return val;
|
|
|
|
},
|
2009-12-21 21:32:32 +01:00
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
testChange = function testChange( e ) {
|
2009-12-21 21:32:32 +01:00
|
|
|
var elem = e.target, data, val;
|
|
|
|
|
2010-09-22 15:16:28 +02:00
|
|
|
if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
|
2009-12-21 21:32:32 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-09 22:52:33 +01:00
|
|
|
data = jQuery._data( elem, "_change_data" );
|
2009-12-21 21:32:32 +01:00
|
|
|
val = getVal(elem);
|
2009-12-04 17:28:50 +01:00
|
|
|
|
2009-12-21 21:32:32 +01:00
|
|
|
// the current data will be also retrieved by beforeactivate
|
|
|
|
if ( e.type !== "focusout" || elem.type !== "radio" ) {
|
2011-01-09 22:52:33 +01:00
|
|
|
jQuery._data( elem, "_change_data", val );
|
2009-12-21 21:32:32 +01:00
|
|
|
}
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2010-01-23 18:52:32 +01:00
|
|
|
if ( data === undefined || val === data ) {
|
|
|
|
return;
|
|
|
|
}
|
2009-12-21 21:32:32 +01:00
|
|
|
|
2010-01-18 23:52:36 +01:00
|
|
|
if ( data != null || val ) {
|
2009-12-21 21:32:32 +01:00
|
|
|
e.type = "change";
|
2010-10-10 00:16:08 +02:00
|
|
|
e.liveFired = undefined;
|
2010-01-18 23:52:36 +01:00
|
|
|
return jQuery.event.trigger( e, arguments[1], elem );
|
2009-12-21 21:32:32 +01:00
|
|
|
}
|
2010-02-09 05:28:15 +01:00
|
|
|
};
|
2009-12-21 21:32:32 +01:00
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
jQuery.event.special.change = {
|
|
|
|
filters: {
|
2010-12-26 21:28:13 +01:00
|
|
|
focusout: testChange,
|
2009-12-21 21:32:32 +01:00
|
|
|
|
2010-10-13 16:38:29 +02:00
|
|
|
beforedeactivate: testChange,
|
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
click: function( e ) {
|
|
|
|
var elem = e.target, type = elem.type;
|
2009-12-21 21:32:32 +01:00
|
|
|
|
2010-02-09 05:28:15 +01: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 17:28:50 +01:00
|
|
|
|
2010-02-09 05:28:15 +01: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 17:28:50 +01:00
|
|
|
|
2010-02-09 05:28:15 +01: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-10 01:04:15 +02:00
|
|
|
// information
|
2010-02-09 05:28:15 +01:00
|
|
|
beforeactivate: function( e ) {
|
|
|
|
var elem = e.target;
|
2011-01-09 22:52:33 +01:00
|
|
|
jQuery._data( elem, "_change_data", getVal(elem) );
|
2009-12-04 17:28:50 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
setup: function( data, namespaces ) {
|
2010-02-13 10:40:26 +01:00
|
|
|
if ( this.type === "file" ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
for ( var type in changeFilters ) {
|
|
|
|
jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
|
|
|
|
}
|
2010-02-05 17:02:56 +01:00
|
|
|
|
2010-09-22 15:16:28 +02:00
|
|
|
return rformElems.test( this.nodeName );
|
2010-02-09 05:28:15 +01:00
|
|
|
},
|
2009-12-21 21:32:32 +01:00
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
teardown: function( namespaces ) {
|
2010-02-10 21:56:53 +01:00
|
|
|
jQuery.event.remove( this, ".specialChange" );
|
2010-02-05 17:02:56 +01:00
|
|
|
|
2010-09-22 15:16:28 +02:00
|
|
|
return rformElems.test( this.nodeName );
|
2009-09-16 10:33:00 +02:00
|
|
|
}
|
2010-02-09 05:28:15 +01:00
|
|
|
};
|
2009-12-21 21:32:32 +01:00
|
|
|
|
2010-02-09 05:28:15 +01:00
|
|
|
changeFilters = jQuery.event.special.change.filters;
|
2010-10-10 01:04:15 +02:00
|
|
|
|
|
|
|
// Handle when the input is .focus()'d
|
|
|
|
changeFilters.focus = changeFilters.beforeactivate;
|
2009-12-07 16:38:16 +01:00
|
|
|
}
|
|
|
|
|
2009-12-04 17:28:50 +01:00
|
|
|
function trigger( type, elem, args ) {
|
|
|
|
args[0].type = type;
|
|
|
|
return jQuery.event.handle.apply( elem, args );
|
|
|
|
}
|
2009-09-16 10:33:00 +02:00
|
|
|
|
2009-09-15 00:04:22 +02:00
|
|
|
// Create "bubbling" focus and blur events
|
2009-12-21 22:10:21 +01:00
|
|
|
if ( document.addEventListener ) {
|
2009-12-22 01:58:13 +01:00
|
|
|
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
|
2009-12-21 22:10:21 +01:00
|
|
|
jQuery.event.special[ fix ] = {
|
|
|
|
setup: function() {
|
2011-01-21 15:24:09 +01:00
|
|
|
this.addEventListener( orig, handler, true );
|
|
|
|
},
|
|
|
|
teardown: function() {
|
|
|
|
this.removeEventListener( orig, handler, true );
|
2009-12-21 22:10:21 +01:00
|
|
|
}
|
|
|
|
};
|
2009-09-15 00:04:22 +02:00
|
|
|
|
2010-12-26 21:28:13 +01:00
|
|
|
function handler( e ) {
|
2009-12-21 22:10:21 +01:00
|
|
|
e = jQuery.event.fix( e );
|
|
|
|
e.type = fix;
|
2011-01-21 15:24:09 +01:00
|
|
|
return jQuery.event.handle.call( this, e );
|
2009-09-15 00:04:22 +02:00
|
|
|
}
|
2009-12-21 22:10:21 +01:00
|
|
|
});
|
2009-12-07 03:02:58 +01:00
|
|
|
}
|
|
|
|
|
2009-12-22 01:58:13 +01:00
|
|
|
jQuery.each(["bind", "one"], function( i, name ) {
|
2009-12-31 06:37:23 +01:00
|
|
|
jQuery.fn[ name ] = function( type, data, fn ) {
|
2009-09-16 04:19:18 +02:00
|
|
|
// Handle object literals
|
|
|
|
if ( typeof type === "object" ) {
|
|
|
|
for ( var key in type ) {
|
2009-12-10 23:44:30 +01:00
|
|
|
this[ name ](key, data, type[key], fn);
|
2009-09-16 04:19:18 +02:00
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2010-02-27 15:02:13 +01:00
|
|
|
if ( jQuery.isFunction( data ) || data === false ) {
|
2009-05-07 02:50:28 +02:00
|
|
|
fn = data;
|
|
|
|
data = undefined;
|
|
|
|
}
|
2009-12-31 06:37:23 +01:00
|
|
|
|
|
|
|
var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
|
2009-12-10 23:44:30 +01:00
|
|
|
jQuery( this ).unbind( event, handler );
|
2009-05-07 02:50:28 +02:00
|
|
|
return fn.apply( this, arguments );
|
2009-12-10 23:44:30 +01:00
|
|
|
}) : fn;
|
2009-12-31 06:37:23 +01:00
|
|
|
|
2010-01-28 20:12:44 +01: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 23:44:30 +01:00
|
|
|
};
|
|
|
|
});
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2009-12-10 23:44:30 +01:00
|
|
|
jQuery.fn.extend({
|
2007-12-19 02:10:20 +01:00
|
|
|
unbind: function( type, fn ) {
|
2009-09-16 04:19:18 +02:00
|
|
|
// Handle object literals
|
|
|
|
if ( typeof type === "object" && !type.preventDefault ) {
|
|
|
|
for ( var key in type ) {
|
|
|
|
this.unbind(key, type[key]);
|
|
|
|
}
|
2010-01-28 20:12:44 +01:00
|
|
|
|
|
|
|
} else {
|
|
|
|
for ( var i = 0, l = this.length; i < l; i++ ) {
|
|
|
|
jQuery.event.remove( this[i], type, fn );
|
|
|
|
}
|
2009-09-16 04:19:18 +02:00
|
|
|
}
|
2009-12-10 23:44:30 +01:00
|
|
|
|
2010-01-28 20:12:44 +01:00
|
|
|
return this;
|
2007-12-19 02:10:20 +01:00
|
|
|
},
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2010-02-02 00:06:03 +01:00
|
|
|
delegate: function( selector, types, data, fn ) {
|
|
|
|
return this.live( types, data, fn, selector );
|
|
|
|
},
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2010-02-02 00:06:03 +01:00
|
|
|
undelegate: function( selector, types, fn ) {
|
|
|
|
if ( arguments.length === 0 ) {
|
|
|
|
return this.unbind( "live" );
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2010-02-02 00:06:03 +01:00
|
|
|
} else {
|
|
|
|
return this.die( types, null, fn, selector );
|
|
|
|
}
|
|
|
|
},
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2009-01-02 23:23:52 +01:00
|
|
|
trigger: function( type, data ) {
|
2010-01-11 19:48:40 +01:00
|
|
|
return this.each(function() {
|
2009-01-02 23:23:52 +01:00
|
|
|
jQuery.event.trigger( type, data, this );
|
2007-12-19 02:10:20 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2009-01-02 23:23:52 +01:00
|
|
|
triggerHandler: function( type, data ) {
|
2009-04-30 03:26:09 +02:00
|
|
|
if ( this[0] ) {
|
|
|
|
var event = jQuery.Event( type );
|
2008-12-31 03:58:13 +01:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2009-01-02 23:23:52 +01:00
|
|
|
jQuery.event.trigger( event, data, this[0] );
|
2008-12-31 03:58:13 +01:00
|
|
|
return event.result;
|
2009-03-23 02:55:17 +01:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
},
|
|
|
|
|
2008-04-30 00:06:54 +02:00
|
|
|
toggle: function( fn ) {
|
2007-12-19 02:10:20 +01:00
|
|
|
// Save reference to arguments for access in closure
|
2010-11-09 17:09:07 +01:00
|
|
|
var args = arguments,
|
|
|
|
i = 1;
|
2008-04-30 00:06:54 +02:00
|
|
|
|
|
|
|
// link all the functions, so any of them can unbind this click handler
|
2009-12-22 01:58:13 +01:00
|
|
|
while ( i < args.length ) {
|
2009-12-31 06:37:23 +01:00
|
|
|
jQuery.proxy( fn, args[ i++ ] );
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2009-12-31 06:37:23 +01:00
|
|
|
return this.click( jQuery.proxy( fn, function( event ) {
|
2007-12-19 02:10:20 +01:00
|
|
|
// Figure out which function to execute
|
2011-01-09 22:52:33 +01:00
|
|
|
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
|
|
|
|
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-12-19 02:10:20 +01:00
|
|
|
// Make sure that clicks stop
|
|
|
|
event.preventDefault();
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-12-19 02:10:20 +01:00
|
|
|
// and execute the function
|
2009-11-11 15:46:24 +01:00
|
|
|
return args[ lastToggle ].apply( this, arguments ) || false;
|
2008-04-30 00:06:54 +02:00
|
|
|
}));
|
2007-12-19 02:10:20 +01:00
|
|
|
},
|
|
|
|
|
2009-04-30 03:26:09 +02:00
|
|
|
hover: function( fnOver, fnOut ) {
|
2009-05-06 04:17:24 +02:00
|
|
|
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
|
2010-01-23 17:56:24 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2010-02-11 22:50:26 +01:00
|
|
|
var liveMap = {
|
|
|
|
focus: "focusin",
|
|
|
|
blur: "focusout",
|
|
|
|
mouseenter: "mouseover",
|
|
|
|
mouseleave: "mouseout"
|
|
|
|
};
|
|
|
|
|
2010-01-23 17:56:24 +01:00
|
|
|
jQuery.each(["live", "die"], function( i, name ) {
|
2010-02-02 00:06:03 +01:00
|
|
|
jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
|
2010-02-11 22:50:26 +01:00
|
|
|
var type, i = 0, match, namespaces, preType,
|
2010-02-02 00:06:03 +01:00
|
|
|
selector = origSelector || this.selector,
|
|
|
|
context = origSelector ? this : jQuery( this.context );
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2010-03-14 12:34:32 +01:00
|
|
|
if ( typeof types === "object" && !types.preventDefault ) {
|
|
|
|
for ( var key in types ) {
|
|
|
|
context[ name ]( key, data, types[key], selector );
|
|
|
|
}
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2010-03-14 12:34:32 +01:00
|
|
|
return this;
|
|
|
|
}
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2009-05-07 02:50:28 +02:00
|
|
|
if ( jQuery.isFunction( data ) ) {
|
|
|
|
fn = data;
|
|
|
|
data = undefined;
|
|
|
|
}
|
2009-12-31 06:37:23 +01:00
|
|
|
|
2010-02-05 03:36:32 +01:00
|
|
|
types = (types || "").split(" ");
|
2009-12-31 06:37:23 +01:00
|
|
|
|
2010-01-23 22:37:12 +01:00
|
|
|
while ( (type = types[ i++ ]) != null ) {
|
2010-02-05 03:36:32 +01:00
|
|
|
match = rnamespaces.exec( type );
|
|
|
|
namespaces = "";
|
|
|
|
|
|
|
|
if ( match ) {
|
|
|
|
namespaces = match[0];
|
|
|
|
type = type.replace( rnamespaces, "" );
|
|
|
|
}
|
|
|
|
|
2010-02-11 22:50:26 +01:00
|
|
|
if ( type === "hover" ) {
|
|
|
|
types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
|
|
|
|
continue;
|
|
|
|
}
|
2010-02-05 03:36:32 +01:00
|
|
|
|
2010-02-11 22:50:26 +01:00
|
|
|
preType = type;
|
2010-02-13 11:37:17 +01:00
|
|
|
|
|
|
|
if ( type === "focus" || type === "blur" ) {
|
|
|
|
types.push( liveMap[ type ] + namespaces );
|
|
|
|
type = type + namespaces;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
type = (liveMap[ type ] || type) + namespaces;
|
|
|
|
}
|
2010-02-05 03:36:32 +01:00
|
|
|
|
2010-01-23 17:56:24 +01:00
|
|
|
if ( name === "live" ) {
|
|
|
|
// bind live handler
|
2010-03-01 18:44:56 +01:00
|
|
|
for ( var j = 0, l = context.length; j < l; j++ ) {
|
2010-03-09 18:22:25 +01:00
|
|
|
jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
|
2010-02-11 22:50:26 +01:00
|
|
|
{ data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
|
2010-03-01 18:44:56 +01:00
|
|
|
}
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2010-01-23 17:56:24 +01:00
|
|
|
} else {
|
|
|
|
// unbind live handler
|
2010-03-09 18:22:25 +01:00
|
|
|
context.unbind( "live." + liveConvert( type, selector ), fn );
|
2010-01-23 17:56:24 +01:00
|
|
|
}
|
|
|
|
}
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2008-12-22 05:59:34 +01:00
|
|
|
return this;
|
2010-03-01 18:44:56 +01:00
|
|
|
};
|
2007-12-19 02:10:20 +01:00
|
|
|
});
|
|
|
|
|
2009-04-30 03:26:09 +02:00
|
|
|
function liveHandler( event ) {
|
2010-11-09 17:09:07 +01:00
|
|
|
var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
|
|
|
|
elems = [],
|
|
|
|
selectors = [],
|
2011-01-09 22:52:33 +01:00
|
|
|
events = jQuery._data( this, eventKey );
|
2008-12-31 00:29:14 +01:00
|
|
|
|
2010-09-29 15:46:25 +02:00
|
|
|
if ( typeof events === "function" ) {
|
|
|
|
events = events.events;
|
|
|
|
}
|
|
|
|
|
2010-11-22 01:54:56 +01: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 17:12:26 +01:00
|
|
|
return;
|
|
|
|
}
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2010-03-02 23:34:12 +01:00
|
|
|
if ( event.namespace ) {
|
|
|
|
namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
|
|
|
|
}
|
|
|
|
|
2010-02-05 03:36:32 +01: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 17:28:50 +01:00
|
|
|
|
2009-12-03 17:15:26 +01:00
|
|
|
} else {
|
2010-02-05 03:36:32 +01:00
|
|
|
live.splice( j--, 1 );
|
2009-12-03 16:51:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
match = jQuery( event.target ).closest( selectors, event.currentTarget );
|
|
|
|
|
|
|
|
for ( i = 0, l = match.length; i < l; i++ ) {
|
2010-02-26 15:26:14 +01:00
|
|
|
close = match[i];
|
|
|
|
|
2010-02-05 03:36:32 +01:00
|
|
|
for ( j = 0; j < live.length; j++ ) {
|
|
|
|
handleObj = live[j];
|
|
|
|
|
2010-03-02 23:34:12 +01:00
|
|
|
if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) {
|
2010-02-26 15:26:14 +01:00
|
|
|
elem = close.elem;
|
2010-02-05 03:36:32 +01:00
|
|
|
related = null;
|
2009-12-03 16:51:04 +01:00
|
|
|
|
2009-11-09 12:59:54 +01:00
|
|
|
// Those two events require additional checking
|
2010-02-11 22:50:26 +01:00
|
|
|
if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
|
2010-02-26 17:23:49 +01:00
|
|
|
event.type = handleObj.preType;
|
2010-02-05 03:36:32 +01:00
|
|
|
related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
|
2009-11-09 12:59:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( !related || related !== elem ) {
|
2010-02-26 15:26:14 +01:00
|
|
|
elems.push({ elem: elem, handleObj: handleObj, level: close.level });
|
2009-11-09 12:59:54 +01:00
|
|
|
}
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2008-12-22 05:59:34 +01:00
|
|
|
}
|
2009-12-03 16:51:04 +01:00
|
|
|
}
|
2009-01-10 20:57:07 +01:00
|
|
|
|
2009-12-03 16:51:04 +01:00
|
|
|
for ( i = 0, l = elems.length; i < l; i++ ) {
|
|
|
|
match = elems[i];
|
2010-02-26 15:26:14 +01:00
|
|
|
|
|
|
|
if ( maxLevel && match.level > maxLevel ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-12-03 16:51:04 +01:00
|
|
|
event.currentTarget = match.elem;
|
2010-02-05 03:36:32 +01:00
|
|
|
event.data = match.handleObj.data;
|
|
|
|
event.handleObj = match.handleObj;
|
|
|
|
|
2010-02-26 15:26:14 +01: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 20:36:24 +02:00
|
|
|
if ( event.isImmediatePropagationStopped() ) {
|
|
|
|
break;
|
|
|
|
}
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2009-12-03 16:51:04 +01:00
|
|
|
}
|
2009-01-10 20:57:07 +01:00
|
|
|
|
2008-12-30 21:45:33 +01:00
|
|
|
return stop;
|
2008-12-22 05:59:34 +01:00
|
|
|
}
|
|
|
|
|
2009-04-30 03:26:09 +02:00
|
|
|
function liveConvert( type, selector ) {
|
2010-09-22 15:16:28 +02:00
|
|
|
return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&");
|
2008-12-22 05:59:34 +01:00
|
|
|
}
|
|
|
|
|
2010-01-12 23:03:34 +01:00
|
|
|
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
|
2009-10-23 17:52:38 +02:00
|
|
|
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
|
|
|
|
"change select submit keydown keypress keyup error").split(" "), function( i, name ) {
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2007-12-19 02:10:20 +01:00
|
|
|
// Handle event binding
|
2010-02-27 02:01:19 +01:00
|
|
|
jQuery.fn[ name ] = function( data, fn ) {
|
2010-03-02 03:24:49 +01:00
|
|
|
if ( fn == null ) {
|
2010-02-27 15:02:13 +01:00
|
|
|
fn = data;
|
|
|
|
data = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return arguments.length > 0 ?
|
|
|
|
this.bind( name, data, fn ) :
|
2010-02-27 02:01:19 +01:00
|
|
|
this.trigger( name );
|
2007-12-19 02:10:20 +01:00
|
|
|
};
|
2009-12-10 06:28:33 +01:00
|
|
|
|
2010-01-13 03:54:06 +01:00
|
|
|
if ( jQuery.attrFn ) {
|
|
|
|
jQuery.attrFn[ name ] = true;
|
2009-12-10 06:28:33 +01:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
});
|
|
|
|
|
2010-09-08 19:54:33 +02:00
|
|
|
})( jQuery );
|