Ticket #25963: 25963.3.diff
File 25963.3.diff, 4.5 KB (added by , 11 years ago) |
---|
-
src/wp-admin/js/theme.js
282 282 scroll = document.body.scrollTop; 283 283 284 284 // Clean the url structure 285 themes.router.navigate( '');285 themes.router.navigate( themes.data.settings.root ); 286 286 287 287 // Restore scroll position 288 288 document.body.scrollTop = scroll; … … 476 476 return view; 477 477 }, 478 478 479 buildNavigation: function( url ) { 480 return themes.data.settings.root + url; 481 }, 482 479 483 // Renders the overlay with the ThemeDetails view 480 484 // Uses the current model data 481 485 expand: function( id ) { … … 485 489 this.model = self.collection.get( id ); 486 490 487 491 // Trigger a route update for the current model 488 themes.router.navigate( 'theme/' + this.model.id);492 themes.router.navigate( self.buildNavigation( '?theme=' + this.model.id ), { trigger: true, replace: true } ); 489 493 490 494 // Sets this.view to 'detail' 491 495 this.setView( 'detail' ); … … 497 501 }); 498 502 499 503 this.overlay.render(); 500 this.$el.append( this.overlay.el ); 504 if ( 0 === $( 'div.theme-overlay' ).length ) { 505 this.$el.append( this.overlay.el ); 506 } else { 507 $( 'div.theme-overlay' ).html( this.overlay.el ); 508 } 501 509 502 510 this.overlay.screenshotGallery(); 503 511 … … 540 548 541 549 // Trigger a route update for the current model 542 550 // that renders the new theme's overlay 543 themes.router.navigate( 'theme/' + nextModel.id, { trigger: true } );551 themes.router.navigate( self.buildNavigation( '?theme=' + nextModel.id ), { trigger: true } ); 544 552 } 545 553 }, 546 554 … … 564 572 565 573 // Trigger a route update for the current model 566 574 // that renders the new theme's overlay 567 themes.router.navigate( 'theme/' + previousModel.id, { trigger: true } );575 themes.router.navigate( self.buildNavigation( '?theme=' + previousModel.id ), { trigger: true } ); 568 576 } 569 577 } 570 578 }); … … 598 606 599 607 // Update the URL hash 600 608 if ( event.target.value ) { 601 themes.router.navigate( 'search/' + event.target.value, { replace: true } );609 themes.router.navigate( themes.data.settings.root + '/search/' + event.target.value, { replace: true } ); 602 610 } else { 603 themes.router.navigate( '');611 themes.router.navigate( themes.data.settings.root ); 604 612 } 605 613 } 606 614 }); … … 611 619 612 620 routes: { 613 621 'search/*query': 'search', 614 ' theme/*slug': 'theme'622 '*path': 'default' 615 623 }, 616 624 617 625 // Set the search input value based on url … … 646 654 this.routes(); 647 655 648 656 // Set ups history with pushState and our root 649 Backbone.history.start({ root: themes.data.settings.root }); 657 if ( window.history && window.history.pushState ) { 658 Backbone.history.start({ pushState: true }); 659 } 650 660 }, 651 661 652 662 routes: function() { 653 var self = this;663 var queryvars, self = this; 654 664 // Bind to our global thx object 655 665 // so that the object is available to sub-views 656 666 themes.router = new themes.routes(); … … 664 674 themes.router.on( 'route:search', function( query ) { 665 675 self.themes.doSearch( query ); 666 676 }); 667 } 677 678 // Handles default route event 679 themes.router.on( 'route:default', function() { 680 queryvars = self.getURLParams( document.URL ); 681 if ( 'undefined' !== typeof queryvars.theme ) { 682 self.view.view.expand( queryvars.theme ); 683 } 684 }); 685 686 }, 687 getURLParams: function( url ) { 688 var base, params, results, i, param, 689 parts = url.split( '?' ); 690 691 if ( parts.length === 1 ) { 692 return {}; 693 } 694 695 base = parts.shift(); 696 params = parts.pop().split( '&' ); 697 698 if ( params.length === 1 && params[ 0 ] === '' ) { 699 return {}; 700 } 701 702 result = {}; 703 for ( i = 0, len = params.length; i < len; i++ ) { 704 param = params[ i ].split( '=' ); 705 result[ param[ 0 ] ] = decodeURIComponent( param[ 1 ] ); 706 } 707 return result; 708 } 668 709 }; 669 710 670 711 // Ready... -
src/wp-admin/themes.php
98 98 'canInstall' => ( ! is_multisite() && current_user_can( 'install_themes' ) ), 99 99 'installURI' => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null, 100 100 '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'),101 'root' => parse_url( admin_url( 'themes.php' ), PHP_URL_PATH ), 102 102 'extraRoutes' => '', 103 103 ), 104 104 'l10n' => array(