Merge pull request #5181 from splashingpixels/jshint

Jshint
This commit is contained in:
Mike Jolley 2014-03-20 09:06:38 +00:00
commit a7ffcc6b46
8 changed files with 84 additions and 82 deletions

View File

@ -1,12 +1,12 @@
jQuery( function() { jQuery( function( $ ) {
jQuery('.wc-credit-card-form-card-number').payment('formatCardNumber'); $( '.wc-credit-card-form-card-number' ).payment( 'formatCardNumber' );
jQuery('.wc-credit-card-form-card-expiry').payment('formatCardExpiry'); $( '.wc-credit-card-form-card-expiry' ).payment( 'formatCardExpiry' );
jQuery('.wc-credit-card-form-card-cvc').payment('formatCardCVC'); $( '.wc-credit-card-form-card-cvc' ).payment( 'formatCardCVC' );
jQuery('body') $( 'body' )
.on('updated_checkout', function() { .on( 'updated_checkout', function() {
jQuery('.wc-credit-card-form-card-number').payment('formatCardNumber'); $( '.wc-credit-card-form-card-number' ).payment( 'formatCardNumber' );
jQuery('.wc-credit-card-form-card-expiry').payment('formatCardExpiry'); $( '.wc-credit-card-form-card-expiry' ).payment( 'formatCardExpiry' );
jQuery('.wc-credit-card-form-card-cvc').payment('formatCardCVC'); $( '.wc-credit-card-form-card-cvc' ).payment( 'formatCardCVC' );
}); });
} ); } );

View File

@ -1 +1 @@
jQuery(function(){jQuery(".wc-credit-card-form-card-number").payment("formatCardNumber"),jQuery(".wc-credit-card-form-card-expiry").payment("formatCardExpiry"),jQuery(".wc-credit-card-form-card-cvc").payment("formatCardCVC"),jQuery("body").on("updated_checkout",function(){jQuery(".wc-credit-card-form-card-number").payment("formatCardNumber"),jQuery(".wc-credit-card-form-card-expiry").payment("formatCardExpiry"),jQuery(".wc-credit-card-form-card-cvc").payment("formatCardCVC")})}); jQuery(function(e){e(".wc-credit-card-form-card-number").payment("formatCardNumber");e(".wc-credit-card-form-card-expiry").payment("formatCardExpiry");e(".wc-credit-card-form-card-cvc").payment("formatCardCVC");e("body").on("updated_checkout",function(){e(".wc-credit-card-form-card-number").payment("formatCardNumber");e(".wc-credit-card-form-card-expiry").payment("formatCardExpiry");e(".wc-credit-card-form-card-cvc").payment("formatCardCVC")})})

View File

@ -1,72 +1,73 @@
jQuery(function($) { jQuery( function( $ ) {
// woocommerce_price_slider_params is required to continue, ensure the object exists // woocommerce_price_slider_params is required to continue, ensure the object exists
if (typeof woocommerce_price_slider_params === "undefined") if ( typeof woocommerce_price_slider_params === 'undefined' ) {
return false; return false;
}
// Get markup ready for slider // Get markup ready for slider
$('input#min_price, input#max_price').hide(); $( 'input#min_price, input#max_price' ).hide();
$('.price_slider, .price_label').show(); $( '.price_slider, .price_label' ).show();
// Price slider uses jquery ui // Price slider uses jquery ui
var min_price = $('.price_slider_amount #min_price').data('min'); var min_price = $( '.price_slider_amount #min_price' ).data( 'min' ),
var max_price = $('.price_slider_amount #max_price').data('max'); max_price = $( '.price_slider_amount #max_price' ).data( 'max' );
current_min_price = parseInt(min_price); current_min_price = parseInt( min_price, 10 );
current_max_price = parseInt(max_price); current_max_price = parseInt( max_price, 10 );
if (woocommerce_price_slider_params.min_price) current_min_price = parseInt(woocommerce_price_slider_params.min_price); if ( woocommerce_price_slider_params.min_price ) current_min_price = parseInt( woocommerce_price_slider_params.min_price, 10 );
if (woocommerce_price_slider_params.max_price) current_max_price = parseInt(woocommerce_price_slider_params.max_price); if ( woocommerce_price_slider_params.max_price ) current_max_price = parseInt( woocommerce_price_slider_params.max_price, 10 );
$('body').bind('price_slider_create price_slider_slide', function( event, min, max ) { $( 'body' ).bind( 'price_slider_create price_slider_slide', function( event, min, max ) {
if (woocommerce_price_slider_params.currency_pos == "left") { if ( woocommerce_price_slider_params.currency_pos === 'left' ) {
$( ".price_slider_amount span.from" ).html( woocommerce_price_slider_params.currency_symbol + min ); $( '.price_slider_amount span.from' ).html( woocommerce_price_slider_params.currency_symbol + min );
$( ".price_slider_amount span.to" ).html( woocommerce_price_slider_params.currency_symbol + max ); $( '.price_slider_amount span.to' ).html( woocommerce_price_slider_params.currency_symbol + max );
} else if (woocommerce_price_slider_params.currency_pos == "left_space") { } else if ( woocommerce_price_slider_params.currency_pos === 'left_space' ) {
$( ".price_slider_amount span.from" ).html( woocommerce_price_slider_params.currency_symbol + " " + min ); $( '.price_slider_amount span.from' ).html( woocommerce_price_slider_params.currency_symbol + " " + min );
$( ".price_slider_amount span.to" ).html( woocommerce_price_slider_params.currency_symbol + " " + max ); $( '.price_slider_amount span.to' ).html( woocommerce_price_slider_params.currency_symbol + " " + max );
} else if (woocommerce_price_slider_params.currency_pos == "right") { } else if ( woocommerce_price_slider_params.currency_pos === 'right' ) {
$( ".price_slider_amount span.from" ).html( min + woocommerce_price_slider_params.currency_symbol ); $( '.price_slider_amount span.from' ).html( min + woocommerce_price_slider_params.currency_symbol );
$( ".price_slider_amount span.to" ).html( max + woocommerce_price_slider_params.currency_symbol ); $( '.price_slider_amount span.to' ).html( max + woocommerce_price_slider_params.currency_symbol );
} else if (woocommerce_price_slider_params.currency_pos == "right_space") { } else if ( woocommerce_price_slider_params.currency_pos === 'right_space' ) {
$( ".price_slider_amount span.from" ).html( min + " " + woocommerce_price_slider_params.currency_symbol ); $( '.price_slider_amount span.from' ).html( min + " " + woocommerce_price_slider_params.currency_symbol );
$( ".price_slider_amount span.to" ).html( max + " " + woocommerce_price_slider_params.currency_symbol ); $( '.price_slider_amount span.to' ).html( max + " " + woocommerce_price_slider_params.currency_symbol );
} }
$('body').trigger('price_slider_updated', min, max ); $( 'body' ).trigger( 'price_slider_updated', min, max );
}); });
$('.price_slider').slider({ $( '.price_slider' ).slider({
range: true, range: true,
animate: true, animate: true,
min: min_price, min: min_price,
max: max_price, max: max_price,
values: [current_min_price,current_max_price], values: [ current_min_price, current_max_price ],
create : function( event, ui ) { create : function( event, ui ) {
$( ".price_slider_amount #min_price" ).val(current_min_price); $( '.price_slider_amount #min_price' ).val( current_min_price );
$( ".price_slider_amount #max_price" ).val(current_max_price); $( '.price_slider_amount #max_price' ).val( current_max_price );
$('body').trigger('price_slider_create', [current_min_price, current_max_price]); $( 'body' ).trigger( 'price_slider_create', [ current_min_price, current_max_price ] );
}, },
slide: function( event, ui ) { slide: function( event, ui ) {
$( "input#min_price" ).val(ui.values[ 0 ]); $( 'input#min_price' ).val( ui.values[0] );
$( "input#max_price" ).val(ui.values[ 1 ]); $( 'input#max_price' ).val( ui.values[1] );
$('body').trigger('price_slider_slide', [ui.values[ 0 ], ui.values[ 1 ]] ); $( 'body' ).trigger( 'price_slider_slide', [ ui.values[0], ui.values[1] ] );
}, },
change: function( event, ui ) { change: function( event, ui ) {
$('body').trigger('price_slider_change', [ui.values[ 0 ], ui.values[ 1 ]] ); $( 'body' ).trigger( 'price_slider_change', [ ui.values[0], ui.values[1] ] );
}, },
}); });

View File

@ -1 +1 @@
jQuery(function(a){if("undefined"==typeof woocommerce_price_slider_params)return!1;a("input#min_price, input#max_price").hide(),a(".price_slider, .price_label").show();var b=a(".price_slider_amount #min_price").data("min"),c=a(".price_slider_amount #max_price").data("max");current_min_price=parseInt(b),current_max_price=parseInt(c),woocommerce_price_slider_params.min_price&&(current_min_price=parseInt(woocommerce_price_slider_params.min_price)),woocommerce_price_slider_params.max_price&&(current_max_price=parseInt(woocommerce_price_slider_params.max_price)),a("body").bind("price_slider_create price_slider_slide",function(b,c,d){"left"==woocommerce_price_slider_params.currency_pos?(a(".price_slider_amount span.from").html(woocommerce_price_slider_params.currency_symbol+c),a(".price_slider_amount span.to").html(woocommerce_price_slider_params.currency_symbol+d)):"left_space"==woocommerce_price_slider_params.currency_pos?(a(".price_slider_amount span.from").html(woocommerce_price_slider_params.currency_symbol+" "+c),a(".price_slider_amount span.to").html(woocommerce_price_slider_params.currency_symbol+" "+d)):"right"==woocommerce_price_slider_params.currency_pos?(a(".price_slider_amount span.from").html(c+woocommerce_price_slider_params.currency_symbol),a(".price_slider_amount span.to").html(d+woocommerce_price_slider_params.currency_symbol)):"right_space"==woocommerce_price_slider_params.currency_pos&&(a(".price_slider_amount span.from").html(c+" "+woocommerce_price_slider_params.currency_symbol),a(".price_slider_amount span.to").html(d+" "+woocommerce_price_slider_params.currency_symbol)),a("body").trigger("price_slider_updated",c,d)}),a(".price_slider").slider({range:!0,animate:!0,min:b,max:c,values:[current_min_price,current_max_price],create:function(){a(".price_slider_amount #min_price").val(current_min_price),a(".price_slider_amount #max_price").val(current_max_price),a("body").trigger("price_slider_create",[current_min_price,current_max_price])},slide:function(b,c){a("input#min_price").val(c.values[0]),a("input#max_price").val(c.values[1]),a("body").trigger("price_slider_slide",[c.values[0],c.values[1]])},change:function(b,c){a("body").trigger("price_slider_change",[c.values[0],c.values[1]])}})}); jQuery(function(e){if(typeof woocommerce_price_slider_params==="undefined"){return false}e("input#min_price, input#max_price").hide();e(".price_slider, .price_label").show();var t=e(".price_slider_amount #min_price").data("min"),n=e(".price_slider_amount #max_price").data("max");current_min_price=parseInt(t,10);current_max_price=parseInt(n,10);if(woocommerce_price_slider_params.min_price)current_min_price=parseInt(woocommerce_price_slider_params.min_price,10);if(woocommerce_price_slider_params.max_price)current_max_price=parseInt(woocommerce_price_slider_params.max_price,10);e("body").bind("price_slider_create price_slider_slide",function(t,n,r){if(woocommerce_price_slider_params.currency_pos==="left"){e(".price_slider_amount span.from").html(woocommerce_price_slider_params.currency_symbol+n);e(".price_slider_amount span.to").html(woocommerce_price_slider_params.currency_symbol+r)}else if(woocommerce_price_slider_params.currency_pos==="left_space"){e(".price_slider_amount span.from").html(woocommerce_price_slider_params.currency_symbol+" "+n);e(".price_slider_amount span.to").html(woocommerce_price_slider_params.currency_symbol+" "+r)}else if(woocommerce_price_slider_params.currency_pos==="right"){e(".price_slider_amount span.from").html(n+woocommerce_price_slider_params.currency_symbol);e(".price_slider_amount span.to").html(r+woocommerce_price_slider_params.currency_symbol)}else if(woocommerce_price_slider_params.currency_pos==="right_space"){e(".price_slider_amount span.from").html(n+" "+woocommerce_price_slider_params.currency_symbol);e(".price_slider_amount span.to").html(r+" "+woocommerce_price_slider_params.currency_symbol)}e("body").trigger("price_slider_updated",n,r)});e(".price_slider").slider({range:true,animate:true,min:t,max:n,values:[current_min_price,current_max_price],create:function(t,n){e(".price_slider_amount #min_price").val(current_min_price);e(".price_slider_amount #max_price").val(current_max_price);e("body").trigger("price_slider_create",[current_min_price,current_max_price])},slide:function(t,n){e("input#min_price").val(n.values[0]);e("input#max_price").val(n.values[1]);e("body").trigger("price_slider_slide",[n.values[0],n.values[1]])},change:function(t,n){e("body").trigger("price_slider_change",[n.values[0],n.values[1]])}})})

View File

@ -1,8 +1,9 @@
jQuery( function( $ ) { jQuery( function( $ ) {
// wc_single_product_params is required to continue, ensure the object exists // wc_single_product_params is required to continue, ensure the object exists
if ( typeof wc_single_product_params === "undefined" ) if ( typeof wc_single_product_params === 'undefined' ) {
return false; return false;
}
// Tabs // Tabs
$( '.woocommerce-tabs .panel' ).hide(); $( '.woocommerce-tabs .panel' ).hide();

View File

@ -1 +1 @@
jQuery(function(a){return"undefined"==typeof wc_single_product_params?!1:(a(".woocommerce-tabs .panel").hide(),a(".woocommerce-tabs ul.tabs li a").click(function(){var b=a(this),c=b.closest(".woocommerce-tabs");return a("ul.tabs li",c).removeClass("active"),a("div.panel",c).hide(),a("div"+b.attr("href"),c).show(),b.parent().addClass("active"),!1}),a(".woocommerce-tabs").each(function(){var b=window.location.hash,c=window.location.href,d=a(this);b.toLowerCase().indexOf("comment-")>=0?a("ul.tabs li.reviews_tab a",d).click():c.indexOf("comment-page-")>0||c.indexOf("cpage=")>0?a("ul.tabs li.reviews_tab a",a(this)).click():a("ul.tabs li:first a",d).click()}),a("a.woocommerce-review-link").click(function(){return a(".reviews_tab a").click(),!0}),a("#rating").hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>'),a("body").on("click","#respond p.stars a",function(){var b=a(this),c=a(this).closest("#respond").find("#rating");return c.val(b.text()),b.siblings("a").removeClass("active"),b.addClass("active"),!1}).on("click","#respond #submit",function(){var b=a(this).closest("#respond").find("#rating"),c=b.val();return b.size()>0&&!c&&"yes"===wc_single_product_params.review_rating_required?(alert(wc_single_product_params.i18n_required_rating_text),!1):void 0}),void a("form.cart").submit(function(){a(this).find(":submit").attr("disabled","disabled")}))}); jQuery(function(e){if(typeof wc_single_product_params==="undefined"){return false}e(".woocommerce-tabs .panel").hide();e(".woocommerce-tabs ul.tabs li a").click(function(){var t=e(this),n=t.closest(".woocommerce-tabs");e("ul.tabs li",n).removeClass("active");e("div.panel",n).hide();e("div"+t.attr("href"),n).show();t.parent().addClass("active");return false});e(".woocommerce-tabs").each(function(){var t=window.location.hash,n=window.location.href,r=e(this);if(t.toLowerCase().indexOf("comment-")>=0){e("ul.tabs li.reviews_tab a",r).click()}else if(n.indexOf("comment-page-")>0||n.indexOf("cpage=")>0){e("ul.tabs li.reviews_tab a",e(this)).click()}else{e("ul.tabs li:first a",r).click()}});e("a.woocommerce-review-link").click(function(){e(".reviews_tab a").click();return true});e("#rating").hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>');e("body").on("click","#respond p.stars a",function(){var t=e(this),n=e(this).closest("#respond").find("#rating");n.val(t.text());t.siblings("a").removeClass("active");t.addClass("active");return false}).on("click","#respond #submit",function(){var t=e(this).closest("#respond").find("#rating"),n=t.val();if(t.size()>0&&!n&&wc_single_product_params.review_rating_required==="yes"){alert(wc_single_product_params.i18n_required_rating_text);return false}});e("form.cart").submit(function(){e(this).find(":submit").attr("disabled","disabled")})})

View File

@ -1,57 +1,57 @@
jQuery(function($) { jQuery( function( $ ) {
// Orderby // Orderby
$('.woocommerce-ordering').on( 'change', 'select.orderby', function() { $( '.woocommerce-ordering' ).on( 'change', 'select.orderby', function() {
$(this).closest('form').submit(); $( this ).closest( 'form' ).submit();
}); });
// Quantity buttons // Quantity buttons
$("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass('buttons_added').append('<input type="button" value="+" class="plus" />').prepend('<input type="button" value="-" class="minus" />'); $( 'div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)' ).addClass( 'buttons_added' ).append( '<input type="button" value="+" class="plus" />' ).prepend( '<input type="button" value="-" class="minus" />' );
// Target quantity inputs on product pages // Target quantity inputs on product pages
$("input.qty:not(.product-quantity input.qty)").each(function(){ $( 'input.qty:not(.product-quantity input.qty)' ).each( function() {
var min = parseFloat( $(this).attr('min') ); var min = parseFloat( $( this ).attr( 'min' ) );
if ( min && min > 0 && parseFloat( $(this).val() ) < min ) { if ( min && min > 0 && parseFloat( $( this ).val() ) < min ) {
$(this).val( min ); $( this ).val( min );
} }
}); });
$(document).on( 'click', '.plus, .minus', function() { $( document ).on( 'click', '.plus, .minus', function() {
// Get values // Get values
var $qty = $(this).closest('.quantity').find(".qty"); var $qty = $( this ).closest( '.quantity' ).find( '.qty' ),
var currentVal = parseFloat( $qty.val() ); currentVal = parseFloat( $qty.val() ),
var max = parseFloat( $qty.attr('max') ); max = parseFloat( $qty.attr( 'max' ) ),
var min = parseFloat( $qty.attr('min') ); min = parseFloat( $qty.attr( 'min' ) ),
var step = $qty.attr('step'); step = $qty.attr( 'step' );
// Format values // Format values
if ( ! currentVal || currentVal == "" || currentVal == "NaN" ) currentVal = 0; if ( ! currentVal || currentVal === '' || currentVal === 'NaN' ) currentVal = 0;
if ( max == "" || max == "NaN" ) max = ''; if ( max === '' || max === 'NaN' ) max = '';
if ( min == "" || min == "NaN" ) min = 0; if ( min === '' || min === 'NaN' ) min = 0;
if ( step == 'any' || step == "" || step == undefined || parseFloat( step ) == "NaN" ) step = 1; if ( step === 'any' || step === '' || step === undefined || parseFloat( step ) === 'NaN' ) step = 1;
// Change the value // Change the value
if ( $(this).is('.plus') ) { if ( $( this ).is( '.plus' ) ) {
if ( max && ( max == currentVal || currentVal > max ) ) { if ( max && ( max == currentVal || currentVal > max ) ) {
$qty.val( max ); $qty.val( max );
} else { } else {
$qty.val( currentVal + parseFloat( step ) ); $qty.val( currentVal + parseFloat( step ) );
} }
} else { } else {
if ( min && ( min==currentVal || currentVal < min ) ) { if ( min && ( min == currentVal || currentVal < min ) ) {
$qty.val( min ); $qty.val( min );
} else if ( currentVal > 0 ) { } else if ( currentVal > 0 ) {
$qty.val( currentVal - parseFloat( step ) ); $qty.val( currentVal - parseFloat( step ) );
} }
} }
// Trigger change event // Trigger change event
$qty.trigger('change'); $qty.trigger( 'change' );
}); });
}); });

View File

@ -1 +1 @@
jQuery(function(a){a(".woocommerce-ordering").on("change","select.orderby",function(){a(this).closest("form").submit()}),a("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" class="plus" />').prepend('<input type="button" value="-" class="minus" />'),a("input.qty:not(.product-quantity input.qty)").each(function(){var b=parseFloat(a(this).attr("min"));b&&b>0&&parseFloat(a(this).val())<b&&a(this).val(b)}),a(document).on("click",".plus, .minus",function(){var b=a(this).closest(".quantity").find(".qty"),c=parseFloat(b.val()),d=parseFloat(b.attr("max")),e=parseFloat(b.attr("min")),f=b.attr("step");c&&""!=c&&"NaN"!=c||(c=0),(""==d||"NaN"==d)&&(d=""),(""==e||"NaN"==e)&&(e=0),("any"==f||""==f||void 0==f||"NaN"==parseFloat(f))&&(f=1),a(this).is(".plus")?b.val(d&&(d==c||c>d)?d:c+parseFloat(f)):e&&(e==c||e>c)?b.val(e):c>0&&b.val(c-parseFloat(f)),b.trigger("change")})}); jQuery(function(e){e(".woocommerce-ordering").on("change","select.orderby",function(){e(this).closest("form").submit()});e("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" class="plus" />').prepend('<input type="button" value="-" class="minus" />');e("input.qty:not(.product-quantity input.qty)").each(function(){var t=parseFloat(e(this).attr("min"));if(t&&t>0&&parseFloat(e(this).val())<t){e(this).val(t)}});e(document).on("click",".plus, .minus",function(){var t=e(this).closest(".quantity").find(".qty"),n=parseFloat(t.val()),r=parseFloat(t.attr("max")),i=parseFloat(t.attr("min")),s=t.attr("step");if(!n||n===""||n==="NaN")n=0;if(r===""||r==="NaN")r="";if(i===""||i==="NaN")i=0;if(s==="any"||s===""||s===undefined||parseFloat(s)==="NaN")s=1;if(e(this).is(".plus")){if(r&&(r==n||n>r)){t.val(r)}else{t.val(n+parseFloat(s))}}else{if(i&&(i==n||n<i)){t.val(i)}else if(n>0){t.val(n-parseFloat(s))}}t.trigger("change")})})