Skip to content

Commit

Permalink
Improved uploader error handling and updated library.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Nov 3, 2015
1 parent b008761 commit 9436861
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
7 changes: 7 additions & 0 deletions assets/js/ajax-file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ jQuery(function($) {
fail: function (e, data) {
var $file_field = $( this );
var $form = $file_field.closest( 'form' );

if ( data.errorThrown ) {
alert( data.errorThrown );
}

data.context.remove();

$form.find(':input[type="submit"]').removeAttr( 'disabled' );
},
done: function (e, data) {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/ajax-file-upload.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions assets/js/jquery-fileupload/jquery.fileupload.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* jQuery File Upload Plugin 5.42.3
* jQuery File Upload Plugin
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
Expand Down Expand Up @@ -277,7 +277,8 @@
// The following are jQuery ajax settings required for the file uploads:
processData: false,
contentType: false,
cache: false
cache: false,
timeout: 0
},

// A list of options that require reinitializing event listeners and/or
Expand Down Expand Up @@ -983,7 +984,10 @@
fileSet,
i,
j = 0;
if (limitSize && (!filesLength || files[0].size === undefined)) {
if (!filesLength) {
return false;
}
if (limitSize && files[0].size === undefined) {
limitSize = undefined;
}
if (!(options.singleFileUploads || limit || limitSize) ||
Expand Down Expand Up @@ -1042,13 +1046,19 @@

_replaceFileInput: function (data) {
var input = data.fileInput,
inputClone = input.clone(true);
inputClone = input.clone(true),
restoreFocus = input.is(document.activeElement);
// Add a reference for the new cloned file input to the data argument:
data.fileInputClone = inputClone;
$('<form></form>').append(inputClone)[0].reset();
// Detaching allows to insert the fileInput on another form
// without loosing the file input value:
input.after(inputClone).detach();
// If the fileInput had focus before it was detached,
// restore focus to the inputClone.
if (restoreFocus) {
inputClone.focus();
}
// Avoid memory leaks with the detached file input:
$.cleanData(input.unbind('remove'));
// Replace the original file input element in the fileInput
Expand Down Expand Up @@ -1464,4 +1474,4 @@

});

}));
}));
2 changes: 1 addition & 1 deletion assets/js/jquery-fileupload/jquery.iframe-transport.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* jQuery Iframe Transport Plugin 1.8.3
* jQuery Iframe Transport Plugin
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2011, Sebastian Tschan
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ You can view (and contribute) translations via the [translate.wordpress.org](htt
* Fix - Handle WP 4.3 signup notification.
* Fix - Map mime types to those that WordPress knows.
* Fix - Alert text color.
* Tweak - Improved uploader error handling and updated library.
* Tweak - Improve job_manager_user_can_post_job and job_manager_user_can_edit_job capability handling in job-submit.php
* Tweak - Clear transients in batches of 500.
* Tweak - Removed transifex and translations - translation will take place on https://translate.wordpress.org/projects/wp-plugins/wp-job-manager
Expand Down
2 changes: 1 addition & 1 deletion wp-job-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function frontend_scripts() {

if ( apply_filters( 'job_manager_ajax_file_upload_enabled', true ) ) {
wp_register_script( 'jquery-iframe-transport', JOB_MANAGER_PLUGIN_URL . '/assets/js/jquery-fileupload/jquery.iframe-transport.js', array( 'jquery' ), '1.8.3', true );
wp_register_script( 'jquery-fileupload', JOB_MANAGER_PLUGIN_URL . '/assets/js/jquery-fileupload/jquery.fileupload.js', array( 'jquery', 'jquery-iframe-transport', 'jquery-ui-widget' ), '5.42.3', true );
wp_register_script( 'jquery-fileupload', JOB_MANAGER_PLUGIN_URL . '/assets/js/jquery-fileupload/jquery.fileupload.js', array( 'jquery', 'jquery-iframe-transport', 'jquery-ui-widget' ), '9.11.2', true );
wp_register_script( 'wp-job-manager-ajax-file-upload', JOB_MANAGER_PLUGIN_URL . '/assets/js/ajax-file-upload.min.js', array( 'jquery', 'jquery-fileupload' ), JOB_MANAGER_VERSION, true );

ob_start();
Expand Down

0 comments on commit 9436861

Please sign in to comment.