(function($){
 $("aks-file-upload").aksFileUpload({
	//input: "#file", 
    fileUpload: "#aksfileupload",
	fileType: ["jpg","jpeg","png"],
	label: "Drag & Drop your Image or Browse",
    dragDrop: true,
    maxSize: "1 GB",
    multiple: false,
    maxFile: 1,
	
  });

function text_image_file_upload(fd){
jQuery.ajax({
	   type: "POST",
		url: ajaxurl,
		data: fd,
		contentType: false,
		processData: false,
		cache: false,
		async: true,
		enctype: "multipart/form-data",
		beforeSend	: function(){
		jQuery('.extracting-text-loder').show();	
		},	   
	  })
	   .done(function(data){
		if(data.isError == false){
		 $("#extracted_text").val(data.data.text);
		}else{
		 $("#extracted_text").val(data.message);	
		}
		jQuery('.extracting-text-loder').hide();
	   }).fail(function (data, errorThrown) {
		 $("#extracted_text").val("You have passed worng details. Please make sure all details must be correct.");	
		 jQuery('.extracting-text-loder').hide();  
	   });	 
}
  
$('.aks-file-upload').on('drop', function (e) {
        e.stopPropagation();
        e.preventDefault();

        var file = e.originalEvent.dataTransfer.files;
        var fd = new FormData();
        fd.append('file', file[0]);
        fd.append('action', 'etfi_get_text_form_image');  
        text_image_file_upload(fd);
  
    });  
   
 $(document).on('change','#aksfileupload',function(e){
  	  e.preventDefault();
	  var fd = new FormData();
      var file = $("#aksfileupload")
      var individual_file = file[0].files[0];
	  fd.append('action', 'etfi_get_text_form_image');  
      fd.append("file", individual_file);
	  if ($('#aksfileupload').length > 0) {	
	   text_image_file_upload(fd);
	  }
  });	  
  
$(document).on('click','.aks-file-upload-delete',function(e){	
    event.preventDefault();
   $("#extracted_text").val("");
});
})(jQuery);







