From 5c4c5c151675bc5d473dceb11f75ec19bc938793 Mon Sep 17 00:00:00 2001 From: Mike Hughes Date: Tue, 9 Sep 2014 12:43:56 +0100 Subject: [PATCH] Fixed indentation for fix #6193 --- assets/js/frontend/add-to-cart.js | 156 +++++++++++++++--------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/assets/js/frontend/add-to-cart.js b/assets/js/frontend/add-to-cart.js index cf11ddf66dd..ff7c168ceff 100644 --- a/assets/js/frontend/add-to-cart.js +++ b/assets/js/frontend/add-to-cart.js @@ -1,115 +1,115 @@ jQuery( function( $ ) { - // wc_add_to_cart_params is required to continue, ensure the object exists - if ( typeof wc_add_to_cart_params === 'undefined' ) - return false; + // wc_add_to_cart_params is required to continue, ensure the object exists + if ( typeof wc_add_to_cart_params === 'undefined' ) + return false; - // Ajax add to cart - $( document ).on( 'click', '.add_to_cart_button', function(e) { + // Ajax add to cart + $( document ).on( 'click', '.add_to_cart_button', function(e) { - // AJAX add to cart request - var $thisbutton = $( this ); + // AJAX add to cart request + var $thisbutton = $( this ); - if ( $thisbutton.is( '.product_type_simple' ) ) { + if ( $thisbutton.is( '.product_type_simple' ) ) { - if ( ! $thisbutton.attr( 'data-product_id' ) ) - return true; + if ( ! $thisbutton.attr( 'data-product_id' ) ) + return true; - $thisbutton.removeClass( 'added' ); - $thisbutton.addClass( 'loading' ); + $thisbutton.removeClass( 'added' ); + $thisbutton.addClass( 'loading' ); - var data = { - action: 'woocommerce_add_to_cart', - }; + var data = { + action: 'woocommerce_add_to_cart', + }; - $.each( $thisbutton.data(), function( key, value ) { - data[key] = value; - }); + $.each( $thisbutton.data(), function( key, value ) { + data[key] = value; + }); - // Trigger event - $( 'body' ).trigger( 'adding_to_cart', [ $thisbutton, data ] ); + // Trigger event + $( 'body' ).trigger( 'adding_to_cart', [ $thisbutton, data ] ); - // Ajax action - $.post( wc_add_to_cart_params.ajax_url, data, function( response ) { + // Ajax action + $.post( wc_add_to_cart_params.ajax_url, data, function( response ) { - if ( ! response ) - return; + if ( ! response ) + return; - var this_page = window.location.toString(); + var this_page = window.location.toString(); - this_page = this_page.replace( 'add-to-cart', 'added-to-cart' ); + this_page = this_page.replace( 'add-to-cart', 'added-to-cart' ); - if ( response.error && response.product_url ) { - window.location = response.product_url; - return; - } + if ( response.error && response.product_url ) { + window.location = response.product_url; + return; + } - // Redirect to cart option - if ( wc_add_to_cart_params.cart_redirect_after_add === 'yes' ) { + // Redirect to cart option + if ( wc_add_to_cart_params.cart_redirect_after_add === 'yes' ) { - window.location = wc_add_to_cart_params.cart_url; - return; + window.location = wc_add_to_cart_params.cart_url; + return; - } else { + } else { - $thisbutton.removeClass( 'loading' ); + $thisbutton.removeClass( 'loading' ); - fragments = response.fragments; - cart_hash = response.cart_hash; + fragments = response.fragments; + cart_hash = response.cart_hash; - // Block fragments class - if ( fragments ) { - $.each( fragments, function( key, value ) { - $( key ).addClass( 'updating' ); - }); - } + // Block fragments class + if ( fragments ) { + $.each( fragments, function( key, value ) { + $( key ).addClass( 'updating' ); + }); + } - // Block widgets and fragments - $( '.shop_table.cart, .updating, .cart_totals' ).fadeTo( '400', '0.6' ).block({ message: null, overlayCSS: { background: 'transparent url(' + wc_add_to_cart_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } } ); + // Block widgets and fragments + $( '.shop_table.cart, .updating, .cart_totals' ).fadeTo( '400', '0.6' ).block({ message: null, overlayCSS: { background: 'transparent url(' + wc_add_to_cart_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } } ); - // Changes button classes - $thisbutton.addClass( 'added' ); + // Changes button classes + $thisbutton.addClass( 'added' ); - // View cart text - if ( ! wc_add_to_cart_params.is_cart && $thisbutton.parent().find( '.added_to_cart' ).size() === 0 ) { - $thisbutton.after( ' ' + wc_add_to_cart_params.i18n_view_cart + '' ); - } + // View cart text + if ( ! wc_add_to_cart_params.is_cart && $thisbutton.parent().find( '.added_to_cart' ).size() === 0 ) { + $thisbutton.after( ' ' + wc_add_to_cart_params.i18n_view_cart + '' ); + } - // Replace fragments - if ( fragments ) { - $.each( fragments, function( key, value ) { - $( key ).replaceWith( value ); - }); - } + // Replace fragments + if ( fragments ) { + $.each( fragments, function( key, value ) { + $( key ).replaceWith( value ); + }); + } - // Unblock - $( '.widget_shopping_cart, .updating' ).stop( true ).css( 'opacity', '1' ).unblock(); + // Unblock + $( '.widget_shopping_cart, .updating' ).stop( true ).css( 'opacity', '1' ).unblock(); - // Cart page elements - $( '.shop_table.cart' ).load( this_page + ' .shop_table.cart:eq(0) > *', function() { + // Cart page elements + $( '.shop_table.cart' ).load( this_page + ' .shop_table.cart:eq(0) > *', function() { - $( 'div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)' ).addClass( 'buttons_added' ).append( '' ).prepend( '' ); + $( 'div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)' ).addClass( 'buttons_added' ).append( '' ).prepend( '' ); - $( '.shop_table.cart' ).stop( true ).css( 'opacity', '1' ).unblock(); + $( '.shop_table.cart' ).stop( true ).css( 'opacity', '1' ).unblock(); - $( 'body' ).trigger( 'cart_page_refreshed' ); - }); + $( 'body' ).trigger( 'cart_page_refreshed' ); + }); - $( '.cart_totals' ).load( this_page + ' .cart_totals:eq(0) > *', function() { - $( '.cart_totals' ).stop( true ).css( 'opacity', '1' ).unblock(); - }); + $( '.cart_totals' ).load( this_page + ' .cart_totals:eq(0) > *', function() { + $( '.cart_totals' ).stop( true ).css( 'opacity', '1' ).unblock(); + }); - // Trigger event so themes can refresh other areas - $( 'body' ).trigger( 'added_to_cart', [ fragments, cart_hash ] ); - } - }); + // Trigger event so themes can refresh other areas + $( 'body' ).trigger( 'added_to_cart', [ fragments, cart_hash ] ); + } + }); - return false; + return false; - } + } - return true; - }); + return true; + }); });