From 838f6b5d93a6abec9a9b4fd79df07325bb8a5a1d Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 23 Oct 2008 16:34:21 +0000 Subject: [PATCH] Bring back Quick Edit links git-svn-id: http://svn.automattic.com/wordpress/trunk@9297 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/template.php | 6 ++++++ wp-admin/js/edit-comments.js | 28 ++++++++++++---------------- wp-admin/js/inline-edit-post.js | 12 +++++++++++- wp-admin/js/inline-edit-tax.js | 10 ++++++++++ wp-includes/script-loader.php | 9 +++++---- 5 files changed, 44 insertions(+), 21 deletions(-) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 58e88746ca..246ec40f3f 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -123,6 +123,7 @@ function _cat_row( $category, $level, $name_override = false ) { $edit = "name)) . "'>" . attribute_escape( $name ) . '
'; $actions = array(); $actions['edit'] = '' . __('Edit') . ''; + $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; if ( $default_cat_id != $category->term_id ) $actions['delete'] = "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') . ""; $action_count = count($actions); @@ -291,6 +292,7 @@ function link_cat_row( $category, $name_override = false ) { $edit = "name)) . "'>$name
"; $actions = array(); $actions['edit'] = '' . __('Edit') . ''; + $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; if ( $default_cat_id != $category->term_id ) $actions['delete'] = "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') . ""; $action_count = count($actions); @@ -606,6 +608,7 @@ function _tag_row( $tag, $class = '' ) { $out .= '' . $name . '
'; $actions = array(); $actions['edit'] = '' . __('Edit') . ''; + $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; $actions['delete'] = "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') . ""; $action_count = count($actions); $i = 0; @@ -1271,6 +1274,7 @@ function _post_row($a_post, $pending_comments, $mode) { $actions = array(); if ( current_user_can('edit_post', $post->ID) ) { $actions['edit'] = '' . __('Edit') . ''; + $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; $actions['delete'] = "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') . ""; } if ( in_array($post->post_status, array('pending', 'draft')) ) @@ -1455,6 +1459,7 @@ foreach ($posts_columns as $column_name=>$column_display_name) { ' . __('Edit') . ''; + $actions['inline'] = '' . __('Quick Edit') . ''; $actions['delete'] = "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') . ""; if ( in_array($post->post_status, array('pending', 'draft')) ) $actions['view'] = '' . __('Preview') . ''; @@ -1902,6 +1907,7 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true $actions['spam'] = "" . __( 'Spam' ) . ''; $actions['delete'] = "" . __('Delete') . ''; $actions['edit'] = "". __('Edit') . ''; + $actions['quickedit'] = '' . __('Quick Edit') . ''; if ( 'spam' != $the_comment_status ) $actions['reply'] = '' . __('Reply') . ''; diff --git a/wp-admin/js/edit-comments.js b/wp-admin/js/edit-comments.js index 04b87d5641..9792b68fb9 100644 --- a/wp-admin/js/edit-comments.js +++ b/wp-admin/js/edit-comments.js @@ -109,25 +109,24 @@ commentReply = { addEvents : function(r) { r.each(function() { $(this).dblclick(function(){ - commentReply.toggle_edit(this); + commentReply.toggle(this); }); }); }, - toggle_edit : function(el) { - if ( $(el).css('display') != 'none' ) { - var id = $(el).attr('id').substr(8); - if (id) this.open(id, '', 'edit'); - } + toggle : function(el) { + if ( $(el).css('display') != 'none' ) + $(el).find('a.vim-q').click(); }, revert : function() { - if ( $('#the-comment-list #replyrow').length > 0 ) { - $('#replyrow').fadeOut('fast', function(){ - commentReply.close(); - }); - } + if ( $('#the-comment-list #replyrow').length < 1 ) + return false; + + $('#replyrow').fadeOut('fast', function(){ + commentReply.close(); + }); return false; }, @@ -147,10 +146,7 @@ commentReply = { open : function(id, p, a) { var t = this; - - if ( $('#the-comment-list #replyrow').length > 0 ) - t.close(); - + t.close(); t.o = '#comment-'+id; $('#replyrow td').attr('colspan', $('.widefat thead th:visible').length); @@ -320,7 +316,7 @@ $(document).ready(function(){ $('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+d', make_bulk('delete')], ['shift+x', toggle_all], ['shift+u', make_bulk('unapprove')]], diff --git a/wp-admin/js/inline-edit-post.js b/wp-admin/js/inline-edit-post.js index a9a06b3e17..403d5f5156 100644 --- a/wp-admin/js/inline-edit-post.js +++ b/wp-admin/js/inline-edit-post.js @@ -26,6 +26,7 @@ inlineEditPost = { // add events t.rows.dblclick(function() { inlineEditPost.toggle(this); }); + t.addEvents(t.rows); $('#bulk-title-div').after( $('#inline-edit div.categories').clone(), @@ -78,6 +79,14 @@ inlineEditPost = { $(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() { var te = '', c = ''; this.revert(); @@ -89,7 +98,7 @@ inlineEditPost = { if ( $(this).attr('checked') ) { var id = $(this).val(); c = c == '' ? ' class="alternate"' : ''; - te += 'X'+$('#inline_'+id+' .post_title').text()+''; + te += 'X'+$('#inline_'+id+' .post_title').text()+''; } }); @@ -199,6 +208,7 @@ inlineEditPost = { row.html($(r).html()).show() .animate( { backgroundColor: '#CCEEBB' }, 500) .animate( { backgroundColor: '#eefee7' }, 500); + inlineEditPost.addEvents(row); } else { $('#edit-'+id+' .quick-edit-save').append(''+inlineEditL10n.error+''); } diff --git a/wp-admin/js/inline-edit-tax.js b/wp-admin/js/inline-edit-tax.js index ed102bbdd0..1c9d048f10 100644 --- a/wp-admin/js/inline-edit-tax.js +++ b/wp-admin/js/inline-edit-tax.js @@ -20,6 +20,7 @@ inlineEditTax = { // add events t.rows.dblclick(function() { inlineEditTax.toggle(this); }); + t.addEvents(t.rows); $('#doaction, #doaction2, #post-query-submit').click(function(e){ 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); }, + 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) { var t = this; t.revert(); @@ -103,6 +112,7 @@ inlineEditTax = { row.html($(r).html()).show() .animate( { backgroundColor: '#CCEEBB' }, 500) .animate( { backgroundColor: '#eefee7' }, 500); + inlineEditTax.addEvents(row); } else $('#edit-'+id+' .quick-edit-save .error').html(r).show(); } else diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 65477bd9f1..285ab29eae 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -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( '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( - 'error' => __('Error while saving the changes.'), - 'rem_title' => __('Remove from batch edit') + 'edit' => __('Double-click to 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( + 'edit' => __('Double-click to edit'), 'error' => __('Error while saving the changes.') ) );