jQuery: The Write Less, Do More JavaScript Library

Changeset 5577

Show
Ignore:
Timestamp:
05/13/08 01:45:58 (3 months ago)
Author:
aflesler
Message:

jquery: removing unnecessary trailing and leading spaces & tabs.

Location:
trunk/jquery/src
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/jquery/src/ajax.js

    r5501 r5577  
    22    // Keep a copy of the old load 
    33    _load: jQuery.fn.load, 
    4      
     4 
    55    load: function( url, params, callback ) { 
    66        if ( typeof url != 'string' ) 
     
    7272        }) 
    7373        .filter(function(){ 
    74             return this.name && !this.disabled &&  
    75                 (this.checked || /select|textarea/i.test(this.nodeName) ||  
     74            return this.name && !this.disabled && 
     75                (this.checked || /select|textarea/i.test(this.nodeName) || 
    7676                    /text|hidden|password/i.test(this.type)); 
    7777        }) 
     
    104104            data = null; 
    105105        } 
    106          
     106 
    107107        return jQuery.ajax({ 
    108108            type: "GET", 
     
    160160        } 
    161161    }, 
    162      
     162 
    163163    // Last-Modified header cache for next request 
    164164    lastModified: {}, 
     
    249249                // Attach handlers for all browsers 
    250250                script.onload = script.onreadystatechange = function(){ 
    251                     if ( !done && (!this.readyState ||  
     251                    if ( !done && (!this.readyState || 
    252252                            this.readyState == "loaded" || this.readyState == "complete") ) { 
    253253                        done = true; 
     
    302302            return false; 
    303303        } 
    304          
     304 
    305305        if ( s.global ) 
    306306            jQuery.event.trigger("ajaxSend", [xml, s]); 
     
    311311            if ( !requestDone && xml && (xml.readyState == 4 || isTimeout == "timeout") ) { 
    312312                requestDone = true; 
    313                  
     313 
    314314                // clear poll interval 
    315315                if (ival) { 
     
    317317                    ival = null; 
    318318                } 
    319                  
     319 
    320320                status = isTimeout == "timeout" && "timeout" || 
    321321                    !jQuery.httpSuccess( xml ) && "error" || 
     
    340340                        modRes = xml.getResponseHeader("Last-Modified"); 
    341341                    } catch(e) {} // swallow exception thrown by FF if header is not available 
    342      
     342 
    343343                    if ( s.ifModified && modRes ) 
    344344                        jQuery.lastModified[s.url] = modRes; 
     
    346346                    // JSONP handles its own success callback 
    347347                    if ( !jsonp ) 
    348                         success();   
     348                        success(); 
    349349                } else 
    350350                    jQuery.handleError(s, xml, status); 
     
    358358            } 
    359359        }; 
    360          
     360 
    361361        if ( s.async ) { 
    362362            // don't attach the handler to the request, just poll it instead 
    363             var ival = setInterval(onreadystatechange, 13);  
     363            var ival = setInterval(onreadystatechange, 13); 
    364364 
    365365            // Timeout checker 
     
    370370                        // Cancel the request 
    371371                        xml.abort(); 
    372      
     372 
    373373                        if( !requestDone ) 
    374374                            onreadystatechange( "timeout" ); 
     
    376376                }, s.timeout); 
    377377        } 
    378              
     378 
    379379        // Send the data 
    380380        try { 
     
    383383            jQuery.handleError(s, xml, null, e); 
    384384        } 
    385          
     385 
    386386        // firefox 1.5 doesn't fire statechange for sync requests 
    387387        if ( !s.async ) 
     
    411411                jQuery.event.trigger( "ajaxStop" ); 
    412412        } 
    413          
     413 
    414414        // return XMLHttpRequest to allow aborting the request etc. 
    415415        return xml; 
  • trunk/jquery/src/core.js

    r5575 r5577  
    1212// Map over jQuery in case of overwrite 
    1313var _jQuery = window.jQuery, 
    14 // Map over the $ in case of overwrite   
     14// Map over the $ in case of overwrite 
    1515    _$ = window.$; 
    1616 
     
    2727    isSimple = /^.[^:#\[\.]*$/, 
    2828 
    29 // Will speed up references to undefined, and allows munging its name.   
     29// Will speed up references to undefined, and allows munging its name. 
    3030    undefined; 
    3131 
     
    7979        } else if ( jQuery.isFunction( selector ) ) 
    8080            return jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector ); 
    81          
     81 
    8282        return this.setArray(jQuery.makeArray(selector)); 
    8383    }, 
    84      
     84 
    8585    // The current version of jQuery being used 
    8686    jquery: "@VERSION", 
     
    9090        return this.length; 
    9191    }, 
    92      
     92 
    9393    // The number of elements contained in the matched element set 
    9494    length: 0, 
     
    105105            this[ num ]; 
    106106    }, 
    107      
     107 
    108108    // Take an array of elements and push it onto the stack 
    109109    // (returning the new matched element set) 
     
    118118        return ret; 
    119119    }, 
    120      
     120 
    121121    // Force the current matched set of elements to become 
    122122    // the specified array of elements (destroying the stack in the process) 
     
    127127        this.length = 0; 
    128128        Array.prototype.push.apply( this, elems ); 
    129          
     129 
    130130        return this; 
    131131    }, 
     
    138138    }, 
    139139 
    140     // Determine the position of an element within  
     140    // Determine the position of an element within 
    141141    // the matched set of elements 
    142142    index: function( elem ) { 
     
    144144 
    145145        // Locate the position of the desired element 
    146         return jQuery.inArray(  
     146        return jQuery.inArray( 
    147147            // If it receives a jQuery object, the first element is used 
    148148            elem && elem.jquery ? elem[0] : elem 
     
    152152    attr: function( name, value, type ) { 
    153153        var options = name; 
    154          
     154 
    155155        // Look for the case where we're accessing a style value 
    156156        if ( name.constructor == String ) 
     
    162162                options[ name ] = value; 
    163163            } 
    164          
     164 
    165165        // Check to see if we're setting style values 
    166166        return this.each(function(i){ 
     
    245245        }); 
    246246    }, 
    247      
     247 
    248248    before: function() { 
    249249        return this.domManip(arguments, false, false, function(elem){ 
     
    280280                // clone will also remove the events from the orignal 
    281281                // In order to get around this, we use innerHTML. 
    282                 // Unfortunately, this means some modifications to  
    283                 // attributes in IE that are actually only stored  
     282                // Unfortunately, this means some modifications to 
     283                // attributes in IE that are actually only stored 
    284284                // as properties will not be copied (such as the 
    285285                // the name attribute on an input). 
     
    299299                this[ expando ] = null; 
    300300        }); 
    301          
     301 
    302302        // Copy the events from the original to the clone 
    303303        if ( events === true ) 
     
    341341 
    342342    add: function( selector ) { 
    343         return this.pushStack( jQuery.unique( jQuery.merge(  
     343        return this.pushStack( jQuery.unique( jQuery.merge( 
    344344            this.get(), 
    345             typeof selector == 'string' ?  
     345            typeof selector == 'string' ? 
    346346                jQuery( selector ) : 
    347347                jQuery.makeArray( selector ) 
     
    356356        return this.is( "." + selector ); 
    357357    }, 
    358      
     358 
    359359    val: function( value ) { 
    360360        if ( value == undefined ) { 
     
    369369                        options = elem.options, 
    370370                        one = elem.type == "select-one"; 
    371                      
     371 
    372372                    // Nothing was selected 
    373373                    if ( index < 0 ) 
     
    381381                            // Get the specifc value for the option 
    382382                            value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value; 
    383                              
     383 
    384384                            // We don't need an array for one selects 
    385385                            if ( one ) 
    386386                                return value; 
    387                              
     387 
    388388                            // Multi-Selects return an array 
    389389                            values.push( value ); 
    390390                        } 
    391391                    } 
    392                      
     392 
    393393                    return values; 
    394                      
     394 
    395395                // Everything else, we just grab the value 
    396396                } else 
     
    427427        }); 
    428428    }, 
    429      
     429 
    430430    html: function( value ) { 
    431431        return value == undefined ? 
     
    464464        if ( value === undefined ) { 
    465465            var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); 
    466              
     466 
    467467            if ( data === undefined && this.length ) 
    468468                data = jQuery.data( this[0], key ); 
     
    482482        }); 
    483483    }, 
    484      
     484 
    485485    domManip: function( args, table, reverse, callback ) { 
    486         var clone = this.length > 1, elems;  
     486        var clone = this.length > 1, elems; 
    487487 
    488488        return this.each(function(){ 
     
    573573            // Extend the base object 
    574574            for ( var name in options ) { 
    575                 var src = target[ name ], copy = options[ name ];  
    576                  
     575                var src = target[ name ], copy = options[ name ]; 
     576 
    577577                // Prevent never-ending loop 
    578578                if ( target === copy ) 
     
    612612    // See test/unit/core.js for details concerning this function. 
    613613    isFunction: function( fn ) { 
    614         return !!fn && typeof fn != "string" && !fn.nodeName &&  
     614        return !!fn && typeof fn != "string" && !fn.nodeName && 
    615615            fn.constructor != Array && /function/i.test( fn + "" ); 
    616616    }, 
    617      
     617 
    618618    // check if an element is in a (or is an) XML document 
    619619    isXMLDoc: function( elem ) { 
     
    646646        return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); 
    647647    }, 
    648      
     648 
    649649    cache: {}, 
    650      
     650 
    651651    data: function( elem, name, data ) { 
    652652        elem = elem == window ? 
     
    657657 
    658658        // Compute a unique ID for the element 
    659         if ( !id )  
     659        if ( !id ) 
    660660            id = elem[ expando ] = ++uuid; 
    661661 
     
    664664        if ( name && !jQuery.cache[ id ] ) 
    665665            jQuery.cache[ id ] = {}; 
    666          
     666 
    667667        // Prevent overriding the named cache with undefined values 
    668668        if ( data !== undefined ) 
    669669            jQuery.cache[ id ][ name ] = data; 
    670          
    671         // Return the named cache data, or the ID for the element    
     670 
     671        // Return the named cache data, or the ID for the element 
    672672        return name ? 
    673673            jQuery.cache[ id ][ name ] : 
    674674            id; 
    675675    }, 
    676      
     676 
    677677    removeData: function( elem, name ) { 
    678678        elem = elem == window ? 
     
    718718    each: function( object, callback, args ) { 
    719719        var name, i = 0, length = object.length; 
    720          
     720 
    721721        if ( args ) { 
    722722            if ( length == undefined ) { 
     
    736736                        break; 
    737737            } else 
    738                 for ( var value = object[0];  
     738                for ( var value = object[0]; 
    739739                    i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} 
    740740        } 
     
    742742        return object; 
    743743    }, 
    744      
     744 
    745745    prop: function( elem, value, type, i, name ) { 
    746746            // Handle executable functions 
    747747            if ( jQuery.isFunction( value ) ) 
    748748                value = value.call( elem, i ); 
    749                  
     749 
    750750            // Handle passing in a number to a CSS property 
    751751            return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ? 
     
    768768                elem.className = classNames != undefined ? 
    769769                    jQuery.grep(elem.className.split(/\s+/), function(className){ 
    770                         return !jQuery.className.has( classNames, className );   
     770                        return !jQuery.className.has( classNames, className ); 
    771771                    }).join(" ") : 
    772772                    ""; 
     
    798798        if ( name == "width" || name == "height" ) { 
    799799            var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; 
    800          
     800 
    801801            function getWH() { 
    802802                val = name == "width" ? elem.offsetWidth : elem.offsetHeight; 
     
    808808                val -= Math.round(padding + border); 
    809809            } 
    810          
     810 
    811811            if ( jQuery(elem).is(":visible") ) 
    812812                getWH(); 
    813813            else 
    814814                jQuery.swap( elem, props, getWH ); 
    815              
     815 
    816816            return Math.max(0, val); 
    817817        } 
    818          
     818 
    819819        return jQuery.curCSS( elem, name, force ); 
    820820    }, 
     
    827827            if ( !jQuery.browser.safari ) 
    828828                return false; 
    829              
     829 
    830830            // getComputedStyle is cached 
    831831            var ret = getComputedStyle( elem, null ); 
     
    847847            style.outline = save; 
    848848        } 
    849          
     849 
    850850        // Make sure we're using the right name for getting the float value 
    851851        if ( name.match( /float/i ) ) 
     
    930930        return ret; 
    931931    }, 
    932      
     932 
    933933    clean: function( elems, context ) { 
    934934        var ret = []; 
    935935        context = context || document; 
    936936        // !context.createElement fails in IE with an error but returns typeof 'object' 
    937         if (typeof context.createElement == 'undefined')  
     937        if (typeof context.createElement == 'undefined') 
    938938            context = context.ownerDocument || context[0] && context[0].ownerDocument || document; 
    939939 
     
    944944            if ( elem.constructor == Number ) 
    945945                elem += ''; 
    946              
     946 
    947947            // Convert html string into DOM nodes 
    948948            if ( typeof elem == "string" ) { 
     
    961961                    !tags.indexOf("<opt") && 
    962962                    [ 1, "<select multiple='multiple'>", "</select>" ] || 
    963                      
     963 
    964964                    !tags.indexOf("<leg") && 
    965965                    [ 1, "<fieldset>", "</fieldset>" ] || 
    966                      
     966 
    967967                    tags.match(/^<(thead|tbody|tfoot|colg|cap)/) && 
    968968                    [ 1, "<table>", "</table>" ] || 
    969                      
     969 
    970970                    !tags.indexOf("<tr") && 
    971971                    [ 2, "<table><tbody>", "</tbody></table>" ] || 
    972                      
     972 
    973973                    // <thead> matched above 
    974974                    (!tags.indexOf("<td") || !tags.indexOf("<th")) && 
    975975                    [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] || 
    976                      
     976 
    977977                    !tags.indexOf("<col") && 
    978978                    [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] || 
     
    981981                    jQuery.browser.msie && 
    982982                    [ 1, "div<div>", "</div>" ] || 
    983                      
     983 
    984984                    [ 0, "", "" ]; 
    985985 
    986986                // Go to html and back, then peel off extra wrappers 
    987987                div.innerHTML = wrap[1] + elem + wrap[2]; 
    988                  
     988 
    989989                // Move to the right depth 
    990990                while ( wrap[0]-- ) 
    991991                    div = div.lastChild; 
    992                  
     992 
    993993                // Remove IE's autoinserted <tbody> from table fragments 
    994994                if ( jQuery.browser.msie ) { 
    995                      
     995 
    996996                    // String was a <table>, *may* have spurious <tbody> 
    997997                    var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ? 
    998998                        div.firstChild && div.firstChild.childNodes : 
    999                          
     999 
    10001000                        // String was a bare <thead> or <tfoot> 
    10011001                        wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ? 
    10021002                            div.childNodes : 
    10031003                            []; 
    1004                  
     1004 
    10051005                    for ( var j = tbody.length - 1; j >= 0 ; --j ) 
    10061006                        if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) 
    10071007                            tbody[ j ].parentNode.removeChild( tbody[ j ] ); 
    1008                      
    1009                     // IE completely kills leading whitespace when innerHTML is used     
    1010                     if ( /^\s/.test( elem ) )    
     1008 
     1009                    // IE completely kills leading whitespace when innerHTML is used 
     1010                    if ( /^\s/.test( elem ) ) 
    10111011                        div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild ); 
    1012                  
     1012 
    10131013                } 
    1014                  
     1014 
    10151015                elem = jQuery.makeArray( div.childNodes ); 
    10161016            } 
     
    10791079                elem.setAttribute( name, "" + value ); 
    10801080 
    1081             if ( msie && special && notxml )  
     1081            if ( msie && special && notxml ) 
    10821082                return elem.getAttribute( name, 2 ); 
    10831083 
     
    10931093                // IE has trouble with opacity if it does not have layout 
    10941094                // Force it by setting the zoom level 
    1095                 elem.zoom = 1;  
     1095                elem.zoom = 1; 
    10961096 
    10971097                // Set the alpha filter to set the opacity 
     
    11141114        return elem[ name ]; 
    11151115    }, 
    1116      
     1116 
    11171117    trim: function( text ) { 
    11181118        return (text || "").replace( /^\s+|\s+$/g, "" ); 
     
    12251225    "styleFloat" : 
    12261226    "cssFloat"; 
    1227      
     1227 
    12281228jQuery.extend({ 
    12291229    // Check to see if the W3C box model is being used 
    12301230    boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat", 
    1231