1( function( $ ) { 2 $( document ).on( "click", '.cptch_reload_button', function() { 3 cptch_reload( $( this ) ); 4 }).on( "touchstart", function( event ) { 5 event = event || window.event; 6 var item = $( event.target ); 7 if ( cptch_vars.enlarge == '1' ) { 8 var element = $( event.target ); 9 if ( element.hasClass( 'cptch_img' ) ) { 10 event.preventDefault(); 11 element.toggleClass( 'cptch_reduce' ); 12 $( '.cptch_img' ).not( element ).removeClass( 'cptch_reduce' ); 13 } else { 14 $( '.cptch_img' ).removeClass( 'cptch_reduce' ); 15 } 16 } 17 if ( item.hasClass( 'cptch_reload_button' ) || item.attr( 'name' ) == 'ac_form_submit' ) 18 cptch_reload( item ); 19 }).ready( function() { 20 if ( $( '.cptch_recognition' ).length ) { 21 $( '.cptch_recognition' ).each( function() { 22 $( this ).find( '.cptch_input' ).css( 'width', $( this ).find( '.cptch_images_wrap' ).css( 'width' ) ); 23 } ); 24 } 25 26 var ajax_containers = $( '.cptch_ajax_wrap' ); 27 28 if ( ! ajax_containers.length ) 29 return; 30 31 ajax_containers.each( function() { 32 cptch_reload( $( this ), true ); 33 }); 34 }); 35})(jQuery); 36 37/** 38 * Reload captcha 39 */ 40function cptch_reload( object, is_ajax_load ) { 41 is_ajax_load = is_ajax_load || false; 42 (function($) { 43 if ( is_ajax_load ) { 44 var captcha = object; 45 } else { 46 var captcha = object.hasClass( 'cptch_reload_button' ) ? object.parent().parent( '.cptch_wrap' ) : object.closest( 'form' ).find( '.cptch_wrap' ); 47 } 48 var button = captcha.find( '.cptch_reload_button' ); 49 if ( ! captcha.length || button.hasClass( 'cptch_active' ) ) 50 return false; 51 button.addClass( 'cptch_active' ); 52 var captcha_block = captcha.parent(), 53 input = captcha.find( 'input:text' ), 54 input_name = is_ajax_load ? captcha.attr( 'data-cptch-input' ) : input.attr( 'name' ), 55 input_class = is_ajax_load ? captcha.attr( 'data-cptch-class' ) : input.attr( 'class' ).replace( /cptch_input/, '' ).replace( /^\s+|\s+$/g, '' ), 56 form_slug = is_ajax_load ? captcha.attr( 'data-cptch-form' ) : captcha_block.find( 'input[name="cptch_form"]' ).val(); 57 $.ajax({ 58 type: 'POST', 59 url: cptch_vars.ajaxurl, 60 data: { 61 action: 'cptch_reload', 62 cptch_nonce: cptch_vars.nonce, 63 cptch_input_name: input_name, 64 cptch_input_class: input_class, 65 cptch_form_slug: form_slug 66 }, 67 success: function( result ) { 68 captcha_block.find( '.cptch_to_remove' ).remove(); 69 if ( input_class === '' ) 70 captcha.replaceWith( result ); /* for default forms */ 71 else 72 captcha_block.replaceWith( result ); /* for custom forms */ 73 74 if ( $( result ).hasClass( 'cptch_recognition' ) || $( result ).find( '.cptch_wrap' ).hasClass( 'cptch_recognition' ) ) { 75 $( '.cptch_recognition' ).each( function() { 76 $( this ).find( '.cptch_input' ).css( 'width', $( this ).find( '.cptch_images_wrap' ).css( 'width' ) ); 77 } ); 78 } 79 }, 80 error : function ( xhr, ajaxOptions, thrownError ) { 81 alert( xhr.status ); 82 alert( thrownError ); 83 } 84 }); 85 })(jQuery); 86}
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.