]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/plupload/handlers.js
WordPress 3.8.2
[autoinstalls/wordpress.git] / wp-includes / js / plupload / handlers.js
index 0b9937c4dbf3f57cc979cbe82b6c5f7be0337bc8..7b1a7b09530b5d3f65b6d12294003e303d6c9618 100644 (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;
 
-function fileDialogStart() {
-       jQuery("#media-upload-error").empty();
-}
-
 // progress and success handlers for media multi uploads
 function fileQueued(fileObj) {
        // Get rid of unused form
@@ -49,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', '<a class="uploader-html" href="#">').replace('%2$s', '</a>'));
                                up.stop(); // stops the whole queue
                                up.removeFile(file);
@@ -106,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 {
@@ -129,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();});
        }
 }
 
@@ -171,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);
 
@@ -210,21 +208,23 @@ function itemAjaxError(id, message) {
        if ( last_err == id ) // prevent firing an error for the same file twice
                return;
 
-       item.html('<div class="error-div">'
-                               + '<a class="dismiss" href="#">' + pluploadL10n.dismiss + '</a>'
-                               + '<strong>' + pluploadL10n.error_uploading.replace('%s', jQuery.trim(filename)) + '</strong> '
-                               + message
-                               '</div>').data('last-err', id);
+       item.html('<div class="error-div">' +
+                               '<a class="dismiss" href="#">' + pluploadL10n.dismiss + '</a>' +
+                               '<strong>' + pluploadL10n.error_uploading.replace('%s', jQuery.trim(filename)) + '</strong> ' +
+                               message +
+                               '</div>').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() )
@@ -252,7 +252,7 @@ function deleteSuccess(data, textStatus) {
        return;
 }
 
-function deleteError(X, textStatus, errorThrown) {
+function deleteError() {
        // 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) {
        var hundredmb = 100 * 1024 * 1024, max;
 
@@ -459,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);
@@ -480,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();
+       }
 
 });