mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-01 21:21:24 +01:00
Themes: enable browser history support in add new theme screen.
Enable history support for the new theme screen, including navigating theme details and closing the details modal. Theme selection is now also bookmark-able, so linking to a URL like `/wp-admin/theme-install.php?theme=twentyseventeen` correctly opens the theme preview. Props dd32. Fixes #36613. Built from https://develop.svn.wordpress.org/trunk@40107 git-svn-id: http://core.svn.wordpress.org/trunk@40044 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
eb8457d3f4
commit
33286df4c1
@ -492,7 +492,7 @@ themes.view.Theme = wp.Backbone.View.extend({
|
||||
themes.focusedTheme = this.$el;
|
||||
|
||||
// Construct a new Preview view.
|
||||
preview = new themes.view.Preview({
|
||||
themes.currentPreview = preview = new themes.view.Preview({
|
||||
model: this.model
|
||||
});
|
||||
|
||||
@ -572,6 +572,11 @@ themes.view.Theme = wp.Backbone.View.extend({
|
||||
this.listenTo( preview, 'preview:close', function() {
|
||||
self.current = self.model;
|
||||
});
|
||||
|
||||
// Listen for closepreview events, closing the preview.
|
||||
this.listenTo( preview, 'closepreview', function() {
|
||||
preview.close();
|
||||
});
|
||||
},
|
||||
|
||||
// Handles .disabled classes for previous/next buttons in theme installer preview
|
||||
@ -885,7 +890,7 @@ themes.view.Preview = themes.view.Details.extend({
|
||||
self.tooglePreviewDeviceButtons( currentPreviewDevice );
|
||||
}
|
||||
|
||||
themes.router.navigate( themes.router.baseUrl( themes.router.themePath + this.model.get( 'id' ) ), { replace: true } );
|
||||
themes.router.navigate( themes.router.baseUrl( themes.router.themePath + this.model.get( 'id' ) ), { replace: false } );
|
||||
|
||||
this.$el.fadeIn( 200, function() {
|
||||
$body.addClass( 'theme-installer-active full-overlay-active' );
|
||||
@ -1908,11 +1913,24 @@ themes.RunInstaller = {
|
||||
// Handles `theme` route event
|
||||
// Queries the API for the passed theme slug
|
||||
themes.router.on( 'route:preview', function( slug ) {
|
||||
request.theme = slug;
|
||||
self.view.collection.query( request );
|
||||
self.view.collection.once( 'update', function() {
|
||||
|
||||
// If the theme preview is active, set the current theme.
|
||||
if ( self.view.view.theme && self.view.view.theme.preview ) {
|
||||
self.view.view.theme.model = self.view.collection.findWhere( { 'slug': slug } );
|
||||
self.view.view.theme.preview();
|
||||
});
|
||||
} else {
|
||||
|
||||
// Select the theme by slug.
|
||||
request.theme = slug;
|
||||
self.view.collection.query( request );
|
||||
self.view.collection.trigger( 'update' );
|
||||
|
||||
// Open the theme preview.
|
||||
self.view.collection.once( 'query:success', function() {
|
||||
$( 'div[data-slug="' + slug + '"]' ).trigger( 'click' );
|
||||
})
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// Handles sorting / browsing routes
|
||||
@ -1923,7 +1941,11 @@ themes.RunInstaller = {
|
||||
sort = 'featured';
|
||||
}
|
||||
self.view.sort( sort );
|
||||
self.view.trigger( 'theme:close' );
|
||||
|
||||
// Close the preview if open.
|
||||
if ( themes.currentPreview ) {
|
||||
themes.currentPreview.trigger( 'closepreview' );
|
||||
}
|
||||
});
|
||||
|
||||
// The `search` route event. The router populates the input field.
|
||||
|
2
wp-admin/js/theme.min.js
vendored
2
wp-admin/js/theme.min.js
vendored
File diff suppressed because one or more lines are too long
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.8-alpha-40106';
|
||||
$wp_version = '4.8-alpha-40107';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user