Plugin Directory

Changeset 2924195


Ignore:
Timestamp:
06/10/2023 10:23:26 AM (3 years ago)
Author:
intolap
Message:

INTL version updated to 18

Location:
country-code-selector/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • country-code-selector/trunk/README.txt

    r2874090 r2924195  
    33Donate link: http://www.intolap.com/
    44Tags: woocommerce checkout, shopp checkout, gravity form, contact form 7, phone number validator, phone field validator, country code selector
    5 Requires at least: 5.9
    6 Tested up to: 6.0
    7 WC requires at least: 6.8
    8 WC tested up to: 6.8
    9 Requires PHP: 7.2
     5Requires at least: 6.1
     6Tested up to: 6.2
     7WC requires at least: 7.0
     8WC tested up to: 7.7
     9Requires PHP: 7.4
    1010Stable tag: trunk
    1111License: GPLv2 or later
     
    8383== Changelog ==
    8484
     85= 1.7 =
     86* INTL Version upgraded to the latest i.e. 18
     87
    8588= 1.6 =
    8689* Latest WordPress and WooCommerce version compatibility.
  • country-code-selector/trunk/country-code-selector.php

    r2666731 r2924195  
    99 * Plugin URI:        http://www.intolap.com/products/country-code-selector/
    1010 * Description:       Country Code Selector uses a JavaScript base to allow customers checking out in WooCommerce, Shopp, Contact form 7, Gravity form plugins select the country code using a dropdown field.
    11  * Version:           1.6
    12  * WC requires at least: 6.0
    13  * WC tested up to: 6.1
     11 * Version:           1.7
     12 * WC requires at least: 7.0
     13 * WC tested up to: 7.7
    1414 * Author:            INTOLAP
    1515 * Author URI:        http://www.intolap.com
     
    3030 * Rename this for your plugin and update it as you release new versions.
    3131 */
    32 define( 'COUNTRY_CODE_SELECTOR_VERSION', '1.6' );
     32define( 'COUNTRY_CODE_SELECTOR_VERSION', '1.7' );
    3333
    3434/**
  • country-code-selector/trunk/public/class-country-code-selector-public.php

    r2874062 r2924195  
    7777         */
    7878
    79         wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/country-code-selector-public.css', array(), $this->version, 'all' );
    80 
     79        // wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/country-code-selector-public.css', array(), $this->version, 'all' );
     80        wp_enqueue_style( $this->plugin_name, 'https://cdn.jsdelivr.net/npm/intl-tel-input@18.1.1/build/css/intlTelInput.css', array(), $this->version, 'all' );
     81       
    8182    }
    8283
     
    100101         */
    101102
    102         wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/country-code-selector-public.js', array( 'jquery' ), $this->version, false );
    103 
     103        // wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/country-code-selector-public.js', array( 'jquery' ), $this->version, false );
     104
     105        wp_enqueue_script( $this->plugin_name, 'https://cdn.jsdelivr.net/npm/intl-tel-input@18.1.1/build/js/intlTelInput.min.js', array( 'jquery' ), $this->version, false );
     106       
    104107    }
    105108
     
    133136                    separateDialCode: true,
    134137                    formatOnDisplay: true,
     138                    autoPlaceholder: "polite",
    135139                    <?php
    136140                    if(!empty(get_option('initial_country'))){
     
    145149                    }
    146150                    ?>
    147                     utilsScript: "<?php echo esc_url( plugin_dir_url( __FILE__ ) .'js/wc-utils.js' );?>",
     151                    utilsScript: "<?php echo esc_url( plugin_dir_url( __FILE__ ) .'js/utils.js' );?>"
    148152                });
    149153
     
    151155                    jQuery('[name=billing_phone][type=hidden]').val(jQuery('#billing_phone').val());
    152156                });
     157
     158                // Validation program
     159                var errorMap = [
     160                    "<?php _e( 'Invalid number', 'country-code-selector' ); ?>",
     161                    "<?php _e( 'Invalid country code', 'country-code-selector' ); ?>",
     162                    "<?php _e( 'Too short', 'country-code-selector' ); ?>",
     163                    "<?php _e( 'Too long', 'country-code-selector' ); ?>"
     164                ];
     165
     166                var preventAlert = true;
     167
     168                const reset = () => {
     169                    preventAlert = true;
     170                };
     171
     172                // on blur: validate
     173                input.addEventListener('blur', () => {
     174                    reset();
     175                    if (input.value.trim()) {
     176                        if (iti.isValidNumber()) {
     177                            document.getElementById("place_order").disabled = false;
     178                        } else {
     179                            const errorCode = iti.getValidationError();
     180                            if(preventAlert){
     181                                document.getElementById("place_order").disabled = true;
     182                                alert(errorMap[errorCode]);
     183                                preventAlert = false;
     184                            }
     185                        }
     186                    }
     187                });
     188
     189                // on keyup / change flag: reset
     190                input.addEventListener('change', reset);
     191                input.addEventListener('keyup', reset);
     192
     193                jQuery('select#billing_country').on( 'change', function (){
     194                    var billingCountry = jQuery('#billing_country :selected').val();
     195                    iti.setCountry(billingCountry.toLowerCase());
     196                });
     197
     198                /* // detect the change
     199                jQuery('input#billing_phone').on("keyup paste input",function() {
     200                    var full_number = iti.getNumber(intlTelInputUtils.numberFormat.E164);
     201                    jQuery(this).siblings('[name=billing_phone][type=hidden]').val(full_number);
     202                }); */
     203
     204                input.addEventListener("countrychange", function() {
     205                    var country_data = iti.getSelectedCountryData();
     206                    // alert(country_data.name+'-'+country_data.iso2+'-'+country_data.dialCode);
     207                    jQuery('input#billing_phone').val('');
     208                    jQuery('select#billing_country').val(country_data.iso2.toUpperCase()).trigger('change');
     209                });
    153210            }
    154211        </script>
    155        
    156         <script>
    157             var input = document.querySelector("#billing_phone");
    158 
    159             var errorMap = [
    160                 "<?php _e( 'Invalid number', 'country-code-selector' ); ?>",
    161                 "<?php _e( 'Invalid country code', 'country-code-selector' ); ?>",
    162                 "<?php _e( 'Too short', 'country-code-selector' ); ?>",
    163                 "<?php _e( 'Too long', 'country-code-selector' ); ?>"
    164             ];
    165            
    166             var preventAlert = true;
    167 
    168             var reset = function() {
    169               preventAlert = true;
    170             };
    171 
    172             input.addEventListener('blur', function() {
    173               if (input.value.trim()) {
    174                 if (iti.isValidNumber()) {
    175                   document.getElementById("place_order").disabled = false;
    176                 } else {
    177                   var errorCode = iti.getValidationError();
    178 
    179                   if(preventAlert){
    180                     document.getElementById("place_order").disabled = true;
    181                     alert(errorMap[errorCode]);
    182                     preventAlert = false;
    183                   }
    184                 }
    185               }
    186             });
    187 
    188             // on keyup / change flag: reset
    189             input.addEventListener('change', reset);
    190             input.addEventListener('keyup', reset);
    191 
    192             jQuery('select#billing_country').on( 'change', function (){
    193                 var billingCountry = jQuery('#billing_country :selected').val();
    194                 iti.setCountry(billingCountry.toLowerCase());
    195             });
    196 
    197             input.addEventListener("countrychange", function() {
    198               var country_data = iti.getSelectedCountryData();
    199               // alert(country_data.name+'-'+country_data.iso2+'-'+country_data.dialCode);
    200               jQuery('input#billing_phone').val('');
    201               jQuery('select#billing_country').val(country_data.iso2.toUpperCase()).trigger('change');
    202             });
    203         </script>
    204212 <?php
    205213        }
     
    252260                    }
    253261                    ?>
    254                     utilsScript: "<?php echo esc_url( plugin_dir_url( __FILE__ ) .'js/wc-utils.js' );?>",
     262                    utilsScript: "<?php echo esc_url( plugin_dir_url( __FILE__ ) .'js/utils.js' );?>",
    255263                });
    256264            }
     
    350358            }
    351359
    352             $script .= 'utilsScript: "' . esc_url( plugin_dir_url( __FILE__ ) .'js/wc-utils.js' ).'",';
     360            $script .= 'utilsScript: "' . esc_url( plugin_dir_url( __FILE__ ) .'js/utils.js' ).'",';
    353361            $script .= '});';
    354362
     
    471479                            }
    472480                            ?>
    473                             utilsScript: "<?php echo esc_url( plugin_dir_url( __FILE__ ) .'js/wc-utils.js' );?>",
     481                            utilsScript: "<?php echo esc_url( plugin_dir_url( __FILE__ ) .'js/utils.js' );?>",
    474482                        });
    475483                    }
Note: See TracChangeset for help on using the changeset viewer.