* Allows the Customizer to be overlayed on any page.
*
* By default, any element in the body with the load-customize class will open
* Allows the Customizer to be overlayed on any page.
*
* By default, any element in the body with the load-customize class will open
- // Dirty state of customizer in iframe
+ /*
+ * Track the dirtiness state (whether the drafted changes have been published)
+ * of the Customizer in the iframe. This is used to decide whether to display
+ * an AYS alert if the user tries to close the window before saving changes.
+ */
this.iframe.one( 'load', this.loaded );
// Create a postMessage connection with the iframe.
this.iframe.one( 'load', this.loaded );
// Create a postMessage connection with the iframe.
// Prompt AYS dialog when navigating away
$( window ).on( 'beforeunload', this.beforeunload );
// Prompt AYS dialog when navigating away
$( window ).on( 'beforeunload', this.beforeunload );
// Ensure we don't call pushState if the user hit the forward button.
if ( $.support.history && window.location.href !== src ) {
history.pushState( { customize: src }, '', src );
} else if ( ! $.support.history && $.support.hashchange && hash ) {
// Ensure we don't call pushState if the user hit the forward button.
if ( $.support.history && window.location.href !== src ) {
history.pushState( { customize: src }, '', src );
} else if ( ! $.support.history && $.support.hashchange && hash ) {
if ( ! this.saved() && ! confirm( Loader.settings.l10n.saveAlert ) ) {
// Go forward since Customizer is exited by history.back()
history.forward();
if ( ! this.saved() && ! confirm( Loader.settings.l10n.saveAlert ) ) {
// Go forward since Customizer is exited by history.back()
history.forward();