1/* 2(function($) { 3 4$(document).ready( function() { 5 var file_frame; // variable for the wp.media file_frame 6 7 // attach a click event (or whatever you want) to some element on your page 8 $( '#frontend-button' ).on( 'click', function( event ) { 9 event.preventDefault(); 10 11 // if the file_frame has already been created, just reuse it 12 if ( file_frame ) { 13 file_frame.open(); 14 return; 15 } 16 17 file_frame = wp.media.frames.file_frame = wp.media({ 18 title: $( this ).data( 'uploader_title' ), 19 button: { 20 text: $( this ).data( 'uploader_button_text' ), 21 }, 22 multiple: false // set this to true for multiple file selection 23 }); 24 25 file_frame.on( 'select', function() { 26 attachment = file_frame.state().get('selection').first().toJSON(); 27 28 // do something with the file here 29 $( '#frontend-button' ).hide(); 30 $( '#frontend-image' ).attr('src', attachment.url); 31 $( '#propic' ).val(attachment.url); 32 }); 33 34 file_frame.open(); 35 }); 36}); 37 38})(jQuery);*/ 39 40(function($){ 41$(document).ready( function() { 42 $('input[type=file][data-ajaxed=Y]').on('change', function(event) { 43 44 files = event.target.files; 45 var cont = $(this).attr('data-cont'); 46 var name = $(this).attr('name'); 47 48 var data = new FormData(); 49 $.each(files, function(key, value) 50 { 51 data.append(key, value); 52 }); 53 54 //data.append('partner_info_post_id', $(this).closest('form').find("#partner_info_post_id").val() ); 55 data.append('type', $(this).data('type')); 56 57 //$(cont).html('<img src="/assets/images/preloader.gif" />'); 58 $( '#frontend-image' ).attr('src', '/wp-admin/images/loading.gif'); 59 60 $.ajax({ 61 url: '/wp-admin/admin-ajax.php?action=file_upload&fname='+name, // Url to which the request is send 62 type: "POST", // Type of request to be send, called as method 63 data: data, // Data sent to server, a set of key/value pairs (i.e. form fields and values) 64 65 dataType: 'json', 66 contentType: false, // The content type used when sending data to the server. 67 cache: false, // To unable request pages to be cached 68 processData:false, // To send DOMDocument or non processed data file it is set to false 69 success: function(data) // A function to be called if request succeeds 70 { 71 console.log(data); 72 if(data.error) 73 { 74 alert(data.error); 75 } 76 else 77 { 78 //$(cont).html('<img src="'+data.src+'" style="max-width:100%;" />'); 79 $( '#frontend-image' ).attr('src', data.src); 80 //$('[name='+name+'_aid]').val(data.aid); 81 $('#propic').val(data.src); 82 } 83 }, 84 error: function(jqXHR, textStatus, errorThrown) 85 { 86 // Handle errors here 87 console.log('ERRORS: ' + textStatus); 88 alert('ERRORS: ' + textStatus); 89 $(cont).html('error'); 90 // STOP LOADING SPINNER 91 } 92 }); 93 94 }); 95 96 $('.scheck').on('change', function(event) { 97 $('.scheck').removeAttr('checked'); 98 $(this).prop("checked",true); 99 100 var vale; 101 vale = $(this).val(); 102 103 if($(this).prop("checked") == true){ 104 105 $('#input_6_8').val(vale); 106 } 107}); 108}); 109 110 111})(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.