wp/wp-includes/js/customize-loader.js
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 21 48c4eec2b7e6
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
   104 		},
   104 		},
   105 
   105 
   106 		/**
   106 		/**
   107 		 * Open the Customizer overlay for a specific URL.
   107 		 * Open the Customizer overlay for a specific URL.
   108 		 *
   108 		 *
   109 		 * @param  string src URL to load in the Customizer.
   109 		 * @param string src URL to load in the Customizer.
   110 		 */
   110 		 */
   111 		open: function( src ) {
   111 		open: function( src ) {
   112 
   112 
   113 			if ( this.active ) {
   113 			if ( this.active ) {
   114 				return;
   114 				return;
   117 			// Load the full page on mobile devices.
   117 			// Load the full page on mobile devices.
   118 			if ( Loader.settings.browser.mobile ) {
   118 			if ( Loader.settings.browser.mobile ) {
   119 				return window.location = src;
   119 				return window.location = src;
   120 			}
   120 			}
   121 
   121 
   122 			// Store the document title prior to opening the Live Preview
   122 			// Store the document title prior to opening the Live Preview.
   123 			this.originalDocumentTitle = document.title;
   123 			this.originalDocumentTitle = document.title;
   124 
   124 
   125 			this.active = true;
   125 			this.active = true;
   126 			this.body.addClass('customize-loading');
   126 			this.body.addClass('customize-loading');
   127 
   127 
   168 				} else {
   168 				} else {
   169 					Loader.close();
   169 					Loader.close();
   170 				}
   170 				}
   171 			});
   171 			});
   172 
   172 
   173 			// Prompt AYS dialog when navigating away
   173 			// Prompt AYS dialog when navigating away.
   174 			$( window ).on( 'beforeunload', this.beforeunload );
   174 			$( window ).on( 'beforeunload', this.beforeunload );
   175 
   175 
   176 			this.messenger.bind( 'saved', function () {
   176 			this.messenger.bind( 'saved', function () {
   177 				Loader.saved( true );
   177 				Loader.saved( true );
   178 			} );
   178 			} );
   221 			onConfirmClose = function( confirmed ) {
   221 			onConfirmClose = function( confirmed ) {
   222 				if ( confirmed ) {
   222 				if ( confirmed ) {
   223 					self.active = false;
   223 					self.active = false;
   224 					self.trigger( 'close' );
   224 					self.trigger( 'close' );
   225 
   225 
   226 					// Restore document title prior to opening the Live Preview
   226 					// Restore document title prior to opening the Live Preview.
   227 					if ( self.originalDocumentTitle ) {
   227 					if ( self.originalDocumentTitle ) {
   228 						document.title = self.originalDocumentTitle;
   228 						document.title = self.originalDocumentTitle;
   229 					}
   229 					}
   230 				} else {
   230 				} else {
   231 
   231 
   232 					// Go forward since Customizer is exited by history.back()
   232 					// Go forward since Customizer is exited by history.back().
   233 					history.forward();
   233 					history.forward();
   234 				}
   234 				}
   235 				self.messenger.unbind( 'confirmed-close', onConfirmClose );
   235 				self.messenger.unbind( 'confirmed-close', onConfirmClose );
   236 			};
   236 			};
   237 			self.messenger.bind( 'confirmed-close', onConfirmClose );
   237 			self.messenger.bind( 'confirmed-close', onConfirmClose );
   284 	$( function() {
   284 	$( function() {
   285 		Loader.settings = _wpCustomizeLoaderSettings;
   285 		Loader.settings = _wpCustomizeLoaderSettings;
   286 		Loader.initialize();
   286 		Loader.initialize();
   287 	});
   287 	});
   288 
   288 
   289 	// Expose the API publicly on window.wp.customize.Loader
   289 	// Expose the API publicly on window.wp.customize.Loader.
   290 	api.Loader = Loader;
   290 	api.Loader = Loader;
   291 })( wp, jQuery );
   291 })( wp, jQuery );