Ticket #26543: 26543-theme-js.diff
| File 26543-theme-js.diff, 2.0 KB (added by , 12 years ago) |
|---|
-
wp-admin/js/theme.js
645 645 // Listens to [theme] and [search] params 646 646 themes.routes = Backbone.Router.extend({ 647 647 648 initialize: function() { 649 this.routes = _.object([ 650 ]); 648 routes: { 649 'themes.php?theme=:slug': 'theme', 650 'themes.php?search=:query': 'search', 651 'themes.php?s=:query': 'search' 651 652 }, 652 653 653 654 baseUrl: function( url ) { 654 return themes.data.settings.root + url; 655 return 'themes.php' + url; 656 }, 657 658 search: function( query ) { 659 $( '.theme-search' ).val( query ); 655 660 } 656 661 }); 657 662 … … 675 680 this.view.render(); 676 681 this.routes(); 677 682 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 } 683 // Sets up Backbone.history 684 Backbone.history.start({ root: themes.data.settings.root.replace( 'themes.php', '' ), pushState: true, queryUri: true }); 694 685 }, 695 686 696 687 routes: function() { 688 var self = this; 697 689 // Bind to our global thx object 698 690 // so that the object is available to sub-views 699 691 themes.router = new themes.routes(); 692 693 // Handles theme details route event 694 themes.router.on( 'route:theme', function( slug ) { 695 self.view.view.expand( slug ); 696 }); 697 698 // Handles search route event 699 themes.router.on( 'route:search', function( query ) { 700 self.themes.doSearch( query ); 701 }); 700 702 } 701 703 }; 702 704