Make WordPress Core

Ticket #15503: garyc40-15503.patch

File garyc40-15503.patch, 7.1 KB (added by garyc40, 15 years ago)

disable pagination buttons using span, also properly update href attributes when changing pages

  • wp-admin/css/colors-classic.dev.css

    diff --git wp-admin/css/colors-classic.dev.css wp-admin/css/colors-classic.dev.css
    index 0b8183c..d99a7d5 100644
    fieldset.inline-edit-col-right .inline-edit-col { 
    14081408        color: #555;
    14091409}
    14101410
    1411 .tablenav .tablenav-pages a {
     1411.tablenav .tablenav-pages a, .tablenav .tablenav-pages span.disabled {
    14121412        border-color: #D1E5EE;
    14131413        background: #eee url('../images/menu-bits-vs.gif?ver=20101102') repeat-x scroll left -379px;
    14141414}
    14151415
     1416.tablenav .tablenav-pages span.disabled {
     1417        color:#ccc;
     1418}
     1419
    14161420.tablenav .tablenav-pages a:hover {
    14171421        color: #d54e21;
    14181422        border-color: #d54321;
  • wp-admin/css/colors-fresh.dev.css

    diff --git wp-admin/css/colors-fresh.dev.css wp-admin/css/colors-fresh.dev.css
    index ede8f38..a325d37 100644
    fieldset.inline-edit-col-right .inline-edit-col { 
    14051405        color: #555;
    14061406}
    14071407
    1408 .tablenav .tablenav-pages a {
     1408.tablenav .tablenav-pages a, .tablenav .tablenav-pages span.disabled {
    14091409        border-color: #e3e3e3;
    14101410        background: #eee url('../images/menu-bits.gif?ver=20100610') repeat-x scroll left -379px;
    14111411}
    14121412
     1413.tablenav .tablenav-pages span.disabled {
     1414        color: #ccc;
     1415}
     1416
    14131417.tablenav .tablenav-pages a:hover {
    14141418        color: #d54e21;
    14151419        border-color: #d54321;
  • wp-admin/css/wp-admin.dev.css

    diff --git wp-admin/css/wp-admin.dev.css wp-admin/css/wp-admin.dev.css
    index 13694dd..3171b04 100644
    th.asc:hover span.sorting-indicator { 
    14381438}
    14391439
    14401440.tablenav .tablenav-pages a,
    1441 .tablenav-pages span.current  {
     1441.tablenav-pages span.current,
     1442.tablenav-pages span.disabled  {
    14421443        text-decoration: none;
    14431444        border: none;
    14441445        padding: 3px 6px;
  • wp-admin/includes/class-wp-list-table.php

    diff --git wp-admin/includes/class-wp-list-table.php wp-admin/includes/class-wp-list-table.php
    index 024c7b6..8964e79 100644
    class WP_List_Table { 
    481481                $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    482482
    483483                $page_links = array();
    484 
    485                 $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
    486                         'first-page',
    487                         esc_attr__( 'Go to the first page' ),
    488                         esc_url( remove_query_arg( 'paged', $current_url ) ),
    489                         '&laquo;&laquo;'
    490                 );
    491 
    492                 $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
    493                         'prev-page',
    494                         esc_attr__( 'Go to the previous page' ),
    495                         esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
    496                         '&laquo;'
    497                 );
     484               
     485                if ( $current == 1 ) {
     486                        $page_links[] = sprintf( "<span class='%s'>%s</span>",
     487                                'first-page disabled',
     488                                '&laquo;&laquo;'
     489                        );
     490                        $page_links[] = sprintf( "<span class='%s'>%s</span>",
     491                                'prev-page disabled',
     492                                '&laquo;'
     493                        );
     494                } else {
     495                        $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
     496                                'first-page',
     497                                esc_attr__( 'Go to the first page' ),
     498                                esc_url( remove_query_arg( 'paged', $current_url ) ),
     499                                '&laquo;&laquo;'
     500                        );
     501                        $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
     502                                'prev-page',
     503                                esc_attr__( 'Go to the previous page' ),
     504                                esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
     505                                '&laquo;'
     506                        );
     507                }
    498508
    499509                $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='%s' value='%s' size='%d' />",
    500510                        esc_attr__( 'Current page' ),
    class WP_List_Table { 
    505515                $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
    506516                $page_links[] = sprintf( _x( '%s of %s', 'paging' ), $html_current_page, $html_total_pages );
    507517
    508                 $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
    509                         'next-page',
    510                         esc_attr__( 'Go to the next page' ),
    511                         esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
    512                         '&raquo;'
    513                 );
     518                if ( $current == $total_pages ) {
     519                        $page_links[] = sprintf( "<span class='%s'>%s</span>",
     520                                'next-page disabled',
     521                                '&raquo;'
     522                        );
    514523
    515                 $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
    516                         'last-page',
    517                         esc_attr__( 'Go to the last page' ),
    518                         esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
    519                         '&raquo;&raquo;'
    520                 );
     524                        $page_links[] = sprintf( "<span class='%s'>%s</span>",
     525                                'last-page disabled',
     526                                '&raquo;&raquo;'
     527                        );
     528                } else {
     529                        $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
     530                                'next-page',
     531                                esc_attr__( 'Go to the next page' ),
     532                                esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
     533                                '&raquo;'
     534                        );
     535
     536                        $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
     537                                'last-page',
     538                                esc_attr__( 'Go to the last page' ),
     539                                esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
     540                                '&raquo;&raquo;'
     541                        );
     542                }
    521543
    522544                $output .= join( "\n", $page_links );
    523545
  • wp-admin/js/list-table.dev.js

    diff --git wp-admin/js/list-table.dev.js wp-admin/js/list-table.dev.js
    index d44e7a7..b87c404 100644
    listTable.init(); 
    148148
    149149// Ajaxify various UI elements
    150150
    151         function change_page(paged, $el) {
     151        var spanify = function(selectors) {
     152                $('.tablenav-pages a').
     153                        filter(selectors).
     154                        each(function(){
     155                                var $this = $(this), span = $('<span />');
     156                                span.
     157                                        addClass($this.attr('class') + ' disabled').
     158                                        text($this.text());
     159                                $this.replaceWith(span);
     160                        });
     161        };
     162       
     163        var linkify = function() {
     164                $('.tablenav-pages span.disabled').each(function(){
     165                        var $this = $(this), a = $('<a />');
     166                        a.
     167                                addClass($this.attr('class')).
     168                                removeClass('disabled').
     169                                text($this.text());
     170                               
     171                        $this.replaceWith(a);
     172                });
     173        }
     174       
     175        var updatePageLinks = function(paged) {                 
     176                $('.tablenav-pages a').each(function(){
     177                        var a = $(this), href = '#';
     178                       
     179                        switch (a.attr('class')) {
     180                                case 'first-page':
     181                                        href = $.query.set('paged', 1).toString();
     182                                        break;
     183                                case 'prev-page':
     184                                        href = $.query.set('paged', paged - 1).toString();
     185                                        break;
     186                                case 'next-page':
     187                                        href = $.query.set('paged', paged + 1).toString();
     188                                        break;
     189                                case 'last-page':
     190                                        href = $.query.set('paged', listTable.get_total_pages()).toString();
     191                                        break;
     192                        }
     193                       
     194                        a.attr('href', href);
     195                });
     196        };
     197
     198        function change_page(paged, $el) {             
    152199                if ( paged < 1 )
    153200                        paged = 1;
    154201
    listTable.init(); 
    158205                listTable.update_rows({'paged': paged}, false, function() {
    159206                        if ( $el.parents('.tablenav.bottom').length )
    160207                                scrollTo(0, 0);
     208                       
     209                        // convert disabled buttons to links
     210                        linkify();
     211                               
     212                        // disable pagination links in case of first or last page
     213                        if ( paged == 1 ) {
     214                                spanify('.prev-page, .first-page');
     215                        } else if ( paged == listTable.get_total_pages() ) {
     216                                spanify('.next-page, .last-page');
     217                        }
     218                       
     219                        // update href attribute of pagination links
     220                        updatePageLinks(paged);
    161221                               
    162222                        $(listTable).trigger('changePage');
    163223                });
    164224        }
    165225
    166226        // pagination
    167         $('.tablenav-pages a').click(function() {
     227        $('.tablenav-pages a').live('click', function() {
    168228                var $el = $(this),
    169229                        paged = $.query.GET('paged');
    170230