From 22120cea66ad88f83b96535416f5baab605fe530 Mon Sep 17 00:00:00 2001 From: Oleg Date: Thu, 7 Nov 2013 21:14:23 +0100 Subject: [PATCH] Fix some code style inconsistencies --- src/ajax.js | 11 +++++------ src/ajax/parseXML.js | 2 +- src/attributes/support.js | 2 +- src/attributes/val.js | 2 +- src/callbacks.js | 2 +- src/core/ready.js | 1 - src/css.js | 2 +- src/css/support.js | 3 +-- src/css/var/rmargin.js | 2 +- src/css/var/rnumnonpx.js | 2 +- src/data.js | 2 +- src/data/support.js | 2 +- src/deferred.js | 5 +++-- src/effects.js | 10 ++++------ src/effects/Tween.js | 2 +- src/effects/support.js | 4 ++-- src/event.js | 4 ++-- src/event/support.js | 2 +- src/manipulation.js | 6 +++--- src/manipulation/support.js | 2 +- src/offset.js | 6 +++--- src/queue.js | 2 +- src/selector-sizzle.js | 2 +- src/serialize.js | 8 ++++---- 24 files changed, 41 insertions(+), 45 deletions(-) diff --git a/src/ajax.js b/src/ajax.js index aa3bab348..174e8274d 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -102,7 +102,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX inspected[ dataType ] = true; jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); - if( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) { + if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) { options.dataTypes.unshift( dataTypeOrTransport ); inspect( dataTypeOrTransport ); return false; @@ -135,7 +135,6 @@ function ajaxExtend( target, src ) { return target; } - /* Handles responses to an ajax request: * - finds the right dataType (mediates between content-type and expected dataType) * - returns the corresponding response @@ -146,7 +145,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) { dataTypes = s.dataTypes; // Remove auto dataType and get content-type in the process - while( dataTypes[ 0 ] === "*" ) { + while ( dataTypes[ 0 ] === "*" ) { dataTypes.shift(); if ( ct === undefined ) { ct = s.mimeType || jqXHR.getResponseHeader("Content-Type"); @@ -512,7 +511,7 @@ jQuery.extend({ s.type = options.method || options.type || s.method || s.type; // Extract dataTypes list - s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [""]; + s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ]; // A cross-domain request is in order when we have a protocol:host:port mismatch if ( s.crossDomain == null ) { @@ -798,8 +797,8 @@ jQuery.each( [ "get", "post" ], function( i, method ) { }); // Attach a bunch of functions for handling common AJAX events -jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ){ - jQuery.fn[ type ] = function( fn ){ +jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) { + jQuery.fn[ type ] = function( fn ) { return this.on( type, fn ); }; }); diff --git a/src/ajax/parseXML.js b/src/ajax/parseXML.js index a987f57fc..0b92c7a42 100644 --- a/src/ajax/parseXML.js +++ b/src/ajax/parseXML.js @@ -11,7 +11,7 @@ jQuery.parseXML = function( data ) { try { if ( window.DOMParser ) { // Standard tmp = new DOMParser(); - xml = tmp.parseFromString( data , "text/xml" ); + xml = tmp.parseFromString( data, "text/xml" ); } else { // IE xml = new ActiveXObject( "Microsoft.XMLDOM" ); xml.async = "false"; diff --git a/src/attributes/support.js b/src/attributes/support.js index aeeb3af2f..230722499 100644 --- a/src/attributes/support.js +++ b/src/attributes/support.js @@ -2,7 +2,7 @@ define([ "../var/support" ], function( support ) { -(function () { +(function() { var a, input, select, opt, div = document.createElement("div" ); diff --git a/src/attributes/val.js b/src/attributes/val.js index 1b5e86e1e..8454e80d0 100644 --- a/src/attributes/val.js +++ b/src/attributes/val.js @@ -52,7 +52,7 @@ jQuery.fn.extend({ } else if ( typeof val === "number" ) { val += ""; } else if ( jQuery.isArray( val ) ) { - val = jQuery.map(val, function ( value ) { + val = jQuery.map( val, function( value ) { return value == null ? "" : value + ""; }); } diff --git a/src/callbacks.js b/src/callbacks.js index 7090384ac..9d12823d9 100644 --- a/src/callbacks.js +++ b/src/callbacks.js @@ -126,7 +126,7 @@ jQuery.Callbacks = function( options ) { if ( list ) { jQuery.each( arguments, function( _, arg ) { var index; - while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { + while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { list.splice( index, 1 ); // Handle firing indexes if ( firing ) { diff --git a/src/core/ready.js b/src/core/ready.js index 87be24155..3d0510e38 100644 --- a/src/core/ready.js +++ b/src/core/ready.js @@ -87,7 +87,6 @@ function completed() { } } - jQuery.ready.promise = function( obj ) { if ( !readyList ) { diff --git a/src/css.js b/src/css.js index b18f82202..0f90f0b6a 100644 --- a/src/css.js +++ b/src/css.js @@ -422,7 +422,7 @@ if ( !support.opacity ) { } jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, - function ( elem, computed ) { + function( elem, computed ) { if ( computed ) { // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right // Work around by temporarily setting element display to inline-block diff --git a/src/css/support.js b/src/css/support.js index fdc1dbd12..d5ea92820 100644 --- a/src/css/support.js +++ b/src/css/support.js @@ -3,7 +3,7 @@ define([ "../var/support" ], function( jQuery, support ) { -(function () { +(function() { var a, reliableHiddenOffsetsVal, boxSizingVal, boxSizingReliableVal, pixelPositionVal, reliableMarginRightVal, div = document.createElement( "div" ), @@ -34,7 +34,6 @@ define([ // Null elements to avoid leaks in IE. a = div = null; - jQuery.extend(support, { reliableHiddenOffsets: function() { if ( reliableHiddenOffsetsVal != null ) { diff --git a/src/css/var/rmargin.js b/src/css/var/rmargin.js index 7597cd311..da0438db6 100644 --- a/src/css/var/rmargin.js +++ b/src/css/var/rmargin.js @@ -1,3 +1,3 @@ define(function() { return (/^margin/); -}); \ No newline at end of file +}); diff --git a/src/css/var/rnumnonpx.js b/src/css/var/rnumnonpx.js index ec4fd615c..c93be2850 100644 --- a/src/css/var/rnumnonpx.js +++ b/src/css/var/rnumnonpx.js @@ -2,4 +2,4 @@ define([ "../../var/pnum" ], function( pnum ) { return new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); -}); \ No newline at end of file +}); diff --git a/src/data.js b/src/data.js index 256bed7cd..03994cdb3 100644 --- a/src/data.js +++ b/src/data.js @@ -56,7 +56,7 @@ function isEmptyDataObject( obj ) { return true; } -function internalData( elem, name, data, pvt /* Internal Use Only */ ){ +function internalData( elem, name, data, pvt /* Internal Use Only */ ) { if ( !jQuery.acceptData( elem ) ) { return; } diff --git a/src/data/support.js b/src/data/support.js index 52250b21d..e57f6f7de 100644 --- a/src/data/support.js +++ b/src/data/support.js @@ -2,7 +2,7 @@ define([ "../var/support" ], function( support ) { -(function () { +(function() { var div = document.createElement( "div" ); // Execute the test only if not already executed in another module. diff --git a/src/deferred.js b/src/deferred.js index 1c2f87e86..8dedbf74c 100644 --- a/src/deferred.js +++ b/src/deferred.js @@ -109,9 +109,10 @@ jQuery.extend({ return function( value ) { contexts[ i ] = this; values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; - if( values === progressValues ) { + if ( values === progressValues ) { deferred.notifyWith( contexts, values ); - } else if ( !( --remaining ) ) { + + } else if ( !(--remaining) ) { deferred.resolveWith( contexts, values ); } }; diff --git a/src/effects.js b/src/effects.js index 582870fe9..bd2e4eef9 100644 --- a/src/effects.js +++ b/src/effects.js @@ -21,7 +21,7 @@ var rrun = /queueHooks$/, animationPrefilters = [ defaultPrefilter ], tweeners = { - "*": [function( prop, value ) { + "*": [ function( prop, value ) { var tween = this.createTween( prop, value ), target = tween.cur(), parts = rfxnum.exec( value ), @@ -68,7 +68,7 @@ var } return tween; - }] + } ] }; // Animations created synchronously will run synchronously @@ -87,8 +87,8 @@ function genFx( type, includeWidth ) { // if we include width, step value is 1 to do all cssExpand values, // if we don't include width, step value is 2 to skip over Left and Right - includeWidth = includeWidth? 1 : 0; - for( ; i < 4 ; i += 2 - includeWidth ) { + includeWidth = includeWidth ? 1 : 0; + for ( ; i < 4 ; i += 2 - includeWidth ) { which = cssExpand[ i ]; attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; } @@ -100,7 +100,6 @@ function genFx( type, includeWidth ) { return attrs; } - function createTween( value, prop, animation ) { var tween, collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), @@ -189,7 +188,6 @@ function defaultPrefilter( elem, props, opts ) { } } - // show/hide pass for ( prop in props ) { value = props[ prop ]; diff --git a/src/effects/Tween.js b/src/effects/Tween.js index 43779b065..12eec55cf 100644 --- a/src/effects/Tween.js +++ b/src/effects/Tween.js @@ -102,7 +102,7 @@ jQuery.easing = { return p; }, swing: function( p ) { - return 0.5 - Math.cos( p*Math.PI ) / 2; + return 0.5 - Math.cos( p * Math.PI ) / 2; } }; diff --git a/src/effects/support.js b/src/effects/support.js index 0299cae4e..2391bcbff 100644 --- a/src/effects/support.js +++ b/src/effects/support.js @@ -3,7 +3,7 @@ define([ "../var/support" ], function( strundefined, support ) { -(function () { +(function() { var a, shrinkWrapBlocksVal, div = document.createElement( "div" ), divReset = @@ -32,7 +32,7 @@ define([ // Null elements to avoid leaks in IE. a = div = null; - support.shrinkWrapBlocks = function () { + support.shrinkWrapBlocks = function() { var body, container, div, containerStyles; if ( shrinkWrapBlocksVal == null ) { diff --git a/src/event.js b/src/event.js index a6f69f49f..2ca50aba4 100644 --- a/src/event.js +++ b/src/event.js @@ -79,7 +79,7 @@ jQuery.event = { } // Handle multiple events separated by a space - types = ( types || "" ).match( rnotwhite ) || [""]; + types = ( types || "" ).match( rnotwhite ) || [ "" ]; t = types.length; while ( t-- ) { tmp = rtypenamespace.exec( types[t] ) || []; @@ -165,7 +165,7 @@ jQuery.event = { } // Once for each type.namespace in types; type may be omitted - types = ( types || "" ).match( rnotwhite ) || [""]; + types = ( types || "" ).match( rnotwhite ) || [ "" ]; t = types.length; while ( t-- ) { tmp = rtypenamespace.exec( types[t] ) || []; diff --git a/src/event/support.js b/src/event/support.js index d2a092250..caac5179f 100644 --- a/src/event/support.js +++ b/src/event/support.js @@ -2,7 +2,7 @@ define([ "../var/support" ], function( support ) { -(function () { +(function() { var i, eventName, div = document.createElement( "div" ); diff --git a/src/manipulation.js b/src/manipulation.js index 08a9b7c04..ee0baeb7c 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -311,7 +311,7 @@ jQuery.extend({ tmp = tmp || safe.appendChild( context.createElement("div") ); // Deserialize a standard representation - tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(); + tag = (rtagName.exec( elem ) || [ "", "" ])[ 1 ].toLowerCase(); wrap = wrapMap[ tag ] || wrapMap._default; tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1>" ) + wrap[2]; @@ -556,7 +556,7 @@ jQuery.fn.extend({ dataAndEvents = dataAndEvents == null ? false : dataAndEvents; deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; - return this.map( function () { + return this.map(function() { return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); }); }, @@ -577,7 +577,7 @@ jQuery.fn.extend({ if ( typeof value === "string" && !rnoInnerhtml.test( value ) && ( support.htmlSerialize || !rnoshimcache.test( value ) ) && ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && - !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) { + !wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) { value = value.replace( rxhtmlTag, "<$1>" ); diff --git a/src/manipulation/support.js b/src/manipulation/support.js index fd719274e..427660361 100644 --- a/src/manipulation/support.js +++ b/src/manipulation/support.js @@ -2,7 +2,7 @@ define([ "../var/support" ], function( support ) { -(function () { +(function() { var fragment = document.createDocumentFragment(), div = document.createElement("div"), input = document.createElement("input"); diff --git a/src/offset.js b/src/offset.js index 8b6bacd3f..0d35a4f09 100644 --- a/src/offset.js +++ b/src/offset.js @@ -44,7 +44,7 @@ jQuery.offset = { curCSSTop = jQuery.css( elem, "top" ); curCSSLeft = jQuery.css( elem, "left" ); calculatePosition = ( position === "absolute" || position === "fixed" ) && - jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1; + jQuery.inArray("auto", [ curCSSTop, curCSSLeft ] ) > -1; // need to be able to calculate position if either top or left is auto and position is either absolute or fixed if ( calculatePosition ) { @@ -163,7 +163,7 @@ jQuery.fn.extend({ }); // Create scrollLeft and scrollTop methods -jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) { +jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { var top = /Y/.test( prop ); jQuery.fn[ method ] = function( val ) { @@ -195,7 +195,7 @@ jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( me // rather than make the css module depend on the offset module, we just check for it here jQuery.each( [ "top", "left" ], function( i, prop ) { jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, - function ( elem, computed ) { + function( elem, computed ) { if ( computed ) { computed = curCSS( elem, prop ); // if curCSS returns percentage, fallback to offset diff --git a/src/queue.js b/src/queue.js index f5a1b7467..29e766078 100644 --- a/src/queue.js +++ b/src/queue.js @@ -126,7 +126,7 @@ jQuery.fn.extend({ } type = type || "fx"; - while( i-- ) { + while ( i-- ) { tmp = jQuery._data( elements[ i ], type + "queueHooks" ); if ( tmp && tmp.empty ) { count++; diff --git a/src/selector-sizzle.js b/src/selector-sizzle.js index 3dbfa3cd0..7d3926b1a 100644 --- a/src/selector-sizzle.js +++ b/src/selector-sizzle.js @@ -1,7 +1,7 @@ define([ "./core", "sizzle" -], function ( jQuery, Sizzle ) { +], function( jQuery, Sizzle ) { jQuery.find = Sizzle; jQuery.expr = Sizzle.selectors; diff --git a/src/serialize.js b/src/serialize.js index 797d735aa..5b09cb614 100644 --- a/src/serialize.js +++ b/src/serialize.js @@ -80,25 +80,25 @@ jQuery.fn.extend({ return jQuery.param( this.serializeArray() ); }, serializeArray: function() { - return this.map(function(){ + return this.map(function() { // Can add propHook for "elements" to filter or add form elements var elements = jQuery.prop( this, "elements" ); return elements ? jQuery.makeArray( elements ) : this; }) - .filter(function(){ + .filter(function() { var type = this.type; // Use .is(":disabled") so that fieldset[disabled] works return this.name && !jQuery( this ).is( ":disabled" ) && rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && ( this.checked || !rcheckableType.test( type ) ); }) - .map(function( i, elem ){ + .map(function( i, elem ) { var val = jQuery( this ).val(); return val == null ? null : jQuery.isArray( val ) ? - jQuery.map( val, function( val ){ + jQuery.map( val, function( val ) { return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; }) : { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; -- 2.39.5