Making WordPress.org

Changeset 1282


Ignore:
Timestamp:
02/19/2015 08:01:44 PM (12 years ago)
Author:
obenland
Message:

WP.org Themes: Give previews their own place in history.

Allows users to navigate from index to Detail to Preview and back, using UI or
the browser back button. Also makes sure that if they navigate between themes
while in Preview, Detail come along for the ride and greets them with the right
theme once they leave Preview.

Fixes #843.

File:
1 edited

Legend:

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

    r1279 r1282  
    280280                        // for `theme:next` and `theme:previous` events.
    281281                        this.listenTo( preview, 'theme:next', function() {
     282                                this.trigger( 'theme:next' );
    282283
    283284                                // Keep local track of current theme model.
     
    306307                        })
    307308                                .listenTo( preview, 'theme:previous', function() {
     309                                        this.trigger( 'theme:previous' );
    308310
    309311                                        // Keep track of current theme model.
     
    442444        _.extend( wp.themes.view.Preview.prototype, {
    443445
     446                render: function() {
     447                        var data = this.model.toJSON();
     448
     449                        this.$el.html( this.html( data ) );
     450
     451                        wp.themes.router.navigate( wp.themes.router.baseUrl( wp.themes.router.themePath + this.model.get( 'id' ) + '/preview' ) );
     452
     453                        this.$el.fadeIn( 200, function() {
     454                                $( 'body' ).addClass( 'theme-installer-active full-overlay-active' );
     455                                $( '.close-full-overlay' ).focus();
     456                        });
     457                },
     458
    444459                close: function() {
    445460                        this.$el.fadeOut( 200, function() {
     
    455470                        this.undelegateEvents();
    456471                        this.unbind();
     472                        wp.themes.router.navigate( wp.themes.router.baseUrl( wp.themes.router.themePath + this.model.get( 'id' ) ) );
    457473                        return false;
    458474                },
     
    521537        _.extend( wp.themes.InstallerRouter.prototype, {
    522538                routes: {
    523                         'browse/:sort/': 'sort',
    524                         'tag/:tag/': 'tag',
    525                         'search/:query/': 'search',
     539                        'browse/:sort/'  : 'sort',
     540                        'tag/:tag/'      : 'tag',
     541                        'search/:query/' : 'search',
    526542                        'author/:author/': 'author',
    527                         ':slug/': 'preview',
    528                         '': 'sort'
     543                        ':slug/preview/' : 'preview',
     544                        ':slug/'         : 'preview',
     545                        ''               : 'sort'
    529546                },
    530547
     
    548565                        // Open the modal when matching the route for a single themes.
    549566                        wp.themes.router.on( 'route:preview', function( slug ) {
     567                                $( '.close-full-overlay' ).trigger( 'click' );
    550568                                this.listenToOnce( self.view.collection, 'query:success', function() {
    551569                                        self.view.view.expand( slug );
Note: See TracChangeset for help on using the changeset viewer.