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