1//Handle the file uploads 2jQuery(document).ready(function($) { 3 'use strict'; 4 5 /** 6 * Function called when the File upload button is called 7 * We upload the files before we submit the forms 8 */ 9 function tco_woo_file_upload(){ 10 $(document).on('click', 'button.tco_woo_file_upload', function(e) { 11 e.preventDefault(); 12 var sending = false; 13 var $inputFile = $(this).prev(); 14 var $button = $(this); 15 $inputFile.click(); 16 $inputFile.on('change', function() { 17 if(!sending){ 18 var data = new FormData(); 19 var id = $(this).attr('id'); 20 var $loading = $('#'+id+'_loading'); 21 var $ok = $('#'+id+'_ok'); 22 $loading.attr('src', tco_woo_js.loading_image).attr('alt', tco_woo_js.processing); 23 24 data.append('action', 'tco_woo_handle_file_upload'); 25 data.append('security', $(id+'_secret').val()); 26 data.append('tco_woo_file', $(this).prop('files')[0]); 27 28 $.ajax({ 29 type: 'POST', 30 processData: false, // important 31 contentType: false, // important 32 data: data, 33 url: tco_woo_js.ajaxurl, 34 success: function(jsonData) { 35 if( jsonData.error ) { 36 return false; 37 } 38 $button.hide(); 39 $loading.show(); 40 $loading.fadeOut(2000, function() { 41 $button.fadeIn('fast'); 42 if(!jsonData.error){ 43 $('#'+id+'_file').val(jsonData.url); 44 } 45 $inputFile.hide(); 46 $ok.show(); 47 $ok.fadeOut(2000, function() { }); 48 }); 49 $inputFile.hide(); 50 }, 51 error : function(){ 52 $loading.fadeOut(2000, function() { 53 $button.fadeIn('fast'); 54 }); 55 alert(tco_woo_js.error); 56 } 57 }); 58 } 59 sending = true; 60 }); 61 }); 62 } 63 64 tco_woo_file_upload(); //Call put function 65 66});
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.