Customize: Eliminate use of customize-loader in core so Customizer is opened consistently in top window.

* Open the door for future browser history feature in #28536, which is currently not feasible when customize-loader is used.
* Remove customizer-loader from being used on admin screens for Dashboard, Themes, non-shiny theme install/update.
* Keep the customize-loader functionality available for plugins, for the time being. It may become deprecated.
* Ensure `return` param in customizer links in Themes screen update to reflect `search` updated by `pushState`.
* Persist `return` when reloading Customizer due to theme switch, autosave restoration, or changeset trashing.
* Use `location.replace()` instead of changing `location.href` when trashing.
* Hide theme browser while Themes screen is loading when there is a `search` to prevent flash of unfiltered themes.
* Use throttling instead of debouncing when searching themes to ensure that screen is updated immediately on page load.
* Fix encoding and decoding of `search` param between URL and search field.
* Add support for dismissing autosaves when closing customize-loader, when it is used by plugins.
* Skip sending changeset UUID to customize-loader for population in browser location if changeset branching is not enabled.

See #28536.
Fixes #40254.

Built from https://develop.svn.wordpress.org/trunk@41797


git-svn-id: http://core.svn.wordpress.org/trunk@41631 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter
2017-10-09 16:04:48 +00:00
parent c9e8431582
commit 35b5c9e762
18 changed files with 142 additions and 80 deletions

View File

@@ -1,4 +1,4 @@
/* global _wpCustomizeLoaderSettings, confirm */
/* global _wpCustomizeLoaderSettings */
/**
* Expose a public API that allows the customizer to be
* loaded on any page.
@@ -208,25 +208,30 @@ window.wp = window.wp || {};
* Close the Customizer overlay.
*/
close: function() {
if ( ! this.active ) {
var self = this, onConfirmClose;
if ( ! self.active ) {
return;
}
// Display AYS dialog if Customizer is dirty
if ( ! this.saved() && ! confirm( Loader.settings.l10n.saveAlert ) ) {
// Go forward since Customizer is exited by history.back()
history.forward();
return;
}
onConfirmClose = function( confirmed ) {
if ( confirmed ) {
self.active = false;
self.trigger( 'close' );
this.active = false;
// Restore document title prior to opening the Live Preview
if ( self.originalDocumentTitle ) {
document.title = self.originalDocumentTitle;
}
} else {
this.trigger( 'close' );
// Go forward since Customizer is exited by history.back()
history.forward();
}
self.messenger.unbind( 'confirmed-close', onConfirmClose );
};
self.messenger.bind( 'confirmed-close', onConfirmClose );
// Restore document title prior to opening the Live Preview
if ( this.originalDocumentTitle ) {
document.title = this.originalDocumentTitle;
}
Loader.messenger.send( 'confirm-close' );
},
/**