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 jQuery(function ($) { 32 33 function showOfferOnVariation() { 34 this.init = function () { 35 this.detectVariationChange(); 36 } 37 38 this.detectVariationChange = function () { 39 var parent = this; 40 $("input[type='hidden'].variation_id").on('change', function () { 41 var variation_id = parseInt($(this).val()); 42 if (variation_id !== "") { 43 parent.getMessageBox(variation_id); 44 } 45 }); 46 $("input[type='hidden'].variation_id").trigger('change'); 47 } 48 49 this.getMessageBox = function (variation_id) { 50 var parent = this; 51 this.hideAllMethod(); 52 jQuery(".pi-msg-container").each(function () { 53 var box_variation_id = jQuery(this).data('variation_id'); 54 var selected = jQuery(this).data('variations_selected'); 55 if (variation_id == box_variation_id) { 56 jQuery(this).fadeIn(); 57 } 58 }); 59 } 60 61 this.hideAllMethod = function () { 62 jQuery(".pi-msg-container").css('display', 'none'); 63 } 64 65 66 } 67 var show_offer_obj = new showOfferOnVariation(); 68 show_offer_obj.init(); 69 70 function reloadCartOnEmailChange(){ 71 var typingTimer; 72 var doneTypingInterval = 600; 73 jQuery("input[name='billing_email']").on('keyup.bogo_email_change', function(){ 74 clearTimeout(typingTimer); 75 typingTimer = setTimeout(doneTypingEmail, doneTypingInterval); 76 }); 77 } 78 reloadCartOnEmailChange(); 79 function doneTypingEmail(){ 80 jQuery("body").trigger("update_checkout"); 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.