Making WordPress.org

Changeset 1450


Ignore:
Timestamp:
03/25/2015 05:18:59 PM (12 years ago)
Author:
obenland
Message:

WP.org Themes: Only update URL when actually closing the modal.

Fixes a bug where URLs were updated when navigating between themes.
Introduced in r1409.

File:
1 edited

Legend:

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

    r1448 r1450  
    789789                collapse: function( event ) {
    790790                        var self = this,
    791                                 scroll;
    792 
    793                         event = event || window.event;
     791                                args = {},
     792                                scroll, author, search, tags, sorter;
    794793
    795794                        // Prevent collapsing detailed view when there is only one theme available
    … …  
    797796                                return;
    798797                        }
     798
     799                        event = event || window.event;
    799800
    800801                        // Detect if the click is inside the overlay
    … …  
    815816                                        // Get scroll position to avoid jumping to the top
    816817                                        scroll = document.body.scrollTop;
     818
     819                                        // Clean the url structure
     820                                        if ( author = themes.Collection.prototype.currentQuery.request.author ) {
     821                                                themes.router.navigate( themes.router.baseUrl( 'author/' + author ) );
     822                                                themes.utils.title( author );
     823                                        }
     824                                        else if ( search = themes.Collection.prototype.currentQuery.request.search ) {
     825                                                themes.router.navigate( themes.router.baseUrl( themes.router.searchPath + search ) );
     826                                                themes.utils.title( search );
     827                                        }
     828                                        else if ( tags = themes.view.Installer.prototype.filtersChecked() ) {
     829                                                themes.router.navigate( themes.router.baseUrl( 'tags/' + tags.join( '+' ) ) );
     830                                                themes.utils.title( _.each( tags, function( tag, i ) {
     831                                                        tags[ i ] = $( 'label[for="filter-id-' + tag + '"]' ).text();
     832                                                }).join( ', ' ) );
     833                                        }
     834                                        else if ( sorter = $( '.filter-links .current' ) ) {
     835                                                if ( ! sorter.length ) {
     836                                                        sorter = $( '.filter-links [data-sort="featured"]' );
     837                                                        args   = { trigger: true };
     838                                                }
     839                                                themes.router.navigate( themes.router.baseUrl( themes.router.browsePath + sorter.data( 'sort' ) ), args );
     840                                                themes.utils.title( sorter.text() );
     841                                        }
    817842
    818843                                        // Restore scroll position
    … …  
    888913                // the theme details overlay
    889914                closeOverlay: function() {
    890                         var args = {},
    891                                 author, search, tags, sorter;
    892 
    893915                        $( 'body' ).removeClass( 'modal-open' );
    894916                        this.remove();
    895917                        this.unbind();
    896918                        this.trigger( 'theme:collapse' );
    897 
    898                         // Clean the url structure
    899                         if ( author = themes.Collection.prototype.currentQuery.request.author ) {
    900                                 themes.router.navigate( themes.router.baseUrl( 'author/' + author ) );
    901                                 themes.utils.title( author );
    902                         }
    903                         else if ( search = themes.Collection.prototype.currentQuery.request.search ) {
    904                                 themes.router.navigate( themes.router.baseUrl( themes.router.searchPath + search ) );
    905                                 themes.utils.title( search );
    906                         }
    907                         else if ( tags = themes.view.Installer.prototype.filtersChecked() ) {
    908                                 themes.router.navigate( themes.router.baseUrl( 'tags/' + tags.join( '+' ) ) );
    909                                 themes.utils.title( _.each( tags, function( tag, i ) {
    910                                         tags[ i ] = $( 'label[for="filter-id-' + tag + '"]' ).text();
    911                                 }).join( ', ' ) );
    912                         }
    913                         else if ( sorter = $( '.filter-links .current' ) ) {
    914                                 if ( ! sorter.length ) {
    915                                         sorter = $( '.filter-links [data-sort="featured"]' );
    916                                         args   = { trigger: true };
    917                                 }
    918                                 themes.router.navigate( themes.router.baseUrl( themes.router.browsePath + sorter.data( 'sort' ) ), args );
    919                                 themes.utils.title( sorter.text() );
    920                         }
    921919                },
    922920
Note: See TracChangeset for help on using the changeset viewer.