WordPress.org

Make WordPress Core

Changeset 7256


Ignore:
Timestamp:
03/11/2008 11:15:17 PM (10 years ago)
Author:
ryan
Message:

media handling fixes from andy. see #5911

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/swfupload/handlers.js

    r7228 r7256  
    5656    jQuery('#media-item-' + fileObj.id + ' a.delete').bind('click',function(){
    5757        // Tell the server to delete it. TODO: handle exceptions
    58         jQuery.ajax({url:'admin-ajax.php',type:'post',data:{
     58        jQuery.ajax({url:'admin-ajax.php',type:'post',success:deleteSuccess,error:deleteError,id:fileObj.id,data:{
    5959            id : this.id.replace(/[^0-9]/g,''),
    6060            action : 'delete-post',
    6161            _ajax_nonce : this.href.replace(/^.*wpnonce=/,'')}
    6262            });
    63 
    64         // Decrement the counters.
    65         if ( type = jQuery('#type-of-' + this.id.replace(/[^0-9]/g,'')).val() )
    66             jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-1);
    67         if ( jQuery(this).parents('.media-item').eq(0).hasClass('child-of-'+post_id) )
    68             jQuery('#attachments-count').text(jQuery('#attachments-count').text()-1);
    69 
    70         // Vanish it.
    71         jQuery(this).parents(".media-item").eq(0).slideToggle(300,function(){jQuery(this).remove();if(jQuery('.media-item').length==0)jQuery('.insert-gallery').hide();updateMediaForm();});
    7263        return false;
    7364    });
     
    8071}
    8172
     73function itemAjaxError(id, html) {
     74    var error = jQuery('#media-item-error' + id);
     75
     76    error.html('<div class="file-error"><button type="button" id="dismiss-'+id+'" class="button dismiss">'+swfuploadL10n.dismiss+'</button>'+html+'</div>');
     77    jQuery('#dismiss-'+id).click(function(){jQuery(this).parents('.file-error').slideUp(200, function(){jQuery(this).empty();})});
     78}
     79
     80function deleteSuccess(data, textStatus) {
     81    if ( data == '-1' )
     82        return itemAjaxError(this.id, 'You do not have permission. Has your session expired?');
     83    if ( data == '0' )
     84        return itemAjaxError(this.id, 'Could not be deleted. Has it been deleted already?');
     85
     86    var item = jQuery('#media-item-' + this.id);
     87
     88    // Decrement the counters.
     89    if ( type = jQuery('#type-of-' + this.id).val() )
     90        jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-1);
     91    if ( item.hasClass('child-of-'+post_id) )
     92        jQuery('#attachments-count').text(jQuery('#attachments-count').text()-1);
     93
     94    if ( jQuery('.type-form #media-items>*').length == 1 && jQuery('#media-items .hidden').length > 0 ) {
     95        jQuery('.toggle').toggle();
     96        jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden');
     97    }
     98
     99    jQuery('#media-item-' + this.id + ' .filename:empty').remove();
     100    jQuery('#media-item-' + this.id + ' .filename').append(' <span class="file-error">'+swfuploadL10n.deleted+'</span>').siblings('a.toggle').remove();
     101    jQuery('#media-item-' + this.id + ' .describe').slideUp(500, function(){jQuery(this).parents('.media-item').slideUp(1500,function(){jQuery(this).remove();updateMediaForm();})}).end.remove();
     102
     103    return;
     104    // Vanish it.
     105    item.slideToggle(300,function(){jQuery(this).remove();if(jQuery('.media-item').length==0)jQuery('.insert-gallery').hide();updateMediaForm();});
     106}
     107
     108function deleteError(X, textStatus, errorThrown) {
     109    // TODO
     110}
     111
    82112function updateMediaForm() {
    83113    // Just one file, no need for collapsible part
     
    131161// file-specific message
    132162function wpFileError(fileObj, message) {
    133     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();
    134     jQuery('.dismiss').click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})});
     163    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();
     164    jQuery('#dismiss-' + fileObj.id).click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})});
    135165}
    136166
  • trunk/wp-includes/script-loader.php

    r7236 r7256  
    8585        $this->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.0.2');
    8686        $this->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.0.2');
    87         $this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-20080228');
     87        $this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-20080301');
    8888        // these error messages came from the sample swfupload js, they might need changing.
    8989        $this->localize( 'swfupload-handlers', 'swfuploadL10n', array(
     
    103103                'dismiss' => __('Dismiss'),
    104104                'crunching' => __('Crunching&hellip;'),
     105                'deleted' => __('Deleted'),
    105106        ) );
    106107
Note: See TracChangeset for help on using the changeset viewer.