wp/wp-includes/js/customize-loader.js
author ymh <ymh.work@gmail.com>
Tue, 15 Dec 2020 13:49:49 +0100
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 21 48c4eec2b7e6
permissions -rw-r--r--
update enmi-conf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     1
/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     2
 * @output wp-includes/js/customize-loader.js
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     3
 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     4
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     5
/* global _wpCustomizeLoaderSettings */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     6
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     7
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     8
 * Expose a public API that allows the customizer to be
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     9
 * loaded on any page.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    10
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    11
 * @namespace wp
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    12
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
window.wp = window.wp || {};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
(function( exports, $ ){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
	var api = wp.customize,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
		Loader;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
	$.extend( $.support, {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
		history: !! ( window.history && history.pushState ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
		hashchange: ('onhashchange' in window) && (document.documentMode === undefined || document.documentMode > 7)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
	});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    24
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    25
	 * Allows the Customizer to be overlayed on any page.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    26
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    27
	 * By default, any element in the body with the load-customize class will open
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    28
	 * an iframe overlay with the URL specified.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    29
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    30
	 *     e.g. <a class="load-customize" href="<?php echo wp_customize_url(); ?>">Open Customizer</a>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    31
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    32
	 * @memberOf wp.customize
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    33
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    34
	 * @class
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    35
	 * @augments wp.customize.Events
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    36
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    37
	Loader = $.extend( {}, api.Events,/** @lends wp.customize.Loader.prototype */{
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    38
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    39
		 * Setup the Loader; triggered on document#ready.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    40
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
		initialize: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
			this.body = $( document.body );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
			// Ensure the loader is supported.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
			// Check for settings, postMessage support, and whether we require CORS support.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
			if ( ! Loader.settings || ! $.support.postMessage || ( ! $.support.cors && Loader.settings.isCrossDomain ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
				return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
			this.window  = $( window );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
			this.element = $( '<div id="customize-container" />' ).appendTo( this.body );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    53
			// Bind events for opening and closing the overlay.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
			this.bind( 'open', this.overlay.show );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
			this.bind( 'close', this.overlay.hide );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    57
			// Any element in the body with the `load-customize` class opens
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    58
			// the Customizer.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
			$('#wpbody').on( 'click', '.load-customize', function( event ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
				event.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    62
				// Store a reference to the link that opened the Customizer.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
				Loader.link = $(this);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
				// Load the theme.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
				Loader.open( Loader.link.attr('href') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
			});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
			// Add navigation listeners.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    69
			if ( $.support.history ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
				this.window.on( 'popstate', Loader.popstate );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    71
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
			if ( $.support.hashchange ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
				this.window.on( 'hashchange', Loader.hashchange );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
				this.window.triggerHandler( 'hashchange' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
		popstate: function( e ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
			var state = e.originalEvent.state;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    81
			if ( state && state.customize ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
				Loader.open( state.customize );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    83
			} else if ( Loader.active ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
				Loader.close();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    85
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    88
		hashchange: function() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
			var hash = window.location.toString().split('#')[1];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    91
			if ( hash && 0 === hash.indexOf( 'wp_customize=on' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
				Loader.open( Loader.settings.url + '?' + hash );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    93
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    95
			if ( ! hash && ! $.support.history ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
				Loader.close();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    97
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    98
		},
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    99
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   100
		beforeunload: function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   101
			if ( ! Loader.saved() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   102
				return Loader.settings.l10n.saveAlert;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   103
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   106
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   107
		 * Open the Customizer overlay for a specific URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   108
		 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   109
		 * @param string src URL to load in the Customizer.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   110
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
		open: function( src ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   113
			if ( this.active ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
				return;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   115
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
			// Load the full page on mobile devices.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   118
			if ( Loader.settings.browser.mobile ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
				return window.location = src;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   120
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   121
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   122
			// Store the document title prior to opening the Live Preview.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   123
			this.originalDocumentTitle = document.title;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
			this.active = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
			this.body.addClass('customize-loading');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   128
			/*
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   129
			 * Track the dirtiness state (whether the drafted changes have been published)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   130
			 * of the Customizer in the iframe. This is used to decide whether to display
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   131
			 * an AYS alert if the user tries to close the window before saving changes.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   132
			 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   133
			this.saved = new api.Value( true );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   134
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   135
			this.iframe = $( '<iframe />', { 'src': src, 'title': Loader.settings.l10n.mainIframeTitle } ).appendTo( this.element );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
			this.iframe.one( 'load', this.loaded );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
			// Create a postMessage connection with the iframe.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
			this.messenger = new api.Messenger({
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
				url: src,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
				channel: 'loader',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
				targetWindow: this.iframe[0].contentWindow
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
			});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   145
			// Expose the changeset UUID on the parent window's URL so that the customized state can survive a refresh.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   146
			if ( history.replaceState ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   147
				this.messenger.bind( 'changeset-uuid', function( changesetUuid ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   148
					var urlParser = document.createElement( 'a' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   149
					urlParser.href = location.href;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   150
					urlParser.search = $.param( _.extend(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   151
						api.utils.parseQueryString( urlParser.search.substr( 1 ) ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   152
						{ changeset_uuid: changesetUuid }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   153
					) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   154
					history.replaceState( { customize: urlParser.href }, '', urlParser.href );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   155
				} );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   156
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   157
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
			// Wait for the connection from the iframe before sending any postMessage events.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
			this.messenger.bind( 'ready', function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
				Loader.messenger.send( 'back' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
			});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
			this.messenger.bind( 'close', function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   164
				if ( $.support.history ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
					history.back();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   166
				} else if ( $.support.hashchange ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
					window.location.hash = '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   168
				} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
					Loader.close();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   170
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
			});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   173
			// Prompt AYS dialog when navigating away.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   174
			$( window ).on( 'beforeunload', this.beforeunload );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   175
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   176
			this.messenger.bind( 'saved', function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   177
				Loader.saved( true );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   178
			} );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   179
			this.messenger.bind( 'change', function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   180
				Loader.saved( false );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   181
			} );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   183
			this.messenger.bind( 'title', function( newTitle ){
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   184
				window.document.title = newTitle;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   185
			});
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   186
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   187
			this.pushState( src );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
			this.trigger( 'open' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   192
		pushState: function ( src ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   193
			var hash = src.split( '?' )[1];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   194
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   195
			// Ensure we don't call pushState if the user hit the forward button.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   196
			if ( $.support.history && window.location.href !== src ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   197
				history.pushState( { customize: src }, '', src );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   198
			} else if ( ! $.support.history && $.support.hashchange && hash ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   199
				window.location.hash = 'wp_customize=on&' + hash;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   200
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   201
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   202
			this.trigger( 'open' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   203
		},
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   204
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   205
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   206
		 * Callback after the Customizer has been opened.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   207
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
		opened: function() {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   209
			Loader.body.addClass( 'customize-active full-overlay-active' ).attr( 'aria-busy', 'true' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   212
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   213
		 * Close the Customizer overlay.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   214
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
		close: function() {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   216
			var self = this, onConfirmClose;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   217
			if ( ! self.active ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
				return;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   219
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   220
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   221
			onConfirmClose = function( confirmed ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   222
				if ( confirmed ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   223
					self.active = false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   224
					self.trigger( 'close' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   226
					// Restore document title prior to opening the Live Preview.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   227
					if ( self.originalDocumentTitle ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   228
						document.title = self.originalDocumentTitle;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   229
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   230
				} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   232
					// Go forward since Customizer is exited by history.back().
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   233
					history.forward();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   234
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   235
				self.messenger.unbind( 'confirmed-close', onConfirmClose );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   236
			};
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   237
			self.messenger.bind( 'confirmed-close', onConfirmClose );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   238
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   239
			Loader.messenger.send( 'confirm-close' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   242
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   243
		 * Callback after the Customizer has been closed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   244
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
		closed: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
			Loader.iframe.remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
			Loader.messenger.destroy();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
			Loader.iframe    = null;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
			Loader.messenger = null;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   250
			Loader.saved     = null;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
			Loader.body.removeClass( 'customize-active full-overlay-active' ).removeClass( 'customize-loading' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   252
			$( window ).off( 'beforeunload', Loader.beforeunload );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   253
			/*
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   254
			 * Return focus to the link that opened the Customizer overlay after
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   255
			 * the body element visibility is restored.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   256
			 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   257
			if ( Loader.link ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   258
				Loader.link.focus();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   259
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   262
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   263
		 * Callback for the `load` event on the Customizer iframe.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   264
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
		loaded: function() {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   266
			Loader.body.removeClass( 'customize-loading' ).attr( 'aria-busy', 'false' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   269
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   270
		 * Overlay hide/show utility methods.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   271
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
		overlay: {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
			show: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
				this.element.fadeIn( 200, Loader.opened );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
			},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
			hide: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
				this.element.fadeOut( 200, Loader.closed );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
	});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   283
	// Bootstrap the Loader on document#ready.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
	$( function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
		Loader.settings = _wpCustomizeLoaderSettings;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
		Loader.initialize();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
	});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   289
	// Expose the API publicly on window.wp.customize.Loader.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
	api.Loader = Loader;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
})( wp, jQuery );