1jQuery(document).ready(function(){ 2 // Discount code JS if we are showing discount codes. 3 if ( pmpro.show_discount_code ) { 4 //update discount code link to show field at top of form 5 jQuery('#other_discount_code_a').attr('href', 'javascript:void(0);'); 6 jQuery('#other_discount_code_a').click(function() { 7 jQuery('#other_discount_code_tr').show(); 8 jQuery('#other_discount_code_p').hide(); 9 jQuery('#other_discount_code').focus(); 10 }); 11 12 //update real discount code field as the other discount code field is updated 13 jQuery('#other_discount_code').keyup(function() { 14 jQuery('#discount_code').val(jQuery('#other_discount_code').val()); 15 }); 16 jQuery('#other_discount_code').blur(function() { 17 jQuery('#discount_code').val(jQuery('#other_discount_code').val()); 18 }); 19 20 //update other discount code field as the real discount code field is updated 21 jQuery('#discount_code').keyup(function() { 22 jQuery('#other_discount_code').val(jQuery('#discount_code').val()); 23 }); 24 jQuery('#discount_code').blur(function() { 25 jQuery('#other_discount_code').val(jQuery('#discount_code').val()); 26 }); 27 28 // Top discount code field click handler. 29 jQuery('#other_discount_code_button').click(function() { 30 var code = jQuery('#other_discount_code').val(); 31 var level_id = jQuery('#level').val(); 32 33 if(code) 34 { 35 //hide any previous message 36 jQuery('.pmpro_discount_code_msg').hide(); 37 38 //disable the apply button 39 jQuery('#other_discount_code_button').attr('disabled', 'disabled'); 40 41 jQuery.ajax({ 42 url: pmpro.ajaxurl, type:'GET',timeout: pmpro.ajax_timeout, 43 dataType: 'html', 44 data: "action=applydiscountcode&code=" + code + "&level=" + level_id + "&msgfield=pmpro_message", 45 error: function(xml){ 46 alert('Error applying discount code [1]'); 47 48 //enable apply button 49 jQuery('#other_discount_code_button').removeAttr('disabled'); 50 }, 51 success: function(responseHTML){ 52 if (responseHTML == 'error') 53 { 54 alert('Error applying discount code [2]'); 55 } 56 else 57 { 58 jQuery('#pmpro_message').html(responseHTML); 59 } 60 61 //enable invite button 62 jQuery('#other_discount_code_button').removeAttr('disabled'); 63 } 64 }); 65 } 66 }); 67 68 // Bottom discount code field click handler. 69 jQuery('#discount_code_button').click(function() { 70 var code = jQuery('#discount_code').val(); 71 var level_id = jQuery('#level').val(); 72 73 if(code) 74 { 75 //hide any previous message 76 jQuery('.pmpro_discount_code_msg').hide(); 77 78 //disable the apply button 79 jQuery('#discount_code_button').attr('disabled', 'disabled'); 80 81 jQuery.ajax({ 82 url: pmpro.ajaxurl,type:'GET',timeout: pmpro.ajax_timeout, 83 dataType: 'html', 84 data: "action=applydiscountcode&code=" + code + "&level=" + level_id + "&msgfield=discount_code_message", 85 error: function(xml){ 86 alert('Error applying discount code [1]'); 87 88 //enable apply button 89 jQuery('#discount_code_button').removeAttr('disabled'); 90 }, 91 success: function(responseHTML){ 92 if (responseHTML == 'error') 93 { 94 alert('Error applying discount code [2]'); 95 } 96 else 97 { 98 jQuery('#discount_code_message').html(responseHTML); 99 } 100 101 //enable invite button 102 jQuery('#discount_code_button').removeAttr('disabled'); 103 } 104 }); 105 } 106 }); 107 } 108 109 // Validate credit card number and determine card type. 110 if ( typeof jQuery('#AccountNumber').validateCreditCard == 'function' ) { 111 jQuery('#AccountNumber').validateCreditCard(function(result) { 112 var cardtypenames = { 113 "amex" : "American Express", 114 "diners_club_carte_blanche" : "Diners Club Carte Blanche", 115 "diners_club_international" : "Diners Club International", 116 "discover" : "Discover", 117 "jcb" : "JCB", 118 "laser" : "Laser", 119 "maestro" : "Maestro", 120 "mastercard" : "Mastercard", 121 "visa" : "Visa", 122 "visa_electron" : "Visa Electron" 123 }; 124 125 if(result.card_type) 126 jQuery('#CardType').val(cardtypenames[result.card_type.name]); 127 else 128 jQuery('#CardType').val('Unknown Card Type'); 129 }); 130 } 131 132 // Find ALL <form> tags on your page 133 jQuery('form').submit(function(){ 134 // On submit disable its submit button 135 jQuery('input[type=submit]', this).attr('disabled', 'disabled'); 136 jQuery('input[type=image]', this).attr('disabled', 'disabled'); 137 jQuery('#pmpro_processing_message').css('visibility', 'visible'); 138 }); 139 140 //add required to required fields 141 if ( ! jQuery( '.pmpro_required' ).next().hasClass( "pmpro_asterisk" ) ) { 142 jQuery( '.pmpro_required' ).closest( '.pmpro_checkout-field' ).append( '<span class="pmpro_asterisk"> <abbr title="Required Field">*</abbr></span>' ); 143 } 144 145 //move asterisk for some field types 146 if ( jQuery( '.pmpro_checkout-field-radio' ).find( ".pmpro_asterisk" ) ) { 147 jQuery( '.pmpro_checkout-field-radio' ).find( ".pmpro_asterisk" ).remove(); 148 jQuery( '.pmpro_checkout-field-radio' ).find( 'label' ).first().append( '<span class="pmpro_asterisk"> <abbr title="Required Field">*</abbr></span>' ); 149 } 150 151 //move asterisk before hint <p>'s 152 jQuery( 'span.pmpro_asterisk' ).each(function() { 153 var prev = jQuery(this).prev(); 154 if ( prev.is('p') ) { 155 jQuery(this).insertBefore(prev); 156 } 157 }); 158 159 //unhighlight error fields when the user edits them 160 jQuery('.pmpro_error').bind("change keyup input", function() { 161 jQuery(this).removeClass('pmpro_error'); 162 }); 163 164 //click apply button on enter in discount code box 165 jQuery('#discount_code').keydown(function (e){ 166 if(e.keyCode == 13){ 167 e.preventDefault(); 168 jQuery('#discount_code_button').click(); 169 } 170 }); 171 172 //hide apply button if a discount code was passed in
173 if( pmpro.discount_code_passed_in ) { 174 jQuery('#discount_code_button').hide(); 175 jQuery('#discount_code').bind('change keyup', function() { 176 jQuery('#discount_code_button').show(); 177 }); 178 } 179 180 //click apply button on enter in *other* discount code box 181 jQuery('#other_discount_code').keydown(function (e){ 182 if(e.keyCode == 13){ 183 e.preventDefault(); 184 jQuery('#other_discount_code_button').click(); 185 } 186 }); 187 188 //add javascriptok hidden field to checkout 189 jQuery("input[name=submit-checkout]").after('<input type="hidden" name="javascriptok" value="1" />'); 190 191 // Keep bottom message box in sync with the top one. 192 jQuery('#pmpro_message').bind("DOMSubtreeModified",function(){ 193 setTimeout( function(){ pmpro_copyMessageToBottom() }, 200); 194 }); 195 196 function pmpro_copyMessageToBottom() { 197 jQuery('#pmpro_message_bottom').html(jQuery('#pmpro_message').html()); 198 jQuery('#pmpro_message_bottom').attr('class', jQuery('#pmpro_message').attr('class')); 199 if(jQuery('#pmpro_message').is(":visible")) { 200 jQuery('#pmpro_message_bottom').show(); 201 } else { 202 jQuery('#pmpro_message_bottom').hide(); 203 } 204 } 205});
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.