Skip to content
Permalink
Browse files

Merge branch 'master' of github.com:jquery/jquery

  • Loading branch information
jeresig committed Nov 29, 2009
2 parents e00be67 + 255068d commit 2b7c38f80cf171ce830cd198ed2916a2c258a3cb
Showing with 152 additions and 124 deletions.
  1. +10 −10 src/ajax.js
  2. +34 −30 src/attributes.js
  3. +1 −1 src/css.js
  4. +17 −15 src/data.js
  5. +1 −1 src/dimensions.js
  6. +24 −20 src/event.js
  7. +57 −42 src/fx.js
  8. +8 −5 src/traversing.js
@@ -604,19 +604,19 @@ jQuery.extend({

// If an array was passed in, assume that it is an array
// of form elements
if ( jQuery.isArray(a) || a.jquery )
if ( jQuery.isArray(a) || a.jquery ) {
// Serialize the form elements
jQuery.each( a, function() {
add( this.name, this.value );
});

else
} else {
// Encode parameters from object, recursively. If
// jQuery.param.traditional is set, encode the "old" way
// (the way 1.3.2 or older did it)
jQuery.each( a, function buildParams( prefix, obj ) {

if ( jQuery.isArray(obj) )
if ( jQuery.isArray(obj) ) {
jQuery.each( obj, function(i,v){
// Due to rails' limited request param syntax, numeric array
// indices are not supported. To avoid serialization ambiguity
@@ -626,20 +626,20 @@ jQuery.extend({
add( prefix + ( param_traditional ? "" : "[]" ), v );
});

else if ( typeof obj == "object" )
if ( param_traditional )
} else if ( typeof obj == "object" ) {
if ( param_traditional ) {
add( prefix, obj );

else
} else {
jQuery.each( obj, function(k,v){
buildParams( prefix ? prefix + "[" + k + "]" : k, v );
});

else
}
} else {
add( prefix, obj );

}
});

}
// Return the resulting serialization
return s.join("&").replace(r20, "+");
}
@@ -68,9 +68,9 @@ jQuery.fn.extend({
var elem = this[0];

if ( elem ) {
if( jQuery.nodeName( elem, 'option' ) )
if( jQuery.nodeName( elem, 'option' ) ) {
return (elem.attributes.value || {}).specified ? elem.value : elem.text;

}
// We need to handle select boxes special
if ( jQuery.nodeName( elem, "select" ) ) {
var index = elem.selectedIndex,
@@ -79,9 +79,9 @@ jQuery.fn.extend({
one = elem.type == "select-one";

// Nothing was selected
if ( index < 0 )
if ( index < 0 ) {
return null;

}
// Loop through all the selected options
for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
var option = options[ i ];
@@ -91,9 +91,9 @@ jQuery.fn.extend({
value = jQuery(option).val();

// We don't need an array for one selects
if ( one )
if ( one ) {
return value;

}
// Multi-Selects return an array
values.push( value );
}
@@ -111,46 +111,50 @@ jQuery.fn.extend({
}

// Typecast once if the value is a number
if ( typeof value === "number" )
if ( typeof value === "number" ) {
value += '';

}
var val = value;

return this.each(function(){
if(jQuery.isFunction(value)) {
val = value.call(this);
// Typecast each time if the value is a Function and the appended
// value is therefore different each time.
if( typeof val === "number" ) val += '';
if( typeof val === "number" ) {
val += '';
}
}

if ( this.nodeType != 1 )
if ( this.nodeType != 1 ) {
return;

if ( jQuery.isArray(val) && /radio|checkbox/.test( this.type ) )
}
if ( jQuery.isArray(val) && /radio|checkbox/.test( this.type ) ) {
this.checked = jQuery.inArray(this.value || this.name, val) >= 0;

}
else if ( jQuery.nodeName( this, "select" ) ) {
var values = jQuery.makeArray(val);

jQuery( "option", this ).each(function(){
this.selected = jQuery.inArray( this.value || this.text, values ) >= 0;
});

if ( !values.length )
if ( !values.length ) {
this.selectedIndex = -1;

} else
}
} else {
this.value = val;
}
});
}
});

jQuery.each({
removeAttr: function( name ) {
jQuery.attr( this, name, "" );
if (this.nodeType == 1)
if (this.nodeType == 1) {
this.removeAttribute( name );
}
},

toggleClass: function( classNames, state ) {
@@ -182,9 +186,9 @@ jQuery.each({
jQuery.extend({
attr: function( elem, name, value ) {
// don't set attributes on text and comment nodes
if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
if (!elem || elem.nodeType == 3 || elem.nodeType == 8) {
return undefined;

}
if ( name in jQuery.fn && name !== "attr" ) {
return jQuery(elem)[name](value);
}
@@ -204,23 +208,23 @@ jQuery.extend({

// Safari mis-reports the default selected property of a hidden option
// Accessing the parent's selectedIndex property fixes it
if ( name == "selected" && elem.parentNode )
if ( name == "selected" && elem.parentNode ) {
elem.parentNode.selectedIndex;

}
// If applicable, access the attribute via the DOM 0 way
if ( name in elem && notxml && !special ) {
if ( set ){
if ( set ) {
// We can't allow the type property to be changed (since it causes problems in IE)
if ( name == "type" && /(button|input)/i.test(elem.nodeName) && elem.parentNode )
if ( name == "type" && /(button|input)/i.test(elem.nodeName) && elem.parentNode ) {
throw "type property can't be changed";

}
elem[ name ] = value;
}

// browsers index elements by id/name on forms, give priority to attributes.
if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) )
if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
return elem.getAttributeNode( name ).nodeValue;

}
// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
if ( name == "tabIndex" ) {
@@ -238,16 +242,16 @@ jQuery.extend({
}

if ( !jQuery.support.style && notxml && name == "style" ) {
if ( set )
if ( set ) {
elem.style.cssText = "" + value;

}
return elem.style.cssText;
}

if ( set )
if ( set ) {
// convert the value to a string (all browsers do this but IE) see #1070
elem.setAttribute( name, "" + value );

}
var attr = !jQuery.support.hrefNormalized && notxml && special
// Some attributes require a special call on IE
? elem.getAttribute( name, 2 )
@@ -53,7 +53,7 @@ jQuery.extend({

// Set the alpha filter to set the opacity
style.filter = (style.filter || "").replace( ralpha, "" ) +
(parseInt( value ) + '' === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
(parseInt( value, 10 ) + '' === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
}

return style.filter && style.filter.indexOf("opacity=") >= 0 ?
@@ -80,19 +80,19 @@ jQuery.extend({
},

queue: function( elem, type, data ) {
if( !elem ) return;
if ( !elem ) { return; }

type = (type || "fx") + "queue";
var q = jQuery.data( elem, type );

// Speed up dequeue by getting out quickly if this is just a lookup
if( !data ) return q || [];
if ( !data ) { return q || []; }

if ( !q || jQuery.isArray(data) )
if ( !q || jQuery.isArray(data) ) {
q = jQuery.data( elem, type, jQuery.makeArray(data) );
else
} else {
q.push( data );

}
return q;
},

@@ -102,12 +102,12 @@ jQuery.extend({
var queue = jQuery.queue( elem, type ), fn = queue.shift();

// If the fx queue is dequeued, always remove the progress sentinel
if( fn === "inprogress" ) fn = queue.shift();
if ( fn === "inprogress" ) { fn = queue.shift(); }

if( fn ) {
if ( fn ) {
// Add a progress sentinel to prevent the fx queue from being
// automatically dequeued
if( type == "fx" ) queue.unshift("inprogress");
if ( type == "fx" ) { queue.unshift("inprogress"); }

fn.call(elem, function() { jQuery.dequeue(elem, type); });
}
@@ -126,16 +126,17 @@ jQuery.fn.extend({
if ( value === undefined ) {
var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);

if ( data === undefined && this.length )
if ( data === undefined && this.length ) {
data = jQuery.data( this[0], key );

}
return data === undefined && parts[1] ?
this.data( parts[0] ) :
data;
} else
} else {
return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
jQuery.data( this, key, value );
});
}
},

removeData: function( key ){
@@ -149,14 +150,15 @@ jQuery.fn.extend({
type = "fx";
}

if ( data === undefined )
if ( data === undefined ) {
return jQuery.queue( this[0], type );

}
return this.each(function(i, elem){
var queue = jQuery.queue( this, type, data );

if( type == "fx" && queue[0] !== "inprogress" )
jQuery.dequeue( this, type )
if ( type == "fx" && queue[0] !== "inprogress" ) {
jQuery.dequeue( this, type );
}
});
},
dequeue: function(type){
@@ -20,7 +20,7 @@ jQuery.each([ "Height", "Width" ], function(i, name){
jQuery.fn[ type ] = function( size ) {
// Get window width or height
var elem = this[0];
if ( !elem ) return null;
if ( !elem ) { return null; }
return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window?
// Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
@@ -592,16 +592,18 @@ jQuery.each({

event.special[orig] = {
setup:function() {
if ( this.addEventListener )
if ( this.addEventListener ) {
this.addEventListener( orig, handle, true );
else
} else {
event.add( this, fix, ieHandler );
}
},
teardown:function() {
if ( this.removeEventListener )
if ( this.removeEventListener ) {
this.removeEventListener( orig, handle, true );
else
} else {
event.remove( this, fix, ieHandler );
}
}
};
});
@@ -820,7 +822,7 @@ jQuery.extend({
var readyBound = false;

function bindReady() {
if ( readyBound ) return;
if ( readyBound ) { return; }
readyBound = true;

// Catch cases where $(document).ready() is called after the
@@ -857,23 +859,25 @@ function bindReady() {
toplevel = window.frameElement == null;
} catch(e){}

if ( document.documentElement.doScroll && toplevel ) (function() {
if ( jQuery.isReady ) {
return;
}
if ( document.documentElement.doScroll && toplevel ) {
(function() {
if ( jQuery.isReady ) {
return;
}

try {
// If IE is used, use the trick by Diego Perini
// http://javascript.nwbox.com/IEContentLoaded/
document.documentElement.doScroll("left");
} catch( error ) {
setTimeout( arguments.callee, 0 );
return;
}
try {
// If IE is used, use the trick by Diego Perini
// http://javascript.nwbox.com/IEContentLoaded/
document.documentElement.doScroll("left");
} catch( error ) {
setTimeout( arguments.callee, 0 );
return;
}

// and execute any waiting functions
jQuery.ready();
})();
// and execute any waiting functions
jQuery.ready();
})();
}
}

// A fallback to window.onload, that will always work

0 comments on commit 2b7c38f

Please sign in to comment.
You can’t perform that action at this time.