Skip to content

Commit

Permalink
Fix assets path & more general CSS selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
vyskoczilova committed Oct 13, 2020
1 parent b185dbd commit 48c1953
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion assets/css/style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#customer_details .woolab-ic-dic-toggle,
.woocommerce-billing-fields .woolab-ic-dic-toggle,
.required + .optional,
.woolab-ic-dic-not-optional > .optional,
.woolab-ic-dic-required {
Expand Down
2 changes: 1 addition & 1 deletion assets/css/style.min.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#customer_details .woolab-ic-dic-toggle,.required+.optional,.woolab-ic-dic-not-optional>.optional,.woolab-ic-dic-required{display:none}.woolab-ic-dic-required+.optional{display:inline}
.woocommerce-billing-fields .woolab-ic-dic-toggle,.required+.optional,.woolab-ic-dic-not-optional>.optional,.woolab-ic-dic-required{display:none}.woolab-ic-dic-required+.optional{display:inline}
44 changes: 22 additions & 22 deletions assets/js/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// the event from triggering too preemptively. Without this line,
// using tab/shift+tab will make the focused element fire the callback.
if (e.type=='keyup' && e.keyCode!=8) return;

// Check if timeout has been set. If it has, "reset" the clock and
// start over again.
if (timeoutReference) clearTimeout(timeoutReference);
Expand Down Expand Up @@ -61,7 +61,7 @@
}

/** Toggle fields when country is changed or checkbox is toggled */
$("#customer_details").on("change", "#billing_country, #billing_iscomp", function () {
$(".woocommerce-billing-fields").on("change", "#billing_country, #billing_iscomp", function () {
var $fieldToggle = $('#billing_iscomp');
if ( ! $fieldToggle.length || $fieldToggle.prop("checked") ) {
based_on_country();
Expand Down Expand Up @@ -103,8 +103,8 @@
}

function clear_validation() {
$('.woolab-ic-dic-tip').remove();
ares_remove_disabled_from_input();
$('.woolab-ic-dic-tip').remove();
ares_remove_disabled_from_input();
}

function woolab_remove_class_ok ( selector ) {
Expand Down Expand Up @@ -151,12 +151,12 @@
var ico_class = $('#billing_ic_field');
var not_valid = '<span role="alert" class="woolab-ic-dic-tip">'+woolab.l18n_not_valid+'</span>';

$('.woolab-ic-dic-tip').remove();
$('.woolab-ic-dic-tip').remove();
woolab_remove_class_wrong( ico_class );
woolab_remove_class_ok( ico_class );

if ( (value.length == 7 || value.length == 8) && value.match(/^[0-9]+$/) != null ) {

$.ajax({
url: woolab.ajaxurl,
data: {
Expand All @@ -165,7 +165,7 @@
},
beforeSend: function() {
ico_class.addClass( 'kbnt-validating' );
ico_class.append( '<span role="info" class="woolab-ic-dic-tip">'+woolab.l18n_validating+'</span>' );
ico_class.append( '<span role="info" class="woolab-ic-dic-tip">'+woolab.l18n_validating+'</span>' );
},
success: function ( data ) {
ico_class.removeClass( 'kbnt-validating' );
Expand All @@ -174,51 +174,51 @@

if ( data.error == false ) {

$('.woolab-ic-dic-tip').remove();
$('.woolab-ic-dic-tip').remove();
woolab_add_class_ok( ico_class );

if ( woolab.ares_fill ) {

// Update values
$('#billing_company').val(data.spolecnost).attr('readonly', true);
$('#billing_dic').val(data.dic).attr('readonly', true);
$('#billing_address_1').val(data.adresa).attr('readonly', true);
$('#billing_postcode').val(data.psc).attr('readonly', true);
$('#billing_city').val(data.mesto).attr('readonly', true);
ico_class.append( '<span role="info" class="woolab-ic-dic-tip">'+woolab.l18n_ok+'</span>' );
ico_class.append( '<span role="info" class="woolab-ic-dic-tip">'+woolab.l18n_ok+'</span>' );

// Trigger the checkout update
$('body').trigger('update_checkout');

}
}

} else {
ares_error( ico_class );
if ( $('.woolab-ic-dic-tip').length > 0 ) {
$('.woolab-ic-dic-tip').remove();
$('.woolab-ic-dic-tip').remove();
}
ares_remove_disabled_from_input();
ico_class.append( '<span role="alert" class="woolab-ic-dic-tip error">'+data.error+'</span>' );
ico_class.append( '<span role="alert" class="woolab-ic-dic-tip error">'+data.error+'</span>' );
}

} else {
ares_error( ico_class );
} else {
ares_error( ico_class );
if ( $('.woolab-ic-dic-tip').length == 0 ) {
ares_remove_disabled_from_input();
ico_class.append( not_valid );
}
}
}


},
error: function(errorThrown){
if ( $('.woolab-ic-dic-tip').length == 0 ) {
ico.val('');
ares_error( ico_class );
ares_error( ico_class );
ico_class.append( '<span role="alert" class="woolab-ic-dic-tip error">'+woolab.l18n_error+'</span>' );
}
}
});
}
});

} else {
ares_remove_disabled_from_input();
Expand All @@ -245,4 +245,4 @@
woolab_add_class_wrong( ico_class );
}

})( jQuery );
})( jQuery );
2 changes: 1 addition & 1 deletion assets/js/public.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ Either post it on [GitHub](https://github.com/vyskoczilova/kybernaut-ic-dic) or

== Changelog ==

= 1.5.2 (2020-10-13) =
* Fix wrong assets path.
* Use more general CSS selectors for better compatibility.

= 1.5.1 (2020-09-17) =
* Fix issues with quotes - [#25](https://github.com/vyskoczilova/kybernaut-ic-dic/issues/25)
* Add custom filter for disabling required DIC when ICO filled for SK `add_filter( 'woolab_icdic_sk_required_ic_and_dic', '__return_false' );` - [#26](https://github.com/vyskoczilova/kybernaut-ic-dic/issues/26)
Expand Down
8 changes: 4 additions & 4 deletions woolab-ic-dic.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Kybernaut IC DIC
Plugin URI: https://kybernaut.cz/pluginy/kybernaut-ic-dic
Description: Adds Czech Company & VAT numbers (IČO & DIČ) to WooCommerce billing fields and verifies if data are correct.
Version: 1.5.1
Version: 1.5.2
Author: Karolína Vyskočilová
Author URI: https://kybernaut.cz
Text Domain: woolab-ic-dic
Expand All @@ -27,7 +27,7 @@
define( 'WOOLAB_IC_DIC_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
define( 'WOOLAB_IC_DIC_ABSPATH', dirname( __FILE__ ) . '/' );
define( 'WOOLAB_IC_DIC_URL', plugin_dir_url( __FILE__ ) );
define( 'WOOLAB_IC_DIC_VERSION', '1.5.0' );
define( 'WOOLAB_IC_DIC_VERSION', '1.5.2' );

// Check if WooCommerce active
function woolab_icdic_init() {
Expand Down Expand Up @@ -115,7 +115,7 @@ function woolab_icdic_plugin_admin_notice() {
function woolab_icdic_enqueue_scripts() {
$suffix = SCRIPT_DEBUG ? '' : '.min';
if( is_checkout() ){
wp_enqueue_script( 'woolab-icdic-public-js', WOOLAB_IC_DIC_URL . '/assets/js/public'.$suffix.'.js', array( 'jquery' ), WOOLAB_IC_DIC_VERSION );
wp_enqueue_script( 'woolab-icdic-public-js', WOOLAB_IC_DIC_URL . 'assets/js/public'.$suffix.'.js', array( 'jquery' ), WOOLAB_IC_DIC_VERSION );
wp_localize_script( 'woolab-icdic-public-js', 'woolab', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'l18n_not_valid' => __('Business ID is invalid.', 'woolab-ic-dic'),
Expand All @@ -125,7 +125,7 @@ function woolab_icdic_enqueue_scripts() {
'ares_check' => woolab_icdic_ares_check(),
'ares_fill' => woolab_icdic_ares_fill(),
));
wp_enqueue_style( 'woolab-icdic-public-css', WOOLAB_IC_DIC_URL . '/assets/css/style'.$suffix.'.css', null, WOOLAB_IC_DIC_VERSION );
wp_enqueue_style( 'woolab-icdic-public-css', WOOLAB_IC_DIC_URL . 'assets/css/style'.$suffix.'.css', null, WOOLAB_IC_DIC_VERSION );
}
}

Expand Down

0 comments on commit 48c1953

Please sign in to comment.