Renaming variables to be more consistent

This commit is contained in:
Brandon Aaron 2007-12-16 04:09:53 +00:00
parent 67c7b46ea3
commit 7a6978b324

View File

@ -7,14 +7,14 @@ jQuery.event = {
// Bind an event to an element // Bind an event to an element
// Original by Dean Edwards // Original by Dean Edwards
add: function(element, types, handler, data) { add: function(elem, types, handler, data) {
if ( element.nodeType == 3 || element.nodeType == 8 ) if ( elem.nodeType == 3 || elem.nodeType == 8 )
return; return;
// For whatever reason, IE has trouble passing the window object // For whatever reason, IE has trouble passing the window object
// around, causing it to be cloned in the process // around, causing it to be cloned in the process
if ( jQuery.browser.msie && element.setInterval != undefined ) if ( jQuery.browser.msie && elem.setInterval != undefined )
element = window; elem = window;
// Make sure that the function being executed has a unique ID // Make sure that the function being executed has a unique ID
if ( !handler.guid ) if ( !handler.guid )
@ -39,8 +39,8 @@ jQuery.event = {
} }
// Init the element's event structure // Init the element's event structure
var events = jQuery.data(element, "events") || jQuery.data(element, "events", {}), var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}),
handle = jQuery.data(element, "handle") || jQuery.data(element, "handle", function(){ handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){
// returned undefined or false // returned undefined or false
var val; var val;
@ -49,7 +49,7 @@ jQuery.event = {
if ( typeof jQuery == "undefined" || jQuery.event.triggered ) if ( typeof jQuery == "undefined" || jQuery.event.triggered )
return val; return val;
val = jQuery.event.handle.apply(element, arguments); val = jQuery.event.handle.apply(elem, arguments);
return val; return val;
}); });
@ -72,12 +72,12 @@ jQuery.event = {
// Check for a special event handler // Check for a special event handler
// Only use addEventListener/attachEvent if the special // Only use addEventListener/attachEvent if the special
// events handler returns false // events handler returns false
if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(element) === false ) { if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) {
// Bind the global event handler to the element // Bind the global event handler to the element
if (element.addEventListener) if (elem.addEventListener)
element.addEventListener(type, handle, false); elem.addEventListener(type, handle, false);
else if (element.attachEvent) else if (elem.attachEvent)
element.attachEvent("on" + type, handle); elem.attachEvent("on" + type, handle);
} }
} }
@ -93,18 +93,18 @@ jQuery.event = {
global: {}, global: {},
// Detach an event or set of events from an element // Detach an event or set of events from an element
remove: function(element, types, handler) { remove: function(elem, types, handler) {
// don't do events on text and comment nodes // don't do events on text and comment nodes
if ( element.nodeType == 3 || element.nodeType == 8 ) if ( elem.nodeType == 3 || elem.nodeType == 8 )
return; return;
var events = jQuery.data(element, "events"), ret, index; var events = jQuery.data(elem, "events"), ret, index;
if ( events ) { if ( events ) {
// Unbind all events for the element // Unbind all events for the element
if ( !types ) if ( !types )
for ( var type in events ) for ( var type in events )
this.remove( element, type ); this.remove( elem, type );
else { else {
// types is actually an event object here // types is actually an event object here
if ( types.type ) { if ( types.type ) {
@ -134,11 +134,11 @@ jQuery.event = {
// remove generic event handler if no more handlers exist // remove generic event handler if no more handlers exist
for ( ret in events[type] ) break; for ( ret in events[type] ) break;
if ( !ret ) { if ( !ret ) {
if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(this, element) === false ) { if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(this, elem) === false ) {
if (element.removeEventListener) if (elem.removeEventListener)
element.removeEventListener(type, jQuery.data(element, "handle"), false); elem.removeEventListener(type, jQuery.data(elem, "handle"), false);
else if (element.detachEvent) else if (elem.detachEvent)
element.detachEvent("on" + type, jQuery.data(element, "handle")); elem.detachEvent("on" + type, jQuery.data(elem, "handle"));
} }
ret = null; ret = null;
delete events[type]; delete events[type];
@ -150,18 +150,18 @@ jQuery.event = {
// Remove the expando if it's no longer used // Remove the expando if it's no longer used
for ( ret in events ) break; for ( ret in events ) break;
if ( !ret ) { if ( !ret ) {
jQuery.removeData( element, "events" ); jQuery.removeData( elem, "events" );
jQuery.removeData( element, "handle" ); jQuery.removeData( elem, "handle" );
} }
} }
}, },
trigger: function(type, data, element, donative, extra) { trigger: function(type, data, elem, donative, extra) {
// Clone the incoming data, if any // Clone the incoming data, if any
data = jQuery.makeArray(data || []); data = jQuery.makeArray(data || []);
// Handle a global trigger // Handle a global trigger
if ( !element ) { if ( !elem ) {
// Only trigger if we've ever bound an event for it // Only trigger if we've ever bound an event for it
if ( this.global[type] ) if ( this.global[type] )
jQuery("*").add([window, document]).trigger(type, data); jQuery("*").add([window, document]).trigger(type, data);
@ -169,26 +169,26 @@ jQuery.event = {
// Handle triggering a single element // Handle triggering a single element
} else { } else {
// don't do events on text and comment nodes // don't do events on text and comment nodes
if ( element.nodeType == 3 || element.nodeType == 8 ) if ( elem.nodeType == 3 || elem.nodeType == 8 )
return undefined; return undefined;
var val, ret, fn = jQuery.isFunction( element[ type ] || null ), var val, ret, fn = jQuery.isFunction( elem[ type ] || null ),
// Check to see if we need to provide a fake event, or not // Check to see if we need to provide a fake event, or not
event = !data[0] || !data[0].preventDefault; event = !data[0] || !data[0].preventDefault;
// Pass along a fake event // Pass along a fake event
if ( event ) if ( event )
data.unshift( this.fix({ type: type, target: element }) ); data.unshift( this.fix({ type: type, target: elem }) );
// Enforce the right trigger type // Enforce the right trigger type
data[0].type = type; data[0].type = type;
// Trigger the event // Trigger the event
if ( jQuery.isFunction( jQuery.data(element, "handle") ) ) if ( jQuery.isFunction( jQuery.data(elem, "handle") ) )
val = jQuery.data(element, "handle").apply( element, data ); val = jQuery.data(elem, "handle").apply( elem, data );
// Handle triggering native .onfoo handlers // Handle triggering native .onfoo handlers
if ( !fn && element["on"+type] && element["on"+type].apply( element, data ) === false ) if ( !fn && elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
val = false; val = false;
// Extra functions don't get the custom event object // Extra functions don't get the custom event object
@ -198,17 +198,17 @@ jQuery.event = {
// Handle triggering of extra function // Handle triggering of extra function
if ( extra ) { if ( extra ) {
// call the extra function and tack the current return value on the end for possible inspection // call the extra function and tack the current return value on the end for possible inspection
var ret = extra.apply( element, data.concat( val ) ); var ret = extra.apply( elem, data.concat( val ) );
// if anything is returned, give it precedence and have it overwrite the previous value // if anything is returned, give it precedence and have it overwrite the previous value
if (ret !== undefined) if (ret !== undefined)
val = ret; val = ret;
} }
// Trigger the native events (except for clicks on links) // Trigger the native events (except for clicks on links)
if ( fn && donative !== false && val !== false && !(jQuery.nodeName(element, 'a') && type == "click") ) { if ( fn && donative !== false && val !== false && !(jQuery.nodeName(elem, 'a') && type == "click") ) {
this.triggered = true; this.triggered = true;
try { try {
element[ type ](); elem[ type ]();
// prevent IE from throwing an error for some hidden elements // prevent IE from throwing an error for some hidden elements
} catch (e) {} } catch (e) {}
} }
@ -489,13 +489,13 @@ jQuery.each( ("blur,focus,load,ready,resize,scroll,unload,click,dblclick," +
// Checks if an event happened on an element within another element // Checks if an event happened on an element within another element
// Used in jQuery.event.special.mouseenter and mouseleave handlers // Used in jQuery.event.special.mouseenter and mouseleave handlers
var withinElement = function(event, element) { var withinElement = function(event, elem) {
// Check if mouse(over|out) are still within the same parent element // Check if mouse(over|out) are still within the same parent element
var parent = event.relatedTarget; var parent = event.relatedTarget;
// Traverse up the tree // Traverse up the tree
while ( parent && parent != element ) try { parent = parent.parentNode } catch(error) { parent = element; }; while ( parent && parent != elem ) try { parent = parent.parentNode } catch(error) { parent = elem; };
// Return true if we actually just moused on to a sub-element // Return true if we actually just moused on to a sub-element
return parent == element; return parent == elem;
}; };
// Prevent memory leaks in IE // Prevent memory leaks in IE