| 1 |
(function ($) { |
| 2 |
|
| 3 |
jQuery(document).ready(function () { |
| 4 |
//--------start floating label script------- |
| 5 |
$('.floating-label #customer_details .form-row .input-text, .floating-label form.woocommerce-form-login .form-row-first .input-text, .floating-label form.woocommerce-form-login .form-row-last .input-text').each(function(){ |
| 6 |
$(this).attr('placeholder', ''); |
| 7 |
console.log('default load'); |
| 8 |
|
| 9 |
if( $(this).val().length > 0 ) { |
| 10 |
$(this).parents('.form-row').find('label').addClass('floated'); |
| 11 |
} |
| 12 |
}); |
| 13 |
|
| 14 |
$(document).on('focus','.floating-label #customer_details .form-row .input-text, .floating-label #customer_details .form-row select, .floating-label form.woocommerce-form-login .form-row-first .input-text, .floating-label form.woocommerce-form-login .form-row-last .input-text', function(){ |
| 15 |
$(this).parents('.form-row').find('label').addClass('floated'); |
| 16 |
}); |
| 17 |
|
| 18 |
$(document).on('blur','.floating-label #customer_details .form-row .input-text, .floating-label #customer_details .form-row select, .floating-label form.woocommerce-form-login .form-row-first .input-text, .floating-label form.woocommerce-form-login .form-row-last .input-text', function(){ |
| 19 |
if( $(this).val().length == 0 ) { |
| 20 |
$(this).parents('.form-row').find('label').removeClass('floated'); |
| 21 |
} |
| 22 |
}); |
| 23 |
|
| 24 |
//--------end floating label script------- |
| 25 |
|
| 26 |
// Initialize Enhanced Phone Field in editor |
| 27 |
function initEditorPhoneField() { |
| 28 |
if (typeof window.intlTelInput !== 'function' || !window.wpfnl_obj) { |
| 29 |
return; |
| 30 |
} |
| 31 |
|
| 32 |
// Wait for phone fields that haven't been initialized yet |
| 33 |
$('.wpfnl-phone, #billing_phone, input[type="tel"]').not('.wpfnl-iti-initialized').each(function() { |
| 34 |
var input = this; |
| 35 |
$(input).addClass('wpfnl-iti-initialized'); |
| 36 |
|
| 37 |
var iti = window.intlTelInput(input, { |
| 38 |
initialCountry: "auto", |
| 39 |
separateDialCode: true, |
| 40 |
geoIpLookup: function(success, failure) { |
| 41 |
$.get('https://ipinfo.io', function() {}, "jsonp").always(function(resp) { |
| 42 |
var countryCode = (resp && resp.country) ? resp.country : "us"; |
| 43 |
success(countryCode); |
| 44 |
}); |
| 45 |
}, |
| 46 |
utilsScript: window.wpfnl_obj.phone_utils_url, |
| 47 |
}); |
| 48 |
|
| 49 |
if (window.wpfnl_obj.phone_help_text && !$(input).next('.wpfnl-phone-help-text').length) { |
| 50 |
$('<p class="wpfnl-phone-help-text" style="font-size: 12px; margin-top: 5px; color: #666;">' + window.wpfnl_obj.phone_help_text + '</p>').insertAfter($(input).closest('.iti')); |
| 51 |
} |
| 52 |
}); |
| 53 |
} |
| 54 |
|
| 55 |
// Polling to handle Gutenberg's dynamic rendering of components |
| 56 |
setInterval(initEditorPhoneField, 1000); |
| 57 |
|
| 58 |
}); |
| 59 |
|
| 60 |
})(jQuery); |