From 62d879e86cb5901864045a4774e93ddf9d378991 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Fri, 10 Jul 2015 02:13:30 -0300 Subject: [PATCH] Fixed all jshint errors #4680 --- assets/js/admin/reports.js | 15 +- assets/js/admin/reports.min.js | 2 +- assets/js/admin/users.js | 2 +- assets/js/frontend/add-payment-method.js | 3 +- assets/js/frontend/add-to-cart-variation.js | 134 ++++++++++-------- .../js/frontend/add-to-cart-variation.min.js | 2 +- assets/js/frontend/add-to-cart.js | 18 ++- assets/js/frontend/add-to-cart.min.js | 2 +- assets/js/frontend/address-i18n.js | 3 +- assets/js/frontend/country-select.js | 4 +- assets/js/frontend/geolocation.js | 19 +-- assets/js/frontend/geolocation.min.js | 2 +- assets/js/frontend/single-product.js | 27 ++-- assets/js/frontend/single-product.min.js | 2 +- 14 files changed, 128 insertions(+), 107 deletions(-) diff --git a/assets/js/admin/reports.js b/assets/js/admin/reports.js index 1e89a35953b..b816208dfcf 100644 --- a/assets/js/admin/reports.js +++ b/assets/js/admin/reports.js @@ -138,6 +138,7 @@ jQuery(function( $ ) { var groupby = $( this ) .data( 'groupby' ); var export_format = $( this ).data( 'export' ); var csv_data = 'data:application/csv;charset=utf-8,'; + var s, series_data, d; if ( 'table' === export_format ) { @@ -183,7 +184,7 @@ jQuery(function( $ ) { }); // CSV Headers - for ( var s = 0; s < series.length; ++s ) { + for ( s = 0; s < series.length; ++s ) { csv_data += series[s].label + ','; } @@ -193,9 +194,9 @@ jQuery(function( $ ) { // Get x axis values var xaxis = {}; - for ( var s = 0; s < series.length; ++s ) { - var series_data = series[s].data; - for ( var d = 0; d < series_data.length; ++d ) { + for ( s = 0; s < series.length; ++s ) { + series_data = series[s].data; + for ( d = 0; d < series_data.length; ++d ) { xaxis[series_data[d][0]] = []; // Zero values to start for ( var i = 0; i < series.length; ++i ) { @@ -205,9 +206,9 @@ jQuery(function( $ ) { } // Add chart data - for ( var s = 0; s < series.length; ++s ) { - var series_data = series[s].data; - for ( var d = 0; d < series_data.length; ++d ) { + for ( s = 0; s < series.length; ++s ) { + series_data = series[s].data; + for ( d = 0; d < series_data.length; ++d ) { xaxis[series_data[d][0]][s] = series_data[d][1]; } } diff --git a/assets/js/admin/reports.min.js b/assets/js/admin/reports.min.js index df80ae7524f..2f0b9c2c965 100644 --- a/assets/js/admin/reports.min.js +++ b/assets/js/admin/reports.min.js @@ -1 +1 @@ -jQuery(function(a){function b(b,c,d){a('
'+d+"
").css({top:c-16,left:b+20}).appendTo("body").fadeIn(200)}var c=null,d=null;a(".chart-placeholder").bind("plothover",function(e,f,g){if(g){if((c!==g.dataIndex||d!==g.seriesIndex)&&(c=g.dataIndex,d=g.seriesIndex,a(".chart-tooltip").remove(),g.series.points.show||g.series.enable_tooltip)){var h=g.series.data[g.dataIndex][1],i="";g.series.prepend_label&&(i=i+g.series.label+": "),g.series.prepend_tooltip&&(i+=g.series.prepend_tooltip),i+=h,g.series.append_tooltip&&(i+=g.series.append_tooltip),g.series.pie.show?b(f.pageX,f.pageY,i):b(g.pageX,g.pageY,i)}}else a(".chart-tooltip").remove(),c=null}),a(".wc_sparkline.bars").each(function(){var b=a(this).data("sparkline"),c={grid:{show:!1}},d=[{data:b,color:a(this).data("color"),bars:{fillColor:a(this).data("color"),fill:!0,show:!0,lineWidth:1,barWidth:a(this).data("barwidth"),align:"center"},shadowSize:0}];a.plot(a(this),d,c)}),a(".wc_sparkline.lines").each(function(){var b=a(this).data("sparkline"),c={grid:{show:!1}},d=[{data:b,color:a(this).data("color"),lines:{fill:!1,show:!0,lineWidth:1,align:"center"},shadowSize:0}];a.plot(a(this),d,c)});var e=a(".range_datepicker").datepicker({changeMonth:!0,changeYear:!0,defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,maxDate:"+0D",showButtonPanel:!0,showOn:"focus",buttonImageOnly:!0,onSelect:function(b){var c=a(this).is(".from")?"minDate":"maxDate",d=a(this).data("datepicker"),f=a.datepicker.parseDate(d.settings.dateFormat||a.datepicker._defaults.dateFormat,b,d.settings);e.not(this).datepicker("option",c,f)}}),f=document.createElement("a");"undefined"==typeof f.download&&a(".export_csv").hide(),a(".export_csv").click(function(){var b=a(this).data("exclude_series")||"";b=b.toString(),b=b.split(",");var c=a(this).data("xaxes"),d=a(this).data("groupby"),e=a(this).data("export"),f="data:application/csv;charset=utf-8,";if("table"===e)a(this).closest("div").find("thead tr,tbody tr").each(function(){a(this).find("th, td").each(function(){var b=a(this).text();b=b.replace("[?]",""),f+='"'+b+'",'}),f=f.substring(0,f.length-1),f+="\n"}),a(this).closest("div").find("tfoot tr").each(function(){a(this).find("th, td").each(function(){var b=a(this).text();if(b=b.replace("[?]",""),f+='"'+b+'",',a(this).attr("colspan")>0)for(m=1;m'+d+"").css({top:c-16,left:b+20}).appendTo("body").fadeIn(200)}var c=null,d=null;a(".chart-placeholder").bind("plothover",function(e,f,g){if(g){if((c!==g.dataIndex||d!==g.seriesIndex)&&(c=g.dataIndex,d=g.seriesIndex,a(".chart-tooltip").remove(),g.series.points.show||g.series.enable_tooltip)){var h=g.series.data[g.dataIndex][1],i="";g.series.prepend_label&&(i=i+g.series.label+": "),g.series.prepend_tooltip&&(i+=g.series.prepend_tooltip),i+=h,g.series.append_tooltip&&(i+=g.series.append_tooltip),g.series.pie.show?b(f.pageX,f.pageY,i):b(g.pageX,g.pageY,i)}}else a(".chart-tooltip").remove(),c=null}),a(".wc_sparkline.bars").each(function(){var b=a(this).data("sparkline"),c={grid:{show:!1}},d=[{data:b,color:a(this).data("color"),bars:{fillColor:a(this).data("color"),fill:!0,show:!0,lineWidth:1,barWidth:a(this).data("barwidth"),align:"center"},shadowSize:0}];a.plot(a(this),d,c)}),a(".wc_sparkline.lines").each(function(){var b=a(this).data("sparkline"),c={grid:{show:!1}},d=[{data:b,color:a(this).data("color"),lines:{fill:!1,show:!0,lineWidth:1,align:"center"},shadowSize:0}];a.plot(a(this),d,c)});var e=a(".range_datepicker").datepicker({changeMonth:!0,changeYear:!0,defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,maxDate:"+0D",showButtonPanel:!0,showOn:"focus",buttonImageOnly:!0,onSelect:function(b){var c=a(this).is(".from")?"minDate":"maxDate",d=a(this).data("datepicker"),f=a.datepicker.parseDate(d.settings.dateFormat||a.datepicker._defaults.dateFormat,b,d.settings);e.not(this).datepicker("option",c,f)}}),f=document.createElement("a");"undefined"==typeof f.download&&a(".export_csv").hide(),a(".export_csv").click(function(){var b=a(this).data("exclude_series")||"";b=b.toString(),b=b.split(",");var c,d,e,f=a(this).data("xaxes"),g=a(this).data("groupby"),h=a(this).data("export"),i="data:application/csv;charset=utf-8,";if("table"===h)a(this).closest("div").find("thead tr,tbody tr").each(function(){a(this).find("th, td").each(function(){var b=a(this).text();b=b.replace("[?]",""),i+='"'+b+'",'}),i=i.substring(0,i.length-1),i+="\n"}),a(this).closest("div").find("tfoot tr").each(function(){a(this).find("th, td").each(function(){var b=a(this).text();if(b=b.replace("[?]",""),i+='"'+b+'",',a(this).attr("colspan")>0)for(m=1;m' + all_variations[ selected_index ].variation_description + ''; return var_description_html; @@ -62,10 +62,10 @@ this.find( '.variations select' ).unbind( 'change focusin' ); // Bind events - $form = this + var $form = this // On clicking the reset variation button - .on( 'click', '.reset_variations', function( event ) { + .on( 'click', '.reset_variations', function() { $( this ).closest( '.variations_form' ).find( '.variations select' ).val( '' ).change(); @@ -73,27 +73,30 @@ $weight = $( this ).closest( '.product' ).find( '.product_weight' ), $dimensions = $( this ).closest( '.product' ).find( '.product_dimensions' ); - if ( $sku.attr( 'data-o_sku' ) ) + if ( $sku.attr( 'data-o_sku' ) ) { $sku.text( $sku.attr( 'data-o_sku' ) ); + } - if ( $weight.attr( 'data-o_weight' ) ) + if ( $weight.attr( 'data-o_weight' ) ) { $weight.text( $weight.attr( 'data-o_weight' ) ); + } - if ( $dimensions.attr( 'data-o_dimensions' ) ) + if ( $dimensions.attr( 'data-o_dimensions' ) ) { $dimensions.text( $dimensions.attr( 'data-o_dimensions' ) ); + } return false; } ) // Upon changing an option - .on( 'change', '.variations select', function( event ) { + .on( 'change', '.variations select', function() { var $variation_form = $( this ).closest( '.variations_form' ), var_description = $.fn.wc_variation_form.get_variation_description_html( $variation_form, this.selectedIndex ); // remove variation description on change $variation_form.find( '.variations' ).next( '.woocommerce-variation-description' ).remove(); - + // display variation description if ( var_description ) { $variation_form.find( '.variations' ).after( var_description ); @@ -121,15 +124,17 @@ } ) // Upon gaining focus - .on( 'focusin touchstart', '.variations select', function( event ) { + .on( 'focusin touchstart', '.variations select', function() { - $variation_form = $( this ).closest( '.variations_form' ); + var attribute_name, + $variation_form = $( this ).closest( '.variations_form' ); // Get attribute name from data-attribute_name, or from input name if it doesn't exist - if ( typeof( $( this ).data( 'attribute_name' ) ) != 'undefined' ) + if ( typeof( $( this ).data( 'attribute_name' ) ) !== 'undefined' ) { attribute_name = $( this ).data( 'attribute_name' ); - else + } else { attribute_name = $( this ).attr( 'name' ); + } $variation_form .trigger( 'woocommerce_variation_select_focusin' ) @@ -139,9 +144,9 @@ // Check variations .on( 'check_variations', function( event, exclude, focus ) { - var all_set = true, + var attribute_name, $variation_input, + all_set = true, any_set = false, - showing_variation = false, current_settings = {}, $variation_form = $( this ), $reset_variations = $variation_form.find( '.reset_variations' ); @@ -149,11 +154,11 @@ $variation_form.find( '.variations select' ).each( function() { // Get attribute name from data-attribute_name, or from input name if it doesn't exist - if ( typeof( $( this ).data( 'attribute_name' ) ) != 'undefined' ) + if ( typeof( $( this ).data( 'attribute_name' ) ) !== 'undefined' ) { attribute_name = $( this ).data( 'attribute_name' ); - else + } else { attribute_name = $( this ).attr( 'name' ); - + } if ( $( this ).val().length === 0 ) { all_set = false; @@ -167,26 +172,25 @@ current_settings[ attribute_name ] = ''; } else { - - // Encode entities - value = $( this ).val(); - // Add to settings array - current_settings[ attribute_name ] = value; + current_settings[ attribute_name ] = $( this ).val(); } }); - var product_id = parseInt( $variation_form.data( 'product_id' ) ), + var product_id = parseInt( $variation_form.data( 'product_id' ), 10 ), all_variations = $variation_form.data( 'product_variations' ); // Fallback to window property if not set - backwards compat - if ( ! all_variations ) + if ( ! all_variations ) { all_variations = window.product_variations.product_id; - if ( ! all_variations ) + } + if ( ! all_variations ) { all_variations = window.product_variations; - if ( ! all_variations ) + } + if ( ! all_variations ) { all_variations = window['product_variations_' + product_id ]; + } var matching_variations = $.fn.wc_variation_form.find_matching_variations( all_variations, current_settings ); @@ -199,10 +203,11 @@ // Found - set ID // Get variation input by class, or by input name if class doesn't exist - if ( $variation_form.find( 'input.variation_id' ).length > 0 ) + if ( $variation_form.find( 'input.variation_id' ).length > 0 ) { $variation_input = $variation_form.find( 'input.variation_id' ); - else + } else { $variation_input = $variation_form.find( 'input[name=variation_id]' ); + } // Set ID $variation_input @@ -216,10 +221,11 @@ // Nothing found - reset fields $variation_form.find( '.variations select' ).val( '' ); - if ( ! focus ) + if ( ! focus ) { $variation_form.trigger( 'reset_image' ); + } - alert( wc_add_to_cart_variation_params.i18n_no_matching_variations_text ); + window.alert( wc_add_to_cart_variation_params.i18n_no_matching_variations_text ); } @@ -227,32 +233,29 @@ $variation_form.trigger( 'update_variation_values', [ matching_variations ] ); - if ( ! focus ) + if ( ! focus ) { $variation_form.trigger( 'reset_image' ); + } if ( ! exclude ) { $variation_form.find( '.single_variation_wrap' ).slideUp( 200 ).trigger( 'hide_variation' ); } - } if ( any_set ) { - - if ( $reset_variations.css( 'visibility' ) === 'hidden' ) + if ( $reset_variations.css( 'visibility' ) === 'hidden' ) { $reset_variations.css( 'visibility', 'visible' ).hide().fadeIn(); - + } } else { - $reset_variations.css( 'visibility', 'hidden' ); - $sku = $( this ).closest( '.product' ).find( '.sku' ); + var $sku = $( this ).closest( '.product' ).find( '.sku' ); $sku.text( $sku.attr( 'data-o_sku' ) ); - } } ) // Reset product image - .on( 'reset_image', function( event ) { + .on( 'reset_image', function() { var $product = $(this).closest( '.product' ), $product_img = $product.find( 'div.images img:eq(0)' ), @@ -288,16 +291,18 @@ // Disable option fields that are unavaiable for current set of attributes .on( 'update_variation_values', function( event, variations ) { - $variation_form = $( this ).closest( '.variations_form' ); + var $variation_form = $( this ).closest( '.variations_form' ); // Loop through selects and disable/enable options based on selections $variation_form.find( '.variations select' ).each( function( index, el ) { - current_attr_select = $( el ); + var current_attr_name, variation_active, + current_attr_select = $( el ); // Reset options - if ( ! current_attr_select.data( 'attribute_options' ) ) + if ( ! current_attr_select.data( 'attribute_options' ) ) { current_attr_select.data( 'attribute_options', current_attr_select.find( 'option:gt(0)' ).get() ); + } current_attr_select.find( 'option:gt(0)' ).remove(); current_attr_select.append( current_attr_select.data( 'attribute_options' ) ); @@ -307,15 +312,16 @@ current_attr_select.find( 'option:gt(0)' ).removeAttr( 'disabled' ); // Get name from data-attribute_name, or from input name if it doesn't exist - if ( typeof( current_attr_select.data( 'attribute_name' ) ) != 'undefined' ) + if ( typeof( current_attr_select.data( 'attribute_name' ) ) !== 'undefined' ) { current_attr_name = current_attr_select.data( 'attribute_name' ); - else + } else { current_attr_name = current_attr_select.attr( 'name' ); + } // Loop through variations for ( var num in variations ) { - if ( typeof( variations[ num ] ) != 'undefined' ) { + if ( typeof( variations[ num ] ) !== 'undefined' ) { var attributes = variations[ num ].attributes; @@ -323,12 +329,13 @@ if ( attributes.hasOwnProperty( attr_name ) ) { var attr_val = attributes[ attr_name ]; - if ( attr_name == current_attr_name ) { + if ( attr_name === current_attr_name ) { - if ( variations[ num ].variation_is_active ) + if ( variations[ num ].variation_is_active ) { variation_active = 'enabled'; - else + } else { variation_active = ''; + } if ( attr_val ) { @@ -336,8 +343,8 @@ attr_val = $( '
' ).html( attr_val ).text(); // Add slashes - attr_val = attr_val.replace( /'/g, "\\'" ); - attr_val = attr_val.replace( /"/g, "\\\"" ); + attr_val = attr_val.replace( /'/g, '\\\'' ); + attr_val = attr_val.replace( /"/g, '\\\"' ); // Compare the meerkat current_attr_select.find( 'option[value="' + attr_val + '"]' ).addClass( 'attached ' + variation_active ); @@ -379,8 +386,7 @@ variation_image = variation.image_src, variation_link = variation.image_link, variation_caption = variation.image_caption, - variation_title = variation.image_title, - variation_alt = variation.image_alt; + variation_title = variation.image_title; $variation_form.find( '.variations_button' ).show(); $variation_form.find( '.single_variation' ).html( variation.price_html + variation.availability_html ); @@ -428,14 +434,17 @@ $weight = $product.find( '.product_weight' ), $dimensions = $product.find( '.product_dimensions' ); - if ( ! $sku.attr( 'data-o_sku' ) ) + if ( ! $sku.attr( 'data-o_sku' ) ) { $sku.attr( 'data-o_sku', $sku.text() ); + } - if ( ! $weight.attr( 'data-o_weight' ) ) + if ( ! $weight.attr( 'data-o_weight' ) ) { $weight.attr( 'data-o_weight', $weight.text() ); + } - if ( ! $dimensions.attr( 'data-o_dimensions' ) ) + if ( ! $dimensions.attr( 'data-o_dimensions' ) ) { $dimensions.attr( 'data-o_dimensions', $dimensions.text() ); + } if ( variation.sku ) { $sku.text( variation.sku ); @@ -465,15 +474,17 @@ $variation_form.find( '.single_variation' ).html( '

' + wc_add_to_cart_variation_params.i18n_unavailable_text + '

' ); } - if ( variation.min_qty !== '' ) + if ( variation.min_qty !== '' ) { $single_variation_wrap.find( '.quantity input.qty' ).attr( 'min', variation.min_qty ).val( variation.min_qty ); - else + } else { $single_variation_wrap.find( '.quantity input.qty' ).removeAttr( 'min' ); + } - if ( variation.max_qty !== '' ) + if ( variation.max_qty !== '' ) { $single_variation_wrap.find( '.quantity input.qty' ).attr( 'max', variation.max_qty ); - else + } else { $single_variation_wrap.find( '.quantity input.qty' ).removeAttr( 'max' ); + } if ( variation.is_sold_individually === 'yes' ) { $single_variation_wrap.find( '.quantity input.qty' ).val( '1' ); @@ -492,8 +503,9 @@ $( function() { // wc_add_to_cart_variation_params is required to continue, ensure the object exists - if ( typeof wc_add_to_cart_variation_params === 'undefined' ) + if ( typeof wc_add_to_cart_variation_params === 'undefined' ) { return false; + } $( '.variations_form' ).wc_variation_form(); $( '.variations_form .variations select' ).change(); diff --git a/assets/js/frontend/add-to-cart-variation.min.js b/assets/js/frontend/add-to-cart-variation.min.js index d0f8c83173a..022dc7b7d10 100644 --- a/assets/js/frontend/add-to-cart-variation.min.js +++ b/assets/js/frontend/add-to-cart-variation.min.js @@ -1,4 +1,4 @@ /*! * Variations Plugin */ -!function(a,b,c,d){a.fn.wc_variation_form=function(){return a.fn.wc_variation_form.find_matching_variations=function(b,c){for(var d=[],e=0;e0&&(b--,d[b].hasOwnProperty("variation_description"))?c='
'+d[b].variation_description+"
":""},this.unbind("check_variations update_variation_values found_variation"),this.find(".reset_variations").unbind("click"),this.find(".variations select").unbind("change focusin"),$form=this.on("click",".reset_variations",function(){a(this).closest(".variations_form").find(".variations select").val("").change();var b=a(this).closest(".product").find(".sku"),c=a(this).closest(".product").find(".product_weight"),d=a(this).closest(".product").find(".product_dimensions");return b.attr("data-o_sku")&&b.text(b.attr("data-o_sku")),c.attr("data-o_weight")&&c.text(c.attr("data-o_weight")),d.attr("data-o_dimensions")&&d.text(d.attr("data-o_dimensions")),!1}).on("change",".variations select",function(){var b=a(this).closest(".variations_form"),c=a.fn.wc_variation_form.get_variation_description_html(b,this.selectedIndex);b.find(".variations").next(".woocommerce-variation-description").remove(),c&&b.find(".variations").after(c),b.find("input.variation_id").length>0?b.find("input.variation_id").val("").change():b.find("input[name=variation_id]").val("").change(),b.trigger("woocommerce_variation_select_change").trigger("check_variations",["",!1]),a(this).blur(),a().uniform&&a.isFunction(a.uniform.update)&&a.uniform.update(),b.trigger("woocommerce_variation_has_changed")}).on("focusin touchstart",".variations select",function(){$variation_form=a(this).closest(".variations_form"),attribute_name="undefined"!=typeof a(this).data("attribute_name")?a(this).data("attribute_name"):a(this).attr("name"),$variation_form.trigger("woocommerce_variation_select_focusin").trigger("check_variations",[attribute_name,!0])}).on("check_variations",function(c,d,e){var f=!0,g=!1,h={},i=a(this),j=i.find(".reset_variations");i.find(".variations select").each(function(){attribute_name="undefined"!=typeof a(this).data("attribute_name")?a(this).data("attribute_name"):a(this).attr("name"),0===a(this).val().length?f=!1:g=!0,d&&attribute_name===d?(f=!1,h[attribute_name]=""):(value=a(this).val(),h[attribute_name]=value)});var k=parseInt(i.data("product_id")),l=i.data("product_variations");l||(l=b.product_variations.product_id),l||(l=b.product_variations),l||(l=b["product_variations_"+k]);var m=a.fn.wc_variation_form.find_matching_variations(l,h);if(f){var n=m.shift();n?($variation_input=i.find(i.find("input.variation_id").length>0?"input.variation_id":"input[name=variation_id]"),$variation_input.val(n.variation_id).change(),i.trigger("found_variation",[n])):(i.find(".variations select").val(""),e||i.trigger("reset_image"),alert(wc_add_to_cart_variation_params.i18n_no_matching_variations_text))}else i.trigger("update_variation_values",[m]),e||i.trigger("reset_image"),d||i.find(".single_variation_wrap").slideUp(200).trigger("hide_variation");g?"hidden"===j.css("visibility")&&j.css("visibility","visible").hide().fadeIn():(j.css("visibility","hidden"),$sku=a(this).closest(".product").find(".sku"),$sku.text($sku.attr("data-o_sku")))}).on("reset_image",function(){var b=a(this).closest(".product"),c=b.find("div.images img:eq(0)"),e=b.find("div.images a.zoom:eq(0)"),f=c.attr("data-o_src"),g=c.attr("data-o_title"),h=c.attr("data-o_title"),i=e.attr("data-o_href");f!==d&&c.attr("src",f),i!==d&&e.attr("href",i),g!==d&&(c.attr("title",g),e.attr("title",g)),h!==d&&c.attr("alt",h)}).on("update_variation_values",function(b,c){$variation_form=a(this).closest(".variations_form"),$variation_form.find(".variations select").each(function(b,d){current_attr_select=a(d),current_attr_select.data("attribute_options")||current_attr_select.data("attribute_options",current_attr_select.find("option:gt(0)").get()),current_attr_select.find("option:gt(0)").remove(),current_attr_select.append(current_attr_select.data("attribute_options")),current_attr_select.find("option:gt(0)").removeClass("attached"),current_attr_select.find("option:gt(0)").removeClass("enabled"),current_attr_select.find("option:gt(0)").removeAttr("disabled"),current_attr_name="undefined"!=typeof current_attr_select.data("attribute_name")?current_attr_select.data("attribute_name"):current_attr_select.attr("name");for(var e in c)if("undefined"!=typeof c[e]){var f=c[e].attributes;for(var g in f)if(f.hasOwnProperty(g)){var h=f[g];g==current_attr_name&&(variation_active=c[e].variation_is_active?"enabled":"",h?(h=a("
").html(h).text(),h=h.replace(/'/g,"\\'"),h=h.replace(/"/g,'\\"'),current_attr_select.find('option[value="'+h+'"]').addClass("attached "+variation_active)):current_attr_select.find("option:gt(0)").addClass("attached "+variation_active))}}current_attr_select.find("option:gt(0):not(.attached)").remove(),current_attr_select.find("option:gt(0):not(.enabled)").attr("disabled","disabled")}),$variation_form.trigger("woocommerce_update_variation_values")}).on("found_variation",function(b,c){{var e=a(this),f=a(this).closest(".product"),g=f.find("div.images img:eq(0)"),h=f.find("div.images a.zoom:eq(0)"),i=g.attr("data-o_src"),j=g.attr("data-o_title"),k=g.attr("data-o_alt"),l=h.attr("data-o_href"),m=c.image_src,n=c.image_link,o=c.image_caption,p=c.image_title;c.image_alt}e.find(".variations_button").show(),e.find(".single_variation").html(c.price_html+c.availability_html),i===d&&(i=g.attr("src")?g.attr("src"):"",g.attr("data-o_src",i)),l===d&&(l=h.attr("href")?h.attr("href"):"",h.attr("data-o_href",l)),j===d&&(j=g.attr("title")?g.attr("title"):"",g.attr("data-o_title",j)),k===d&&(k=g.attr("alt")?g.attr("alt"):"",g.attr("data-o_alt",k)),m&&m.length>1?(g.attr("src",m).attr("alt",p).attr("title",p),h.attr("href",n).attr("title",o)):(g.attr("src",i).attr("alt",k).attr("title",j),h.attr("href",l).attr("title",j));var q=e.find(".single_variation_wrap"),r=f.find(".product_meta").find(".sku"),s=f.find(".product_weight"),t=f.find(".product_dimensions");r.attr("data-o_sku")||r.attr("data-o_sku",r.text()),s.attr("data-o_weight")||s.attr("data-o_weight",s.text()),t.attr("data-o_dimensions")||t.attr("data-o_dimensions",t.text()),r.text(c.sku?c.sku:r.attr("data-o_sku")),s.text(c.weight?c.weight:s.attr("data-o_weight")),t.text(c.dimensions?c.dimensions:t.attr("data-o_dimensions")),q.find(".quantity").show(),c.is_purchasable&&c.is_in_stock&&c.variation_is_visible||e.find(".variations_button").hide(),c.variation_is_visible||e.find(".single_variation").html("

"+wc_add_to_cart_variation_params.i18n_unavailable_text+"

"),""!==c.min_qty?q.find(".quantity input.qty").attr("min",c.min_qty).val(c.min_qty):q.find(".quantity input.qty").removeAttr("min"),""!==c.max_qty?q.find(".quantity input.qty").attr("max",c.max_qty):q.find(".quantity input.qty").removeAttr("max"),"yes"===c.is_sold_individually&&(q.find(".quantity input.qty").val("1"),q.find(".quantity").hide()),q.slideDown(200).trigger("show_variation",[c])}),$form.trigger("wc_variation_form"),$form},a(function(){return"undefined"==typeof wc_add_to_cart_variation_params?!1:(a(".variations_form").wc_variation_form(),void a(".variations_form .variations select").change())})}(jQuery,window,document); \ No newline at end of file +!function(a,b,c,d){a.fn.wc_variation_form=function(){a.fn.wc_variation_form.find_matching_variations=function(b,c){for(var d=[],e=0;e0&&(b--,d[b].hasOwnProperty("variation_description"))?c='
'+d[b].variation_description+"
":""},this.unbind("check_variations update_variation_values found_variation"),this.find(".reset_variations").unbind("click"),this.find(".variations select").unbind("change focusin");var c=this.on("click",".reset_variations",function(){a(this).closest(".variations_form").find(".variations select").val("").change();var b=a(this).closest(".product").find(".sku"),c=a(this).closest(".product").find(".product_weight"),d=a(this).closest(".product").find(".product_dimensions");return b.attr("data-o_sku")&&b.text(b.attr("data-o_sku")),c.attr("data-o_weight")&&c.text(c.attr("data-o_weight")),d.attr("data-o_dimensions")&&d.text(d.attr("data-o_dimensions")),!1}).on("change",".variations select",function(){var b=a(this).closest(".variations_form"),c=a.fn.wc_variation_form.get_variation_description_html(b,this.selectedIndex);b.find(".variations").next(".woocommerce-variation-description").remove(),c&&b.find(".variations").after(c),b.find("input.variation_id").length>0?b.find("input.variation_id").val("").change():b.find("input[name=variation_id]").val("").change(),b.trigger("woocommerce_variation_select_change").trigger("check_variations",["",!1]),a(this).blur(),a().uniform&&a.isFunction(a.uniform.update)&&a.uniform.update(),b.trigger("woocommerce_variation_has_changed")}).on("focusin touchstart",".variations select",function(){var b,c=a(this).closest(".variations_form");b="undefined"!=typeof a(this).data("attribute_name")?a(this).data("attribute_name"):a(this).attr("name"),c.trigger("woocommerce_variation_select_focusin").trigger("check_variations",[b,!0])}).on("check_variations",function(c,d,e){var f,g,h=!0,i=!1,j={},k=a(this),l=k.find(".reset_variations");k.find(".variations select").each(function(){f="undefined"!=typeof a(this).data("attribute_name")?a(this).data("attribute_name"):a(this).attr("name"),0===a(this).val().length?h=!1:i=!0,d&&f===d?(h=!1,j[f]=""):j[f]=a(this).val()});var m=parseInt(k.data("product_id"),10),n=k.data("product_variations");n||(n=b.product_variations.product_id),n||(n=b.product_variations),n||(n=b["product_variations_"+m]);var o=a.fn.wc_variation_form.find_matching_variations(n,j);if(h){var p=o.shift();p?(g=k.find(k.find("input.variation_id").length>0?"input.variation_id":"input[name=variation_id]"),g.val(p.variation_id).change(),k.trigger("found_variation",[p])):(k.find(".variations select").val(""),e||k.trigger("reset_image"),b.alert(wc_add_to_cart_variation_params.i18n_no_matching_variations_text))}else k.trigger("update_variation_values",[o]),e||k.trigger("reset_image"),d||k.find(".single_variation_wrap").slideUp(200).trigger("hide_variation");if(i)"hidden"===l.css("visibility")&&l.css("visibility","visible").hide().fadeIn();else{l.css("visibility","hidden");var q=a(this).closest(".product").find(".sku");q.text(q.attr("data-o_sku"))}}).on("reset_image",function(){var b=a(this).closest(".product"),c=b.find("div.images img:eq(0)"),e=b.find("div.images a.zoom:eq(0)"),f=c.attr("data-o_src"),g=c.attr("data-o_title"),h=c.attr("data-o_title"),i=e.attr("data-o_href");f!==d&&c.attr("src",f),i!==d&&e.attr("href",i),g!==d&&(c.attr("title",g),e.attr("title",g)),h!==d&&c.attr("alt",h)}).on("update_variation_values",function(b,c){var d=a(this).closest(".variations_form");d.find(".variations select").each(function(b,d){var e,f,g=a(d);g.data("attribute_options")||g.data("attribute_options",g.find("option:gt(0)").get()),g.find("option:gt(0)").remove(),g.append(g.data("attribute_options")),g.find("option:gt(0)").removeClass("attached"),g.find("option:gt(0)").removeClass("enabled"),g.find("option:gt(0)").removeAttr("disabled"),e="undefined"!=typeof g.data("attribute_name")?g.data("attribute_name"):g.attr("name");for(var h in c)if("undefined"!=typeof c[h]){var i=c[h].attributes;for(var j in i)if(i.hasOwnProperty(j)){var k=i[j];j===e&&(f=c[h].variation_is_active?"enabled":"",k?(k=a("
").html(k).text(),k=k.replace(/'/g,"\\'"),k=k.replace(/"/g,'\\"'),g.find('option[value="'+k+'"]').addClass("attached "+f)):g.find("option:gt(0)").addClass("attached "+f))}}g.find("option:gt(0):not(.attached)").remove(),g.find("option:gt(0):not(.enabled)").attr("disabled","disabled")}),d.trigger("woocommerce_update_variation_values")}).on("found_variation",function(b,c){var e=a(this),f=a(this).closest(".product"),g=f.find("div.images img:eq(0)"),h=f.find("div.images a.zoom:eq(0)"),i=g.attr("data-o_src"),j=g.attr("data-o_title"),k=g.attr("data-o_alt"),l=h.attr("data-o_href"),m=c.image_src,n=c.image_link,o=c.image_caption,p=c.image_title;e.find(".variations_button").show(),e.find(".single_variation").html(c.price_html+c.availability_html),i===d&&(i=g.attr("src")?g.attr("src"):"",g.attr("data-o_src",i)),l===d&&(l=h.attr("href")?h.attr("href"):"",h.attr("data-o_href",l)),j===d&&(j=g.attr("title")?g.attr("title"):"",g.attr("data-o_title",j)),k===d&&(k=g.attr("alt")?g.attr("alt"):"",g.attr("data-o_alt",k)),m&&m.length>1?(g.attr("src",m).attr("alt",p).attr("title",p),h.attr("href",n).attr("title",o)):(g.attr("src",i).attr("alt",k).attr("title",j),h.attr("href",l).attr("title",j));var q=e.find(".single_variation_wrap"),r=f.find(".product_meta").find(".sku"),s=f.find(".product_weight"),t=f.find(".product_dimensions");r.attr("data-o_sku")||r.attr("data-o_sku",r.text()),s.attr("data-o_weight")||s.attr("data-o_weight",s.text()),t.attr("data-o_dimensions")||t.attr("data-o_dimensions",t.text()),r.text(c.sku?c.sku:r.attr("data-o_sku")),s.text(c.weight?c.weight:s.attr("data-o_weight")),t.text(c.dimensions?c.dimensions:t.attr("data-o_dimensions")),q.find(".quantity").show(),c.is_purchasable&&c.is_in_stock&&c.variation_is_visible||e.find(".variations_button").hide(),c.variation_is_visible||e.find(".single_variation").html("

"+wc_add_to_cart_variation_params.i18n_unavailable_text+"

"),""!==c.min_qty?q.find(".quantity input.qty").attr("min",c.min_qty).val(c.min_qty):q.find(".quantity input.qty").removeAttr("min"),""!==c.max_qty?q.find(".quantity input.qty").attr("max",c.max_qty):q.find(".quantity input.qty").removeAttr("max"),"yes"===c.is_sold_individually&&(q.find(".quantity input.qty").val("1"),q.find(".quantity").hide()),q.slideDown(200).trigger("show_variation",[c])});return c.trigger("wc_variation_form"),c},a(function(){return"undefined"==typeof wc_add_to_cart_variation_params?!1:(a(".variations_form").wc_variation_form(),void a(".variations_form .variations select").change())})}(jQuery,window,document); \ No newline at end of file diff --git a/assets/js/frontend/add-to-cart.js b/assets/js/frontend/add-to-cart.js index 10725ed8573..1d0569349a5 100644 --- a/assets/js/frontend/add-to-cart.js +++ b/assets/js/frontend/add-to-cart.js @@ -1,19 +1,22 @@ +/*global wc_add_to_cart_params */ jQuery( function( $ ) { // wc_add_to_cart_params is required to continue, ensure the object exists - if ( typeof wc_add_to_cart_params === 'undefined' ) + if ( typeof wc_add_to_cart_params === 'undefined' ) { return false; + } // Ajax add to cart - $( document ).on( 'click', '.add_to_cart_button', function(e) { + $( document ).on( 'click', '.add_to_cart_button', function() { // AJAX add to cart request var $thisbutton = $( this ); if ( $thisbutton.is( '.product_type_simple' ) ) { - if ( ! $thisbutton.attr( 'data-product_id' ) ) + if ( ! $thisbutton.attr( 'data-product_id' ) ) { return true; + } $thisbutton.removeClass( 'added' ); $thisbutton.addClass( 'loading' ); @@ -30,8 +33,9 @@ jQuery( function( $ ) { // Ajax action $.post( wc_add_to_cart_params.wc_ajax_url + 'add_to_cart', data, function( response ) { - if ( ! response ) + if ( ! response ) { return; + } var this_page = window.location.toString(); @@ -52,12 +56,12 @@ jQuery( function( $ ) { $thisbutton.removeClass( 'loading' ); - fragments = response.fragments; - cart_hash = response.cart_hash; + var fragments = response.fragments; + var cart_hash = response.cart_hash; // Block fragments class if ( fragments ) { - $.each( fragments, function( key, value ) { + $.each( fragments, function( key ) { $( key ).addClass( 'updating' ); }); } diff --git a/assets/js/frontend/add-to-cart.min.js b/assets/js/frontend/add-to-cart.min.js index e6869749377..2d2f1aa23de 100644 --- a/assets/js/frontend/add-to-cart.min.js +++ b/assets/js/frontend/add-to-cart.min.js @@ -1 +1 @@ -jQuery(function(a){return"undefined"==typeof wc_add_to_cart_params?!1:void a(document).on("click",".add_to_cart_button",function(){var b=a(this);if(b.is(".product_type_simple")){if(!b.attr("data-product_id"))return!0;b.removeClass("added"),b.addClass("loading");var c={};return a.each(b.data(),function(a,b){c[a]=b}),a(document.body).trigger("adding_to_cart",[b,c]),a.post(wc_add_to_cart_params.wc_ajax_url+"add_to_cart",c,function(c){if(c){var d=window.location.toString();return d=d.replace("add-to-cart","added-to-cart"),c.error&&c.product_url?void(window.location=c.product_url):"yes"===wc_add_to_cart_params.cart_redirect_after_add?void(window.location=wc_add_to_cart_params.cart_url):(b.removeClass("loading"),fragments=c.fragments,cart_hash=c.cart_hash,fragments&&a.each(fragments,function(b){a(b).addClass("updating")}),a(".shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{opacity:.6}}),b.addClass("added"),wc_add_to_cart_params.is_cart||0!==b.parent().find(".added_to_cart").size()||b.after(' '+wc_add_to_cart_params.i18n_view_cart+""),fragments&&a.each(fragments,function(b,c){a(b).replaceWith(c)}),a(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock(),a(".shop_table.cart").load(d+" .shop_table.cart:eq(0) > *",function(){a(".shop_table.cart").stop(!0).css("opacity","1").unblock(),a(document.body).trigger("cart_page_refreshed")}),a(".cart_totals").load(d+" .cart_totals:eq(0) > *",function(){a(".cart_totals").stop(!0).css("opacity","1").unblock()}),a(document.body).trigger("added_to_cart",[fragments,cart_hash,b]),void 0)}}),!1}return!0})}); \ No newline at end of file +jQuery(function(a){return"undefined"==typeof wc_add_to_cart_params?!1:void a(document).on("click",".add_to_cart_button",function(){var b=a(this);if(b.is(".product_type_simple")){if(!b.attr("data-product_id"))return!0;b.removeClass("added"),b.addClass("loading");var c={};return a.each(b.data(),function(a,b){c[a]=b}),a(document.body).trigger("adding_to_cart",[b,c]),a.post(wc_add_to_cart_params.wc_ajax_url+"add_to_cart",c,function(c){if(c){var d=window.location.toString();if(d=d.replace("add-to-cart","added-to-cart"),c.error&&c.product_url)return void(window.location=c.product_url);if("yes"===wc_add_to_cart_params.cart_redirect_after_add)return void(window.location=wc_add_to_cart_params.cart_url);b.removeClass("loading");var e=c.fragments,f=c.cart_hash;e&&a.each(e,function(b){a(b).addClass("updating")}),a(".shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{opacity:.6}}),b.addClass("added"),wc_add_to_cart_params.is_cart||0!==b.parent().find(".added_to_cart").size()||b.after(' '+wc_add_to_cart_params.i18n_view_cart+""),e&&a.each(e,function(b,c){a(b).replaceWith(c)}),a(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock(),a(".shop_table.cart").load(d+" .shop_table.cart:eq(0) > *",function(){a(".shop_table.cart").stop(!0).css("opacity","1").unblock(),a(document.body).trigger("cart_page_refreshed")}),a(".cart_totals").load(d+" .cart_totals:eq(0) > *",function(){a(".cart_totals").stop(!0).css("opacity","1").unblock()}),a(document.body).trigger("added_to_cart",[e,f,b])}}),!1}return!0})}); \ No newline at end of file diff --git a/assets/js/frontend/address-i18n.js b/assets/js/frontend/address-i18n.js index ba5fda4cba2..026e096e8f2 100644 --- a/assets/js/frontend/address-i18n.js +++ b/assets/js/frontend/address-i18n.js @@ -1,7 +1,8 @@ +/*global wc_address_i18n_params */ jQuery( function( $ ) { // wc_address_i18n_params is required to continue, ensure the object exists - if (typeof wc_address_i18n_params === "undefined") { + if ( typeof wc_address_i18n_params === 'undefined' ) { return false; } diff --git a/assets/js/frontend/country-select.js b/assets/js/frontend/country-select.js index 1ccbf9b13fa..503f02845f0 100644 --- a/assets/js/frontend/country-select.js +++ b/assets/js/frontend/country-select.js @@ -18,7 +18,7 @@ jQuery( function( $ ) { formatNoMatches: function() { return wc_country_select_params.i18n_no_matches; }, - formatAjaxError: function( jqXHR, textStatus, errorThrown ) { + formatAjaxError: function() { return wc_country_select_params.i18n_ajax_error; }, formatInputTooShort: function( input, min ) { @@ -46,7 +46,7 @@ jQuery( function( $ ) { return wc_country_select_params.i18n_selection_too_long_n.replace( '%qty%', limit ); }, - formatLoadMore: function( pageNumber ) { + formatLoadMore: function() { return wc_country_select_params.i18n_load_more; }, formatSearching: function() { diff --git a/assets/js/frontend/geolocation.js b/assets/js/frontend/geolocation.js index f0a262df26a..988e7d3ac55 100644 --- a/assets/js/frontend/geolocation.js +++ b/assets/js/frontend/geolocation.js @@ -1,25 +1,26 @@ +/*global wc_geolocation_params */ jQuery( function( $ ) { var this_page = window.location.toString(); var $append_hashes = function() { if ( wc_geolocation_params.hash ) { - $( "a[href^='" + wc_geolocation_params.home_url + "']:not(a[href*='v=']), a[href^='/']:not(a[href*='v='])").each( function() { - var $this = $(this); - var href = $this.attr('href'); + $( 'a[href^="' + wc_geolocation_params.home_url + '"]:not(a[href*="v="]), a[href^="/"]:not(a[href*="v="])' ).each( function() { + var $this = $( this ); + var href = $this.attr( 'href' ); if ( href.indexOf( '?' ) > 0 ) { - $this.attr( "href", href + '&v=' + wc_geolocation_params.hash ); + $this.attr( 'href', href + '&v=' + wc_geolocation_params.hash ); } else { - $this.attr( "href", href + '?v=' + wc_geolocation_params.hash ); + $this.attr( 'href', href + '?v=' + wc_geolocation_params.hash ); } }); } - } + }; var $geolocation_redirect = function( hash ) { if ( this_page.indexOf( '?v=' ) > 0 || this_page.indexOf( '&v=' ) > 0 ) { - this_page = this_page.replace( /v=[^&]+/,"v=" + hash ); + this_page = this_page.replace( /v=[^&]+/, 'v=' + hash ); } else if ( this_page.indexOf( '?' ) > 0 ) { this_page = this_page + '&v=' + hash; } else { @@ -27,7 +28,7 @@ jQuery( function( $ ) { } window.location = this_page; - } + }; var $geolocate_customer = { url: wc_geolocation_params.wc_ajax_url + 'get_customer_location', @@ -48,4 +49,4 @@ jQuery( function( $ ) { }); $append_hashes(); -}); \ No newline at end of file +}); diff --git a/assets/js/frontend/geolocation.min.js b/assets/js/frontend/geolocation.min.js index f7937a5c3a9..07b8d89eb63 100644 --- a/assets/js/frontend/geolocation.min.js +++ b/assets/js/frontend/geolocation.min.js @@ -1 +1 @@ -jQuery(function(a){var b=window.location.toString(),c=function(){wc_geolocation_params.hash&&a("a[href^='"+wc_geolocation_params.home_url+"']:not(a[href*='v=']), a[href^='/']:not(a[href*='v='])").each(function(){var b=a(this),c=b.attr("href");c.indexOf("?")>0?b.attr("href",c+"&v="+wc_geolocation_params.hash):b.attr("href",c+"?v="+wc_geolocation_params.hash)})},d=function(a){b=b.indexOf("?v=")>0||b.indexOf("&v=")>0?b.replace(/v=[^&]+/,"v="+a):b.indexOf("?")>0?b+"&v="+a:b+"?v="+a,window.location=b},e={url:wc_geolocation_params.wc_ajax_url+"get_customer_location",type:"GET",success:function(a){a.success&&a.data.hash&&a.data.hash!==wc_geolocation_params.hash&&d(a.data.hash)}};"1"!==wc_geolocation_params.is_checkout&&a.ajax(e),a(document.body).on("added_to_cart",function(){c()}),c()}); \ No newline at end of file +jQuery(function(a){var b=window.location.toString(),c=function(){wc_geolocation_params.hash&&a('a[href^="'+wc_geolocation_params.home_url+'"]:not(a[href*="v="]), a[href^="/"]:not(a[href*="v="])').each(function(){var b=a(this),c=b.attr("href");c.indexOf("?")>0?b.attr("href",c+"&v="+wc_geolocation_params.hash):b.attr("href",c+"?v="+wc_geolocation_params.hash)})},d=function(a){b=b.indexOf("?v=")>0||b.indexOf("&v=")>0?b.replace(/v=[^&]+/,"v="+a):b.indexOf("?")>0?b+"&v="+a:b+"?v="+a,window.location=b},e={url:wc_geolocation_params.wc_ajax_url+"get_customer_location",type:"GET",success:function(a){a.success&&a.data.hash&&a.data.hash!==wc_geolocation_params.hash&&d(a.data.hash)}};"1"!==wc_geolocation_params.is_checkout&&a.ajax(e),a(document.body).on("added_to_cart",function(){c()}),c()}); \ No newline at end of file diff --git a/assets/js/frontend/single-product.js b/assets/js/frontend/single-product.js index aa7001f2645..dd1694b37e6 100644 --- a/assets/js/frontend/single-product.js +++ b/assets/js/frontend/single-product.js @@ -1,3 +1,4 @@ +/*global wc_single_product_params */ jQuery( function( $ ) { // wc_single_product_params is required to continue, ensure the object exists @@ -6,20 +7,20 @@ jQuery( function( $ ) { } // Tabs - $('.wc-tabs-wrapper, .woocommerce-tabs') + $( '.wc-tabs-wrapper, .woocommerce-tabs' ) .on( 'init', function() { - $('.wc-tab, .panel:not(.panel .panel)').hide(); + $( '.wc-tab, .panel:not(.panel .panel)' ).hide(); var hash = window.location.hash; var url = window.location.href; - var $tabs = $( this ).find('.wc-tabs, ul.tabs').first(); + var $tabs = $( this ).find( '.wc-tabs, ul.tabs' ).first(); - if ( hash.toLowerCase().indexOf( "comment-" ) >= 0 || hash == '#reviews' ) { - $tabs.find('li.reviews_tab a').click(); - } else if ( url.indexOf( "comment-page-" ) > 0 || url.indexOf( "cpage=" ) > 0 ) { - $tabs.find('li.reviews_tab a').click(); + if ( hash.toLowerCase().indexOf( 'comment-' ) >= 0 || hash === '#reviews' ) { + $tabs.find( 'li.reviews_tab a' ).click(); + } else if ( url.indexOf( 'comment-page-' ) > 0 || url.indexOf( 'cpage=' ) > 0 ) { + $tabs.find( 'li.reviews_tab a' ).click(); } else { - $tabs.find('li:first a').click(); + $tabs.find( 'li:first a' ).click(); } }) .on( 'click', '.wc-tabs li a, ul.tabs li a', function() { @@ -27,15 +28,15 @@ jQuery( function( $ ) { var $tabs_wrapper = $tab.closest( '.wc-tabs-wrapper, .woocommerce-tabs' ); var $tabs = $tabs_wrapper.find( '.wc-tabs, ul.tabs' ); - $tabs.find('li').removeClass( 'active' ); - $tabs_wrapper.find('.wc-tab, .panel:not(.panel .panel)').hide(); + $tabs.find( 'li' ).removeClass( 'active' ); + $tabs_wrapper.find( '.wc-tab, .panel:not(.panel .panel)' ).hide(); - $tab.closest('li').addClass( 'active' ); + $tab.closest( 'li' ).addClass( 'active' ); $tabs_wrapper.find( $tab.attr( 'href' ) ).show(); return false; }) - .trigger('init'); + .trigger( 'init' ); $( 'a.woocommerce-review-link' ).click( function() { $( '.reviews_tab a' ).click(); @@ -61,7 +62,7 @@ jQuery( function( $ ) { rating = $rating.val(); if ( $rating.size() > 0 && ! rating && wc_single_product_params.review_rating_required === 'yes' ) { - alert( wc_single_product_params.i18n_required_rating_text ); + window.alert( wc_single_product_params.i18n_required_rating_text ); return false; } diff --git a/assets/js/frontend/single-product.min.js b/assets/js/frontend/single-product.min.js index c5282aaae93..8a85b91b314 100644 --- a/assets/js/frontend/single-product.min.js +++ b/assets/js/frontend/single-product.min.js @@ -1 +1 @@ -jQuery(function(a){return"undefined"==typeof wc_single_product_params?!1:(a(".wc-tabs-wrapper, .woocommerce-tabs").on("init",function(){a(".wc-tab, .panel:not(.panel .panel)").hide();var b=window.location.hash,c=window.location.href,d=a(this).find(".wc-tabs, ul.tabs").first();b.toLowerCase().indexOf("comment-")>=0||"#reviews"==b?d.find("li.reviews_tab a").click():c.indexOf("comment-page-")>0||c.indexOf("cpage=")>0?d.find("li.reviews_tab a").click():d.find("li:first a").click()}).on("click",".wc-tabs li a, ul.tabs li a",function(){var b=a(this),c=b.closest(".wc-tabs-wrapper, .woocommerce-tabs"),d=c.find(".wc-tabs, ul.tabs");return d.find("li").removeClass("active"),c.find(".wc-tab, .panel:not(.panel .panel)").hide(),b.closest("li").addClass("active"),c.find(b.attr("href")).show(),!1}).trigger("init"),a("a.woocommerce-review-link").click(function(){return a(".reviews_tab a").click(),!0}),a("#rating").hide().before('

12345

'),void 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}))}); \ No newline at end of file +jQuery(function(a){return"undefined"==typeof wc_single_product_params?!1:(a(".wc-tabs-wrapper, .woocommerce-tabs").on("init",function(){a(".wc-tab, .panel:not(.panel .panel)").hide();var b=window.location.hash,c=window.location.href,d=a(this).find(".wc-tabs, ul.tabs").first();b.toLowerCase().indexOf("comment-")>=0||"#reviews"===b?d.find("li.reviews_tab a").click():c.indexOf("comment-page-")>0||c.indexOf("cpage=")>0?d.find("li.reviews_tab a").click():d.find("li:first a").click()}).on("click",".wc-tabs li a, ul.tabs li a",function(){var b=a(this),c=b.closest(".wc-tabs-wrapper, .woocommerce-tabs"),d=c.find(".wc-tabs, ul.tabs");return d.find("li").removeClass("active"),c.find(".wc-tab, .panel:not(.panel .panel)").hide(),b.closest("li").addClass("active"),c.find(b.attr("href")).show(),!1}).trigger("init"),a("a.woocommerce-review-link").click(function(){return a(".reviews_tab a").click(),!0}),a("#rating").hide().before('

12345

'),void 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?(window.alert(wc_single_product_params.i18n_required_rating_text),!1):void 0}))}); \ No newline at end of file