1jQuery( document ).ready( function() { 2 3 ycp_setup_voucherVerification(); 4 5} ); 6 7 8function ycp_setup_voucherVerification() { 9 jQuery( '.voucher-input-title a' ).click( function( ev ) { 10 ev.preventDefault(); 11 } ); 12 13 jQuery( '.apply-voucher' ).on( 'click', function( ev ) { 14 ev.preventDefault(); 15 16 var $button = jQuery( this ), 17 $container = $button.parents( '.voucher-input-container' ), 18 $statusContainer = jQuery( '.voucher-status', $container ), 19 $selectContainer = $container.siblings( '.options-select' ), 20 postID = $container.attr( 'data-post-id' ), 21 $codeInput = jQuery( '#voucher-code-' + postID ), 22 code = $codeInput.val(); 23 24 if ( ! code ) { 25 $statusContainer.hide( 200 ).addClass( 'error' ).text( ajax_ycp_object.empty_fields_message ).show( 200 ); 26 27 return false; 28 } 29 30 $container.addClass( "loading" ); 31 $button.prop( 'disabled', true ); 32 $codeInput.prop( 'disabled', true ); 33 jQuery.ajax( { 34 type: 'POST', 35 dataType: 'json', 36 url: ajax_ycp_object.ajax_url + '?lang=' + ajax_ycp_object.language_code, 37 data: { 38 'action': 'ycp_verify_voucher', 39 'post_id' : postID, 40 'code': code 41 }, 42 43 beforeSend: function() { 44 $statusContainer.removeClass( 'error' ); 45 $statusContainer.hide( 200 ).text( ajax_ycp_object.loading_message ).show( 200 ); 46 }, 47 48 error: function() { 49 $container.removeClass( "loading" ); 50 $button.prop( 'disabled', false ); 51 $codeInput.prop( 'disabled', false ); 52 }, 53 54 success: function( data ) { 55 $container.removeClass( "loading" ); 56 57 if ( data.success == true ) { 58 $statusContainer.fadeOut( 300 ).text( ajax_ycp_object.success_message ).fadeIn( 300, function() { 59 jQuery( '.voucher-input-title', $container ).hide( 300 ); 60 jQuery( '.voucher-input', $container ).hide( 300, function() { 61 $selectContainer.addClass( 'js-updating' ).fadeOut( 500 ).html( data.html ).fadeIn( 500 ).removeClass( 'js-updating' ); 62 } ); 63 } ); 64 } else { 65 $statusContainer.addClass( 'error' ); 66 $statusContainer.hide( 200 ).text( ajax_ycp_object.invalid_voucher_message ).show( 200 ); 67 $button.prop( 'disabled', false ); 68 $codeInput.prop( 'disabled', false ); 69 } 70 } 71 } ); 72 } ); 73}
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.