Making WordPress.org


Ignore:
Timestamp:
09/18/2015 08:09:58 PM (9 years ago)
Author:
ocean90
Message:

Translate, stats overview: Add sorting.

Props samuelsidler.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/translate.wordpress.org/public_html/gp-templates/stats-overview.php

    r1886 r1895  
    11<?php
    22gp_title( __( 'Translation status overview &lt; GlotPress' ) );
     3wp_enqueue_script( 'tablesorter' );
    34
    45$breadcrumb   = array();
     
    89gp_tmpl_header();
    910
    10 
    1111?>
    1212<div class="stats-table">
    13     <table class="table">
     13    <table id="stats-table" class="table">
    1414        <thead>
    1515            <tr>
     
    4141                    <th title="<?php echo esc_attr( $gp_locale->english_name ); ?>">
    4242                        <a href="<?php echo gp_url_join( 'locale', $gp_locale->slug, $set_slug ); ?>">
    43                             <?php echo esc_html( $gp_locale->wp_locale ); ?> 
     43                            <?php echo esc_html( $gp_locale->wp_locale ); ?>
    4444                        </a>
    4545                    </th>
     
    5959                                }
    6060                                $percent_class = 'percent' . $percent_class;
    61                                 echo '<td class="' . $percent_class .'"><a href="' . $projecturl . '">' . number_format( $percent ) . '</a></td>';
     61                                echo '<td data-sort-value="'. esc_attr( $percent ) . '" class="' . $percent_class .'"><a href="' . $projecturl . '">' . number_format( $percent ) . '</a></td>';
    6262                            } else {
    6363                                $percent_class = 'percent' . (int) ( $percent / 10 ) * 10;
    64                                 echo '<td class="' . $percent_class .'"><a href="' . $projecturl . '">' . $percent . '%</a></td>';
     64                                echo '<td data-sort-value="' . esc_attr( $percent ) . '" class="' . $percent_class .'"><a href="' . $projecturl . '">' . $percent . '%</a></td>';
    6565                            }
    6666
    6767                        } else {
    68                             echo '<td class="none">&mdash;</td>';
     68                            echo '<td class="none" data-sort-value="-1">&mdash;</td>';
    6969                        }
    70                        
    71                        
    7270                    }
    7371                    ?>
     
    7674        </tbody>
    7775    </table>
    78 
    7976</div>
    8077
     78<script type="text/javascript">
     79jQuery( document ).ready( function( $ ) {
     80    $( '#stats-table' ).tablesorter( {
     81        textExtraction: function( node ) {
     82            var cellValue = $( node ).text(),
     83                sortValue = $( node ).data( 'sortValue' );
     84
     85            return ( undefined !== sortValue ) ? sortValue : cellValue;
     86        }
     87    });
     88});
     89</script>
    8190<?php
    8291gp_tmpl_footer();
Note: See TracChangeset for help on using the changeset viewer.