Making WordPress.org

Changeset 1241


Ignore:
Timestamp:
02/10/2015 05:56:28 PM (12 years ago)
Author:
obenland
Message:

WP.org Themes: Make tag URLs persistent.

Now users can pass around a tag url and the directory will filter themes based
on that url on first load. Adding and removing filters will also update the url
once they are applied.

See #745.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/index.php

    r1235 r1241  
    6464
    6565                <div class="theme-browser content-filterable">
    66                         <div class="themes" style="display: none;">
     66                        <div class="themes">
    6767                                <?php
    6868                                if ( ! is_wp_error( $themes ) ) :
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.js

    r1240 r1241  
    88
    99        _.extend( wp.themes.view.Installer.prototype, {
    10                 el: '#themes'
     10                el: '#themes',
     11
     12                // Applying filters triggers a tag request.
     13                applyFilters: function( event ) {
     14                        var name,
     15                                tags = this.filtersChecked(),
     16                                request = { tag: tags },
     17                                filteringBy = $( '.filtered-by .tags' );
     18
     19                        if ( event ) {
     20                                event.preventDefault();
     21                        }
     22
     23                        $( 'body' ).addClass( 'filters-applied' );
     24                        $( '.filter-links li > a.current' ).removeClass( 'current' );
     25                        filteringBy.empty();
     26
     27                        _.each( tags, function( tag ) {
     28                                name = $( 'label[for="filter-id-' + tag + '"]' ).text();
     29                                filteringBy.append( '<span class="tag">' + name + '</span>' );
     30                        });
     31
     32                        wp.themes.router.navigate( wp.themes.router.baseUrl( 'tag/' + tags.join( '+' ) ), { replace: true } );
     33
     34                        // Get the themes by sending Ajax POST request to api.wordpress.org/themes
     35                        // or searching the local cache
     36                        this.collection.query( request );
     37                },
     38
     39                // Toggle the full filters navigation.
     40                moreFilters: function( event ) {
     41                        event.preventDefault();
     42
     43                        if ( $( 'body' ).hasClass( 'filters-applied' ) ) {
     44                                return this.backToFilters();
     45                        }
     46
     47                        // If the filters section is opened and filters are checked
     48                        // run the relevant query collapsing to filtered-by state
     49                        if ( $( 'body' ).hasClass( 'show-filters' ) && this.filtersChecked() ) {
     50                                return this.addFilter();
     51                        }
     52
     53                        this.clearSearch();
     54
     55                        $( 'body' ).toggleClass( 'show-filters' );
     56                }
     57
    1158        });
    1259
     
    402449
    403450                        wp.themes.router.on( 'route:tag', function( tag ) {
    404                                 $( '#filter-id-' + tag).prop( 'checked', true );
     451                                _.each( tag.split( '+' ), function( tag ) {
     452                                        $( '#filter-id-' + tag ).prop( 'checked', true );
     453                                });
     454                                $( 'body' ).toggleClass( 'show-filters' );
    405455                                self.view.applyFilters();
    406456                        });
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/style.css

    r1236 r1241  
    606606.wp-filter .button.clear-filters {
    607607        display: none;
    608         margin: 0 0 20px 10px;
     608        margin: 0 0 0 10px;
    609609}
    610610
Note: See TracChangeset for help on using the changeset viewer.