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

git-svn-id: http://svn.automattic.com/wordpress/trunk@12130 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-10-30 07:09:55 +00:00
parent 7578a5b511
commit a55fd568d4
9 changed files with 104 additions and 72 deletions

View File

@ -334,6 +334,7 @@ case 'delete-post' :
die('0'); die('0');
break; break;
case 'trash-post' : case 'trash-post' :
case 'untrash-post' :
check_ajax_referer( "{$action}_$id" ); check_ajax_referer( "{$action}_$id" );
if ( !current_user_can( 'delete_post', $id ) ) if ( !current_user_can( 'delete_post', $id ) )
die('-1'); die('-1');
@ -341,9 +342,14 @@ case 'trash-post' :
if ( !get_post( $id ) ) if ( !get_post( $id ) )
die('1'); die('1');
if ( wp_trash_post( $id ) ) if ( 'trash-post' == $action )
die('1'); $done = wp_trash_post( $id );
else else
$done = wp_untrash_post( $id );
if ( $done )
die('1');
die('0'); die('0');
break; break;
case 'delete-page' : case 'delete-page' :

View File

@ -48,12 +48,6 @@ button.dismiss {
border-left-style: solid; border-left-style: solid;
} }
.describe-toggle-on,
.describe-toggle-off {
float: left;
margin-right: 0;
margin-left: 20px;
}
/* Specific to Uploader */ /* Specific to Uploader */
#media-upload .media-upload-form p { #media-upload .media-upload-form p {
margin: 0 0 1em 1em; margin: 0 0 1em 1em;

View File

@ -1 +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;} 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;}.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;}

View File

@ -134,18 +134,6 @@ abbr.required {
border-style: solid; 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 { .hidden {
height: 0; height: 0;
width: 0; width: 0;

View File

@ -1203,11 +1203,12 @@ function get_media_item( $attachment_id, $args = null ) {
'extra_rows' => array(), 'extra_rows' => array(),
); );
$delete_href = wp_nonce_url("post.php?action=trash&post=$attachment_id", 'trash-post_' . $attachment_id); $trash_href = wp_nonce_url("post.php?action=trash&post=$attachment_id", 'trash-post_' . $attachment_id);
$untrash_href = wp_nonce_url("post.php?action=untrash&post=$attachment_id", 'untrash-post_' . $attachment_id);
if ( $send ) if ( $send )
$send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />"; $send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />";
if ( $delete ) if ( $delete )
$delete = current_user_can('delete_post', $attachment_id) ? "<a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a>" : ""; $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>" : "";
if ( 'image' == $type && get_post_image_id($_GET['post_id']) != $attachment_id ) if ( 'image' == $type && get_post_image_id($_GET['post_id']) != $attachment_id )
$thumbnail = "<a class='wp-post-thumbnail' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\");return false;'>" . esc_html__( "Use as thumbnail" ) . "</a>"; $thumbnail = "<a class='wp-post-thumbnail' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\");return false;'>" . esc_html__( "Use as thumbnail" ) . "</a>";

View File

@ -8,7 +8,7 @@ function fileQueued(fileObj) {
// Get rid of unused form // Get rid of unused form
jQuery('.media-blank').remove(); jQuery('.media-blank').remove();
// Collapse a single item // Collapse a single item
if ( jQuery('.type-form #media-items>*').length == 1 && jQuery('#media-items .hidden').length > 0 ) { if ( jQuery('form.type-form #media-items').children().length == 1 && jQuery('.hidden', '#media-items').length > 0 ) {
jQuery('.describe-toggle-on').show(); jQuery('.describe-toggle-on').show();
jQuery('.describe-toggle-off').hide(); jQuery('.describe-toggle-off').hide();
jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden'); jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden');
@ -16,7 +16,7 @@ function fileQueued(fileObj) {
// Create a progress bar containing the filename // Create a progress bar containing the filename
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>'); 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>');
// Display the progress div // Display the progress div
jQuery('#media-item-' + fileObj.id + ' .progress').show(); jQuery('.progress', '#media-item-' + fileObj.id).show();
// Disable submit and enable cancel // Disable submit and enable cancel
jQuery('#insert-gallery').attr('disabled', 'disabled'); jQuery('#insert-gallery').attr('disabled', 'disabled');
@ -29,63 +29,99 @@ function uploadStart(fileObj) {
function uploadProgress(fileObj, bytesDone, bytesTotal) { function uploadProgress(fileObj, bytesDone, bytesTotal) {
// Lengthen the progress bar // Lengthen the progress bar
var w = jQuery('#media-items').width() - 2; var w = jQuery('#media-items').width() - 2, item = jQuery('#media-item-' + fileObj.id);
jQuery('#media-item-' + fileObj.id + ' .bar').width( w * bytesDone / bytesTotal ); jQuery('.bar', item).width( w * bytesDone / bytesTotal );
jQuery('#media-item-' + fileObj.id + ' .percent').html( Math.ceil(bytesDone / bytesTotal * 100) + '%' ); jQuery('.percent', item).html( Math.ceil(bytesDone / bytesTotal * 100) + '%' );
if ( bytesDone == bytesTotal ) if ( bytesDone == bytesTotal )
jQuery('#media-item-' + fileObj.id + ' .bar').html('<strong class="crunching">' + swfuploadL10n.crunching + '</strong>'); jQuery('.bar', item).html('<strong class="crunching">' + swfuploadL10n.crunching + '</strong>');
} }
function prepareMediaItem(fileObj, serverData) { function prepareMediaItem(fileObj, serverData) {
var f = ( typeof shortform == 'undefined' ) ? 1 : 2, item = jQuery('#media-item-' + fileObj.id);
// Move the progress bar to 100% // Move the progress bar to 100%
jQuery('#media-item-' + fileObj.id + ' .bar').remove(); jQuery('.bar', item).remove();
jQuery('#media-item-' + fileObj.id + ' .progress').hide(); jQuery('.progress', item).hide();
var f = ( typeof shortform == 'undefined' ) ? 1 : 2;
// Old style: Append the HTML returned by the server -- thumbnail and form inputs // Old style: Append the HTML returned by the server -- thumbnail and form inputs
if ( isNaN(serverData) || !serverData ) { if ( isNaN(serverData) || !serverData ) {
jQuery('#media-item-' + fileObj.id).append(serverData); item.append(serverData);
prepareMediaItemInit(fileObj); prepareMediaItemInit(fileObj);
} }
// New style: server data is just the attachment ID, fetch the thumbnail and form html from the server // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server
else { else {
jQuery('#media-item-' + fileObj.id).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()});
} }
} }
function prepareMediaItemInit(fileObj) { function prepareMediaItemInit(fileObj) {
var item = jQuery('#media-item-' + fileObj.id);
// Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename
jQuery('#media-item-' + fileObj.id + ' .thumbnail').clone().attr('className', 'pinkynail toggle').prependTo('#media-item-' + fileObj.id); jQuery('.thumbnail', item).clone().attr('className', 'pinkynail toggle').prependTo(item);
// Replace the original filename with the new (unique) one assigned during upload // Replace the original filename with the new (unique) one assigned during upload
jQuery('#media-item-' + fileObj.id + ' .filename.original').replaceWith(jQuery('#media-item-' + fileObj.id + ' .filename.new')); jQuery('.filename.original', item).replaceWith( jQuery('.filename.new', item) );
// Also bind toggle to the links // Also bind toggle to the links
jQuery('#media-item-' + fileObj.id + ' a.toggle').click(function(){ jQuery('a.toggle', item).click(function(){
jQuery(this).siblings('.slidetoggle').slideToggle(150, function(){ jQuery(this).siblings('.slidetoggle').slideToggle(350, function(){
var o = jQuery(this).offset(); var o = jQuery(this).offset();
window.scrollTo(0, o.top-36); window.scrollTo(0, o.top - 36);
}); });
jQuery(this).parent().children('.toggle').toggle(); jQuery(this).siblings('.toggle').andSelf().toggle();
jQuery(this).siblings('a.toggle').focus(); jQuery(this).siblings('a.toggle').focus();
return false; return false;
}); });
// Bind AJAX to the new Delete button // Bind AJAX to the new Delete button
jQuery('#media-item-' + fileObj.id + ' a.delete').click(function(){ jQuery('a.delete', item).click(function(){
// Tell the server to delete it. TODO: handle exceptions // Tell the server to delete it. TODO: handle exceptions
jQuery.ajax({url:'admin-ajax.php',type:'post',success:deleteSuccess,error:deleteError,id:fileObj.id,data:{ jQuery.ajax({
id : this.id.replace(/[^0-9]/g,''), url: 'admin-ajax.php',
type: 'post',
success: deleteSuccess,
error: deleteError,
id: fileObj.id,
data: {
id : this.id.replace(/[^0-9]/g, ''),
action : 'trash-post', action : 'trash-post',
_ajax_nonce : this.href.replace(/^.*wpnonce=/,'')} _ajax_nonce : this.href.replace(/^.*wpnonce=/,'')
}
});
return false;
});
// Bind AJAX to the new Undo button
jQuery('a.undo', item).click(function(){
// Tell the server to untrash it. TODO: handle exceptions
jQuery.ajax({
url: 'admin-ajax.php',
type: 'post',
id: fileObj.id,
data: {
id : this.id.replace(/[^0-9]/g,''),
action: 'untrash-post',
_ajax_nonce: this.href.replace(/^.*wpnonce=/,'')
},
success: function(data, textStatus){
var item = jQuery('#media-item-' + fileObj.id);
if ( type = jQuery('#type-of-' + fileObj.id).val() )
jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-0+1);
if ( item.hasClass('child-of-'+post_id) )
jQuery('#attachments-count').text(jQuery('#attachments-count').text()-0+1);
jQuery('.filename .trashnotice', item).remove();
jQuery('a.undo', item).addClass('hidden');
jQuery('a.describe-toggle-on, .menu_order_input', item).show();
item.animate( {backgroundColor: '#fff'}, { queue: false, duration: 200, complete: function(){ jQuery(this).css({backgroundColor:''}); } });
}
}); });
return false; return false;
}); });
// Open this item if it says to start open (e.g. to display an error) // Open this item if it says to start open (e.g. to display an error)
jQuery('#media-item-' + fileObj.id + '.startopen').removeClass('startopen').slideToggle(500).parent().children('.toggle').toggle(); jQuery('#media-item-' + fileObj.id + '.startopen').removeClass('startopen').slideToggle(500).siblings('.toggle').toggle();
} }
function itemAjaxError(id, html) { function itemAjaxError(id, html) {
@ -101,27 +137,28 @@ function deleteSuccess(data, textStatus) {
if ( data == '0' ) if ( data == '0' )
return itemAjaxError(this.id, 'Could not be deleted. Has it been deleted already?'); return itemAjaxError(this.id, 'Could not be deleted. Has it been deleted already?');
var item = jQuery('#media-item-' + this.id); var id = this.id, item = jQuery('#media-item-' + id);
// Decrement the counters. // Decrement the counters.
if ( type = jQuery('#type-of-' + this.id).val() ) if ( type = jQuery('#type-of-' + id).val() )
jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-1); jQuery('#' + type + '-counter').text( jQuery('#' + type + '-counter').text() - 1 );
if ( item.hasClass('child-of-'+post_id) ) if ( item.hasClass('child-of-'+post_id) )
jQuery('#attachments-count').text(jQuery('#attachments-count').text()-1); jQuery('#attachments-count').text( jQuery('#attachments-count').text() - 1 );
if ( jQuery('.type-form #media-items>*').length == 1 && jQuery('#media-items .hidden').length > 0 ) { if ( jQuery('form.type-form #media-items').children().length == 1 && jQuery('.hidden', '#media-items').length > 0 ) {
jQuery('.toggle').toggle(); jQuery('.toggle').toggle();
jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden'); jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden');
} }
// Vanish it. // Vanish it.
jQuery('#media-item-' + this.id + ' .filename:empty').remove(); jQuery('.toggle', item).toggle();
jQuery('#media-item-' + this.id + ' .filename').append(' <span class="file-error">'+swfuploadL10n.deleted+'</span>').siblings('a.toggle').remove(); jQuery('.slidetoggle', item).slideUp(200).siblings().removeClass('hidden');
jQuery('#media-item-' + this.id).children('.describe').css({backgroundColor:'#fff'}).end() item.css( {backgroundColor:'#fff'} ).animate( {backgroundColor:'#ffc0c0'}, {queue:false, duration:500} );
.animate({backgroundColor:'#ffc0c0'}, {queue:false,duration:50})
.animate({minHeight:0,height:36}, 400, null, function(){jQuery(this).children('.describe').remove()}) jQuery('.filename:empty', item).remove();
.animate({backgroundColor:'#fff'}, 400) jQuery('.filename', item).append('<span class="trashnotice"> ' + swfuploadL10n.deleted + ' </span>').siblings('a.toggle').hide();
.animate({height:0}, 800, null, function(){jQuery(this).remove();updateMediaForm();}); jQuery('.filename', item).append( jQuery('a.undo', item).removeClass('hidden') );
jQuery('.menu_order_input', item).hide();
return; return;
} }
@ -131,21 +168,21 @@ function deleteError(X, textStatus, errorThrown) {
} }
function updateMediaForm() { function updateMediaForm() {
var one = jQuery('form.type-form #media-items').children(), items = jQuery('#media-items').children();
storeState(); storeState();
// Just one file, no need for collapsible part // Just one file, no need for collapsible part
if ( jQuery('.type-form #media-items>*').length == 1 ) { if ( one.length == 1 ) {
jQuery('#media-items .slidetoggle').slideDown(500).parent().eq(0).children('.toggle').toggle(); jQuery('.slidetoggle', one).slideDown(500).siblings().addClass('hidden').filter('.toggle').toggle();
jQuery('.type-form .slidetoggle').siblings().addClass('hidden');
} }
// Only show Save buttons when there is at least one file. // Only show Save buttons when there is at least one file.
if ( jQuery('#media-items>*').not('.media-blank').length > 0 ) if ( items.not('.media-blank').length > 0 )
jQuery('.savebutton').show(); jQuery('.savebutton').show();
else else
jQuery('.savebutton').hide(); jQuery('.savebutton').hide();
// Only show Gallery button when there are at least two files. // Only show Gallery button when there are at least two files.
if ( jQuery('#media-items>*').length > 1 ) if ( items.length > 1 )
jQuery('.insert-gallery').show(); jQuery('.insert-gallery').show();
else else
jQuery('.insert-gallery').hide(); jQuery('.insert-gallery').hide();

File diff suppressed because one or more lines are too long

View File

@ -1251,6 +1251,9 @@ function wp_trash_post($post_id = 0) {
if ( !$post = wp_get_single_post($post_id, ARRAY_A) ) if ( !$post = wp_get_single_post($post_id, ARRAY_A) )
return $post; return $post;
if ( $post['post_status'] == 'trash' )
return false;
do_action('trash_post', $post_id); do_action('trash_post', $post_id);
add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']); add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);
@ -1278,6 +1281,9 @@ function wp_untrash_post($post_id = 0) {
if ( !$post = wp_get_single_post($post_id, ARRAY_A) ) if ( !$post = wp_get_single_post($post_id, ARRAY_A) )
return $post; return $post;
if ( $post['post_status'] != 'trash' )
return false;
do_action('untrash_post', $post_id); do_action('untrash_post', $post_id);
$post_status = get_post_meta($post_id, '_wp_trash_meta_status', true); $post_status = get_post_meta($post_id, '_wp_trash_meta_status', true);

View File

@ -183,7 +183,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'swfupload-all', '/wp-includes/js/swfupload/swfupload-all.js', array(), '2201'); $scripts->add( 'swfupload-all', '/wp-includes/js/swfupload/swfupload-all.js', array(), '2201');
} }
$scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20090818'); $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20091029');
$max_upload_size = ( (int) ( $max_up = @ini_get('upload_max_filesize') ) < (int) ( $max_post = @ini_get('post_max_size') ) ) ? $max_up : $max_post; $max_upload_size = ( (int) ( $max_up = @ini_get('upload_max_filesize') ) < (int) ( $max_post = @ini_get('post_max_size') ) ) ? $max_up : $max_post;
if ( empty($max_upload_size) ) if ( empty($max_upload_size) )
$max_upload_size = __('not configured'); $max_upload_size = __('not configured');
@ -204,7 +204,7 @@ function wp_default_scripts( &$scripts ) {
'upload_stopped' => __('Upload stopped.'), 'upload_stopped' => __('Upload stopped.'),
'dismiss' => __('Dismiss'), 'dismiss' => __('Dismiss'),
'crunching' => __('Crunching&hellip;'), 'crunching' => __('Crunching&hellip;'),
'deleted' => __('Moved to Trash'), 'deleted' => __('moved to the trash.'),
'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};' 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};'
) ); ) );
@ -433,7 +433,7 @@ function wp_default_styles( &$styles ) {
$styles->add_data( 'colors-classic', 'rtl', true ); $styles->add_data( 'colors-classic', 'rtl', true );
$styles->add( 'global', "/wp-admin/css/global$suffix.css", array(), '20090630' ); $styles->add( 'global', "/wp-admin/css/global$suffix.css", array(), '20090630' );
$styles->add( 'media', "/wp-admin/css/media$suffix.css", array(), '20091023' ); $styles->add( 'media', "/wp-admin/css/media$suffix.css", array(), '20091029' );
$styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array(), '20090603' ); $styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array(), '20090603' );
$styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css", array(), '20090514' ); $styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css", array(), '20090514' );
$styles->add( 'install', "/wp-admin/css/install$suffix.css", array(), '20090514' ); $styles->add( 'install', "/wp-admin/css/install$suffix.css", array(), '20090514' );