| 1 | Index: wp-includes/js/swfupload/handlers.js |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/js/swfupload/handlers.js (revision 7253) |
|---|
| 4 | +++ wp-includes/js/swfupload/handlers.js (working copy) |
|---|
| 5 | @@ -55,20 +55,11 @@ |
|---|
| 6 | // Bind AJAX to the new Delete button |
|---|
| 7 | jQuery('#media-item-' + fileObj.id + ' a.delete').bind('click',function(){ |
|---|
| 8 | // Tell the server to delete it. TODO: handle exceptions |
|---|
| 9 | - jQuery.ajax({url:'admin-ajax.php',type:'post',data:{ |
|---|
| 10 | + jQuery.ajax({url:'admin-ajax.php',type:'post',success:deleteSuccess,error:deleteError,id:fileObj.id,data:{ |
|---|
| 11 | id : this.id.replace(/[^0-9]/g,''), |
|---|
| 12 | action : 'delete-post', |
|---|
| 13 | _ajax_nonce : this.href.replace(/^.*wpnonce=/,'')} |
|---|
| 14 | }); |
|---|
| 15 | - |
|---|
| 16 | - // Decrement the counters. |
|---|
| 17 | - if ( type = jQuery('#type-of-' + this.id.replace(/[^0-9]/g,'')).val() ) |
|---|
| 18 | - jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-1); |
|---|
| 19 | - if ( jQuery(this).parents('.media-item').eq(0).hasClass('child-of-'+post_id) ) |
|---|
| 20 | - jQuery('#attachments-count').text(jQuery('#attachments-count').text()-1); |
|---|
| 21 | - |
|---|
| 22 | - // Vanish it. |
|---|
| 23 | - jQuery(this).parents(".media-item").eq(0).slideToggle(300,function(){jQuery(this).remove();if(jQuery('.media-item').length==0)jQuery('.insert-gallery').hide();updateMediaForm();}); |
|---|
| 24 | return false; |
|---|
| 25 | }); |
|---|
| 26 | |
|---|
| 27 | @@ -79,6 +70,45 @@ |
|---|
| 28 | .parent().eq(0).children('.toggle').toggle(); |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | +function itemAjaxError(id, html) { |
|---|
| 32 | + var error = jQuery('#media-item-error' + id); |
|---|
| 33 | + |
|---|
| 34 | + error.html('<div class="file-error"><button type="button" id="dismiss-'+id+'" class="button dismiss">'+swfuploadL10n.dismiss+'</button>'+html+'</div>'); |
|---|
| 35 | + jQuery('#dismiss-'+id).click(function(){jQuery(this).parents('.file-error').slideUp(200, function(){jQuery(this).empty();})}); |
|---|
| 36 | +} |
|---|
| 37 | + |
|---|
| 38 | +function deleteSuccess(data, textStatus) { |
|---|
| 39 | + if ( data == '-1' ) |
|---|
| 40 | + return itemAjaxError(this.id, 'You do not have permission. Has your session expired?'); |
|---|
| 41 | + if ( data == '0' ) |
|---|
| 42 | + return itemAjaxError(this.id, 'Could not be deleted. Has it been deleted already?'); |
|---|
| 43 | + |
|---|
| 44 | + var item = jQuery('#media-item-' + this.id); |
|---|
| 45 | + |
|---|
| 46 | + // Decrement the counters. |
|---|
| 47 | + if ( type = jQuery('#type-of-' + this.id).val() ) |
|---|
| 48 | + jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-1); |
|---|
| 49 | + if ( item.hasClass('child-of-'+post_id) ) |
|---|
| 50 | + jQuery('#attachments-count').text(jQuery('#attachments-count').text()-1); |
|---|
| 51 | + |
|---|
| 52 | + if ( jQuery('.type-form #media-items>*').length == 1 && jQuery('#media-items .hidden').length > 0 ) { |
|---|
| 53 | + jQuery('.toggle').toggle(); |
|---|
| 54 | + jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden'); |
|---|
| 55 | + } |
|---|
| 56 | + |
|---|
| 57 | + jQuery('#media-item-' + this.id + ' .filename:empty').remove(); |
|---|
| 58 | + jQuery('#media-item-' + this.id + ' .filename').append(' <span class="file-error">'+swfuploadL10n.deleted+'</span>').siblings('a.toggle').remove(); |
|---|
| 59 | + jQuery('#media-item-' + this.id + ' .describe').slideUp(500, function(){jQuery(this).parents('.media-item').slideUp(1500,function(){jQuery(this).remove();updateMediaForm();})}).end.remove(); |
|---|
| 60 | + |
|---|
| 61 | + return; |
|---|
| 62 | + // Vanish it. |
|---|
| 63 | + item.slideToggle(300,function(){jQuery(this).remove();if(jQuery('.media-item').length==0)jQuery('.insert-gallery').hide();updateMediaForm();}); |
|---|
| 64 | +} |
|---|
| 65 | + |
|---|
| 66 | +function deleteError(X, textStatus, errorThrown) { |
|---|
| 67 | + // TODO |
|---|
| 68 | +} |
|---|
| 69 | + |
|---|
| 70 | function updateMediaForm() { |
|---|
| 71 | // Just one file, no need for collapsible part |
|---|
| 72 | if ( jQuery('.type-form #media-items>*').length == 1 ) { |
|---|
| 73 | @@ -130,8 +160,8 @@ |
|---|
| 74 | |
|---|
| 75 | // file-specific message |
|---|
| 76 | function wpFileError(fileObj, message) { |
|---|
| 77 | - jQuery('#media-item-' + fileObj.id + ' .filename').after('<div class="file-error"><button type="button" class="button dismiss">'+swfuploadL10n.dismiss+'</button>'+message+'</div>').siblings('.progress').remove(); |
|---|
| 78 | - jQuery('.dismiss').click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})}); |
|---|
| 79 | + jQuery('#media-item-' + fileObj.id + ' .filename').after('<div class="file-error"><button type="button" id="dismiss-' + fileObj.id + '" class="button dismiss">'+swfuploadL10n.dismiss+'</button>'+message+'</div>').siblings('.toggle').remove(); |
|---|
| 80 | + jQuery('#dismiss-' + fileObj.id).click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})}); |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | function fileQueueError(fileObj, error_code, message) { |
|---|
| 84 | Index: wp-includes/script-loader.php |
|---|
| 85 | =================================================================== |
|---|
| 86 | --- wp-includes/script-loader.php (revision 7253) |
|---|
| 87 | +++ wp-includes/script-loader.php (working copy) |
|---|
| 88 | @@ -84,7 +84,7 @@ |
|---|
| 89 | $this->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.0.2'); |
|---|
| 90 | $this->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.0.2'); |
|---|
| 91 | $this->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.0.2'); |
|---|
| 92 | - $this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-20080228'); |
|---|
| 93 | + $this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-20080301'); |
|---|
| 94 | // these error messages came from the sample swfupload js, they might need changing. |
|---|
| 95 | $this->localize( 'swfupload-handlers', 'swfuploadL10n', array( |
|---|
| 96 | 'queue_limit_exceeded' => __('You have attempted to queue too many files.'), |
|---|
| 97 | @@ -102,6 +102,7 @@ |
|---|
| 98 | 'upload_stopped' => __('Upload stopped.'), |
|---|
| 99 | 'dismiss' => __('Dismiss'), |
|---|
| 100 | 'crunching' => __('Crunching…'), |
|---|
| 101 | + 'deleted' => __('Deleted'), |
|---|
| 102 | ) ); |
|---|
| 103 | |
|---|
| 104 | $this->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui.tabs.js', array('jquery'), '3' ); |
|---|