Making WordPress.org

Changeset 1296


Ignore:
Timestamp:
02/24/2015 04:48:58 AM (12 years ago)
Author:
obenland
Message:

WP.org Themes: Update document title according to current view.

Also improves UX when closing a modal, URL and title are now agnostic of the
last index view.

See #745, #850.

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

Legend:

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

    r1293 r1296  
    7373                        'themes'   => false,
    7474                        'settings' => array(
     75                                'title'      => __( 'WordPress › %s « Free WordPress Themes', 'wporg-themes' ),
    7576                                'isMobile'   => wp_is_mobile(),
    7677                                'isInstall'  => true,
     
    188189                $theme->authorurl          = $user->user_nicename;
    189190                $theme->authordispname = wp_kses( $user->display_name, $themes_allowedtags );
    190                
     191
    191192                $theme->author         = wp_kses( $theme->author,      $themes_allowedtags );
    192193                $theme->version        = wp_kses( $theme->version,     $themes_allowedtags );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.js

    r1282 r1296  
    11( function ( $, wp ) {
    22        google.load("visualization", "1", {packages:["corechart"]});
     3
     4        wp.themes.utils = {
     5                title: function ( item ) {
     6                        var title = $( 'title' );
     7
     8                        title.html( wp.themes.data.settings.title.replace( '%s', item ) );
     9                }
     10        };
    311
    412        _.extend( wp.themes.view.Appearance.prototype, {
     
    1927                        // Trigger a route update for the current model
    2028                        wp.themes.router.navigate( wp.themes.router.baseUrl( wp.themes.router.themePath + this.model.id ) );
     29                        wp.themes.utils.title( this.model.attributes.name );
    2130
    2231                        // Sets this.view to 'detail'
     
    5463                el: '#themes',
    5564
     65                sort: function( sort ) {
     66                        var sorter = $( '.filter-links [data-sort="' + sort + '"]' );
     67                        this.clearSearch();
     68
     69                        $( '.filter-links li > a, .theme-filter' ).removeClass( this.activeClass );
     70                        sorter.addClass( this.activeClass );
     71                        wp.themes.utils.title( sorter.text() );
     72
     73                        this.browse( sort );
     74                },
     75
    5676                // Applying filters triggers a tag request.
    5777                applyFilters: function( event ) {
    58                         var name,
     78                        var names = [],
     79                                name,
    5980                                tags = this.filtersChecked(),
    6081                                request = { tag: tags },
     
    7192                        _.each( tags, function( tag ) {
    7293                                name = $( 'label[for="filter-id-' + tag + '"]' ).text();
     94                                names.push( name );
    7395                                filteringBy.append( '<span class="tag">' + name + '</span>' );
    7496                        });
    7597
    7698                        wp.themes.router.navigate( wp.themes.router.baseUrl( 'tag/' + tags.join( '+' ) ) );
     99                        wp.themes.utils.title( names.join( ', ' ) );
    77100
    78101                        // Get the themes by sending Ajax POST request to api.wordpress.org/themes
     
    439462                                }
    440463                        });
     464                },
     465
     466                // Single theme overlay screen
     467                // It's shown when clicking a theme
     468                collapse: function( event ) {
     469                        var self = this,
     470                                scroll, sorter;
     471
     472                        event = event || window.event;
     473
     474                        // Prevent collapsing detailed view when there is only one theme available
     475                        if ( wp.themes.data.themes.length === 1 ) {
     476                                return;
     477                        }
     478
     479                        // Detect if the click is inside the overlay
     480                        // and don't close it unless the target was
     481                        // the div.back button
     482                        if ( $( event.target ).is( '.theme-backdrop' ) || $( event.target ).is( '.close' ) || event.keyCode === 27 ) {
     483
     484                                // Add a temporary closing class while overlay fades out
     485                                $( 'body' ).addClass( 'closing-overlay' );
     486
     487                                // With a quick fade out animation
     488                                this.$el.fadeOut( 130, function() {
     489                                        // Clicking outside the modal box closes the overlay
     490                                        $( 'body' ).removeClass( 'closing-overlay' );
     491                                        // Handle event cleanup
     492                                        self.closeOverlay();
     493
     494                                        // Get scroll position to avoid jumping to the top
     495                                        scroll = document.body.scrollTop;
     496
     497                                        sorter = $( '.filter-links .current' );
     498
     499                                        // Clean the url structure
     500                                        wp.themes.router.navigate( wp.themes.router.baseUrl( wp.themes.router.browsePath + sorter.data( 'sort' ) ) );
     501                                        wp.themes.utils.title( sorter.text() );
     502
     503                                        // Restore scroll position
     504                                        document.body.scrollTop = scroll;
     505
     506                                        // Return focus to the theme div
     507                                        if ( wp.themes.focusedTheme ) {
     508                                                wp.themes.focusedTheme.focus();
     509                                        }
     510                                });
     511                        }
    441512                }
    442513        });
     
    497568        _.extend( wp.themes.view.InstallerSearch.prototype, {
    498569                doSearch: _.debounce( function( value ) {
    499                         var request = {};
     570                        var request = {},
     571                                sort = 'featured';
    500572
    501573                        request.search = value;
     
    528600                        // Set route
    529601                        if ( value ) {
     602                                wp.themes.utils.title( value );
    530603                                wp.themes.router.navigate( wp.themes.router.baseUrl( wp.themes.router.searchPath + value ), { replace: true } );
    531604                        } else {
    532                                 wp.themes.router.navigate( wp.themes.router.baseUrl( '' ) );
     605                                wp.themes.router.navigate( wp.themes.router.baseUrl( themes.router.browsePath + sort ) );
     606                                this.parent.sort( sort );
    533607                        }
    534608                }, 300 )
     
    582656                                request.author = author;
    583657                                self.view.collection.query( request );
     658                                wp.themes.utils.title( author );
    584659                        });
    585660                }
Note: See TracChangeset for help on using the changeset viewer.