Make WordPress Core

Ticket #22164: 22164.diff

File 22164.diff, 3.6 KB (added by nacin, 11 years ago)
  • wp-admin/edit-comments.php

     
    102102$wp_list_table->prepare_items();
    103103
    104104wp_enqueue_script('admin-comments');
    105 enqueue_comment_hotkeys_js();
     105wp_enqueue_script('jquery-table-hotkeys');
    106106
    107107if ( $post_id )
    108108        $title = sprintf(__('Comments on “%s”'), wp_html_excerpt(_draft_or_post_title($post_id), 50));
  • wp-admin/includes/screen.php

     
    904904                        case 'widgets':
    905905                                $this->_screen_settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n";
    906906                                break;
     907                        case 'edit-comments' :
     908                                $this->_screen_settings = '<div><label for="comment_shortcuts"><input id="comment_shortcuts" name="comment_shortcuts" type="checkbox" checked="checked" /> ' . __( 'Use comment shortcuts' ) . "</label></div>\n" . $this->_screen_settings;
     909                                break;
    907910                }
    908911
    909912                if ( $this->_screen_settings || $this->_options )
  • wp-admin/js/edit-comments.js

     
    555555};
    556556
    557557$(document).ready(function(){
    558         var make_hotkeys_redirect, edit_comment, toggle_all, make_bulk;
     558        var make_hotkeys_redirect, edit_comment, toggle_all, make_bulk,
     559                shortcuts = $('#comment_shortcuts'), keys = false;
    559560
    560561        setCommentsList();
    561562        commentReply.init();
     
    591592                        }
    592593                };
    593594
    594                 $.table_hotkeys(
    595                         $('table.widefat'),
    596                         ['a', 'u', 's', 'd', 'r', 'q', 'z', ['e', edit_comment], ['shift+x', toggle_all],
    597                         ['shift+a', make_bulk('approve')], ['shift+s', make_bulk('spam')],
    598                         ['shift+d', make_bulk('delete')], ['shift+t', make_bulk('trash')],
    599                         ['shift+z', make_bulk('untrash')], ['shift+u', make_bulk('unapprove')]],
    600                         { highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last,
    601                         prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next') }
    602                 );
     595                function add_hotkeys() {
     596                        if ( keys ) return;
     597                        keys = true;
     598                        $.table_hotkeys(
     599                                $('table.widefat'),
     600                                ['a', 'u', 's', 'd', 'r', 'q', 'z', ['e', edit_comment], ['shift+x', toggle_all],
     601                                ['shift+a', make_bulk('approve')], ['shift+s', make_bulk('spam')],
     602                                ['shift+d', make_bulk('delete')], ['shift+t', make_bulk('trash')],
     603                                ['shift+z', make_bulk('untrash')], ['shift+u', make_bulk('unapprove')]],
     604                                { highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last,
     605                                prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next') }
     606                        );
     607                }
     608
     609                function remove_hotkeys() {
     610                        var r = $.hotkeys.remove;
     611                        if ( ! keys ) return;
     612                        $('.vim-current').removeClass('vim-current');
     613                        keys = false;
     614                        r('a'), r('u'), r('s'), r('d'), r('r'), r('q'), r('z'), r('e'), r('shift+x'),
     615                        r('shift+a'), r('shift+s'), r('shift+d'), r('shift+t'), r('shift+z'), r('shift+u');
     616                }
     617
     618                shortcuts.change( function(){
     619                        if ( $(this).prop('checked') )
     620                                add_hotkeys();
     621                        else
     622                                remove_hotkeys();
     623                });
     624                if ( shortcuts.prop('checked') ) {
     625                        add_hotkeys();
     626                        keys = true;
     627                }
    603628        }
    604629});
    605630