Side navigation
Ticket #2743: potpourri.diff
File potpourri.diff, 22.5 KB (added by flesler, April 25, 2008 03:15AM UTC)
Index: ajax.js
===================================================================
--- ajax.js (revision 5317)
+++ ajax.js (working copy)
@@ -20,7 +20,7 @@
if ( jQuery.isFunction( params ) ) {
// We assume that it's the callback
callback = params;
- params = null;
+ params = undefined;
// Otherwise, build a param string
} else {
@@ -74,7 +74,7 @@
})
.map(function(i, elem){
var val = jQuery(this).val();
- return val == null ? null :
+ return val == undefined ? undefined :
val.constructor == Array ?
jQuery.map( val, function(val, i){
return {name: elem.name, value: val};
@@ -98,7 +98,7 @@
// shift arguments if data argument was ommited
if ( jQuery.isFunction( data ) ) {
callback = data;
- data = null;
+ data = undefined;
}
return jQuery.ajax({
@@ -111,7 +111,7 @@
},
getScript: function( url, callback ) {
- return jQuery.get(url, null, callback, "script");
+ return jQuery.get(url, undefined, callback, "script");
},
getJSON: function( url, data, callback ) {
@@ -144,9 +144,9 @@
contentType: "application/x-www-form-urlencoded",
processData: true,
async: true,
- data: null,
- username: null,
- password: null,
+ data: undefined,
+ username: undefined,
+ password: undefined,
accepts: {
xml: "application/xml, text/xml",
html: "text/html",
@@ -207,7 +207,7 @@
};
}
- if ( s.dataType == "script" && s.cache == null )
+ if ( s.dataType == "script" && s.cache == undefined )
s.cache = false;
if ( s.cache === false && s.type.toLowerCase() == "get" ) {
@@ -223,7 +223,7 @@
s.url += (s.url.match(/\?/) ? "&" : "?") + s.data;
// IE likes to send both get and post data, prevent this
- s.data = null;
+ s.data = undefined;
}
// Watch for a new set of requests
@@ -311,7 +311,7 @@
// clear poll interval
if (ival) {
clearInterval(ival);
- ival = null;
+ ival = undefined;
}
status = isTimeout == "timeout" && "timeout" ||
@@ -351,7 +351,7 @@
// Stop memory leaks
if ( s.async )
- xml = null;
+ xml = undefined;
}
};
@@ -377,7 +377,7 @@
try {
xml.send(s.data);
} catch(e) {
- jQuery.handleError(s, xml, null, e);
+ jQuery.handleError(s, xml, undefined, e);
}
// firefox 1.5 doesn't fire statechange for sync requests
@@ -448,9 +448,9 @@
},
httpData: function( r, type ) {
- var ct = r.getResponseHeader("content-type");
- var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0;
- var data = xml ? r.responseXML : r.responseText;
+ var ct = r.getResponseHeader("content-type"),
+ xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
+ data = xml ? r.responseXML : r.responseText;
if ( xml && data.documentElement.tagName == "parsererror" )
throw "parsererror";
Index: core.js
===================================================================
--- core.js (revision 5317)
+++ core.js (working copy)
@@ -10,27 +10,26 @@
*/
// Map over jQuery in case of overwrite
-if ( window.jQuery )
- var _jQuery = window.jQuery;
+var _jQuery = this.jQuery,
-var jQuery = window.jQuery = function( selector, context ) {
- // The jQuery object is actually just the init constructor 'enhanced'
- return new jQuery.prototype.init( selector, context );
-};
-
// Map over the $ in case of overwrite
-if ( window.$ )
- var _$ = window.$;
+ _$ = this.$,
-// Map the jQuery namespace to the '$' one
-window.$ = jQuery;
+//- when munging variables, every undefined turns into one-letter name.
+//- faster lookups: http://snurl.com/25pcd
+ undefined;
+var jQuery = this.jQuery = this.$ = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context );
+};
+
// A simple way to check for HTML strings or ID strings
// (both of which we optimize for)
-var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;
+var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,
// Is it a simple selector
-var isSimple = /^.[^:#\[\.]*$/;
+ isSimple = /^.[^:#\[\.]*$/;
jQuery.fn = jQuery.prototype = {
init: function( selector, context ) {
@@ -148,15 +147,7 @@
// Determine the position of an element within
// the matched set of elements
index: function( elem ) {
- var ret = -1;
-
- // Locate the position of the desired element
- this.each(function(i){
- if ( this == elem )
- ret = i;
- });
-
- return ret;
+ return jQuery.inArray( elem, this );
},
attr: function( name, value, type ) {
@@ -193,7 +184,7 @@
},
text: function( text ) {
- if ( typeof text != "object" && text != null )
+ if ( typeof text != "object" && text != undefined )
return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
var ret = "";
@@ -306,7 +297,7 @@
// this is primarily for IE but the data expando shouldn't be copied over in any browser
var clone = ret.find("*").andSelf().each(function(){
if ( this[ expando ] != undefined )
- this[ expando ] = null;
+ this[ expando ] = undefined;
});
// Copy the events from the original to the clone
@@ -359,9 +350,7 @@
},
is: function( selector ) {
- return selector ?
- jQuery.multiFilter( selector, this ).length > 0 :
- false;
+ return !!selector && jQuery.multiFilter( selector, this ).length > 0 ;
},
hasClass: function( selector ) {
@@ -383,7 +372,7 @@
// Nothing was selected
if ( index < 0 )
- return null;
+ return undefined;
// Loop through all the selected options
for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
@@ -410,7 +399,7 @@
}
- return undefined;
+ return;
}
return this.each(function(){
@@ -443,7 +432,7 @@
return value == undefined ?
(this.length ?
this[0].innerHTML :
- null) :
+ undefined) :
this.empty().append( value );
},
@@ -473,13 +462,13 @@
var parts = key.split(".");
parts[1] = parts[1] ? "." + parts[1] : "";
- if ( value == null ) {
+ if ( value == undefined ) {
var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
if ( data == undefined && this.length )
data = jQuery.data( this[0], key );
- return data == null && parts[1] ?
+ return data == undefined && parts[1] ?
this.data( parts[0] ) :
data;
} else
@@ -536,7 +525,7 @@
};
// Give the init function the jQuery prototype for later instantiation
-jQuery.prototype.init.prototype = jQuery.prototype;
+jQuery.fn.init.prototype = jQuery.fn;
function evalScript( i, elem ) {
if ( elem.src )
@@ -570,27 +559,29 @@
target = {};
// extend jQuery itself if only one argument is passed
- if ( length == 1 ) {
+ if ( length - i == 0 ) {
target = this;
i = 0;
}
for ( ; i < length; i++ )
// Only deal with non-null/undefined values
- if ( (options = arguments[ i ]) != null )
+ if ( (options = arguments[ i ]) != undefined )
// Extend the base object
- for ( var name in options ) {
+ for ( var name in options ) {
+ var src = target[name], copy = options[name];
+
// Prevent never-ending loop
- if ( target === options[ name ] )
+ if ( target === copy )
continue;
// Recurse if we're merging object values
- if ( deep && options[ name ] && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType )
- target[ name ] = jQuery.extend( deep, target[ name ], options[ name ] );
+ if ( deep && copy && typeof copy == "object" && src && !copy.nodeType )
+ target[ name ] = jQuery.extend( deep, src, copy );
// Don't bring in undefined values
- else if ( options[ name ] != undefined )
- target[ name ] = options[ name ];
+ else if ( copy != undefined )
+ target[ name ] = copy;
}
@@ -598,12 +589,12 @@
return target;
};
-var expando = "jQuery" + (new Date()).getTime(), uuid = 0, windowData = {};
+var expando = "jQuery" + (+new Date), uuid = 0, windowData = {},
// exclude the following css properties to add px
-var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
+ exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
// cache getComputedStyle
-var getComputedStyle = document.defaultView && document.defaultView.getComputedStyle;
+ getComputedStyle = document.defaultView && document.defaultView.getComputedStyle;
jQuery.extend({
noConflict: function( deep ) {
@@ -800,7 +791,8 @@
css: function( elem, name, force ) {
if ( name == "width" || name == "height" ) {
- var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
+ var val, props = { position: "absolute", visibility: "hidden", display:"block" },
+ which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
function getWH() {
val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
@@ -874,15 +866,15 @@
// If the element isn't reporting its values properly in Safari
// then some display: none elements are involved
else {
- var swap = [], stack = [];
+ var swap = [], stack = [], a, i;
// Locate all of the parent display: none elements
- for ( var a = elem; a && color(a); a = a.parentNode )
+ for ( a = elem; a && color(a); a = a.parentNode )
stack.unshift(a);
// Go through and make them visible, but in reverse
// (It would be better if we knew the exact display type that they had)
- for ( var i = 0; i < stack.length; i++ )
+ for ( i = 0; i < stack.length; i++ )
if ( color( stack[ i ] ) ) {
swap[ i ] = stack[ i ].style.display;
stack[ i ].style.display = "block";
@@ -890,13 +882,13 @@
// Since we flip the display style, we have to handle that
// one special, otherwise get the value
- ret = name == "display" && swap[ stack.length - 1 ] != null ?
+ ret = name == "display" && swap[ stack.length - 1 ] != undefined ?
"none" :
( computedStyle && computedStyle.getPropertyValue( name ) ) || "";
// Finally, revert the display styles back
- for ( var i = 0; i < swap.length; i++ )
- if ( swap[ i ] != null )
+ for ( i = 0; i < swap.length; i++ )
+ if ( swap[ i ] != undefined )
stack[ i ].style.display = swap[ i ];
}
@@ -946,7 +938,7 @@
return;
if ( elem.constructor == Number )
- elem = elem.toString();
+ elem += '';
// Convert html string into DOM nodes
if ( typeof elem == "string" ) {
@@ -958,7 +950,8 @@
});
// Trim whitespace, otherwise indexOf won't work as expected
- var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div");
+ var tags = jQuery.trim( elem ).toLowerCase(),
+ div = context.createElement("div");
var wrap =
// option or optgroup
@@ -1353,7 +1346,7 @@
// Get or set width or height on the element
size == undefined ?
// Get width or height on the element
- (this.length ? jQuery.css( this[0], type ) : null) :
+ (this.length ? jQuery.css( this[0], type ) : undefined) :
// Set the width or height on the element (default to pixels if value is unitless)
this.css( type, size.constructor == String ? size : size + "px" );
Index: event.js
===================================================================
--- event.js (revision 5317)
+++ event.js (working copy)
@@ -13,7 +13,7 @@
// For whatever reason, IE has trouble passing the window object
// around, causing it to be cloned in the process
- if ( jQuery.browser.msie && elem.setInterval != undefined )
+ if ( jQuery.browser.msie && elem.setInterval )
elem = window;
// Make sure that the function being executed has a unique ID
@@ -51,42 +51,42 @@
// event in IE.
handle.elem = elem;
- // Handle multiple events seperated by a space
- // jQuery(...).bind("mouseover mouseout", fn);
- jQuery.each(types.split(/\s+/), function(index, type) {
- // Namespaced event handlers
- var parts = type.split(".");
- type = parts[0];
- handler.type = parts[1];
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ jQuery.each(types.split(/\s+/), function(index, type) {
+ // Namespaced event handlers
+ var parts = type.split(".");
+ type = parts[0];
+ handler.type = parts[1];
- // Get the current list of functions bound to this event
- var handlers = events[type];
+ // Get the current list of functions bound to this event
+ var handlers = events[type];
- // Init the event handler queue
- if (!handlers) {
- handlers = events[type] = {};
-
- // Check for a special event handler
- // Only use addEventListener/attachEvent if the special
- // events handler returns false
- if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) {
- // Bind the global event handler to the element
- if (elem.addEventListener)
- elem.addEventListener(type, handle, false);
- else if (elem.attachEvent)
- elem.attachEvent("on" + type, handle);
- }
+ // Init the event handler queue
+ if (!handlers) {
+ handlers = events[type] = {};
+
+ // Check for a special event handler
+ // Only use addEventListener/attachEvent if the special
+ // events handler returns false
+ if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) {
+ // Bind the global event handler to the element
+ if (elem.addEventListener)
+ elem.addEventListener(type, handle, false);
+ else if (elem.attachEvent)
+ elem.attachEvent("on" + type, handle);
}
+ }
- // Add the function to the element's handler list
- handlers[handler.guid] = handler;
+ // Add the function to the element's handler list
+ handlers[handler.guid] = handler;
- // Keep track of which events have been used, for global triggering
- jQuery.event.global[type] = true;
- });
+ // Keep track of which events have been used, for global triggering
+ jQuery.event.global[type] = true;
+ });
// Nullify elem to prevent memory leaks in IE
- elem = null;
+ elem = undefined;
},
guid: 1,
@@ -140,7 +140,7 @@
else if (elem.detachEvent)
elem.detachEvent("on" + type, jQuery.data(elem, "handle"));
}
- ret = null;
+ ret = undefined;
delete events[type];
}
}
@@ -151,7 +151,7 @@
for ( ret in events ) break;
if ( !ret ) {
var handle = jQuery.data( elem, "handle" );
- if ( handle ) handle.elem = null;
+ if ( handle ) handle.elem = undefined;
jQuery.removeData( elem, "events" );
jQuery.removeData( elem, "handle" );
}
@@ -179,7 +179,7 @@
if ( elem.nodeType == 3 || elem.nodeType == 8 )
return undefined;
- var val, ret, fn = jQuery.isFunction( elem[ type ] || null ),
+ var val, ret, fn = jQuery.isFunction( elem[ type ] || undefined ),
// Check to see if we need to provide a fake event, or not
event = !data[0] || !data[0].preventDefault;
@@ -208,7 +208,7 @@
// Handle triggering of extra function
if ( extra && jQuery.isFunction( extra ) ) {
// call the extra function and tack the current return value on the end for possible inspection
- ret = extra.apply( elem, val == null ? data : data.concat( val ) );
+ ret = extra.apply( elem, val == undefined ? data : data.concat( val ) );
// if anything is returned, give it precedence and have it overwrite the previous value
if (ret !== undefined)
val = ret;
@@ -268,7 +268,7 @@
// Clean up added properties in IE to prevent memory leak
if (jQuery.browser.msie)
event.target = event.preventDefault = event.stopPropagation =
- event.handler = event.data = null;
+ event.handler = event.data = undefined;
return val;
},
@@ -297,7 +297,7 @@
};
// Fix timeStamp
- event.timeStamp = event.timeStamp || +new Date;
+ event.timeStamp = event.timeStamp || now();
// Fix target property, if necessary
if ( !event.target )
@@ -312,7 +312,7 @@
event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
// Calculate pageX/Y if missing and clientX/Y available
- if ( event.pageX == null && event.clientX != null ) {
+ if ( event.pageX == undefined && event.clientX != undefined ) {
var doc = document.documentElement, body = document.body;
event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0);
@@ -362,7 +362,7 @@
// If we actually just moused on to a sub-element, ignore it
if ( withinElement(event, this) ) return true;
// Execute the right handlers by setting the event type to mouseenter
- arguments[0].type = "mouseenter";
+ event.type = "mouseenter";
return jQuery.event.handle.apply(this, arguments);
}
},
@@ -384,7 +384,7 @@
// If we actually just moused on to a sub-element, ignore it
if ( withinElement(event, this) ) return true;
// Execute the right handlers by setting the event type to mouseleave
- arguments[0].type = "mouseleave";
+ event.type = "mouseleave";
return jQuery.event.handle.apply(this, arguments);
}
}
@@ -420,9 +420,7 @@
},
triggerHandler: function( type, data, fn ) {
- if ( this[0] )
- return jQuery.event.trigger( type, data, this[0], false, fn );
- return undefined;
+ return this[0] && jQuery.event.trigger( type, data, this[0], false, fn );
},
toggle: function() {
@@ -481,7 +479,7 @@
});
// Reset the list of functions
- jQuery.readyList = null;
+ jQuery.readyList = undefined;
}
// Trigger any bound ready events
Index: fx.js
===================================================================
--- fx.js (revision 5317)
+++ fx.js (working copy)
@@ -76,8 +76,9 @@
if ( this.nodeType != 1)
return false;
- var opt = jQuery.extend({}, optall);
- var hidden = jQuery(this).is(":hidden"), self = this;
+ var opt = jQuery.extend({}, optall),
+ hidden = jQuery(this).is(":hidden"),
+ self = this;
for ( var p in prop ) {
if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
@@ -92,7 +93,7 @@
}
}
- if ( opt.overflow != null )
+ if ( opt.overflow != undefined )
this.style.overflow = "hidden";
opt.curAnim = jQuery.extend({}, prop);
@@ -180,16 +181,14 @@
});
var queue = function( elem, type, array ) {
- if ( !elem )
- return undefined;
-
- type = type || "fx";
-
- var q = jQuery.data( elem, type + "queue" );
-
- if ( !q || array )
- q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) );
-
+ if ( elem ){
+ type = type || "fx";
+
+ var q = jQuery.data( elem, type + "queue" );
+
+ if ( !q || array )
+ q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) );
+ }
return q;
};
@@ -242,7 +241,7 @@
},
timers: [],
- timerId: null,
+ timerId: undefined,
fx: function( elem, options, prop ){
this.options = options;
@@ -271,7 +270,7 @@
// Get the current size
cur: function(force){
- if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
+ if ( this.elem[this.prop] != undefined && this.elem.style[this.prop] == undefined )
return this.elem[ this.prop ];
var r = parseFloat(jQuery.css(this.elem, this.prop, force));
@@ -280,7 +279,7 @@
// Start an animation from one number to another
custom: function(from, to, unit){
- this.startTime = (new Date()).getTime();
+ this.startTime = now();
this.start = from;
this.end = to;
this.unit = unit || this.unit || "px";
@@ -297,7 +296,7 @@
jQuery.timers.push(t);
- if ( jQuery.timerId == null ) {
+ if ( jQuery.timerId == undefined ) {
jQuery.timerId = setInterval(function(){
var timers = jQuery.timers;
@@ -307,7 +306,7 @@
if ( !timers.length ) {
clearInterval( jQuery.timerId );
- jQuery.timerId = null;
+ jQuery.timerId = undefined;
}
}, 13);
}
@@ -343,7 +342,7 @@
// Each step of an animation
step: function(gotoEnd){
- var t = (new Date()).getTime();
+ var t = now();
if ( gotoEnd || t > this.options.duration + this.startTime ) {
this.now = this.end;
@@ -358,7 +357,7 @@
done = false;
if ( done ) {
- if ( this.options.display != null ) {
+ if ( this.options.display != undefined ) {
// Reset the overflow
this.elem.style.overflow = this.options.overflow;
@@ -401,20 +400,26 @@
};
-jQuery.fx.step = {
- scrollLeft: function(fx){
- fx.elem.scrollLeft = fx.now;
+jQuery.extend( jQuery.fx, {
+ speeds: {
+ slow: 600,
+ fast: 200
},
-
- scrollTop: function(fx){
- fx.elem.scrollTop = fx.now;
- },
-
- opacity: function(fx){
- jQuery.attr(fx.elem.style, "opacity", fx.now);
- },
-
- _default: function(fx){
- fx.elem.style[ fx.prop ] = fx.now + fx.unit;
+ step: {
+ scrollLeft: function(fx){
+ fx.elem.scrollLeft = fx.now;
+ },
+
+ scrollTop: function(fx){
+ fx.elem.scrollTop = fx.now;
+ },
+
+ opacity: function(fx){
+ jQuery.attr(fx.elem.style, "opacity", fx.now);
+ },
+
+ _default: function(fx){
+ fx.elem.style[ fx.prop ] = fx.now + fx.unit;
+ }
}
-};
+});
\ No newline at end of file
Index: selector.js
===================================================================
--- selector.js (revision 5317)
+++ selector.js (working copy)
@@ -118,8 +118,8 @@
// An attempt at speeding up child selectors that
// point to a specific element tag
- var re = quickChild;
- var m = re.exec(t);
+ var re = quickChild,
+ m = re.exec(t);
if ( m ) {
nodeName = m[1].toUpperCase();
@@ -137,7 +137,7 @@
} else {
re = /^([>+~])\s*(\w*)/i;
- if ( (m = re.exec(t)) != null ) {
+ if ( (m = re.exec(t)) != undefined ) {
r = [];
var merge = {};
@@ -188,8 +188,8 @@
} else {
// Optimize for the case nodeName#idName
- var re2 = quickID;
- var m = re2.exec(t);
+ var re2 = quickID,
+ m = re2.exec(t);
// Re-organize the results, so that they're consistent
if ( m ) {
@@ -336,7 +336,7 @@
for ( var i = 0, rl = r.length; i < rl; i++ ) {
var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ];
- if ( z == null || /href|src|selected/.test(m[2]) )
+ if ( z == undefined || /href|src|selected/.test(m[2]) )
z = jQuery.attr(a,m[2]) || '';
if ( (type == "" && !!z ||
@@ -410,8 +410,8 @@
},
dir: function( elem, dir ){
- var matched = [];
- var cur = elem[dir];
+ var matched = [],
+ cur = elem[dir];
while ( cur && cur != document ) {
if ( cur.nodeType == 1 )
matched.push( cur );
Download in other formats:
Original Format
File potpourri.diff, 22.5 KB (added by flesler, April 25, 2008 03:15AM UTC)
Index: ajax.js
===================================================================
--- ajax.js (revision 5317)
+++ ajax.js (working copy)
@@ -20,7 +20,7 @@
if ( jQuery.isFunction( params ) ) {
// We assume that it's the callback
callback = params;
- params = null;
+ params = undefined;
// Otherwise, build a param string
} else {
@@ -74,7 +74,7 @@
})
.map(function(i, elem){
var val = jQuery(this).val();
- return val == null ? null :
+ return val == undefined ? undefined :
val.constructor == Array ?
jQuery.map( val, function(val, i){
return {name: elem.name, value: val};
@@ -98,7 +98,7 @@
// shift arguments if data argument was ommited
if ( jQuery.isFunction( data ) ) {
callback = data;
- data = null;
+ data = undefined;
}
return jQuery.ajax({
@@ -111,7 +111,7 @@
},
getScript: function( url, callback ) {
- return jQuery.get(url, null, callback, "script");
+ return jQuery.get(url, undefined, callback, "script");
},
getJSON: function( url, data, callback ) {
@@ -144,9 +144,9 @@
contentType: "application/x-www-form-urlencoded",
processData: true,
async: true,
- data: null,
- username: null,
- password: null,
+ data: undefined,
+ username: undefined,
+ password: undefined,
accepts: {
xml: "application/xml, text/xml",
html: "text/html",
@@ -207,7 +207,7 @@
};
}
- if ( s.dataType == "script" && s.cache == null )
+ if ( s.dataType == "script" && s.cache == undefined )
s.cache = false;
if ( s.cache === false && s.type.toLowerCase() == "get" ) {
@@ -223,7 +223,7 @@
s.url += (s.url.match(/\?/) ? "&" : "?") + s.data;
// IE likes to send both get and post data, prevent this
- s.data = null;
+ s.data = undefined;
}
// Watch for a new set of requests
@@ -311,7 +311,7 @@
// clear poll interval
if (ival) {
clearInterval(ival);
- ival = null;
+ ival = undefined;
}
status = isTimeout == "timeout" && "timeout" ||
@@ -351,7 +351,7 @@
// Stop memory leaks
if ( s.async )
- xml = null;
+ xml = undefined;
}
};
@@ -377,7 +377,7 @@
try {
xml.send(s.data);
} catch(e) {
- jQuery.handleError(s, xml, null, e);
+ jQuery.handleError(s, xml, undefined, e);
}
// firefox 1.5 doesn't fire statechange for sync requests
@@ -448,9 +448,9 @@
},
httpData: function( r, type ) {
- var ct = r.getResponseHeader("content-type");
- var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0;
- var data = xml ? r.responseXML : r.responseText;
+ var ct = r.getResponseHeader("content-type"),
+ xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
+ data = xml ? r.responseXML : r.responseText;
if ( xml && data.documentElement.tagName == "parsererror" )
throw "parsererror";
Index: core.js
===================================================================
--- core.js (revision 5317)
+++ core.js (working copy)
@@ -10,27 +10,26 @@
*/
// Map over jQuery in case of overwrite
-if ( window.jQuery )
- var _jQuery = window.jQuery;
+var _jQuery = this.jQuery,
-var jQuery = window.jQuery = function( selector, context ) {
- // The jQuery object is actually just the init constructor 'enhanced'
- return new jQuery.prototype.init( selector, context );
-};
-
// Map over the $ in case of overwrite
-if ( window.$ )
- var _$ = window.$;
+ _$ = this.$,
-// Map the jQuery namespace to the '$' one
-window.$ = jQuery;
+//- when munging variables, every undefined turns into one-letter name.
+//- faster lookups: http://snurl.com/25pcd
+ undefined;
+var jQuery = this.jQuery = this.$ = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context );
+};
+
// A simple way to check for HTML strings or ID strings
// (both of which we optimize for)
-var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;
+var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,
// Is it a simple selector
-var isSimple = /^.[^:#\[\.]*$/;
+ isSimple = /^.[^:#\[\.]*$/;
jQuery.fn = jQuery.prototype = {
init: function( selector, context ) {
@@ -148,15 +147,7 @@
// Determine the position of an element within
// the matched set of elements
index: function( elem ) {
- var ret = -1;
-
- // Locate the position of the desired element
- this.each(function(i){
- if ( this == elem )
- ret = i;
- });
-
- return ret;
+ return jQuery.inArray( elem, this );
},
attr: function( name, value, type ) {
@@ -193,7 +184,7 @@
},
text: function( text ) {
- if ( typeof text != "object" && text != null )
+ if ( typeof text != "object" && text != undefined )
return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
var ret = "";
@@ -306,7 +297,7 @@
// this is primarily for IE but the data expando shouldn't be copied over in any browser
var clone = ret.find("*").andSelf().each(function(){
if ( this[ expando ] != undefined )
- this[ expando ] = null;
+ this[ expando ] = undefined;
});
// Copy the events from the original to the clone
@@ -359,9 +350,7 @@
},
is: function( selector ) {
- return selector ?
- jQuery.multiFilter( selector, this ).length > 0 :
- false;
+ return !!selector && jQuery.multiFilter( selector, this ).length > 0 ;
},
hasClass: function( selector ) {
@@ -383,7 +372,7 @@
// Nothing was selected
if ( index < 0 )
- return null;
+ return undefined;
// Loop through all the selected options
for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
@@ -410,7 +399,7 @@
}
- return undefined;
+ return;
}
return this.each(function(){
@@ -443,7 +432,7 @@
return value == undefined ?
(this.length ?
this[0].innerHTML :
- null) :
+ undefined) :
this.empty().append( value );
},
@@ -473,13 +462,13 @@
var parts = key.split(".");
parts[1] = parts[1] ? "." + parts[1] : "";
- if ( value == null ) {
+ if ( value == undefined ) {
var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
if ( data == undefined && this.length )
data = jQuery.data( this[0], key );
- return data == null && parts[1] ?
+ return data == undefined && parts[1] ?
this.data( parts[0] ) :
data;
} else
@@ -536,7 +525,7 @@
};
// Give the init function the jQuery prototype for later instantiation
-jQuery.prototype.init.prototype = jQuery.prototype;
+jQuery.fn.init.prototype = jQuery.fn;
function evalScript( i, elem ) {
if ( elem.src )
@@ -570,27 +559,29 @@
target = {};
// extend jQuery itself if only one argument is passed
- if ( length == 1 ) {
+ if ( length - i == 0 ) {
target = this;
i = 0;
}
for ( ; i < length; i++ )
// Only deal with non-null/undefined values
- if ( (options = arguments[ i ]) != null )
+ if ( (options = arguments[ i ]) != undefined )
// Extend the base object
- for ( var name in options ) {
+ for ( var name in options ) {
+ var src = target[name], copy = options[name];
+
// Prevent never-ending loop
- if ( target === options[ name ] )
+ if ( target === copy )
continue;
// Recurse if we're merging object values
- if ( deep && options[ name ] && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType )
- target[ name ] = jQuery.extend( deep, target[ name ], options[ name ] );
+ if ( deep && copy && typeof copy == "object" && src && !copy.nodeType )
+ target[ name ] = jQuery.extend( deep, src, copy );
// Don't bring in undefined values
- else if ( options[ name ] != undefined )
- target[ name ] = options[ name ];
+ else if ( copy != undefined )
+ target[ name ] = copy;
}
@@ -598,12 +589,12 @@
return target;
};
-var expando = "jQuery" + (new Date()).getTime(), uuid = 0, windowData = {};
+var expando = "jQuery" + (+new Date), uuid = 0, windowData = {},
// exclude the following css properties to add px
-var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
+ exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
// cache getComputedStyle
-var getComputedStyle = document.defaultView && document.defaultView.getComputedStyle;
+ getComputedStyle = document.defaultView && document.defaultView.getComputedStyle;
jQuery.extend({
noConflict: function( deep ) {
@@ -800,7 +791,8 @@
css: function( elem, name, force ) {
if ( name == "width" || name == "height" ) {
- var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
+ var val, props = { position: "absolute", visibility: "hidden", display:"block" },
+ which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
function getWH() {
val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
@@ -874,15 +866,15 @@
// If the element isn't reporting its values properly in Safari
// then some display: none elements are involved
else {
- var swap = [], stack = [];
+ var swap = [], stack = [], a, i;
// Locate all of the parent display: none elements
- for ( var a = elem; a && color(a); a = a.parentNode )
+ for ( a = elem; a && color(a); a = a.parentNode )
stack.unshift(a);
// Go through and make them visible, but in reverse
// (It would be better if we knew the exact display type that they had)
- for ( var i = 0; i < stack.length; i++ )
+ for ( i = 0; i < stack.length; i++ )
if ( color( stack[ i ] ) ) {
swap[ i ] = stack[ i ].style.display;
stack[ i ].style.display = "block";
@@ -890,13 +882,13 @@
// Since we flip the display style, we have to handle that
// one special, otherwise get the value
- ret = name == "display" && swap[ stack.length - 1 ] != null ?
+ ret = name == "display" && swap[ stack.length - 1 ] != undefined ?
"none" :
( computedStyle && computedStyle.getPropertyValue( name ) ) || "";
// Finally, revert the display styles back
- for ( var i = 0; i < swap.length; i++ )
- if ( swap[ i ] != null )
+ for ( i = 0; i < swap.length; i++ )
+ if ( swap[ i ] != undefined )
stack[ i ].style.display = swap[ i ];
}
@@ -946,7 +938,7 @@
return;
if ( elem.constructor == Number )
- elem = elem.toString();
+ elem += '';
// Convert html string into DOM nodes
if ( typeof elem == "string" ) {
@@ -958,7 +950,8 @@
});
// Trim whitespace, otherwise indexOf won't work as expected
- var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div");
+ var tags = jQuery.trim( elem ).toLowerCase(),
+ div = context.createElement("div");
var wrap =
// option or optgroup
@@ -1353,7 +1346,7 @@
// Get or set width or height on the element
size == undefined ?
// Get width or height on the element
- (this.length ? jQuery.css( this[0], type ) : null) :
+ (this.length ? jQuery.css( this[0], type ) : undefined) :
// Set the width or height on the element (default to pixels if value is unitless)
this.css( type, size.constructor == String ? size : size + "px" );
Index: event.js
===================================================================
--- event.js (revision 5317)
+++ event.js (working copy)
@@ -13,7 +13,7 @@
// For whatever reason, IE has trouble passing the window object
// around, causing it to be cloned in the process
- if ( jQuery.browser.msie && elem.setInterval != undefined )
+ if ( jQuery.browser.msie && elem.setInterval )
elem = window;
// Make sure that the function being executed has a unique ID
@@ -51,42 +51,42 @@
// event in IE.
handle.elem = elem;
- // Handle multiple events seperated by a space
- // jQuery(...).bind("mouseover mouseout", fn);
- jQuery.each(types.split(/\s+/), function(index, type) {
- // Namespaced event handlers
- var parts = type.split(".");
- type = parts[0];
- handler.type = parts[1];
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ jQuery.each(types.split(/\s+/), function(index, type) {
+ // Namespaced event handlers
+ var parts = type.split(".");
+ type = parts[0];
+ handler.type = parts[1];
- // Get the current list of functions bound to this event
- var handlers = events[type];
+ // Get the current list of functions bound to this event
+ var handlers = events[type];
- // Init the event handler queue
- if (!handlers) {
- handlers = events[type] = {};
-
- // Check for a special event handler
- // Only use addEventListener/attachEvent if the special
- // events handler returns false
- if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) {
- // Bind the global event handler to the element
- if (elem.addEventListener)
- elem.addEventListener(type, handle, false);
- else if (elem.attachEvent)
- elem.attachEvent("on" + type, handle);
- }
+ // Init the event handler queue
+ if (!handlers) {
+ handlers = events[type] = {};
+
+ // Check for a special event handler
+ // Only use addEventListener/attachEvent if the special
+ // events handler returns false
+ if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) {
+ // Bind the global event handler to the element
+ if (elem.addEventListener)
+ elem.addEventListener(type, handle, false);
+ else if (elem.attachEvent)
+ elem.attachEvent("on" + type, handle);
}
+ }
- // Add the function to the element's handler list
- handlers[handler.guid] = handler;
+ // Add the function to the element's handler list
+ handlers[handler.guid] = handler;
- // Keep track of which events have been used, for global triggering
- jQuery.event.global[type] = true;
- });
+ // Keep track of which events have been used, for global triggering
+ jQuery.event.global[type] = true;
+ });
// Nullify elem to prevent memory leaks in IE
- elem = null;
+ elem = undefined;
},
guid: 1,
@@ -140,7 +140,7 @@
else if (elem.detachEvent)
elem.detachEvent("on" + type, jQuery.data(elem, "handle"));
}
- ret = null;
+ ret = undefined;
delete events[type];
}
}
@@ -151,7 +151,7 @@
for ( ret in events ) break;
if ( !ret ) {
var handle = jQuery.data( elem, "handle" );
- if ( handle ) handle.elem = null;
+ if ( handle ) handle.elem = undefined;
jQuery.removeData( elem, "events" );
jQuery.removeData( elem, "handle" );
}
@@ -179,7 +179,7 @@
if ( elem.nodeType == 3 || elem.nodeType == 8 )
return undefined;
- var val, ret, fn = jQuery.isFunction( elem[ type ] || null ),
+ var val, ret, fn = jQuery.isFunction( elem[ type ] || undefined ),
// Check to see if we need to provide a fake event, or not
event = !data[0] || !data[0].preventDefault;
@@ -208,7 +208,7 @@
// Handle triggering of extra function
if ( extra && jQuery.isFunction( extra ) ) {
// call the extra function and tack the current return value on the end for possible inspection
- ret = extra.apply( elem, val == null ? data : data.concat( val ) );
+ ret = extra.apply( elem, val == undefined ? data : data.concat( val ) );
// if anything is returned, give it precedence and have it overwrite the previous value
if (ret !== undefined)
val = ret;
@@ -268,7 +268,7 @@
// Clean up added properties in IE to prevent memory leak
if (jQuery.browser.msie)
event.target = event.preventDefault = event.stopPropagation =
- event.handler = event.data = null;
+ event.handler = event.data = undefined;
return val;
},
@@ -297,7 +297,7 @@
};
// Fix timeStamp
- event.timeStamp = event.timeStamp || +new Date;
+ event.timeStamp = event.timeStamp || now();
// Fix target property, if necessary
if ( !event.target )
@@ -312,7 +312,7 @@
event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
// Calculate pageX/Y if missing and clientX/Y available
- if ( event.pageX == null && event.clientX != null ) {
+ if ( event.pageX == undefined && event.clientX != undefined ) {
var doc = document.documentElement, body = document.body;
event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0);
@@ -362,7 +362,7 @@
// If we actually just moused on to a sub-element, ignore it
if ( withinElement(event, this) ) return true;
// Execute the right handlers by setting the event type to mouseenter
- arguments[0].type = "mouseenter";
+ event.type = "mouseenter";
return jQuery.event.handle.apply(this, arguments);
}
},
@@ -384,7 +384,7 @@
// If we actually just moused on to a sub-element, ignore it
if ( withinElement(event, this) ) return true;
// Execute the right handlers by setting the event type to mouseleave
- arguments[0].type = "mouseleave";
+ event.type = "mouseleave";
return jQuery.event.handle.apply(this, arguments);
}
}
@@ -420,9 +420,7 @@
},
triggerHandler: function( type, data, fn ) {
- if ( this[0] )
- return jQuery.event.trigger( type, data, this[0], false, fn );
- return undefined;
+ return this[0] && jQuery.event.trigger( type, data, this[0], false, fn );
},
toggle: function() {
@@ -481,7 +479,7 @@
});
// Reset the list of functions
- jQuery.readyList = null;
+ jQuery.readyList = undefined;
}
// Trigger any bound ready events
Index: fx.js
===================================================================
--- fx.js (revision 5317)
+++ fx.js (working copy)
@@ -76,8 +76,9 @@
if ( this.nodeType != 1)
return false;
- var opt = jQuery.extend({}, optall);
- var hidden = jQuery(this).is(":hidden"), self = this;
+ var opt = jQuery.extend({}, optall),
+ hidden = jQuery(this).is(":hidden"),
+ self = this;
for ( var p in prop ) {
if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
@@ -92,7 +93,7 @@
}
}
- if ( opt.overflow != null )
+ if ( opt.overflow != undefined )
this.style.overflow = "hidden";
opt.curAnim = jQuery.extend({}, prop);
@@ -180,16 +181,14 @@
});
var queue = function( elem, type, array ) {
- if ( !elem )
- return undefined;
-
- type = type || "fx";
-
- var q = jQuery.data( elem, type + "queue" );
-
- if ( !q || array )
- q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) );
-
+ if ( elem ){
+ type = type || "fx";
+
+ var q = jQuery.data( elem, type + "queue" );
+
+ if ( !q || array )
+ q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) );
+ }
return q;
};
@@ -242,7 +241,7 @@
},
timers: [],
- timerId: null,
+ timerId: undefined,
fx: function( elem, options, prop ){
this.options = options;
@@ -271,7 +270,7 @@
// Get the current size
cur: function(force){
- if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
+ if ( this.elem[this.prop] != undefined && this.elem.style[this.prop] == undefined )
return this.elem[ this.prop ];
var r = parseFloat(jQuery.css(this.elem, this.prop, force));
@@ -280,7 +279,7 @@
// Start an animation from one number to another
custom: function(from, to, unit){
- this.startTime = (new Date()).getTime();
+ this.startTime = now();
this.start = from;
this.end = to;
this.unit = unit || this.unit || "px";
@@ -297,7 +296,7 @@
jQuery.timers.push(t);
- if ( jQuery.timerId == null ) {
+ if ( jQuery.timerId == undefined ) {
jQuery.timerId = setInterval(function(){
var timers = jQuery.timers;
@@ -307,7 +306,7 @@
if ( !timers.length ) {
clearInterval( jQuery.timerId );
- jQuery.timerId = null;
+ jQuery.timerId = undefined;
}
}, 13);
}
@@ -343,7 +342,7 @@
// Each step of an animation
step: function(gotoEnd){
- var t = (new Date()).getTime();
+ var t = now();
if ( gotoEnd || t > this.options.duration + this.startTime ) {
this.now = this.end;
@@ -358,7 +357,7 @@
done = false;
if ( done ) {
- if ( this.options.display != null ) {
+ if ( this.options.display != undefined ) {
// Reset the overflow
this.elem.style.overflow = this.options.overflow;
@@ -401,20 +400,26 @@
};
-jQuery.fx.step = {
- scrollLeft: function(fx){
- fx.elem.scrollLeft = fx.now;
+jQuery.extend( jQuery.fx, {
+ speeds: {
+ slow: 600,
+ fast: 200
},
-
- scrollTop: function(fx){
- fx.elem.scrollTop = fx.now;
- },
-
- opacity: function(fx){
- jQuery.attr(fx.elem.style, "opacity", fx.now);
- },
-
- _default: function(fx){
- fx.elem.style[ fx.prop ] = fx.now + fx.unit;
+ step: {
+ scrollLeft: function(fx){
+ fx.elem.scrollLeft = fx.now;
+ },
+
+ scrollTop: function(fx){
+ fx.elem.scrollTop = fx.now;
+ },
+
+ opacity: function(fx){
+ jQuery.attr(fx.elem.style, "opacity", fx.now);
+ },
+
+ _default: function(fx){
+ fx.elem.style[ fx.prop ] = fx.now + fx.unit;
+ }
}
-};
+});
\ No newline at end of file
Index: selector.js
===================================================================
--- selector.js (revision 5317)
+++ selector.js (working copy)
@@ -118,8 +118,8 @@
// An attempt at speeding up child selectors that
// point to a specific element tag
- var re = quickChild;
- var m = re.exec(t);
+ var re = quickChild,
+ m = re.exec(t);
if ( m ) {
nodeName = m[1].toUpperCase();
@@ -137,7 +137,7 @@
} else {
re = /^([>+~])\s*(\w*)/i;
- if ( (m = re.exec(t)) != null ) {
+ if ( (m = re.exec(t)) != undefined ) {
r = [];
var merge = {};
@@ -188,8 +188,8 @@
} else {
// Optimize for the case nodeName#idName
- var re2 = quickID;
- var m = re2.exec(t);
+ var re2 = quickID,
+ m = re2.exec(t);
// Re-organize the results, so that they're consistent
if ( m ) {
@@ -336,7 +336,7 @@
for ( var i = 0, rl = r.length; i < rl; i++ ) {
var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ];
- if ( z == null || /href|src|selected/.test(m[2]) )
+ if ( z == undefined || /href|src|selected/.test(m[2]) )
z = jQuery.attr(a,m[2]) || '';
if ( (type == "" && !!z ||
@@ -410,8 +410,8 @@
},
dir: function( elem, dir ){
- var matched = [];
- var cur = elem[dir];
+ var matched = [],
+ cur = elem[dir];
while ( cur && cur != document ) {
if ( cur.nodeType == 1 )
matched.push( cur );