1(function ($) { 2 'use strict'; 3 4 /** 5 * All of the code for your public-facing JavaScript source 6 * should reside in this file. 7 * 8 * Note: It has been assumed you will write jQuery code here, so the 9 * $ function reference has been prepared for usage within the scope 10 * of this function. 11 * 12 * This enables you to define handlers, for when the DOM is ready: 13 * 14 * $(function() { 15 * 16 * }); 17 * 18 * When the window is loaded: 19 * 20 * $( window ).load(function() { 21 * 22 * }); 23 * 24 * ...and/or other possibilities. 25 * 26 * Ideally, it is not considered best practise to attach more than a 27 * single DOM-ready or window-load handler for a particular page. 28 * Although scripts in the WordPress core, Plugins and Themes may be 29 * practising this, we should strive to set a better example in our own work. 30 */ 31 $(document).on('change', 'input[name="payment_method"]', function () { 32 $('body').trigger('update_checkout'); 33 }); 34 if ($('#billing_state').length) { 35 $(document).on('change', '#billing_state', function () { 36 $('body').trigger('update_checkout'); 37 }); 38 } 39 40 $(document.body).trigger('wc_update_cart'); 41 42 $(document).ready(function ($) { 43 44 /** 45 * Block Compatiblility 46 */ 47 init_tooltip(); 48 49 // Function to update the fee label 50 updateFeeLabel(); 51 52 // Also run it whenever the DOM updates (e.g., when items are added/removed) 53 const observer = new MutationObserver(updateFeeLabel); 54 observer.observe(document.body, { childList: true, subtree: true }); 55 56 function updateFeeLabel() { 57 $.each( wcpfc_public_vars.fee_tooltip_data, function( fee_slug, fee_html ){ 58 if( $('.wc-block-components-totals-fees__'+fee_slug).length > 0 ) { 59 var $valueElement = $('.wc-block-components-totals-fees__'+fee_slug).find('.wc-block-components-totals-item__value'); 60 if ($valueElement.length && $('.wcpfc-help-tip-'+fee_slug).length === 0) { 61 var $tooltip = $('<span class="wc-wcpfc-help-tip wc-block-components-tooltip wcpfc-help-tip-' + fee_slug + '" data-tip="' + fee_html + '"></span>'); 62 $valueElement.after($tooltip); 63 } 64 } 65 }); 66 init_tooltip(); 67 } 68 69 function init_tooltip() { 70 setTimeout( function(){ 71 $('.wc-wcpfc-help-tip').each(function () { 72 return $(this).tipTip({ 73 content: $(this).data('tip'), 74 keepAlive: true, 75 edgeOffset: 2 76 }); 77 }); 78 }, 1000 ); 79 } 80 81 }); 82 83})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.