]> source.dussan.org Git - jquery.git/commitdiff
added curly braces around all if/else statements
authorKarl Swedberg <karl@englishrules.com>
Fri, 27 Nov 2009 19:28:42 +0000 (03:28 +0800)
committerJohn Resig <jeresig@gmail.com>
Fri, 27 Nov 2009 20:09:14 +0000 (04:09 +0800)
src/ajax.js
src/attributes.js
src/data.js
src/dimensions.js
src/event.js
src/fx.js
src/traversing.js

index 1e0729f3fead843a4cdedfb6ba14c925b8071b75..59c231c9b33e52c73c6f69d17c57db35b1ae173e 100644 (file)
@@ -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, "+");
        }
index 0edf21886f8c75c60f46911f5ceba91671ec1729..b5a29e159e56e38139525aeea7317b22800af0ff 100644 (file)
@@ -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,9 +111,9 @@ 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(){
@@ -121,15 +121,17 @@ jQuery.fn.extend({
                                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);
 
@@ -137,11 +139,12 @@ jQuery.fn.extend({
                                        this.selected = jQuery.inArray( this.value || this.text, values ) >= 0;
                                });
 
-                               if ( !values.length )
+                               if ( !values.length ) {
                                        this.selectedIndex = -1;
-
-                       } else
+                               }
+                       } else {
                                this.value = val;
+                       }
                });
        }
 });
@@ -149,8 +152,9 @@ jQuery.fn.extend({
 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 )
index 8fa62dc1eb2cccf1884291f61e92d67a269c1f43..f4dad16366d7f0aa0f68ecb2aead2beb6beb4a76 100644 (file)
@@ -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,19 +150,20 @@ 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){
                return this.each(function(){
-                       jQuery.dequeue( this, type );
+                       jQuery.dequeue( this, type )
                });
        },
        clearQueue: function(type){
index a53254d5499892c741e3952225008254c2cb7ae4..3b74ded9b839c089d2faed74ce921b6eb53788f0 100644 (file)
@@ -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 ] ||
index 7e8707c3b48d0a40956a1aa47d39b30d709206f8..2bb8a0edc8f608ca2440722fa7fdcb9cd8b13919 100644 (file)
@@ -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
index c34b85672033ce68ea9a4a6dfa49e5c401da15a2..46000a58b8b7521c52a11ac876702717efee5a2f 100644 (file)
--- a/src/fx.js
+++ b/src/fx.js
@@ -36,9 +36,9 @@ jQuery.fn.extend({
                                                var elem = jQuery("<" + nodeName + " />").appendTo("body");
 
                                                display = elem.css("display");
-                                               if ( display === "none" )
+                                               if ( display === "none" ) {
                                                        display = "block";
-
+                                               }
                                                elem.remove();
 
                                                elemdisplay[ nodeName ] = display;
@@ -64,8 +64,9 @@ jQuery.fn.extend({
                } 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
@@ -117,9 +118,9 @@ jQuery.fn.extend({
                                        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");
@@ -129,17 +130,17 @@ jQuery.fn.extend({
                                }
                        }
 
-                       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;
 
@@ -155,12 +156,13 @@ jQuery.fn.extend({
                                                }
 
                                                // 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, "" );
+                                       }
                                }
                        });
 
@@ -176,24 +178,26 @@ jQuery.fn.extend({
        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;
        }
 
@@ -228,10 +232,12 @@ jQuery.extend({
                // 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;
@@ -253,8 +259,9 @@ jQuery.extend({
                this.elem = elem;
                this.prop = prop;
 
-               if ( !options.orig )
+               if ( !options.orig ) {
                        options.orig = {};
+               }
        }
 
 });
@@ -263,21 +270,22 @@ jQuery.fx.prototype = {
 
        // 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;
        },
@@ -298,8 +306,9 @@ jQuery.fx.prototype = {
 
                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
@@ -339,10 +348,11 @@ jQuery.fx.prototype = {
                        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
@@ -350,19 +360,21 @@ jQuery.fx.prototype = {
 
                                        // 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 );
                        }
@@ -390,12 +402,14 @@ jQuery.extend( jQuery.fx, {
        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(){
@@ -417,10 +431,11 @@ jQuery.extend( jQuery.fx, {
                },
 
                _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;
+                       }
                }
        }
 });
index 85976a3c05baaaa40c4f0db24ccaa4b39b707eeb..a467e7c9eaa616831c07ae19b238e64ad782247f 100644 (file)
@@ -10,8 +10,11 @@ var winnow = function( elements, qualifier, keep ) {
        } 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) {