]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/customize-loader.js
WordPress 4.6.3-scripts
[autoinstalls/wordpress.git] / wp-includes / js / customize-loader.js
index 07f21966a9014f1127beddb78887cb9d97270846..e7b411df308a0064a90d22d5ae6fa7be86223863 100644 (file)
@@ -1,4 +1,8 @@
 /* global _wpCustomizeLoaderSettings, confirm */
+/*
+ * Expose a public API that allows the customizer to be
+ * loaded on any page.
+ */
 window.wp = window.wp || {};
 
 (function( exports, $ ){
@@ -111,10 +115,14 @@ window.wp = window.wp || {};
                        this.active = true;
                        this.body.addClass('customize-loading');
 
-                       // 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.saved = new api.Value( true );
 
-                       this.iframe = $( '<iframe />', { src: src }).appendTo( this.element );
+                       this.iframe = $( '<iframe />', { 'src': src, 'title': Loader.settings.l10n.mainIframeTitle } ).appendTo( this.element );
                        this.iframe.one( 'load', this.loaded );
 
                        // Create a postMessage connection with the iframe.
@@ -142,12 +150,6 @@ window.wp = window.wp || {};
                        // Prompt AYS dialog when navigating away
                        $( window ).on( 'beforeunload', this.beforeunload );
 
-                       this.messenger.bind( 'activated', function( location ) {
-                               if ( location ) {
-                                       window.location = location;
-                               }
-                       });
-
                        this.messenger.bind( 'saved', function () {
                                Loader.saved( true );
                        } );
@@ -155,6 +157,10 @@ window.wp = window.wp || {};
                                Loader.saved( false );
                        } );
 
+                       this.messenger.bind( 'title', function( newTitle ){
+                               window.document.title = newTitle;
+                       });
+
                        this.pushState( src );
 
                        this.trigger( 'open' );