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 32 function paymentMethod() { 33 this.init = function () { 34 this.detectPaymentChange(); 35 this.dateChange(); 36 } 37 38 this.dateChange = function () { 39 var parent = this; 40 /** this is needed to make it compatible with Different time for different pickup location plugin */ 41 var type = jQuery('input[name="pi_delivery_type"]:checked').val(); 42 if (type != 'delivery') return; 43 /* end */ 44 45 jQuery(document).on('change', '#pi_delivery_date', function () { 46 /**extra code added as it was leading to loop when used with different time for different pickup location addon plugin */ 47 var date = jQuery(this).val(); 48 var upd = localStorage.getItem('trigger_for_date'); 49 if (upd != date) { 50 setTimeout(function () { 51 jQuery('body').trigger('update_checkout', { update_shipping_method: true }); 52 }, 1000); 53 54 localStorage.setItem('trigger_for_date', date); 55 } else { 56 setTimeout(function () { 57 localStorage.removeItem('trigger_for_date'); 58 }, 1); 59 } 60 }); 61 } 62 63 this.detectPaymentChange = function () { 64 var parent = this; 65 jQuery('body').on('change', 'input[name="payment_method"]', function () { 66 parent.cartReload(); 67 }); 68 } 69 70 this.cartReload = function () { 71 jQuery("body").trigger('update_checkout'); 72 } 73 } 74 75 jQuery(function () { 76 var paymentMethod_Obj = new paymentMethod(); 77 paymentMethod_Obj.init(); 78 }); 79 80})(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.