Bring back Quick Edit links

git-svn-id: http://svn.automattic.com/wordpress/trunk@9297 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-10-23 16:34:21 +00:00
parent 91841f2e3c
commit 838f6b5d93
5 changed files with 44 additions and 21 deletions

View File

@ -123,6 +123,7 @@ function _cat_row( $category, $level, $name_override = false ) {
$edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>" . attribute_escape( $name ) . '</a><br />'; $edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>" . attribute_escape( $name ) . '</a><br />';
$actions = array(); $actions = array();
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
if ( $default_cat_id != $category->term_id ) if ( $default_cat_id != $category->term_id )
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("categories.php?action=delete&amp;cat_ID=$category->term_id", 'delete-category_' . $category->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("categories.php?action=delete&amp;cat_ID=$category->term_id", 'delete-category_' . $category->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
$action_count = count($actions); $action_count = count($actions);
@ -291,6 +292,7 @@ function link_cat_row( $category, $name_override = false ) {
$edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>$name</a><br />"; $edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>$name</a><br />";
$actions = array(); $actions = array();
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
if ( $default_cat_id != $category->term_id ) if ( $default_cat_id != $category->term_id )
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link-category.php?action=delete&amp;cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link-category.php?action=delete&amp;cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
$action_count = count($actions); $action_count = count($actions);
@ -606,6 +608,7 @@ function _tag_row( $tag, $class = '' ) {
$out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . attribute_escape(sprintf(__('Edit "%s"'), $name)) . '">' . $name . '</a></strong><br />'; $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . attribute_escape(sprintf(__('Edit "%s"'), $name)) . '">' . $name . '</a></strong><br />';
$actions = array(); $actions = array();
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("edit-tags.php?action=delete&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this tag '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("edit-tags.php?action=delete&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this tag '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
$action_count = count($actions); $action_count = count($actions);
$i = 0; $i = 0;
@ -1271,6 +1274,7 @@ function _post_row($a_post, $pending_comments, $mode) {
$actions = array(); $actions = array();
if ( current_user_can('edit_post', $post->ID) ) { if ( current_user_can('edit_post', $post->ID) ) {
$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . attribute_escape(__('Edit this post')) . '">' . __('Edit') . '</a>'; $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . attribute_escape(__('Edit this post')) . '">' . __('Edit') . '</a>';
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . attribute_escape(__('Edit this post inline')) . '">' . __('Quick Edit') . '</a>';
$actions['delete'] = "<a class='submitdelete' title='" . attribute_escape(__('Delete this post')) . "' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; $actions['delete'] = "<a class='submitdelete' title='" . attribute_escape(__('Delete this post')) . "' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
} }
if ( in_array($post->post_status, array('pending', 'draft')) ) if ( in_array($post->post_status, array('pending', 'draft')) )
@ -1455,6 +1459,7 @@ foreach ($posts_columns as $column_name=>$column_display_name) {
<?php <?php
$actions = array(); $actions = array();
$actions['edit'] = '<a href="' . $edit_link . '" title="' . attribute_escape(__('Edit this page')) . '">' . __('Edit') . '</a>'; $actions['edit'] = '<a href="' . $edit_link . '" title="' . attribute_escape(__('Edit this page')) . '">' . __('Edit') . '</a>';
$actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
$actions['delete'] = "<a class='submitdelete' title='" . attribute_escape(__('Delete this page')) . "' href='" . wp_nonce_url("page.php?action=delete&amp;post=$page->ID", 'delete-page_' . $page->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $page->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $page->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; $actions['delete'] = "<a class='submitdelete' title='" . attribute_escape(__('Delete this page')) . "' href='" . wp_nonce_url("page.php?action=delete&amp;post=$page->ID", 'delete-page_' . $page->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $page->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $page->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
if ( in_array($post->post_status, array('pending', 'draft')) ) if ( in_array($post->post_status, array('pending', 'draft')) )
$actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . attribute_escape(sprintf(__('Preview "%s"'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . attribute_escape(sprintf(__('Preview "%s"'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
@ -1902,6 +1907,7 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true
$actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . __( 'Spam' ) . '</a>'; $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . __( 'Spam' ) . '</a>';
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>'; $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>'; $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
$actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>';
if ( 'spam' != $the_comment_status ) if ( 'spam' != $the_comment_status )
$actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>'; $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';

View File

@ -109,25 +109,24 @@ commentReply = {
addEvents : function(r) { addEvents : function(r) {
r.each(function() { r.each(function() {
$(this).dblclick(function(){ $(this).dblclick(function(){
commentReply.toggle_edit(this); commentReply.toggle(this);
}); });
}); });
}, },
toggle_edit : function(el) { toggle : function(el) {
if ( $(el).css('display') != 'none' ) { if ( $(el).css('display') != 'none' )
var id = $(el).attr('id').substr(8); $(el).find('a.vim-q').click();
if (id) this.open(id, '', 'edit');
}
}, },
revert : function() { revert : function() {
if ( $('#the-comment-list #replyrow').length > 0 ) { if ( $('#the-comment-list #replyrow').length < 1 )
$('#replyrow').fadeOut('fast', function(){ return false;
commentReply.close();
}); $('#replyrow').fadeOut('fast', function(){
} commentReply.close();
});
return false; return false;
}, },
@ -147,10 +146,7 @@ commentReply = {
open : function(id, p, a) { open : function(id, p, a) {
var t = this; var t = this;
t.close();
if ( $('#the-comment-list #replyrow').length > 0 )
t.close();
t.o = '#comment-'+id; t.o = '#comment-'+id;
$('#replyrow td').attr('colspan', $('.widefat thead th:visible').length); $('#replyrow td').attr('colspan', $('.widefat thead th:visible').length);
@ -320,7 +316,7 @@ $(document).ready(function(){
$('form#comments-form')[0].submit(); $('form#comments-form')[0].submit();
} }
}; };
$.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', ['e', edit_comment], $.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', 'q', ['e', edit_comment],
['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')], ['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')],
['shift+d', make_bulk('delete')], ['shift+x', toggle_all], ['shift+d', make_bulk('delete')], ['shift+x', toggle_all],
['shift+u', make_bulk('unapprove')]], ['shift+u', make_bulk('unapprove')]],

View File

@ -26,6 +26,7 @@ inlineEditPost = {
// add events // add events
t.rows.dblclick(function() { inlineEditPost.toggle(this); }); t.rows.dblclick(function() { inlineEditPost.toggle(this); });
t.addEvents(t.rows);
$('#bulk-title-div').after( $('#bulk-title-div').after(
$('#inline-edit div.categories').clone(), $('#inline-edit div.categories').clone(),
@ -78,6 +79,14 @@ inlineEditPost = {
$(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
}, },
addEvents : function(r) {
r.each(function() {
var row = $(this);
$('a.editinline', row).click(function() { inlineEditPost.edit(this); return false; });
row.attr('title', inlineEditL10n.edit);
});
},
setBulk : function() { setBulk : function() {
var te = '', c = ''; var te = '', c = '';
this.revert(); this.revert();
@ -89,7 +98,7 @@ inlineEditPost = {
if ( $(this).attr('checked') ) { if ( $(this).attr('checked') ) {
var id = $(this).val(); var id = $(this).val();
c = c == '' ? ' class="alternate"' : ''; c = c == '' ? ' class="alternate"' : '';
te += '<div'+c+' id="ttle'+id+'"><a id="_'+id+'" title="'+inlineEditL10n.rem_title+'" class="ntdelbutton">X</a>'+$('#inline_'+id+' .post_title').text()+'</div>'; te += '<div'+c+' id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton">X</a>'+$('#inline_'+id+' .post_title').text()+'</div>';
} }
}); });
@ -199,6 +208,7 @@ inlineEditPost = {
row.html($(r).html()).show() row.html($(r).html()).show()
.animate( { backgroundColor: '#CCEEBB' }, 500) .animate( { backgroundColor: '#CCEEBB' }, 500)
.animate( { backgroundColor: '#eefee7' }, 500); .animate( { backgroundColor: '#eefee7' }, 500);
inlineEditPost.addEvents(row);
} else { } else {
$('#edit-'+id+' .quick-edit-save').append('<span class="error">'+inlineEditL10n.error+'</span>'); $('#edit-'+id+' .quick-edit-save').append('<span class="error">'+inlineEditL10n.error+'</span>');
} }

View File

@ -20,6 +20,7 @@ inlineEditTax = {
// add events // add events
t.rows.dblclick(function() { inlineEditTax.toggle(this); }); t.rows.dblclick(function() { inlineEditTax.toggle(this); });
t.addEvents(t.rows);
$('#doaction, #doaction2, #post-query-submit').click(function(e){ $('#doaction, #doaction2, #post-query-submit').click(function(e){
if ( $('form#posts-filter tr.inline-editor').length > 0 ) if ( $('form#posts-filter tr.inline-editor').length > 0 )
@ -33,6 +34,14 @@ inlineEditTax = {
$(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el); $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
}, },
addEvents : function(r) {
r.each(function() {
var row = $(this);
$('a.editinline', row).click(function() { inlineEditTax.edit(this); return false; });
row.attr('title', inlineEditL10n.edit);
});
},
edit : function(id) { edit : function(id) {
var t = this; var t = this;
t.revert(); t.revert();
@ -103,6 +112,7 @@ inlineEditTax = {
row.html($(r).html()).show() row.html($(r).html()).show()
.animate( { backgroundColor: '#CCEEBB' }, 500) .animate( { backgroundColor: '#CCEEBB' }, 500)
.animate( { backgroundColor: '#eefee7' }, 500); .animate( { backgroundColor: '#eefee7' }, 500);
inlineEditTax.addEvents(row);
} else } else
$('#edit-'+id+' .quick-edit-save .error').html(r).show(); $('#edit-'+id+' .quick-edit-save .error').html(r).show();
} else } else

View File

@ -243,14 +243,15 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'theme-preview', '/wp-admin/js/theme-preview.js', array( 'thickbox', 'jquery' ), '20080625' ); $scripts->add( 'theme-preview', '/wp-admin/js/theme-preview.js', array( 'thickbox', 'jquery' ), '20080625' );
$scripts->add( 'inline-edit-post', '/wp-admin/js/inline-edit-post.js', array( 'jquery', 'jquery-form', 'suggest' ), '20081014' ); $scripts->add( 'inline-edit-post', '/wp-admin/js/inline-edit-post.js', array( 'jquery', 'jquery-form', 'suggest' ), '20081007' );
$scripts->localize( 'inline-edit-post', 'inlineEditL10n', array( $scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
'error' => __('Error while saving the changes.'), 'edit' => __('Double-click to edit'),
'rem_title' => __('Remove from batch edit') 'error' => __('Error while saving the changes.')
) ); ) );
$scripts->add( 'inline-edit-tax', '/wp-admin/js/inline-edit-tax.js', array( 'jquery', 'jquery-form' ), '20081014' ); $scripts->add( 'inline-edit-tax', '/wp-admin/js/inline-edit-tax.js', array( 'jquery', 'jquery-form' ), '20081007' );
$scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array( $scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array(
'edit' => __('Double-click to edit'),
'error' => __('Error while saving the changes.') 'error' => __('Error while saving the changes.')
) ); ) );