Ticket #25963: 25963.7.diff
File 25963.7.diff, 5.2 KB (added by , 11 years ago) |
---|
-
src/wp-admin/js/theme.js
292 292 scroll = document.body.scrollTop; 293 293 294 294 // Clean the url structure 295 themes.router.navigate( '');295 themes.router.navigate( themes.router.baseUrl( '' ), { replace: true } ); 296 296 297 297 // Restore scroll position 298 298 document.body.scrollTop = scroll; … … 380 380 themes.view.Themes = wp.Backbone.View.extend({ 381 381 382 382 className: 'themes', 383 $overlay: $( 'div.theme-overlay' ), 383 384 384 385 // Number to keep track of scroll position 385 386 // while in theme-overlay mode … … 511 512 this.model = self.collection.get( id ); 512 513 513 514 // Trigger a route update for the current model 514 themes.router.navigate( 'theme/' + this.model.id);515 themes.router.navigate( themes.router.baseUrl( '?theme=' + this.model.id ), { replace: true } ); 515 516 516 517 // Sets this.view to 'detail' 517 518 this.setView( 'detail' ); … … 523 524 }); 524 525 525 526 this.overlay.render(); 526 this.$ el.append( this.overlay.el );527 this.$overlay.html( this.overlay.el ); 527 528 528 529 this.overlay.screenshotGallery(); 529 530 … … 565 566 this.overlay.closeOverlay(); 566 567 567 568 // Trigger a route update for the current model 568 // that renders the new theme's overlay569 themes.router.navigate( 'theme/' + nextModel.id, { trigger: true } ); 569 self.theme.trigger( 'theme:expand', nextModel.cid ); 570 570 571 } 571 572 }, 572 573 … … 589 590 this.overlay.closeOverlay(); 590 591 591 592 // Trigger a route update for the current model 592 // that renders the new theme's overlay593 themes.router.navigate( 'theme/' + previousModel.id, { trigger: true } ); 593 self.theme.trigger( 'theme:expand', previousModel.cid ); 594 594 595 } 595 596 } 596 597 }); … … 624 625 625 626 // Update the URL hash 626 627 if ( event.target.value ) { 627 themes.router.navigate( 'search/' + event.target.value, { replace: true } );628 themes.router.navigate( themes.router.baseUrl( '?search=' + event.target.value ), { replace: true } ); 628 629 } else { 629 themes.router.navigate( '');630 themes.router.navigate( themes.router.baseUrl( '' ), { replace: true } ); 630 631 } 631 632 } 632 633 }); … … 635 636 // Listens to [theme] and [search] params 636 637 themes.routes = Backbone.Router.extend({ 637 638 638 routes:{639 'search/*query': 'search',640 'theme/*slug': 'theme'639 initialize: function() { 640 this.routes = _.object([ 641 ]); 641 642 }, 642 643 644 baseUrl: function( url ) { 645 return themes.data.settings.root + url; 646 }, 647 643 648 // Set the search input value based on url 644 649 search: function( query ) { 645 650 $( '.theme-search' ).val( query ); 651 _.debounce( self.themes.doSearch( query ), 200 ); 646 652 } 647 653 }); 648 654 … … 667 673 render: function() { 668 674 // Render results 669 675 this.view.render(); 670 671 // Calls the routes functionality672 676 this.routes(); 673 677 674 // Set ups history with pushState and our root 675 Backbone.history.start({ root: themes.data.settings.root }); 678 // Set the initial theme 679 if ( 'undefined' !== typeof themes.data.settings.theme && '' !== themes.data.settings.theme ){ 680 this.view.view.theme.trigger( 'theme:expand', this.view.collection.findWhere( { id: themes.data.settings.theme } ) ); 681 } 682 683 // Set the initial search 684 if ( 'undefined' !== typeof themes.data.settings.search && '' !== themes.data.settings.search ){ 685 $( '.theme-search' ).val( themes.data.settings.search ); 686 this.themes.doSearch( themes.data.settings.search ); 687 } 688 689 // Start the router if browser supports History API 690 if ( window.history && window.history.pushState ) { 691 // Calls the routes functionality 692 Backbone.history.start({ pushState: true, silent: true }); 693 } 676 694 }, 677 695 678 696 routes: function() { … … 680 698 // Bind to our global thx object 681 699 // so that the object is available to sub-views 682 700 themes.router = new themes.routes(); 683 684 // Handles theme details route event685 themes.router.on( 'route:theme', function( slug ) {686 self.view.view.expand( slug );687 });688 689 // Handles search route event690 themes.router.on( 'route:search', function( query ) {691 self.themes.doSearch( query );692 });693 701 } 694 702 }; 695 703 -
src/wp-admin/themes.php
91 91 } else { 92 92 $themes = wp_prepare_themes_for_js( array( wp_get_theme() ) ); 93 93 } 94 wp_reset_vars( array( 'theme', 'search' ) ); 94 95 95 96 wp_localize_script( 'theme', '_wpThemeSettings', array( 96 97 'themes' => $themes, … … 98 99 'canInstall' => ( ! is_multisite() && current_user_can( 'install_themes' ) ), 99 100 'installURI' => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null, 100 101 'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ), 101 'root' => admin_url( 'themes.php'),102 'root' => parse_url( admin_url( 'themes.php' ), PHP_URL_PATH ), 102 103 'extraRoutes' => '', 104 'theme' => esc_html( $theme ), 105 'search' => esc_html( $search ), 106 103 107 ), 104 108 'l10n' => array( 105 109 'addNew' => __( 'Add New Theme' ), … … 180 184 ?> 181 185 182 186 <div class="theme-browser"></div> 187 <div class="theme-overlay"></div> 183 188 184 189 <?php 185 190 // List broken themes, if any.