Advertisement
artemsemkin

Rhye theme: AJAX compatibility with D&D File Upload plugin

May 14th, 2023 (edited)
1,130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (window.theme.isFirstLoad && jQuery('.wpcf7-drag-n-drop-file').length === 0) {
  2.   document.addEventListener( 'wpcf7mailsent', function( event ) {
  3.  
  4.     // Get input type file element
  5.     var inputFile = jQuery('.wpcf7-drag-n-drop-file');
  6.     var $form = inputFile.parents('form');
  7.  
  8.     // Reset upload list for multiple fields
  9.     if ( inputFile.length > 0 ) {
  10.       jQuery.each( inputFile, function(){
  11.         // Reset file counts
  12.         localStorage.setItem( jQuery(this).attr('data-name') + '_count_files', 1 );
  13.       });
  14.     } else {
  15.       // Reset file counts
  16.       localStorage.setItem( inputFile.attr('data-name') + '_count_files', 1 );
  17.     }
  18.  
  19.     // Remove status / progress bar
  20.     jQuery('.dnd-upload-status', $form ).remove();
  21.     jQuery('.dnd-upload-counter span', $form ).text('0');
  22.     jQuery('span.has-error-msg', $form ).remove();
  23.  
  24.   }, false);
  25. }
  26.  
  27. if (!window.theme.isFirstLoad && typeof window.initDragDrop === 'function') {
  28.   window.initDragDrop();
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement