// 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
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, "+");
}
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,
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 ];
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 );
}
}
// Typecast once if the value is a number
- if ( typeof value === "number" )
+ if ( typeof value === "number" ) {
value += '';
-
+ }
var val = value;
return this.each(function(){
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);
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 ) {
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);
}
// 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" ) {
}
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 )
},
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;
},
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); });
}
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 ){
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){
return this.each(function(){
- jQuery.dequeue( this, type );
+ jQuery.dequeue( this, type )
});
},
clearQueue: function(type){
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 ] ||
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 );
+ }
}
};
});
var readyBound = false;
function bindReady() {
- if ( readyBound ) return;
+ if ( readyBound ) { return; }
readyBound = true;
// Catch cases where $(document).ready() is called after the
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
var elem = jQuery("<" + nodeName + " />").appendTo("body");
display = elem.css("display");
- if ( display === "none" )
+ if ( display === "none" ) {
display = "block";
-
+ }
elem.remove();
elemdisplay[ nodeName ] = display;
} else {
for ( var i = 0, l = this.length; i < l; i++ ){
var old = jQuery.data(this[i], "olddisplay");
- if ( !old && old !== "none" )
+ if ( !old && old !== "none" ){
jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
+ }
}
// Set the display of the elements in a second loop
p = name;
}
- if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
+ if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) {
return opt.complete.call(this);
-
+ }
if ( ( p == "height" || p == "width" ) && this.style ) {
// Store display property
opt.display = jQuery.css(this, "display");
}
}
- if ( opt.overflow != null )
+ if ( opt.overflow != null ) {
this.style.overflow = "hidden";
-
+ }
opt.curAnim = jQuery.extend({}, prop);
jQuery.each( prop, function(name, val){
var e = new jQuery.fx( self, opt, name );
- if ( /toggle|show|hide/.test(val) )
+ if ( /toggle|show|hide/.test(val) ) {
e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
- else {
+ } else {
var parts = /^([+-]=)?([\d+-.]+)(.*)$/.exec(val),
start = e.cur(true) || 0;
}
// If a +=/-= token was provided, we're doing a relative animation
- if ( parts[1] )
+ if ( parts[1] ) {
end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
-
+ }
e.custom( start, end, unit );
- } else
+ } else {
e.custom( start, val, "" );
+ }
}
});
stop: function(clearQueue, gotoEnd){
var timers = jQuery.timers;
- if (clearQueue)
+ if (clearQueue) {
this.queue([]);
-
+ }
this.each(function(){
// go in reverse order so anything added to the queue during the loop is ignored
- for ( var i = timers.length - 1; i >= 0; i-- )
+ for ( var i = timers.length - 1; i >= 0; i-- ) {
if ( timers[i].elem == this ) {
- if (gotoEnd)
+ if (gotoEnd) {
// force the next step to be the last
timers[i](true);
+ }
timers.splice(i, 1);
}
+ }
});
// start the next in the queue if the last step wasn't forced
- if (!gotoEnd)
+ if (!gotoEnd) {
this.dequeue();
-
+ }
return this;
}
// Queueing
opt.old = opt.complete;
opt.complete = function(){
- if ( opt.queue !== false )
+ if ( opt.queue !== false ) {
jQuery(this).dequeue();
- if ( jQuery.isFunction( opt.old ) )
+ }
+ if ( jQuery.isFunction( opt.old ) ) {
opt.old.call( this );
+ }
};
return opt;
this.elem = elem;
this.prop = prop;
- if ( !options.orig )
+ if ( !options.orig ) {
options.orig = {};
+ }
}
});
// Simple function for setting a style value
update: function(){
- if ( this.options.step )
+ if ( this.options.step ) {
this.options.step.call( this.elem, this.now, this );
-
+ }
(jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
// Set display property to block for height/width animations
- if ( ( this.prop == "height" || this.prop == "width" ) && this.elem.style )
+ if ( ( this.prop == "height" || this.prop == "width" ) && this.elem.style ) {
this.elem.style.display = "block";
+ }
},
// Get the current size
cur: function(force){
- if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) )
+ if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
return this.elem[ this.prop ];
-
+ }
var r = parseFloat(jQuery.css(this.elem, this.prop, force));
return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
},
t.elem = this.elem;
- if ( t() && jQuery.timers.push(t) && !timerId )
+ if ( t() && jQuery.timers.push(t) && !timerId ) {
timerId = setInterval(jQuery.fx.tick, 13);
+ }
},
// Simple 'show' function
this.options.curAnim[ this.prop ] = true;
var done = true;
- for ( var i in this.options.curAnim )
- if ( this.options.curAnim[i] !== true )
+ for ( var i in this.options.curAnim ) {
+ if ( this.options.curAnim[i] !== true ) {
done = false;
-
+ }
+ }
if ( done ) {
if ( this.options.display != null ) {
// Reset the overflow
// Reset the display
this.elem.style.display = this.options.display;
- if ( jQuery.css(this.elem, "display") == "none" )
+ if ( jQuery.css(this.elem, "display") == "none" ) {
this.elem.style.display = "block";
+ }
}
// Hide the element if the "hide" operation was done
- if ( this.options.hide )
+ if ( this.options.hide ) {
jQuery(this.elem).hide();
-
+ }
// Reset the properties, if the item has been hidden or shown
- if ( this.options.hide || this.options.show )
- for ( var p in this.options.curAnim )
+ if ( this.options.hide || this.options.show ){
+ for ( var p in this.options.curAnim ) {
jQuery.style(this.elem, p, this.options.orig[p]);
-
+ }
+ }
// Execute the complete function
this.options.complete.call( this.elem );
}
tick:function(){
var timers = jQuery.timers;
- for ( var i = 0; i < timers.length; i++ )
- if ( !timers[i]() )
+ for ( var i = 0; i < timers.length; i++ ) {
+ if ( !timers[i]() ) {
timers.splice(i--, 1);
-
- if ( !timers.length )
+ }
+ }
+ if ( !timers.length ) {
jQuery.fx.stop();
+ }
},
stop:function(){
},
_default: function(fx){
- if ( fx.elem.style && fx.elem.style[ fx.prop ] != null )
+ if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
fx.elem.style[ fx.prop ] = fx.now + fx.unit;
- else
+ } else {
fx.elem[ fx.prop ] = fx.now;
+ }
}
}
});
} else if( typeof qualifier === "string" ) {
var filtered = jQuery.grep(elements, function(elem) { return elem.nodeType === 1 });
- if(isSimple.test( qualifier )) return jQuery.filter(qualifier, filtered, !keep);
- else qualifier = jQuery.filter( qualifier, elements );
+ if(isSimple.test( qualifier )) {
+ return jQuery.filter(qualifier, filtered, !keep);
+ } else {
+ qualifier = jQuery.filter( qualifier, elements );
+ }
}
return jQuery.grep(elements, function(elem, i) {