JSHint fixes.

The other advantage of splitting js out of php files — jshint can run
on it! :) :) :)
This commit is contained in:
George Stephanis 2015-08-07 12:10:01 -04:00
parent 69b6936d4d
commit 516977bd01
2 changed files with 22 additions and 23 deletions

View File

@ -1,3 +1,4 @@
/* global htmlSettingsTaxLocalizeScript */
/** /**
* Used by woocommerce/includes/admin/settings/views/html-settings-tax.php * Used by woocommerce/includes/admin/settings/views/html-settings-tax.php
*/ */
@ -15,18 +16,19 @@
$('.wc_tax_rates .remove_tax_rates').click(function() { $('.wc_tax_rates .remove_tax_rates').click(function() {
if ( $tbody.find('tr.current').size() > 0 ) { if ( $tbody.find('tr.current').size() > 0 ) {
$current = $tbody.find('tr.current'); var $current = $tbody.find('tr.current');
$current.find('input').val(''); $current.find('input').val('');
$current.find('input.remove_tax_rate').val('1'); $current.find('input.remove_tax_rate').val('1');
$current.each(function(){ $current.each(function(){
if ( $(this).is('.new') ) if ( $(this).is('.new') ) {
$(this).remove(); $( this ).remove();
else } else {
$(this).hide(); $( this ).hide();
}
}); });
} else { } else {
alert( data.strings.no_rows_selected ); window.alert( data.strings.no_rows_selected );
} }
return false; return false;
}); });
@ -38,28 +40,25 @@
$('#rates tr:visible').each(function() { $('#rates tr:visible').each(function() {
var row = ''; var row = '';
$(this).find('td:not(.sort) input').each(function() { $(this).find('td:not(.sort) input').each(function() {
var val = '';
if ( $(this).is('.checkbox') ) { if ( $(this).is('.checkbox') ) {
if ( $(this).is(':checked') ) { if ( $(this).is(':checked') ) {
val = 1; val = 1;
} else { } else {
val = 0; val = 0;
} }
} else { } else {
val = $(this).val();
var val = $(this).val(); if ( ! val ) {
val = $( this ).attr( 'placeholder' );
if ( ! val ) }
val = $(this).attr('placeholder');
} }
row = row + val + ','; row = row + val + ',';
}); });
row = row + data.current_class; row = row + data.current_class;
//row.substring( 0, row.length - 1 ); //row.substring( 0, row.length - 1 );
csv_data = csv_data + row + "\n"; csv_data = csv_data + row + '\n';
}); });
$(this).attr( 'href', encodeURI( csv_data ) ); $(this).attr( 'href', encodeURI( csv_data ) );
@ -73,7 +72,7 @@
tax_rate_id : 'new-' + size, tax_rate_id : 'new-' + size,
tax_rate_priority : 1, tax_rate_priority : 1,
tax_rate_shipping : 1, tax_rate_shipping : 1,
new : true newRow : true
} ); } );
if ( $tbody.find('tr.current').size() > 0 ) { if ( $tbody.find('tr.current').size() > 0 ) {
@ -82,13 +81,13 @@
$tbody.append( code ); $tbody.append( code );
} }
$( "td.country input" ).autocomplete({ $( 'td.country input' ).autocomplete({
source: availableCountries, source: data.countries,
minLength: 3 minLength: 3
}); });
$( "td.state input" ).autocomplete({ $( 'td.state input' ).autocomplete({
source: availableStates, source: data.states,
minLength: 3 minLength: 3
}); });
@ -99,12 +98,12 @@
$(this).attr( 'name', $(this).attr( 'data-name' ) ); $(this).attr( 'name', $(this).attr( 'data-name' ) );
}); });
$( "td.country input" ).autocomplete({ $( 'td.country input' ).autocomplete({
source: data.countries, source: data.countries,
minLength: 3 minLength: 3
}); });
$( "td.state input" ).autocomplete({ $( 'td.state input' ).autocomplete({
source: data.states, source: data.states,
minLength: 3 minLength: 3
}); });

View File

@ -113,7 +113,7 @@ wp_enqueue_script( 'wc-settings-tax' );
<script type="text/html" id="tmpl-wc-tax-table-row"> <script type="text/html" id="tmpl-wc-tax-table-row">
<tr class="tips" data-tip="<?php echo esc_attr( sprintf( __( 'Tax rate ID: %s', 'woocommerce' ), '{{ data.tax_rate_id }}' ) ); ?>"> <tr class="tips" data-tip="<?php echo esc_attr( sprintf( __( 'Tax rate ID: %s', 'woocommerce' ), '{{ data.tax_rate_id }}' ) ); ?>">
<td class="sort"> <td class="sort">
<# if ( ! data.new ) { #> <# if ( ! data.newRow ) { #>
<input type="hidden" class="remove_tax_rate" name="remove_tax_rate[{{ data.tax_rate_id }}]" value="0" /> <input type="hidden" class="remove_tax_rate" name="remove_tax_rate[{{ data.tax_rate_id }}]" value="0" />
<# } #> <# } #>
</td> </td>