diff --git src/wp-admin/js/theme.js src/wp-admin/js/theme.js
index aba7d9b..4f183a8 100644
|
|
themes.view.Details = wp.Backbone.View.extend({ |
350 | 350 | scroll = document.body.scrollTop; |
351 | 351 | |
352 | 352 | // Clean the url structure |
353 | | themes.router.navigate( themes.router.baseUrl( '' ), { replace: true } ); |
| 353 | themes.router.navigate( themes.router.baseUrl( '' ) ); |
354 | 354 | |
355 | 355 | // Restore scroll position |
356 | 356 | document.body.scrollTop = scroll; |
… |
… |
themes.view.Themes = wp.Backbone.View.extend({ |
451 | 451 | self.renderThemes( self.parent.page ); |
452 | 452 | }); |
453 | 453 | |
| 454 | this.listenTo( this.parent, 'theme:close', function() { |
| 455 | if ( self.overlay ) { |
| 456 | self.overlay.closeOverlay(); |
| 457 | } |
| 458 | } ); |
| 459 | |
454 | 460 | // Bind keyboard events. |
455 | 461 | $('body').on( 'keyup', function( event ) { |
456 | 462 | if ( ! self.overlay ) { |
… |
… |
themes.view.Themes = wp.Backbone.View.extend({ |
573 | 579 | this.model = self.collection.get( id ); |
574 | 580 | |
575 | 581 | // Trigger a route update for the current model |
576 | | themes.router.navigate( themes.router.baseUrl( '?theme=' + this.model.id ), { replace: true } ); |
| 582 | themes.router.navigate( themes.router.baseUrl( '?theme=' + this.model.id ) ); |
577 | 583 | |
578 | 584 | // Sets this.view to 'detail' |
579 | 585 | this.setView( 'detail' ); |
… |
… |
themes.view.Search = wp.Backbone.View.extend({ |
694 | 700 | // Listens to [theme] and [search] params |
695 | 701 | themes.routes = Backbone.Router.extend({ |
696 | 702 | |
697 | | initialize: function() { |
698 | | this.routes = _.object([ |
699 | | ]); |
| 703 | routes: { |
| 704 | 'themes.php?theme=:slug': 'theme', |
| 705 | 'themes.php?search=:query': 'search', |
| 706 | 'themes.php?s=:query': 'search', |
| 707 | 'themes.php': 'themes' |
700 | 708 | }, |
701 | 709 | |
702 | 710 | baseUrl: function( url ) { |
703 | | return themes.data.settings.root + url; |
| 711 | return 'themes.php' + url; |
| 712 | }, |
| 713 | |
| 714 | search: function( query ) { |
| 715 | $( '.theme-search' ).val( query ); |
704 | 716 | } |
| 717 | |
705 | 718 | }); |
706 | 719 | |
707 | 720 | // Execute and setup the application |
… |
… |
themes.Run = { |
720 | 733 | }, |
721 | 734 | |
722 | 735 | render: function() { |
| 736 | var root; |
| 737 | |
723 | 738 | // Render results |
724 | 739 | this.view.render(); |
725 | 740 | this.routes(); |
726 | 741 | |
727 | | // Set the initial theme |
728 | | if ( 'undefined' !== typeof themes.data.settings.theme && '' !== themes.data.settings.theme ){ |
729 | | this.view.view.theme.trigger( 'theme:expand', this.view.collection.findWhere( { id: themes.data.settings.theme } ) ); |
730 | | } |
731 | | |
732 | | // Set the initial search |
733 | | if ( 'undefined' !== typeof themes.data.settings.search && '' !== themes.data.settings.search ){ |
734 | | $( '.theme-search' ).val( themes.data.settings.search ); |
735 | | this.themes.doSearch( themes.data.settings.search ); |
736 | | } |
737 | | |
738 | | // Start the router if browser supports History API |
| 742 | // Sets up Backbone.history |
| 743 | // Only change root if we have a pushState enabled browser - |
| 744 | // fixes redirect to /wp-admin/#themes.php bug in IE8 |
739 | 745 | if ( window.history && window.history.pushState ) { |
740 | | // Calls the routes functionality |
741 | | Backbone.history.start({ pushState: true, silent: true }); |
| 746 | root = themes.data.settings.root.replace( 'themes.php', '' ); |
| 747 | } else { |
| 748 | root = themes.data.settings.root; |
742 | 749 | } |
| 750 | |
| 751 | Backbone.history.start({ root: root, pushState: true }); |
743 | 752 | }, |
744 | 753 | |
745 | 754 | routes: function() { |
| 755 | var self = this; |
746 | 756 | // Bind to our global thx object |
747 | 757 | // so that the object is available to sub-views |
748 | 758 | themes.router = new themes.routes(); |
| 759 | |
| 760 | // Handles theme details route event |
| 761 | themes.router.on( 'route:theme', function( slug ) { |
| 762 | self.view.view.expand( slug ); |
| 763 | }); |
| 764 | |
| 765 | themes.router.on( 'route:themes', function() { |
| 766 | self.view.trigger( 'theme:close' ); |
| 767 | }); |
| 768 | |
| 769 | // Handles search route event |
| 770 | themes.router.on( 'route:search', function( query ) { |
| 771 | self.themes.doSearch( query ); |
| 772 | }); |
749 | 773 | } |
750 | 774 | }; |
751 | 775 | |
diff --git src/wp-admin/themes.php src/wp-admin/themes.php
index db0e1e5..7578b7d 100644
|
|
wp_localize_script( 'theme', '_wpThemeSettings', array( |
100 | 100 | 'installURI' => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null, |
101 | 101 | 'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ), |
102 | 102 | 'root' => parse_url( admin_url( 'themes.php' ), PHP_URL_PATH ), |
103 | | 'theme' => esc_html( $theme ), |
104 | | 'search' => esc_html( $search ), |
105 | | |
106 | 103 | ), |
107 | 104 | 'l10n' => array( |
108 | 105 | 'addNew' => __( 'Add New Theme' ), |