Ticket #26543: 26543-ie8-routing-fix.diff
File 26543-ie8-routing-fix.diff, 4.8 KB (added by , 11 years ago) |
---|
-
src/wp-admin/js/theme.js
694 694 // Listens to [theme] and [search] params 695 695 themes.routes = Backbone.Router.extend({ 696 696 697 initialize: function() { 698 this.routes = _.object([ 699 ]); 697 routes: { 698 'themes.php?theme=:slug': 'theme', 699 'themes.php?search=:query': 'search', 700 'themes.php?s=:query': 'search' 700 701 }, 701 702 702 703 baseUrl: function( url ) { 703 return themes.data.settings.root + url; 704 return 'themes.php' + url; 705 }, 706 707 search: function( query ) { 708 $( '.theme-search' ).val( query ); 704 709 } 705 710 }); 706 711 … … 720 725 }, 721 726 722 727 render: function() { 728 var root; 729 723 730 // Render results 724 731 this.view.render(); 725 732 this.routes(); 726 733 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 } ) ); 734 // Sets up Backbone.history 735 // Only change root if we have a pushState enabled browser - 736 // fixes redirect to /wp-admin/#themes.php bug in IE8 737 if ( window.history && window.history.pushState ) { 738 root = themes.data.settings.root.replace( 'themes.php', '' ); 739 } else { 740 root = themes.data.settings.root; 730 741 } 731 742 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 739 if ( window.history && window.history.pushState ) { 740 // Calls the routes functionality 741 Backbone.history.start({ pushState: true, silent: true }); 742 } 743 Backbone.history.start({ root: root, pushState: true, queryUri: true }); 743 744 }, 744 745 745 746 routes: function() { 747 var self = this; 746 748 // Bind to our global thx object 747 749 // so that the object is available to sub-views 748 750 themes.router = new themes.routes(); 751 752 // Handles theme details route event 753 themes.router.on( 'route:theme', function( slug ) { 754 self.view.view.expand( slug ); 755 }); 756 757 // Handles search route event 758 themes.router.on( 'route:search', function( query ) { 759 self.themes.doSearch( query ); 760 }); 749 761 } 750 762 }; 751 763 -
src/wp-admin/themes.php
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' ), -
src/wp-includes/js/wp-backbone.js
381 381 382 382 ready: function() {} 383 383 }); 384 385 // Backbone.History.prototype 386 // -------------------------- 387 // 388 // Extends Backbone.History to support urls with GET queries in WordPress 389 // Supports basic form ?param=value passing 'paramvalue' as the fragment 390 _.extend( Backbone.History.prototype, { 391 392 // Keep original fragment resolver available 393 originalFragment: Backbone.History.prototype.getFragment, 394 395 // ### Get the fragment 396 // 397 // If history constructor includes 'queryUri' param 398 // Use our own getFragment resolver to handle the location changes 399 // 400 // Appends 'location.search' to pathname in order to deal with 401 // query variables present in URI 402 // 403 // Returns fragment '?paramvalue' 404 getFragment: function( fragment, forcePushState ) { 405 var root; 406 407 // If queryUri is not set via Backbone.history.start 408 // return the original fragment handler 409 if ( ! Backbone.history.options.queryUri ) { 410 return this.originalFragment.apply( this, arguments ); 411 } 412 413 // If we got this far, parse this.location.search 414 // since we have a URL with query vars 415 if ( fragment == null ) { 416 if ( this._hasPushState || ! this._wantsHashChange || forcePushState ) { 417 418 // Constructs fragment attaching the query parameters 419 fragment = this.location.pathname + this.location.search; 420 root = this.root.replace( /\/$/, '' ); 421 422 if ( ! fragment.indexOf( root ) ) { 423 fragment = fragment.slice( root.length ); 424 } 425 426 } else { 427 fragment = this.getHash(); 428 } 429 } 430 431 return fragment.replace(/^\/+|\/+$/g, ''); 432 } 433 }); 434 384 435 }(jQuery));