1(function ( document, $ ) { 2 3 var $cache = {}; 4 5 /** 6 * Cache our DOM selectors. 7 */ 8 function generate_cache() { 9 $cache.document = $( document ); 10 $cache.first_payment_date = $( '.first-payment-date' ); 11 $cache.is_variable_subscription = 0 < $( 'div.product-type-variable-subscription' ).length; 12 } 13 14 /** 15 * Attach DOM events. 16 */ 17 function attach_events() { 18 if ( $cache.is_variable_subscription ) { 19 $cache.document.on( 'found_variation', update_first_payment_element ); 20 $cache.document.on( 'reset_data', clear_first_payment_element ); 21 } 22 } 23 24 /** 25 * Update the variation's first payment element. 26 * 27 * @param {jQuery.Event} event 28 * @param {object} variation_data 29 */ 30 function update_first_payment_element( event, variation_data ) { 31 $cache.first_payment_date.html( variation_data.first_payment_html ); 32 } 33 34 /** 35 * Clear the variation's first payment element. 36 */ 37 function clear_first_payment_element() { 38 $cache.first_payment_date.html( '' ); 39 } 40 41 /** 42 * Initialise. 43 */ 44 function init() { 45 generate_cache(); 46 attach_events(); 47 } 48 49 $( init ); 50 51})( document, jQuery ); 52
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.