2010-09-08 19:54:33 +02:00
|
|
|
(function( jQuery ) {
|
|
|
|
|
2011-04-05 21:55:40 +02:00
|
|
|
var hasOwn = Object.prototype.hasOwnProperty,
|
|
|
|
rnamespaces = /\.(.*)$/,
|
2010-09-22 15:16:28 +02:00
|
|
|
rformElems = /^(?:textarea|input|select)$/i,
|
|
|
|
rperiod = /\./g,
|
2011-04-29 04:24:40 +02:00
|
|
|
rspaces = / /g,
|
2010-09-22 15:16:28 +02:00
|
|
|
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, "\\$&");
|
2011-02-07 17:48:38 +01:00
|
|
|
};
|
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
|
|
|
|
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
|
2011-02-15 22:03:23 +01: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-02-07 17:48:38 +01:00
|
|
|
var events = elemData.events,
|
2010-03-01 18:44:56 +01:00
|
|
|
eventHandle = elemData.handle;
|
2010-12-26 21:28:13 +01:00
|
|
|
|
2011-02-07 17:48:38 +01:00
|
|
|
if ( !events ) {
|
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 ) {
|
2011-03-05 03:16:40 +01:00
|
|
|
elemData.handle = eventHandle = function( e ) {
|
2011-04-06 16:31:14 +02:00
|
|
|
// Discard the second event of a jQuery.event.trigger() and
|
|
|
|
// when an event is called after a page has unloaded
|
2011-04-17 19:21:46 +02:00
|
|
|
return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
|
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
|
|
|
|
2011-03-16 04:40:25 +01:00
|
|
|
// Keep track of which events have been used, for event optimization
|
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 ),
|
2011-02-07 17:48:38 +01:00
|
|
|
events = elemData && elemData.events;
|
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-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
|
|
|
|
2011-02-07 17:48:38 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2011-04-07 05:41:47 +02:00
|
|
|
|
|
|
|
// Events that are safe to short-circuit if no handlers are attached.
|
|
|
|
// Native DOM events should not be added, they may have inline handlers.
|
|
|
|
customEvent: {
|
|
|
|
"getData": true,
|
|
|
|
"setData": true,
|
|
|
|
"changeData": true
|
|
|
|
},
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2011-04-17 02:48:27 +02:00
|
|
|
trigger: function( event, data, elem, onlyHandlers ) {
|
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,
|
2011-04-11 17:15:00 +02:00
|
|
|
namespaces = [],
|
|
|
|
exclusive;
|
2011-04-06 17:34:41 +02:00
|
|
|
|
|
|
|
if ( type.indexOf("!") >= 0 ) {
|
2011-04-11 17:15:00 +02:00
|
|
|
// Exclusive events trigger only for the exact event (no namespaces)
|
|
|
|
type = type.slice(0, -1);
|
|
|
|
exclusive = true;
|
2011-04-06 17:34:41 +02:00
|
|
|
}
|
2011-04-12 20:58:55 +02:00
|
|
|
|
2011-02-11 05:43:45 +01:00
|
|
|
if ( type.indexOf(".") >= 0 ) {
|
|
|
|
// Namespaced trigger; create a regexp to match event type in handle()
|
|
|
|
namespaces = type.split(".");
|
2011-04-11 17:15:00 +02:00
|
|
|
type = namespaces.shift();
|
2011-02-11 05:43:45 +01:00
|
|
|
namespaces.sort();
|
|
|
|
}
|
2011-04-07 05:41:47 +02:00
|
|
|
|
2011-04-17 02:48:27 +02:00
|
|
|
if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
|
2011-04-07 05:41:47 +02:00
|
|
|
// No jQuery handlers for this event type, and it can't have inline handlers
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-11 17:15:00 +02:00
|
|
|
// Caller can pass in an Event, Object, or just an event type string
|
|
|
|
event = typeof event === "object" ?
|
|
|
|
// jQuery.Event object
|
|
|
|
event[ jQuery.expando ] ? event :
|
|
|
|
// Object literal
|
2011-04-13 01:29:09 +02:00
|
|
|
new jQuery.Event( type, event ) :
|
2011-04-11 17:15:00 +02:00
|
|
|
// Just the event type (string)
|
2011-04-13 01:29:09 +02:00
|
|
|
new jQuery.Event( type );
|
2011-04-12 20:58:55 +02:00
|
|
|
|
2011-04-13 00:32:23 +02:00
|
|
|
event.type = type;
|
2011-04-17 02:48:27 +02:00
|
|
|
event.exclusive = exclusive;
|
2011-02-11 05:43:45 +01:00
|
|
|
event.namespace = namespaces.join(".");
|
|
|
|
event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
|
2011-04-17 02:48:27 +02:00
|
|
|
|
|
|
|
// triggerHandler() and global events don't bubble or run the default action
|
|
|
|
if ( onlyHandlers || !elem ) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
2011-04-11 17:32:23 +02:00
|
|
|
|
2011-04-06 17:34:41 +02:00
|
|
|
// Handle a global trigger
|
|
|
|
if ( !elem ) {
|
2011-04-17 02:48:27 +02:00
|
|
|
// TODO: Stop taunting the data cache; remove global events and always attach to document
|
|
|
|
jQuery.each( jQuery.cache, function() {
|
|
|
|
// 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 );
|
|
|
|
}
|
|
|
|
});
|
2011-04-06 17:34:41 +02:00
|
|
|
return;
|
|
|
|
}
|
2009-01-03 00:07:16 +01:00
|
|
|
|
2011-03-16 04:40:25 +01:00
|
|
|
// Don't do events on text and comment nodes
|
2011-02-11 05:43:45 +01:00
|
|
|
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
|
|
|
|
return;
|
2011-04-06 17:34:41 +02:00
|
|
|
}
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2011-03-16 04:40:25 +01:00
|
|
|
// Clean up the event in case it is being reused
|
2011-04-06 17:34:41 +02:00
|
|
|
event.result = undefined;
|
|
|
|
event.target = elem;
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2011-03-16 04:40:25 +01:00
|
|
|
// Clone any incoming data and prepend the event, creating the handler arg list
|
2011-04-12 20:58:55 +02:00
|
|
|
data = data ? jQuery.makeArray( data ) : [];
|
2011-04-06 17:34:41 +02:00
|
|
|
data.unshift( event );
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2011-04-08 04:52:15 +02:00
|
|
|
var cur = elem,
|
|
|
|
// IE doesn't like method names with a colon (#3533, #8272)
|
2011-04-12 21:54:30 +02:00
|
|
|
ontype = type.indexOf(":") < 0 ? "on" + type : "";
|
2011-04-08 04:52:15 +02:00
|
|
|
|
2011-03-16 04:40:25 +01:00
|
|
|
// Fire event on the current element, then bubble up the DOM tree
|
2011-02-11 05:43:45 +01:00
|
|
|
do {
|
|
|
|
var handle = jQuery._data( cur, "handle" );
|
2010-09-29 15:46:25 +02:00
|
|
|
|
2011-02-11 05:43:45 +01:00
|
|
|
event.currentTarget = cur;
|
2011-04-06 17:34:41 +02:00
|
|
|
if ( handle ) {
|
2011-02-11 05:43:45 +01:00
|
|
|
handle.apply( cur, data );
|
2011-04-06 17:34:41 +02:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2011-04-08 04:52:15 +02:00
|
|
|
// Trigger an inline bound script
|
2011-04-12 21:54:30 +02:00
|
|
|
if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
|
2011-04-08 04:52:15 +02:00
|
|
|
event.result = false;
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
2010-01-25 19:45:07 +01:00
|
|
|
|
2011-04-07 04:11:58 +02:00
|
|
|
// Bubble up to document, then to window
|
|
|
|
cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window;
|
2011-04-06 16:31:14 +02:00
|
|
|
} while ( cur && !event.isPropagationStopped() );
|
2009-12-05 05:18:05 +01:00
|
|
|
|
2011-02-11 05:43:45 +01:00
|
|
|
// If nobody prevented the default action, do it now
|
|
|
|
if ( !event.isDefaultPrevented() ) {
|
2010-11-09 17:09:07 +01:00
|
|
|
var old,
|
2011-02-11 05:43:45 +01:00
|
|
|
special = jQuery.event.special[ type ] || {};
|
2010-01-28 20:34:09 +01:00
|
|
|
|
2011-02-11 05:43:45 +01:00
|
|
|
if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) &&
|
|
|
|
!(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
|
2009-12-05 05:18:05 +01:00
|
|
|
|
2011-03-16 04:40:25 +01:00
|
|
|
// Call a native DOM method on the target with the same name name as the event.
|
|
|
|
// Can't use an .isFunction)() check here because IE6/7 fails that test.
|
2011-04-08 04:52:15 +02:00
|
|
|
// IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch.
|
2010-01-25 19:45:07 +01:00
|
|
|
try {
|
2011-04-08 04:52:15 +02:00
|
|
|
if ( ontype && elem[ type ] ) {
|
2011-03-16 04:40:25 +01:00
|
|
|
// Don't re-trigger an onFOO event when we call its FOO() method
|
|
|
|
old = elem[ ontype ];
|
2010-01-25 19:45:07 +01:00
|
|
|
|
|
|
|
if ( old ) {
|
2011-03-16 04:40:25 +01:00
|
|
|
elem[ ontype ] = null;
|
2010-01-25 19:45:07 +01:00
|
|
|
}
|
|
|
|
|
2011-03-16 04:40:25 +01:00
|
|
|
jQuery.event.triggered = type;
|
2011-02-11 05:43:45 +01:00
|
|
|
elem[ type ]();
|
2010-01-25 19:45:07 +01:00
|
|
|
}
|
2011-04-08 04:52:15 +02:00
|
|
|
} catch ( ieError ) {}
|
2010-01-25 19:45:07 +01:00
|
|
|
|
|
|
|
if ( old ) {
|
2011-03-16 04:40:25 +01:00
|
|
|
elem[ ontype ] = old;
|
2010-01-25 19:45:07 +01:00
|
|
|
}
|
2009-01-05 21:43:24 +01:00
|
|
|
|
2011-03-05 03:16:40 +01:00
|
|
|
jQuery.event.triggered = undefined;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
}
|
2011-04-17 02:48:27 +02:00
|
|
|
|
|
|
|
return event.result;
|
2007-12-19 02:10:20 +01:00
|
|
|
},
|
|
|
|
|
2009-04-30 03:26:09 +02:00
|
|
|
handle: function( event ) {
|
2011-02-11 05:43:45 +01:00
|
|
|
event = jQuery.event.fix( event || window.event );
|
2011-04-06 17:34:41 +02:00
|
|
|
// Snapshot the handlers list since a called handler may add/remove events.
|
2011-03-16 04:40:25 +01:00
|
|
|
var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0),
|
2011-04-06 17:34:41 +02:00
|
|
|
run_all = !event.exclusive && !event.namespace,
|
2011-04-11 19:19:00 +02:00
|
|
|
args = Array.prototype.slice.call( arguments, 0 );
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2011-02-11 05:43:45 +01:00
|
|
|
// Use the fix-ed Event rather than the (read-only) native event
|
|
|
|
args[0] = event;
|
2009-02-17 13:38:16 +01:00
|
|
|
event.currentTarget = this;
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2011-04-06 17:34:41 +02:00
|
|
|
for ( var j = 0, l = handlers.length; j < l; j++ ) {
|
|
|
|
var handleObj = handlers[ j ];
|
2010-02-04 06:20:52 +01:00
|
|
|
|
2011-02-11 05:43:45 +01:00
|
|
|
// Triggered event must 1) be non-exclusive and have no namespace, or
|
|
|
|
// 2) have namespace(s) a subset or equal to those in the bound event.
|
2011-04-06 17:34:41 +02:00
|
|
|
if ( run_all || event.namespace_re.test( handleObj.namespace ) ) {
|
|
|
|
// Pass in a reference to the handler function itself
|
|
|
|
// So that we can later remove it
|
|
|
|
event.handler = handleObj.handler;
|
|
|
|
event.data = handleObj.data;
|
|
|
|
event.handleObj = handleObj;
|
|
|
|
|
|
|
|
var ret = handleObj.handler.apply( this, args );
|
|
|
|
|
|
|
|
if ( ret !== undefined ) {
|
|
|
|
event.result = ret;
|
|
|
|
if ( ret === false ) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2008-12-31 03:58:13 +01:00
|
|
|
}
|
2011-04-06 17:34:41 +02:00
|
|
|
}
|
2008-10-19 00:46:04 +02:00
|
|
|
|
2011-04-06 17:34:41 +02:00
|
|
|
if ( event.isImmediatePropagationStopped() ) {
|
|
|
|
break;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
}
|
2011-04-06 17:34:41 +02: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 ) {
|
2011-03-16 04:40:25 +01:00
|
|
|
var eventDocument = event.target.ownerDocument || document,
|
|
|
|
doc = eventDocument.documentElement,
|
|
|
|
body = eventDocument.body;
|
2010-11-09 17:09:07 +01:00
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2011-04-13 01:29:09 +02:00
|
|
|
jQuery.Event = function( src, props ) {
|
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 ) {
|
2011-04-13 01:29:09 +02:00
|
|
|
return new jQuery.Event( src, props );
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
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;
|
2011-04-11 17:32:23 +02:00
|
|
|
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.
|
2011-02-07 17:48:38 +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
|
|
|
|
2011-04-13 01:29:09 +02:00
|
|
|
// Put explicitly provided properties onto the event object
|
|
|
|
if ( props ) {
|
|
|
|
jQuery.extend( this, props );
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2011-05-10 17:49:32 +02:00
|
|
|
// set the correct event type
|
|
|
|
event.type = event.data;
|
|
|
|
|
2010-02-13 11:45:48 +01:00
|
|
|
// Firefox sometimes assigns relatedTarget a XUL element
|
|
|
|
// which we cannot access the parentNode property of
|
|
|
|
try {
|
2011-02-08 17:15:55 +01:00
|
|
|
|
|
|
|
// Chrome does something similar, the parentNode property
|
|
|
|
// can be accessed but is null.
|
2011-03-10 04:38:26 +01:00
|
|
|
if ( parent && parent !== document && !parent.parentNode ) {
|
2011-02-08 17:15:55 +01:00
|
|
|
return;
|
|
|
|
}
|
2011-05-10 17:49:32 +02:00
|
|
|
|
2010-02-13 11:45:48 +01:00
|
|
|
// 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
|
|
|
|
2011-02-08 17:08:25 +01:00
|
|
|
if ( parent !== this ) {
|
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 ) {
|
2011-04-23 23:58:56 +02:00
|
|
|
if ( !jQuery.nodeName( this, "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 ) {
|
2011-02-10 03:25:29 +01:00
|
|
|
trigger( "submit", this, arguments );
|
2010-02-09 05:28:15 +01:00
|
|
|
}
|
|
|
|
});
|
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 ) {
|
2011-02-10 03:25:29 +01:00
|
|
|
trigger( "submit", this, arguments );
|
2010-02-09 05:28:15 +01:00
|
|
|
}
|
|
|
|
});
|
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
|
|
|
|
2011-04-23 23:58:56 +02:00
|
|
|
} else if ( jQuery.nodeName( elem, "select" ) ) {
|
2010-02-09 05:28:15 +01:00
|
|
|
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;
|
2011-02-10 03:25:29 +01:00
|
|
|
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 ) {
|
2011-04-12 22:48:22 +02:00
|
|
|
var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
|
2009-12-21 21:32:32 +01:00
|
|
|
|
2011-04-23 23:58:56 +02:00
|
|
|
if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) {
|
2011-02-10 03:25:29 +01:00
|
|
|
testChange.call( this, e );
|
2010-02-09 05:28:15 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// Change has to be called before submit
|
|
|
|
// Keydown will be called before keypress, which is used in submit-event delegation
|
|
|
|
keydown: function( e ) {
|
2011-04-12 22:48:22 +02:00
|
|
|
var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
|
2009-12-04 17:28:50 +01:00
|
|
|
|
2011-04-23 23:58:56 +02:00
|
|
|
if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) ||
|
2010-02-09 05:28:15 +01:00
|
|
|
(e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
|
|
|
|
type === "select-multiple" ) {
|
2011-02-10 03:25:29 +01:00
|
|
|
testChange.call( this, e );
|
2010-02-09 05:28:15 +01:00
|
|
|
}
|
|
|
|
},
|
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 ) {
|
2011-02-10 03:25:29 +01:00
|
|
|
// Piggyback on a donor event to simulate a different one.
|
|
|
|
// Fake originalEvent to avoid donor's stopPropagation, but if the
|
|
|
|
// simulated event prevents default then we do the same on the donor.
|
|
|
|
// Don't pass args or remember liveFired; they apply to the donor event.
|
|
|
|
var event = jQuery.extend( {}, args[ 0 ] );
|
|
|
|
event.type = type;
|
|
|
|
event.originalEvent = {};
|
|
|
|
event.liveFired = undefined;
|
|
|
|
jQuery.event.handle.call( elem, event );
|
|
|
|
if ( event.isDefaultPrevented() ) {
|
|
|
|
args[ 0 ].preventDefault();
|
|
|
|
}
|
2009-12-04 17:28:50 +01:00
|
|
|
}
|
2009-09-16 10:33:00 +02:00
|
|
|
|
2009-09-15 00:04:22 +02:00
|
|
|
// Create "bubbling" focus and blur events
|
2011-04-04 16:27:31 +02:00
|
|
|
if ( !jQuery.support.focusinBubbles ) {
|
2009-12-22 01:58:13 +01:00
|
|
|
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
|
2011-04-05 21:55:40 +02:00
|
|
|
|
2011-03-05 03:16:40 +01:00
|
|
|
// Attach a single capturing handler while someone wants focusin/focusout
|
|
|
|
var attaches = 0;
|
2011-04-05 21:55:40 +02:00
|
|
|
|
2009-12-21 22:10:21 +01:00
|
|
|
jQuery.event.special[ fix ] = {
|
|
|
|
setup: function() {
|
2011-03-05 03:16:40 +01:00
|
|
|
if ( attaches++ === 0 ) {
|
|
|
|
document.addEventListener( orig, handler, true );
|
|
|
|
}
|
2011-02-07 17:48:38 +01:00
|
|
|
},
|
|
|
|
teardown: function() {
|
2011-03-05 03:16:40 +01:00
|
|
|
if ( --attaches === 0 ) {
|
|
|
|
document.removeEventListener( orig, handler, true );
|
|
|
|
}
|
2009-12-21 22:10:21 +01:00
|
|
|
}
|
|
|
|
};
|
2009-09-15 00:04:22 +02:00
|
|
|
|
2011-03-05 03:16:40 +01:00
|
|
|
function handler( donor ) {
|
|
|
|
// Donor event is always a native one; fix it and switch its type.
|
|
|
|
// Let focusin/out handler cancel the donor focus/blur event.
|
|
|
|
var e = jQuery.event.fix( donor );
|
2009-12-21 22:10:21 +01:00
|
|
|
e.type = fix;
|
2011-03-05 03:16:40 +01:00
|
|
|
e.originalEvent = {};
|
|
|
|
jQuery.event.trigger( e, null, e.target );
|
|
|
|
if ( e.isDefaultPrevented() ) {
|
|
|
|
donor.preventDefault();
|
|
|
|
}
|
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 ) {
|
2010-12-15 03:53:04 +01:00
|
|
|
var handler;
|
|
|
|
|
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
|
|
|
|
2011-04-17 02:37:35 +02:00
|
|
|
if ( arguments.length === 2 || data === false ) {
|
2009-05-07 02:50:28 +02:00
|
|
|
fn = data;
|
|
|
|
data = undefined;
|
|
|
|
}
|
2009-12-31 06:37:23 +01:00
|
|
|
|
2010-12-15 03:53:04 +01:00
|
|
|
if ( name === "one" ) {
|
|
|
|
handler = function( event ) {
|
|
|
|
jQuery( this ).unbind( event, handler );
|
|
|
|
return fn.apply( this, arguments );
|
|
|
|
};
|
|
|
|
handler.guid = fn.guid || jQuery.guid++;
|
|
|
|
} else {
|
|
|
|
handler = 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 ) {
|
2011-04-14 05:10:32 +02:00
|
|
|
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] ) {
|
2011-04-17 02:48:27 +02:00
|
|
|
return jQuery.event.trigger( type, data, this[0], true );
|
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,
|
2010-12-15 03:53:04 +01:00
|
|
|
guid = fn.guid || jQuery.guid++,
|
|
|
|
i = 0,
|
|
|
|
toggler = function( event ) {
|
|
|
|
// Figure out which function to execute
|
|
|
|
var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
|
|
|
|
jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
|
|
|
|
|
|
|
|
// Make sure that clicks stop
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
// and execute the function
|
|
|
|
return args[ lastToggle ].apply( this, arguments ) || false;
|
|
|
|
};
|
2008-04-30 00:06:54 +02:00
|
|
|
|
|
|
|
// link all the functions, so any of them can unbind this click handler
|
2010-12-15 03:53:04 +01:00
|
|
|
toggler.guid = guid;
|
2009-12-22 01:58:13 +01:00
|
|
|
while ( i < args.length ) {
|
2010-12-15 03:53:04 +01:00
|
|
|
args[ i++ ].guid = guid;
|
2009-04-30 03:26:09 +02:00
|
|
|
}
|
2007-12-19 02:10:20 +01:00
|
|
|
|
2010-12-15 03:53:04 +01:00
|
|
|
return this.click( toggler );
|
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
|
|
|
|
2011-04-06 00:12:50 +02:00
|
|
|
if ( name === "die" && !types &&
|
2011-04-14 05:10:32 +02:00
|
|
|
origSelector && origSelector.charAt(0) === "." ) {
|
2011-04-06 00:12:50 +02:00
|
|
|
|
|
|
|
context.unbind( origSelector );
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2011-04-06 03:59:09 +02:00
|
|
|
if ( data === false || jQuery.isFunction( data ) ) {
|
|
|
|
fn = data || returnFalse;
|
2009-05-07 02:50:28 +02:00
|
|
|
data = undefined;
|
2011-04-11 17:32:23 +02:00
|
|
|
}
|
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
|
|
|
|
2011-04-18 00:29:49 +02:00
|
|
|
if ( liveMap[ type ] ) {
|
2010-02-13 11:37:17 +01:00
|
|
|
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-02-07 17:48:38 +01:00
|
|
|
events = jQuery._data( this, "events" );
|
2010-09-29 15:46:25 +02:00
|
|
|
|
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];
|
|
|
|
|
2011-02-18 19:09:07 +01:00
|
|
|
if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
|
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];
|
2011-04-17 19:34:38 +02:00
|
|
|
|
|
|
|
// Make sure not to accidentally match a child element with the same selector
|
|
|
|
if ( related && jQuery.contains( elem, related ) ) {
|
|
|
|
related = elem;
|
|
|
|
}
|
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 ) {
|
2011-04-28 20:11:34 +02:00
|
|
|
return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&");
|
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 );
|
2011-04-05 21:55:40 +02:00
|
|
|
|