WordPress.org

Make WordPress Core

Changeset 12130


Ignore:
Timestamp:
10/30/2009 07:09:55 AM (9 years ago)
Author:
azaozz
Message:

Trash undo for the uploader, props caesarsgrunt, see #4529

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r12052 r12130  
    335335    break;
    336336case 'trash-post' :
     337case 'untrash-post' :
    337338    check_ajax_referer( "{$action}_$id" );
    338339    if ( !current_user_can( 'delete_post', $id ) )
     
    342343        die('1');
    343344
    344     if ( wp_trash_post( $id ) )
    345         die('1');
     345    if ( 'trash-post' == $action )
     346        $done = wp_trash_post( $id );
    346347    else
    347         die('0');
     348        $done = wp_untrash_post( $id );
     349
     350    if ( $done )
     351        die('1');
     352
     353    die('0');
    348354    break;
    349355case 'delete-page' :
  • trunk/wp-admin/css/media-rtl.css

    r11557 r12130  
    4949}
    5050
    51 .describe-toggle-on,
    52 .describe-toggle-off {
    53     float: left;
    54     margin-right: 0;
    55     margin-left: 20px;
    56 }
    5751/* Specific to Uploader */
    5852#media-upload .media-upload-form p {
  • trunk/wp-admin/css/media.css

    r12098 r12130  
    1 div#media-upload-header{margin:0;padding:0 5px;font-weight:bold;position:relative;border-bottom-width:1px;border-bottom-style:solid;height:2.5em;}body#media-upload ul#sidemenu{font-weight:normal;margin:0 5px;position:absolute;left:0;bottom:-1px;}div#media-upload-error{margin:1em;font-weight:bold;}form{margin:1em;}#search-filter{text-align:right;}th{position:relative;}.media-upload-form label.form-help,td.help{font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif;font-style:italic;font-weight:normal;}.media-upload-form p.help{margin:0;padding:0;}.media-upload-form fieldset{width:100%;border:none;text-align:justify;margin:0 0 1em 0;padding:0;}.image-align-none-label{background:url(../images/align-none.png) no-repeat center left;}.image-align-left-label{background:url(../images/align-left.png) no-repeat center left;}.image-align-center-label{background:url(../images/align-center.png) no-repeat center left;}.image-align-right-label{background:url(../images/align-right.png) no-repeat center left;}tr.image-size td{width:460px;}tr.image-size div.image-size-item{float:left;width:25%;margin:0;}#library-form .progress,#gallery-form .progress,#flash-upload-ui,.insert-gallery,.describe.startopen,.describe.startclosed{display:none;}.media-item .thumbnail{max-width:128px;max-height:128px;}thead.media-item-info tr{background-color:transparent;}thead.media-item-info th,thead.media-item-info td{border:none;margin:0;}.form-table thead.media-item-info{border:8px solid #fff;}abbr.required{text-decoration:none;border:none;}.describe label{display:inline;}.describe td{vertical-align:middle;padding:0 5px 8px 0;}.describe td.A1{width:132px;}.describe input[type="text"],.describe textarea{width:460px;border-width:1px;border-style:solid;}.describe-toggle-on,.describe-toggle-off{display:block;line-height:36px;float:right;margin-right:20px;}.describe-toggle-off{display:none;}.hidden{height:0;width:0;overflow:hidden;border:none;}#media-upload p.ml-submit{padding:1em 0;}#media-upload p.help,#media-upload label.help{font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif;font-style:italic;font-weight:normal;}#media-upload tr.image-size td.field{text-align:center;}#media-upload #media-items{border-width:1px;border-style:solid;border-bottom:none;width:623px;}#media-upload .media-item{border-bottom-width:1px;border-bottom-style:solid;min-height:36px;width:100%;}#media-upload .ui-sortable .media-item{cursor:move;}.filename{line-height:36px;padding:0 10px;overflow:hidden;}#media-upload .describe{padding:5px;width:100%;clear:both;cursor:default;}#media-upload .slidetoggle{border-top-width:1px;border-top-style:solid;}#media-upload .describe th.label{padding-top:.2em;text-align:left;min-width:120px;}#media-upload tr.align td.field{text-align:center;}#media-upload tr.image-size{margin-bottom:1em;height:3em;}#media-upload #filter{width:623px;}#media-upload #filter .subsubsub{margin:8px 0;}#filter .tablenav select{border-style:solid;border-width:1px;padding:2px;vertical-align:top;width:auto;}#media-upload .del-attachment{display:none;margin:5px 0;}.menu_order{float:right;font-size:11px;margin:10px 10px 0;}.menu_order_input{border:1px solid #ddd;font-size:10px;padding:1px;width:23px;}.ui-sortable-helper{background-color:#fff;border:1px solid #aaa;opacity:.6;filter:alpha(opacity=60);}#media-upload th.order-head{width:20%;text-align:center;}#media-upload th.actions-head{width:25%;text-align:center;}#media-upload a.wp-post-thumbnail{margin:0 20px;}#media-items a.delete{display:block;float:right;}#media-upload .widefat{width:626px;border-style:solid solid none;}.sorthelper{height:37px;width:623px;display:block;}#gallery-settings th.label{width:160px;}#gallery-settings #basic th.label{padding:5px 5px 5px 0;}#gallery-settings .title{clear:both;padding:0 0 3px;font-size:1.6em;border-bottom:1px solid #DADADA;}h3.media-title{font-size:1.6em;}h4.media-sub-title{border-bottom:1px solid #DADADA;font-size:1.3em;margin:12px;padding:0 0 3px;}#gallery-settings .title,h3.media-title,h4.media-sub-title{font-family:Georgia,"Times New Roman",Times,serif;font-weight:normal;color:#5A5A5A;}#gallery-settings .describe td{vertical-align:middle;height:3em;}#gallery-settings .describe th.label{padding-top:.5em;text-align:left;}#gallery-settings .describe{padding:5px;width:615px;clear:both;cursor:default;}#gallery-settings .describe select{width:15em;}#gallery-settings .describe select option,#gallery-settings .describe td{padding:0;}#gallery-settings label,#gallery-settings legend{font-size:13px;color:#464646;margin-right:15px;}#gallery-settings .align .field label{margin:0 1.5em 0 0;}#gallery-settings p.ml-submit{border-top:1px solid #dfdfdf;}#gallery-settings select#columns{width:6em;}#sort-buttons{font-size:.8em;margin:3px 25px -8px 0;text-align:right;max-width:625px;}#sort-buttons a{text-decoration:none;}#sort-buttons #asc,#sort-buttons #showall{padding-left:5px;}#sort-buttons span{margin-right:25px;}
     1div#media-upload-header{margin:0;padding:0 5px;font-weight:bold;position:relative;border-bottom-width:1px;border-bottom-style:solid;height:2.5em;}body#media-upload ul#sidemenu{font-weight:normal;margin:0 5px;position:absolute;left:0;bottom:-1px;}div#media-upload-error{margin:1em;font-weight:bold;}form{margin:1em;}#search-filter{text-align:right;}th{position:relative;}.media-upload-form label.form-help,td.help{font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif;font-style:italic;font-weight:normal;}.media-upload-form p.help{margin:0;padding:0;}.media-upload-form fieldset{width:100%;border:none;text-align:justify;margin:0 0 1em 0;padding:0;}.image-align-none-label{background:url(../images/align-none.png) no-repeat center left;}.image-align-left-label{background:url(../images/align-left.png) no-repeat center left;}.image-align-center-label{background:url(../images/align-center.png) no-repeat center left;}.image-align-right-label{background:url(../images/align-right.png) no-repeat center left;}tr.image-size td{width:460px;}tr.image-size div.image-size-item{float:left;width:25%;margin:0;}#library-form .progress,#gallery-form .progress,#flash-upload-ui,.insert-gallery,.describe.startopen,.describe.startclosed{display:none;}.media-item .thumbnail{max-width:128px;max-height:128px;}thead.media-item-info tr{background-color:transparent;}thead.media-item-info th,thead.media-item-info td{border:none;margin:0;}.form-table thead.media-item-info{border:8px solid #fff;}abbr.required{text-decoration:none;border:none;}.describe label{display:inline;}.describe td{vertical-align:middle;padding:0 5px 8px 0;}.describe td.A1{width:132px;}.describe input[type="text"],.describe textarea{width:460px;border-width:1px;border-style:solid;}.hidden{height:0;width:0;overflow:hidden;border:none;}#media-upload p.ml-submit{padding:1em 0;}#media-upload p.help,#media-upload label.help{font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif;font-style:italic;font-weight:normal;}#media-upload tr.image-size td.field{text-align:center;}#media-upload #media-items{border-width:1px;border-style:solid;border-bottom:none;width:623px;}#media-upload .media-item{border-bottom-width:1px;border-bottom-style:solid;min-height:36px;width:100%;}#media-upload .ui-sortable .media-item{cursor:move;}.filename{line-height:36px;padding:0 10px;overflow:hidden;}#media-upload .describe{padding:5px;width:100%;clear:both;cursor:default;}#media-upload .slidetoggle{border-top-width:1px;border-top-style:solid;}#media-upload .describe th.label{padding-top:.2em;text-align:left;min-width:120px;}#media-upload tr.align td.field{text-align:center;}#media-upload tr.image-size{margin-bottom:1em;height:3em;}#media-upload #filter{width:623px;}#media-upload #filter .subsubsub{margin:8px 0;}#filter .tablenav select{border-style:solid;border-width:1px;padding:2px;vertical-align:top;width:auto;}#media-upload .del-attachment{display:none;margin:5px 0;}.menu_order{float:right;font-size:11px;margin:10px 10px 0;}.menu_order_input{border:1px solid #ddd;font-size:10px;padding:1px;width:23px;}.ui-sortable-helper{background-color:#fff;border:1px solid #aaa;opacity:.6;filter:alpha(opacity=60);}#media-upload th.order-head{width:20%;text-align:center;}#media-upload th.actions-head{width:25%;text-align:center;}#media-upload a.wp-post-thumbnail{margin:0 20px;}#media-items a.delete{display:block;float:right;}#media-upload .widefat{width:626px;border-style:solid solid none;}.sorthelper{height:37px;width:623px;display:block;}#gallery-settings th.label{width:160px;}#gallery-settings #basic th.label{padding:5px 5px 5px 0;}#gallery-settings .title{clear:both;padding:0 0 3px;font-size:1.6em;border-bottom:1px solid #DADADA;}h3.media-title{font-size:1.6em;}h4.media-sub-title{border-bottom:1px solid #DADADA;font-size:1.3em;margin:12px;padding:0 0 3px;}#gallery-settings .title,h3.media-title,h4.media-sub-title{font-family:Georgia,"Times New Roman",Times,serif;font-weight:normal;color:#5A5A5A;}#gallery-settings .describe td{vertical-align:middle;height:3em;}#gallery-settings .describe th.label{padding-top:.5em;text-align:left;}#gallery-settings .describe{padding:5px;width:615px;clear:both;cursor:default;}#gallery-settings .describe select{width:15em;}#gallery-settings .describe select option,#gallery-settings .describe td{padding:0;}#gallery-settings label,#gallery-settings legend{font-size:13px;color:#464646;margin-right:15px;}#gallery-settings .align .field label{margin:0 1.5em 0 0;}#gallery-settings p.ml-submit{border-top:1px solid #dfdfdf;}#gallery-settings select#columns{width:6em;}#sort-buttons{font-size:.8em;margin:3px 25px -8px 0;text-align:right;max-width:625px;}#sort-buttons a{text-decoration:none;}#sort-buttons #asc,#sort-buttons #showall{padding-left:5px;}#sort-buttons span{margin-right:25px;}
  • trunk/wp-admin/css/media.dev.css

    r12098 r12130  
    135135}
    136136
    137 .describe-toggle-on,
    138 .describe-toggle-off {
    139     display: block;
    140     line-height: 36px;
    141     float: right;
    142     margin-right: 20px;
    143 }
    144 
    145 .describe-toggle-off {
    146     display: none;
    147 }
    148 
    149137.hidden {
    150138    height: 0;
  • trunk/wp-admin/includes/media.php

    r12110 r12130  
    12041204    );
    12051205
    1206     $delete_href = wp_nonce_url("post.php?action=trash&post=$attachment_id", 'trash-post_' . $attachment_id);
     1206    $trash_href = wp_nonce_url("post.php?action=trash&post=$attachment_id", 'trash-post_' . $attachment_id);
     1207    $untrash_href = wp_nonce_url("post.php?action=untrash&post=$attachment_id", 'untrash-post_' . $attachment_id);
    12071208    if ( $send )
    12081209        $send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />";
    12091210    if ( $delete )
    1210         $delete = current_user_can('delete_post', $attachment_id) ? "<a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a>" : "";
     1211        $delete = current_user_can('delete_post', $attachment_id) ? "<a href=\"$trash_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a> <a href=\"$untrash_href\" id=\"undo[$attachment_id]\" class=\"undo hidden\">" . __('Undo?') . "</a>" : "";
    12111212    if ( 'image' == $type && get_post_image_id($_GET['post_id']) != $attachment_id )
    12121213        $thumbnail = "<a class='wp-post-thumbnail' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\");return false;'>" . esc_html__( "Use as thumbnail" ) . "</a>";
  • trunk/wp-includes/js/swfupload/handlers.dev.js

    r11841 r12130  
    99    jQuery('.media-blank').remove();
    1010    // Collapse a single item
    11     if ( jQuery('.type-form #media-items>*').length == 1 && jQuery('#media-items .hidden').length > 0 ) {
     11    if ( jQuery('form.type-form #media-items').children().length == 1 && jQuery('.hidden', '#media-items').length > 0 ) {
    1212        jQuery('.describe-toggle-on').show();
    1313        jQuery('.describe-toggle-off').hide();
     
    1717    jQuery('#media-items').append('<div id="media-item-' + fileObj.id + '" class="media-item child-of-' + post_id + '"><div class="progress"><div class="bar"></div></div><div class="filename original"><span class="percent"></span> ' + fileObj.name + '</div></div>');
    1818    // Display the progress div
    19     jQuery('#media-item-' + fileObj.id + ' .progress').show();
     19    jQuery('.progress', '#media-item-' + fileObj.id).show();
    2020
    2121    // Disable submit and enable cancel
     
    3030function uploadProgress(fileObj, bytesDone, bytesTotal) {
    3131    // Lengthen the progress bar
    32     var w = jQuery('#media-items').width() - 2;
    33     jQuery('#media-item-' + fileObj.id + ' .bar').width( w * bytesDone / bytesTotal );
    34     jQuery('#media-item-' + fileObj.id + ' .percent').html( Math.ceil(bytesDone / bytesTotal * 100) + '%' );
     32    var w = jQuery('#media-items').width() - 2, item = jQuery('#media-item-' + fileObj.id);
     33    jQuery('.bar', item).width( w * bytesDone / bytesTotal );
     34    jQuery('.percent', item).html( Math.ceil(bytesDone / bytesTotal * 100) + '%' );
    3535
    3636    if ( bytesDone == bytesTotal )
    37         jQuery('#media-item-' + fileObj.id + ' .bar').html('<strong class="crunching">' + swfuploadL10n.crunching + '</strong>');
     37        jQuery('.bar', item).html('<strong class="crunching">' + swfuploadL10n.crunching + '</strong>');
    3838}
    3939
    4040function prepareMediaItem(fileObj, serverData) {
     41    var f = ( typeof shortform == 'undefined' ) ? 1 : 2, item = jQuery('#media-item-' + fileObj.id);
    4142    // Move the progress bar to 100%
    42     jQuery('#media-item-' + fileObj.id + ' .bar').remove();
    43     jQuery('#media-item-' + fileObj.id + ' .progress').hide();
    44 
    45     var f = ( typeof shortform == 'undefined' ) ? 1 : 2;
     43    jQuery('.bar', item).remove();
     44    jQuery('.progress', item).hide();
     45
    4646    // Old style: Append the HTML returned by the server -- thumbnail and form inputs
    4747    if ( isNaN(serverData) || !serverData ) {
    48         jQuery('#media-item-' + fileObj.id).append(serverData);
     48        item.append(serverData);
    4949        prepareMediaItemInit(fileObj);
    5050    }
    5151    // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server
    5252    else {
    53         jQuery('#media-item-' + fileObj.id).load('async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit(fileObj);updateMediaForm()});
    54     }
    55 }
    56        
     53        item.load('async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit(fileObj);updateMediaForm()});
     54    }
     55}
     56
    5757function prepareMediaItemInit(fileObj) {
    58 
     58    var item = jQuery('#media-item-' + fileObj.id);
    5959    // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename
    60     jQuery('#media-item-' + fileObj.id + ' .thumbnail').clone().attr('className', 'pinkynail toggle').prependTo('#media-item-' + fileObj.id);
     60    jQuery('.thumbnail', item).clone().attr('className', 'pinkynail toggle').prependTo(item);
    6161
    6262    // Replace the original filename with the new (unique) one assigned during upload
    63     jQuery('#media-item-' + fileObj.id + ' .filename.original').replaceWith(jQuery('#media-item-' + fileObj.id + ' .filename.new'));
     63    jQuery('.filename.original', item).replaceWith( jQuery('.filename.new', item) );
    6464
    6565    // Also bind toggle to the links
    66     jQuery('#media-item-' + fileObj.id + ' a.toggle').click(function(){
    67         jQuery(this).siblings('.slidetoggle').slideToggle(150, function(){
     66    jQuery('a.toggle', item).click(function(){
     67        jQuery(this).siblings('.slidetoggle').slideToggle(350, function(){
    6868            var o = jQuery(this).offset();
    69             window.scrollTo(0, o.top-36);
     69            window.scrollTo(0, o.top - 36);
    7070        });
    71         jQuery(this).parent().children('.toggle').toggle();
     71        jQuery(this).siblings('.toggle').andSelf().toggle();
    7272        jQuery(this).siblings('a.toggle').focus();
    7373        return false;
     
    7575
    7676    // Bind AJAX to the new Delete button
    77     jQuery('#media-item-' + fileObj.id + ' a.delete').click(function(){
     77    jQuery('a.delete', item).click(function(){
    7878        // Tell the server to delete it. TODO: handle exceptions
    79         jQuery.ajax({url:'admin-ajax.php',type:'post',success:deleteSuccess,error:deleteError,id:fileObj.id,data:{
    80             id : this.id.replace(/[^0-9]/g,''),
    81             action : 'trash-post',
    82             _ajax_nonce : this.href.replace(/^.*wpnonce=/,'')}
    83             });
     79        jQuery.ajax({
     80            url: 'admin-ajax.php',
     81            type: 'post',
     82            success: deleteSuccess,
     83            error: deleteError,
     84            id: fileObj.id,
     85            data: {
     86                id : this.id.replace(/[^0-9]/g, ''),
     87                action : 'trash-post',
     88                _ajax_nonce : this.href.replace(/^.*wpnonce=/,'')
     89            }
     90        });
    8491        return false;
    8592    });
    8693
     94    // Bind AJAX to the new Undo button
     95    jQuery('a.undo', item).click(function(){
     96        // Tell the server to untrash it. TODO: handle exceptions
     97        jQuery.ajax({
     98            url: 'admin-ajax.php',
     99            type: 'post',
     100            id: fileObj.id,
     101            data: {
     102                id : this.id.replace(/[^0-9]/g,''),
     103                action: 'untrash-post',
     104                _ajax_nonce: this.href.replace(/^.*wpnonce=/,'')
     105            },
     106            success: function(data, textStatus){
     107                var item = jQuery('#media-item-' + fileObj.id);
     108
     109                if ( type = jQuery('#type-of-' + fileObj.id).val() )
     110                    jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-0+1);
     111                if ( item.hasClass('child-of-'+post_id) )
     112                    jQuery('#attachments-count').text(jQuery('#attachments-count').text()-0+1);
     113
     114                jQuery('.filename .trashnotice', item).remove();
     115                jQuery('a.undo', item).addClass('hidden');
     116                jQuery('a.describe-toggle-on, .menu_order_input', item).show();
     117                item.animate( {backgroundColor: '#fff'}, { queue: false, duration: 200, complete: function(){ jQuery(this).css({backgroundColor:''}); } });
     118            }
     119        });
     120        return false;
     121    });
     122
    87123    // Open this item if it says to start open (e.g. to display an error)
    88     jQuery('#media-item-' + fileObj.id + '.startopen').removeClass('startopen').slideToggle(500).parent().children('.toggle').toggle();
     124    jQuery('#media-item-' + fileObj.id + '.startopen').removeClass('startopen').slideToggle(500).siblings('.toggle').toggle();
    89125}
    90126
     
    102138        return itemAjaxError(this.id, 'Could not be deleted. Has it been deleted already?');
    103139
    104     var item = jQuery('#media-item-' + this.id);
     140    var id = this.id, item = jQuery('#media-item-' + id);
    105141
    106142    // Decrement the counters.
    107     if ( type = jQuery('#type-of-' + this.id).val() )
    108         jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-1);
     143    if ( type = jQuery('#type-of-' + id).val() )
     144        jQuery('#' + type + '-counter').text( jQuery('#' + type + '-counter').text() - 1 );
    109145    if ( item.hasClass('child-of-'+post_id) )
    110         jQuery('#attachments-count').text(jQuery('#attachments-count').text()-1);
    111 
    112     if ( jQuery('.type-form #media-items>*').length == 1 && jQuery('#media-items .hidden').length > 0 ) {
     146        jQuery('#attachments-count').text( jQuery('#attachments-count').text() - 1 );
     147
     148    if ( jQuery('form.type-form #media-items').children().length == 1 && jQuery('.hidden', '#media-items').length > 0 ) {
    113149        jQuery('.toggle').toggle();
    114150        jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden');
     
    116152
    117153    // Vanish it.
    118     jQuery('#media-item-' + this.id + ' .filename:empty').remove();
    119     jQuery('#media-item-' + this.id + ' .filename').append(' <span class="file-error">'+swfuploadL10n.deleted+'</span>').siblings('a.toggle').remove();
    120     jQuery('#media-item-' + this.id).children('.describe').css({backgroundColor:'#fff'}).end()
    121             .animate({backgroundColor:'#ffc0c0'}, {queue:false,duration:50})
    122             .animate({minHeight:0,height:36}, 400, null, function(){jQuery(this).children('.describe').remove()})
    123             .animate({backgroundColor:'#fff'}, 400)
    124             .animate({height:0}, 800, null, function(){jQuery(this).remove();updateMediaForm();});
     154    jQuery('.toggle', item).toggle();
     155    jQuery('.slidetoggle', item).slideUp(200).siblings().removeClass('hidden');
     156    item.css( {backgroundColor:'#fff'} ).animate( {backgroundColor:'#ffc0c0'}, {queue:false, duration:500} );
     157
     158    jQuery('.filename:empty', item).remove();
     159    jQuery('.filename', item).append('<span class="trashnotice"> ' + swfuploadL10n.deleted + ' </span>').siblings('a.toggle').hide();
     160    jQuery('.filename', item).append( jQuery('a.undo', item).removeClass('hidden') );
     161    jQuery('.menu_order_input', item).hide();
    125162
    126163    return;
     
    132169
    133170function updateMediaForm() {
     171    var one = jQuery('form.type-form #media-items').children(), items = jQuery('#media-items').children();
    134172    storeState();
    135173    // Just one file, no need for collapsible part
    136     if ( jQuery('.type-form #media-items>*').length == 1 ) {
    137         jQuery('#media-items .slidetoggle').slideDown(500).parent().eq(0).children('.toggle').toggle();
    138         jQuery('.type-form .slidetoggle').siblings().addClass('hidden');
     174    if ( one.length == 1 ) {
     175        jQuery('.slidetoggle', one).slideDown(500).siblings().addClass('hidden').filter('.toggle').toggle();
    139176    }
    140177
    141178    // Only show Save buttons when there is at least one file.
    142     if ( jQuery('#media-items>*').not('.media-blank').length > 0 )
     179    if ( items.not('.media-blank').length > 0 )
    143180        jQuery('.savebutton').show();
    144181    else
     
    146183
    147184    // Only show Gallery button when there are at least two files.
    148     if ( jQuery('#media-items>*').length > 1 )
     185    if ( items.length > 1 )
    149186        jQuery('.insert-gallery').show();
    150187    else
     
    246283
    247284function uploadError(fileObj, errorCode, message) {
    248    
     285
    249286    switch (errorCode) {
    250287        case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
  • trunk/wp-includes/js/swfupload/handlers.js

    r11841 r12130  
    1 function fileDialogStart(){jQuery("#media-upload-error").empty()}function fileQueued(a){jQuery(".media-blank").remove();if(jQuery(".type-form #media-items>*").length==1&&jQuery("#media-items .hidden").length>0){jQuery(".describe-toggle-on").show();jQuery(".describe-toggle-off").hide();jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")}jQuery("#media-items").append('<div id="media-item-'+a.id+'" class="media-item child-of-'+post_id+'"><div class="progress"><div class="bar"></div></div><div class="filename original"><span class="percent"></span> '+a.name+"</div></div>");jQuery("#media-item-"+a.id+" .progress").show();jQuery("#insert-gallery").attr("disabled","disabled");jQuery("#cancel-upload").attr("disabled","")}function uploadStart(a){return true}function uploadProgress(d,b,c){var a=jQuery("#media-items").width()-2;jQuery("#media-item-"+d.id+" .bar").width(a*b/c);jQuery("#media-item-"+d.id+" .percent").html(Math.ceil(b/c*100)+"%");if(b==c){jQuery("#media-item-"+d.id+" .bar").html('<strong class="crunching">'+swfuploadL10n.crunching+"</strong>")}}function prepareMediaItem(b,a){jQuery("#media-item-"+b.id+" .bar").remove();jQuery("#media-item-"+b.id+" .progress").hide();var c=(typeof shortform=="undefined")?1:2;if(isNaN(a)||!a){jQuery("#media-item-"+b.id).append(a);prepareMediaItemInit(b)}else{jQuery("#media-item-"+b.id).load("async-upload.php",{attachment_id:a,fetch:c},function(){prepareMediaItemInit(b);updateMediaForm()})}}function prepareMediaItemInit(a){jQuery("#media-item-"+a.id+" .thumbnail").clone().attr("className","pinkynail toggle").prependTo("#media-item-"+a.id);jQuery("#media-item-"+a.id+" .filename.original").replaceWith(jQuery("#media-item-"+a.id+" .filename.new"));jQuery("#media-item-"+a.id+" a.toggle").click(function(){jQuery(this).siblings(".slidetoggle").slideToggle(150,function(){var b=jQuery(this).offset();window.scrollTo(0,b.top-36)});jQuery(this).parent().children(".toggle").toggle();jQuery(this).siblings("a.toggle").focus();return false});jQuery("#media-item-"+a.id+" a.delete").click(function(){jQuery.ajax({url:"admin-ajax.php",type:"post",success:deleteSuccess,error:deleteError,id:a.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"trash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")}});return false});jQuery("#media-item-"+a.id+".startopen").removeClass("startopen").slideToggle(500).parent().children(".toggle").toggle()}function itemAjaxError(c,b){var a=jQuery("#media-item-error"+c);a.html('<div class="file-error"><button type="button" id="dismiss-'+c+'" class="button dismiss">'+swfuploadL10n.dismiss+"</button>"+b+"</div>");jQuery("#dismiss-"+c).click(function(){jQuery(this).parents(".file-error").slideUp(200,function(){jQuery(this).empty()})})}function deleteSuccess(b,c){if(b=="-1"){return itemAjaxError(this.id,"You do not have permission. Has your session expired?")}if(b=="0"){return itemAjaxError(this.id,"Could not be deleted. Has it been deleted already?")}var a=jQuery("#media-item-"+this.id);if(type=jQuery("#type-of-"+this.id).val()){jQuery("#"+type+"-counter").text(jQuery("#"+type+"-counter").text()-1)}if(a.hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(jQuery("#attachments-count").text()-1)}if(jQuery(".type-form #media-items>*").length==1&&jQuery("#media-items .hidden").length>0){jQuery(".toggle").toggle();jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")}jQuery("#media-item-"+this.id+" .filename:empty").remove();jQuery("#media-item-"+this.id+" .filename").append(' <span class="file-error">'+swfuploadL10n.deleted+"</span>").siblings("a.toggle").remove();jQuery("#media-item-"+this.id).children(".describe").css({backgroundColor:"#fff"}).end().animate({backgroundColor:"#ffc0c0"},{queue:false,duration:50}).animate({minHeight:0,height:36},400,null,function(){jQuery(this).children(".describe").remove()}).animate({backgroundColor:"#fff"},400).animate({height:0},800,null,function(){jQuery(this).remove();updateMediaForm()});return}function deleteError(c,b,a){}function updateMediaForm(){storeState();if(jQuery(".type-form #media-items>*").length==1){jQuery("#media-items .slidetoggle").slideDown(500).parent().eq(0).children(".toggle").toggle();jQuery(".type-form .slidetoggle").siblings().addClass("hidden")}if(jQuery("#media-items>*").not(".media-blank").length>0){jQuery(".savebutton").show()}else{jQuery(".savebutton").hide()}if(jQuery("#media-items>*").length>1){jQuery(".insert-gallery").show()}else{jQuery(".insert-gallery").hide()}}function uploadSuccess(b,a){if(a.match("media-upload-error")){jQuery("#media-item-"+b.id).html(a);return}prepareMediaItem(b,a);updateMediaForm();if(jQuery("#media-item-"+b.id).hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(1*jQuery("#attachments-count").text()+1)}}function uploadComplete(a){if(swfu.getStats().files_queued==0){jQuery("#cancel-upload").attr("disabled","disabled");jQuery("#insert-gallery").attr("disabled","")}}function wpQueueError(a){jQuery("#media-upload-error").show().text(a)}function wpFileError(b,a){jQuery("#media-item-"+b.id+" .filename").after('<div class="file-error"><button type="button" id="dismiss-'+b.id+'" class="button dismiss">'+swfuploadL10n.dismiss+"</button>"+a+"</div>").siblings(".toggle").remove();jQuery("#dismiss-"+b.id).click(function(){jQuery(this).parents(".media-item").slideUp(200,function(){jQuery(this).remove()})})}function fileQueueError(c,a,b){if(a==SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED){wpQueueError(swfuploadL10n.queue_limit_exceeded)}else{if(a==SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT){fileQueued(c);wpFileError(c,swfuploadL10n.file_exceeds_size_limit)}else{if(a==SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE){fileQueued(c);wpFileError(c,swfuploadL10n.zero_byte_file)}else{if(a==SWFUpload.QUEUE_ERROR.INVALID_FILETYPE){fileQueued(c);wpFileError(c,swfuploadL10n.invalid_filetype)}else{wpQueueError(swfuploadL10n.default_error)}}}}}function fileDialogComplete(b){try{if(b>0){this.startUpload()}}catch(a){this.debug(a)}}function switchUploader(b){var c=document.getElementById(swfu.customSettings.swfupload_element_id),a=document.getElementById(swfu.customSettings.degraded_element_id);if(b){c.style.display="block";a.style.display="none"}else{c.style.display="none";a.style.display="block"}}function swfuploadPreLoad(){if(!uploaderMode){switchUploader(1)}else{switchUploader(0)}}function swfuploadLoadFailed(){switchUploader(0);jQuery(".upload-html-bypass").hide()}function uploadError(b,c,a){switch(c){case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:wpFileError(b,swfuploadL10n.missing_upload_url);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:wpFileError(b,swfuploadL10n.upload_limit_exceeded);break;case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:wpQueueError(swfuploadL10n.http_error);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:wpQueueError(swfuploadL10n.upload_failed);break;case SWFUpload.UPLOAD_ERROR.IO_ERROR:wpQueueError(swfuploadL10n.io_error);break;case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:wpQueueError(swfuploadL10n.security_error);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:jQuery("#media-item-"+b.id).remove();break;default:wpFileError(b,swfuploadL10n.default_error)}}function cancelUpload(){swfu.cancelQueue()}var storeState;(function(a){storeState=function(){var c=getUserSetting("align")||"",b=getUserSetting("imgsize")||"";a('tr.align input[type="radio"]').click(function(){setUserSetting("align",a(this).val())}).filter(function(){if(a(this).val()==c){return true}return false}).attr("checked","checked");a('tr.image-size input[type="radio"]').click(function(){setUserSetting("imgsize",a(this).val())}).filter(function(){if(a(this).attr("disabled")||a(this).val()!=b){return false}return true}).attr("checked","checked");a("tr.url button").click(function(){var d=this.className||"";d=d.replace(/.*?(url[^ '"]+).*/,"$1");if(d){setUserSetting("urlbutton",d)}a(this).siblings(".urlfield").val(a(this).attr("title"))});a("tr.url .urlfield").each(function(){var d=getUserSetting("urlbutton");a(this).val(a(this).siblings("button."+d).attr("title"))})}})(jQuery);
     1function fileDialogStart(){jQuery("#media-upload-error").empty()}function fileQueued(a){jQuery(".media-blank").remove();if(jQuery("form.type-form #media-items").children().length==1&&jQuery(".hidden","#media-items").length>0){jQuery(".describe-toggle-on").show();jQuery(".describe-toggle-off").hide();jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")}jQuery("#media-items").append('<div id="media-item-'+a.id+'" class="media-item child-of-'+post_id+'"><div class="progress"><div class="bar"></div></div><div class="filename original"><span class="percent"></span> '+a.name+"</div></div>");jQuery(".progress","#media-item-"+a.id).show();jQuery("#insert-gallery").attr("disabled","disabled");jQuery("#cancel-upload").attr("disabled","")}function uploadStart(a){return true}function uploadProgress(e,b,d){var a=jQuery("#media-items").width()-2,c=jQuery("#media-item-"+e.id);jQuery(".bar",c).width(a*b/d);jQuery(".percent",c).html(Math.ceil(b/d*100)+"%");if(b==d){jQuery(".bar",c).html('<strong class="crunching">'+swfuploadL10n.crunching+"</strong>")}}function prepareMediaItem(c,a){var d=(typeof shortform=="undefined")?1:2,b=jQuery("#media-item-"+c.id);jQuery(".bar",b).remove();jQuery(".progress",b).hide();if(isNaN(a)||!a){b.append(a);prepareMediaItemInit(c)}else{b.load("async-upload.php",{attachment_id:a,fetch:d},function(){prepareMediaItemInit(c);updateMediaForm()})}}function prepareMediaItemInit(b){var a=jQuery("#media-item-"+b.id);jQuery(".thumbnail",a).clone().attr("className","pinkynail toggle").prependTo(a);jQuery(".filename.original",a).replaceWith(jQuery(".filename.new",a));jQuery("a.toggle",a).click(function(){jQuery(this).siblings(".slidetoggle").slideToggle(350,function(){var c=jQuery(this).offset();window.scrollTo(0,c.top-36)});jQuery(this).siblings(".toggle").andSelf().toggle();jQuery(this).siblings("a.toggle").focus();return false});jQuery("a.delete",a).click(function(){jQuery.ajax({url:"admin-ajax.php",type:"post",success:deleteSuccess,error:deleteError,id:b.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"trash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")}});return false});jQuery("a.undo",a).click(function(){jQuery.ajax({url:"admin-ajax.php",type:"post",id:b.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"untrash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")},success:function(d,e){var c=jQuery("#media-item-"+b.id);if(type=jQuery("#type-of-"+b.id).val()){jQuery("#"+type+"-counter").text(jQuery("#"+type+"-counter").text()-0+1)}if(c.hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(jQuery("#attachments-count").text()-0+1)}jQuery(".filename .trashnotice",c).remove();jQuery("a.undo",c).addClass("hidden");jQuery("a.describe-toggle-on, .menu_order_input",c).show();c.animate({backgroundColor:"#fff"},{queue:false,duration:200,complete:function(){jQuery(this).css({backgroundColor:""})}})}});return false});jQuery("#media-item-"+b.id+".startopen").removeClass("startopen").slideToggle(500).siblings(".toggle").toggle()}function itemAjaxError(c,b){var a=jQuery("#media-item-error"+c);a.html('<div class="file-error"><button type="button" id="dismiss-'+c+'" class="button dismiss">'+swfuploadL10n.dismiss+"</button>"+b+"</div>");jQuery("#dismiss-"+c).click(function(){jQuery(this).parents(".file-error").slideUp(200,function(){jQuery(this).empty()})})}function deleteSuccess(b,d){if(b=="-1"){return itemAjaxError(this.id,"You do not have permission. Has your session expired?")}if(b=="0"){return itemAjaxError(this.id,"Could not be deleted. Has it been deleted already?")}var c=this.id,a=jQuery("#media-item-"+c);if(type=jQuery("#type-of-"+c).val()){jQuery("#"+type+"-counter").text(jQuery("#"+type+"-counter").text()-1)}if(a.hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(jQuery("#attachments-count").text()-1)}if(jQuery("form.type-form #media-items").children().length==1&&jQuery(".hidden","#media-items").length>0){jQuery(".toggle").toggle();jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")}jQuery(".toggle",a).toggle();jQuery(".slidetoggle",a).slideUp(200).siblings().removeClass("hidden");a.css({backgroundColor:"#fff"}).animate({backgroundColor:"#ffc0c0"},{queue:false,duration:500});jQuery(".filename:empty",a).remove();jQuery(".filename",a).append('<span class="trashnotice"> '+swfuploadL10n.deleted+" </span>").siblings("a.toggle").hide();jQuery(".filename",a).append(jQuery("a.undo",a).removeClass("hidden"));jQuery(".menu_order_input",a).hide();return}function deleteError(c,b,a){}function updateMediaForm(){var b=jQuery("form.type-form #media-items").children(),a=jQuery("#media-items").children();storeState();if(b.length==1){jQuery(".slidetoggle",b).slideDown(500).siblings().addClass("hidden").filter(".toggle").toggle()}if(a.not(".media-blank").length>0){jQuery(".savebutton").show()}else{jQuery(".savebutton").hide()}if(a.length>1){jQuery(".insert-gallery").show()}else{jQuery(".insert-gallery").hide()}}function uploadSuccess(b,a){if(a.match("media-upload-error")){jQuery("#media-item-"+b.id).html(a);return}prepareMediaItem(b,a);updateMediaForm();if(jQuery("#media-item-"+b.id).hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(1*jQuery("#attachments-count").text()+1)}}function uploadComplete(a){if(swfu.getStats().files_queued==0){jQuery("#cancel-upload").attr("disabled","disabled");jQuery("#insert-gallery").attr("disabled","")}}function wpQueueError(a){jQuery("#media-upload-error").show().text(a)}function wpFileError(b,a){jQuery("#media-item-"+b.id+" .filename").after('<div class="file-error"><button type="button" id="dismiss-'+b.id+'" class="button dismiss">'+swfuploadL10n.dismiss+"</button>"+a+"</div>").siblings(".toggle").remove();jQuery("#dismiss-"+b.id).click(function(){jQuery(this).parents(".media-item").slideUp(200,function(){jQuery(this).remove()})})}function fileQueueError(c,a,b){if(a==SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED){wpQueueError(swfuploadL10n.queue_limit_exceeded)}else{if(a==SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT){fileQueued(c);wpFileError(c,swfuploadL10n.file_exceeds_size_limit)}else{if(a==SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE){fileQueued(c);wpFileError(c,swfuploadL10n.zero_byte_file)}else{if(a==SWFUpload.QUEUE_ERROR.INVALID_FILETYPE){fileQueued(c);wpFileError(c,swfuploadL10n.invalid_filetype)}else{wpQueueError(swfuploadL10n.default_error)}}}}}function fileDialogComplete(b){try{if(b>0){this.startUpload()}}catch(a){this.debug(a)}}function switchUploader(b){var c=document.getElementById(swfu.customSettings.swfupload_element_id),a=document.getElementById(swfu.customSettings.degraded_element_id);if(b){c.style.display="block";a.style.display="none"}else{c.style.display="none";a.style.display="block"}}function swfuploadPreLoad(){if(!uploaderMode){switchUploader(1)}else{switchUploader(0)}}function swfuploadLoadFailed(){switchUploader(0);jQuery(".upload-html-bypass").hide()}function uploadError(b,c,a){switch(c){case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:wpFileError(b,swfuploadL10n.missing_upload_url);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:wpFileError(b,swfuploadL10n.upload_limit_exceeded);break;case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:wpQueueError(swfuploadL10n.http_error);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:wpQueueError(swfuploadL10n.upload_failed);break;case SWFUpload.UPLOAD_ERROR.IO_ERROR:wpQueueError(swfuploadL10n.io_error);break;case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:wpQueueError(swfuploadL10n.security_error);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:jQuery("#media-item-"+b.id).remove();break;default:wpFileError(b,swfuploadL10n.default_error)}}function cancelUpload(){swfu.cancelQueue()}var storeState;(function(a){storeState=function(){var c=getUserSetting("align")||"",b=getUserSetting("imgsize")||"";a('tr.align input[type="radio"]').click(function(){setUserSetting("align",a(this).val())}).filter(function(){if(a(this).val()==c){return true}return false}).attr("checked","checked");a('tr.image-size input[type="radio"]').click(function(){setUserSetting("imgsize",a(this).val())}).filter(function(){if(a(this).attr("disabled")||a(this).val()!=b){return false}return true}).attr("checked","checked");a("tr.url button").click(function(){var d=this.className||"";d=d.replace(/.*?(url[^ '"]+).*/,"$1");if(d){setUserSetting("urlbutton",d)}a(this).siblings(".urlfield").val(a(this).attr("title"))});a("tr.url .urlfield").each(function(){var d=getUserSetting("urlbutton");a(this).val(a(this).siblings("button."+d).attr("title"))})}})(jQuery);
  • trunk/wp-includes/post.php

    r12106 r12130  
    12521252        return $post;
    12531253
     1254    if ( $post['post_status'] == 'trash' )
     1255        return false;
     1256
    12541257    do_action('trash_post', $post_id);
    12551258
     
    12781281    if ( !$post = wp_get_single_post($post_id, ARRAY_A) )
    12791282        return $post;
     1283
     1284    if ( $post['post_status'] != 'trash' )
     1285        return false;
    12801286
    12811287    do_action('untrash_post', $post_id);
  • trunk/wp-includes/script-loader.php

    r12114 r12130  
    184184    }
    185185
    186     $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20090818');
     186    $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20091029');
    187187    $max_upload_size = ( (int) ( $max_up = @ini_get('upload_max_filesize') ) < (int) ( $max_post = @ini_get('post_max_size') ) ) ? $max_up : $max_post;
    188188    if ( empty($max_upload_size) )
     
    205205            'dismiss' => __('Dismiss'),
    206206            'crunching' => __('Crunching&hellip;'),
    207             'deleted' => __('Moved to Trash'),
     207            'deleted' => __('moved to the trash.'),
    208208            'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};'
    209209    ) );
     
    434434
    435435    $styles->add( 'global', "/wp-admin/css/global$suffix.css", array(), '20090630' );
    436     $styles->add( 'media', "/wp-admin/css/media$suffix.css", array(), '20091023' );
     436    $styles->add( 'media', "/wp-admin/css/media$suffix.css", array(), '20091029' );
    437437    $styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array(), '20090603' );
    438438    $styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css", array(), '20090514' );
Note: See TracChangeset for help on using the changeset viewer.