Fix JSHint errors in plupload handlers.js.

props mdbitz.
fixes #26041.


git-svn-id: https://develop.svn.wordpress.org/trunk@26205 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-11-15 05:55:24 +00:00
parent 1337df1724
commit 6ee347085f
1 changed files with 26 additions and 37 deletions

View File

@ -1,9 +1,7 @@
/* global plupload, pluploadL10n, ajaxurl, post_id, wpUploaderInit, deleteUserSetting, setUserSetting, getUserSetting */
/* global resize_width, resize_height, shortform */
var topWin = window.dialogArguments || opener || parent || top, uploader, uploader_init; var topWin = window.dialogArguments || opener || parent || top, uploader, uploader_init;
function fileDialogStart() {
jQuery("#media-upload-error").empty();
}
// progress and success handlers for media multi uploads // progress and success handlers for media multi uploads
function fileQueued(fileObj) { function fileQueued(fileObj) {
// Get rid of unused form // Get rid of unused form
@ -49,9 +47,8 @@ function fileUploading(up, file) {
if ( max > hundredmb && file.size > hundredmb ) { if ( max > hundredmb && file.size > hundredmb ) {
setTimeout(function(){ setTimeout(function(){
var done;
if ( file.status < 3 && file.loaded === 0 ) { // not uploading
if ( file.status < 3 && file.loaded == 0 ) { // not uploading
wpFileError(file, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>')); wpFileError(file, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>'));
up.stop(); // stops the whole queue up.stop(); // stops the whole queue
up.removeFile(file); up.removeFile(file);
@ -106,7 +103,7 @@ function uploadSuccess(fileObj, serverData) {
function setResize(arg) { function setResize(arg) {
if ( arg ) { if ( arg ) {
if ( uploader.features.jpgresize ) if ( uploader.features.jpgresize )
uploader.settings['resize'] = { width: resize_width, height: resize_height, quality: 100 }; uploader.settings.resize = { width: resize_width, height: resize_height, quality: 100 };
else else
uploader.settings.multipart_params.image_resize = true; uploader.settings.multipart_params.image_resize = true;
} else { } else {
@ -129,7 +126,7 @@ function prepareMediaItem(fileObj, serverData) {
item.append(serverData); item.append(serverData);
prepareMediaItemInit(fileObj); prepareMediaItemInit(fileObj);
} else { // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server } else { // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server
item.load('async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit(fileObj);updateMediaForm()}); item.load('async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit(fileObj);updateMediaForm();});
} }
} }
@ -171,9 +168,10 @@ function prepareMediaItemInit(fileObj) {
action: 'untrash-post', action: 'untrash-post',
_ajax_nonce: this.href.replace(/^.*wpnonce=/,'') _ajax_nonce: this.href.replace(/^.*wpnonce=/,'')
}, },
success: function(data, textStatus){ success: function( ){
var item = jQuery('#media-item-' + fileObj.id); var type,
item = jQuery('#media-item-' + fileObj.id);
if ( type = jQuery('#type-of-' + fileObj.id).val() ) if ( type = jQuery('#type-of-' + fileObj.id).val() )
jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-0+1); jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-0+1);
@ -210,21 +208,23 @@ function itemAjaxError(id, message) {
if ( last_err == id ) // prevent firing an error for the same file twice if ( last_err == id ) // prevent firing an error for the same file twice
return; return;
item.html('<div class="error-div">' item.html('<div class="error-div">' +
+ '<a class="dismiss" href="#">' + pluploadL10n.dismiss + '</a>' '<a class="dismiss" href="#">' + pluploadL10n.dismiss + '</a>' +
+ '<strong>' + pluploadL10n.error_uploading.replace('%s', jQuery.trim(filename)) + '</strong> ' '<strong>' + pluploadL10n.error_uploading.replace('%s', jQuery.trim(filename)) + '</strong> ' +
+ message message +
+ '</div>').data('last-err', id); '</div>').data('last-err', id);
} }
function deleteSuccess(data, textStatus) { function deleteSuccess(data) {
var type, id, item;
if ( data == '-1' ) if ( data == '-1' )
return itemAjaxError(this.id, 'You do not have permission. Has your session expired?'); return itemAjaxError(this.id, 'You do not have permission. Has your session expired?');
if ( data == '0' ) if ( data == '0' )
return itemAjaxError(this.id, 'Could not be deleted. Has it been deleted already?'); return itemAjaxError(this.id, 'Could not be deleted. Has it been deleted already?');
var id = this.id, item = jQuery('#media-item-' + id); id = this.id;
item = jQuery('#media-item-' + id);
// Decrement the counters. // Decrement the counters.
if ( type = jQuery('#type-of-' + id).val() ) if ( type = jQuery('#type-of-' + id).val() )
@ -252,7 +252,7 @@ function deleteSuccess(data, textStatus) {
return; return;
} }
function deleteError(X, textStatus, errorThrown) { function deleteError() {
// TODO // TODO
} }
@ -273,16 +273,6 @@ function switchUploader(s) {
} }
} }
function dndHelper(s) {
var d = document.getElementById('dnd-helper');
if ( s ) {
d.style.display = 'block';
} else {
d.style.display = 'none';
}
}
function uploadError(fileObj, errorCode, message, uploader) { function uploadError(fileObj, errorCode, message, uploader) {
var hundredmb = 100 * 1024 * 1024, max; var hundredmb = 100 * 1024 * 1024, max;
@ -459,9 +449,7 @@ jQuery(document).ready(function($){
up.start(); up.start();
}); });
uploader.bind('BeforeUpload', function(up, file) { // uploader.bind('BeforeUpload', function(up, file) {});
// something
});
uploader.bind('UploadFile', function(up, file) { uploader.bind('UploadFile', function(up, file) {
fileUploading(up, file); fileUploading(up, file);
@ -480,12 +468,13 @@ jQuery(document).ready(function($){
uploadSuccess(file, response.response); uploadSuccess(file, response.response);
}); });
uploader.bind('UploadComplete', function(up, files) { uploader.bind('UploadComplete', function() {
uploadComplete(); uploadComplete();
}); });
};
if ( typeof(wpUploaderInit) == 'object' ) {
uploader_init();
} }
if ( typeof(wpUploaderInit) == 'object' )
uploader_init();
}); });