X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/6c8f14c09105d0afa4c1574215c59b5021040e76..ceb5a929e00123b4e224977c6b5a149f6431b250:/wp-includes/js/plupload/handlers.js diff --git a/wp-includes/js/plupload/handlers.js b/wp-includes/js/plupload/handlers.js index e903f570..7b1a7b09 100644 --- a/wp-includes/js/plupload/handlers.js +++ b/wp-includes/js/plupload/handlers.js @@ -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; -function fileDialogStart() { - jQuery("#media-upload-error").empty(); -} - // progress and success handlers for media multi uploads function fileQueued(fileObj) { // Get rid of unused form @@ -16,7 +14,12 @@ function fileQueued(fileObj) { items.removeClass('open').find('.slidetoggle').slideUp(200); } // Create a progress bar containing the filename - jQuery('#media-items').append('
0%
' + fileObj.name + '
'); + jQuery('
') + .attr( 'id', 'media-item-' + fileObj.id ) + .addClass('child-of-' + postid) + .append('
0%
', + jQuery('
').text( ' ' + fileObj.name )) + .appendTo( jQuery('#media-items' ) ); // Disable submit jQuery('#insert-gallery').prop('disabled', true); @@ -44,9 +47,8 @@ function fileUploading(up, file) { if ( max > hundredmb && file.size > hundredmb ) { 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', '').replace('%2$s', '')); up.stop(); // stops the whole queue up.removeFile(file); @@ -101,7 +103,7 @@ function uploadSuccess(fileObj, serverData) { function setResize(arg) { if ( arg ) { 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 uploader.settings.multipart_params.image_resize = true; } else { @@ -124,7 +126,7 @@ function prepareMediaItem(fileObj, serverData) { item.append(serverData); prepareMediaItemInit(fileObj); } 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();}); } } @@ -166,9 +168,10 @@ function prepareMediaItemInit(fileObj) { action: 'untrash-post', _ajax_nonce: this.href.replace(/^.*wpnonce=/,'') }, - success: function(data, textStatus){ - var item = jQuery('#media-item-' + fileObj.id); - + success: function( ){ + var type, + item = jQuery('#media-item-' + fileObj.id); + if ( type = jQuery('#type-of-' + fileObj.id).val() ) jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-0+1); @@ -205,21 +208,23 @@ function itemAjaxError(id, message) { if ( last_err == id ) // prevent firing an error for the same file twice return; - item.html('
' - + '' + pluploadL10n.dismiss + '' - + '' + pluploadL10n.error_uploading.replace('%s', jQuery.trim(filename)) + ' ' - + message - + '
').data('last-err', id); + item.html('
' + + '' + pluploadL10n.dismiss + '' + + '' + pluploadL10n.error_uploading.replace('%s', jQuery.trim(filename)) + ' ' + + message + + '
').data('last-err', id); } -function deleteSuccess(data, textStatus) { +function deleteSuccess(data) { + var type, id, item; if ( data == '-1' ) return itemAjaxError(this.id, 'You do not have permission. Has your session expired?'); if ( data == '0' ) 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. if ( type = jQuery('#type-of-' + id).val() ) @@ -247,7 +252,7 @@ function deleteSuccess(data, textStatus) { return; } -function deleteError(X, textStatus, errorThrown) { +function deleteError() { // TODO } @@ -268,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) { var hundredmb = 100 * 1024 * 1024, max; @@ -454,9 +449,7 @@ jQuery(document).ready(function($){ up.start(); }); - uploader.bind('BeforeUpload', function(up, file) { - // something - }); + // uploader.bind('BeforeUpload', function(up, file) {}); uploader.bind('UploadFile', function(up, file) { fileUploading(up, file); @@ -475,12 +468,13 @@ jQuery(document).ready(function($){ uploadSuccess(file, response.response); }); - uploader.bind('UploadComplete', function(up, files) { + uploader.bind('UploadComplete', function() { uploadComplete(); }); - } + }; - if ( typeof(wpUploaderInit) == 'object' ) + if ( typeof(wpUploaderInit) == 'object' ) { uploader_init(); + } });