Making WordPress.org


Ignore:
Timestamp:
11/11/2015 02:00:12 AM (10 years ago)
Author:
dd32
Message:

Translate: Add a basic sorting dropdown to project views.
Patches welcome to integrate the UI into the listing UI better.

Fixes #1122

File:
1 edited

Legend:

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

    r1888 r2072  
    7575    </div>
    7676</div>
     77<div class="sort-bar">
     78    <select id="sort-filter" disabled="disabled">
     79        <?php
     80            $sorts = array();
     81            if ( GP::$user->current()->id && in_array( $project->slug, array( 'waiting', 'wp-themes', 'wp-plugins' ) ) ) {
     82                $sorts['special'] = 'Untranslated Favorites, Remaining Strings (Most first)';
     83                $sorts['favorites'] = 'My Favorites';
     84            }
     85            $sorts['strings-remaining'] = 'Remaining Strings (Most first)';
     86            $sorts['strings-remaining-asc'] = 'Remaining Strings (Least first)';
     87            $sorts['strings-waiting-and-fuzzy'] = 'Waiting + Fuzzy (Most first)';
     88            $sorts['strings-waiting-and-fuzzy-asc'] = 'Waiting + Fuzzy (Least first)';
     89            $sorts['percent-completed'] = 'Percent Completed (Most first)';
     90            $sorts['percent-completed-asc'] = 'Percent Completed (Least first)';
     91
     92            foreach ( $sorts as $value => $text ) {
     93                printf( '<option value="%s" %s>%s</option>', esc_attr( $value ), ( $value == $filter ? 'selected="selected"' : '' ), esc_attr( $text ) );
     94            }
     95        ?>
     96    </select>
     97</div>
     98<script>
     99    jQuery('#sort-filter').change( function() {
     100        var current_url = document.location.href.replace(/[?&]filter=[^&$]*/, '' );
     101        document.location.replace(
     102            current_url +
     103            ( -1 == current_url.indexOf('?') ? '?filter=' : '&filter=' ) +
     104            this.options[ this.options.selectedIndex ].value
     105        );
     106    } ).prop('disabled', '');
     107</script>
    77108
    78109<div id="projects" class="projects">
Note: See TracChangeset for help on using the changeset viewer.