wp/wp-admin/js/customize-controls.js
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
       
     1 /**
       
     2  * @output wp-admin/js/customize-controls.js
       
     3  */
       
     4 
     1 /* global _wpCustomizeHeader, _wpCustomizeBackground, _wpMediaViewsL10n, MediaElementPlayer, console, confirm */
     5 /* global _wpCustomizeHeader, _wpCustomizeBackground, _wpMediaViewsL10n, MediaElementPlayer, console, confirm */
     2 (function( exports, $ ){
     6 (function( exports, $ ){
     3 	var Container, focus, normalizedTransitionendEventName, api = wp.customize;
     7 	var Container, focus, normalizedTransitionendEventName, api = wp.customize;
     4 
     8 
     5 	/**
     9 	api.OverlayNotification = api.Notification.extend(/** @lends wp.customize.OverlayNotification.prototype */{
     6 	 * A notification that is displayed in a full-screen overlay.
       
     7 	 *
       
     8 	 * @since 4.9.0
       
     9 	 * @class
       
    10 	 * @augments wp.customize.Notification
       
    11 	 */
       
    12 	api.OverlayNotification = api.Notification.extend({
       
    13 
    10 
    14 		/**
    11 		/**
    15 		 * Whether the notification should show a loading spinner.
    12 		 * Whether the notification should show a loading spinner.
    16 		 *
    13 		 *
    17 		 * @since 4.9.0
    14 		 * @since 4.9.0
    18 		 * @var {boolean}
    15 		 * @var {boolean}
    19 		 */
    16 		 */
    20 		loading: false,
    17 		loading: false,
    21 
    18 
    22 		/**
    19 		/**
    23 		 * Initialize.
    20 		 * A notification that is displayed in a full-screen overlay.
       
    21 		 *
       
    22 		 * @constructs wp.customize.OverlayNotification
       
    23 		 * @augments   wp.customize.Notification
    24 		 *
    24 		 *
    25 		 * @since 4.9.0
    25 		 * @since 4.9.0
    26 		 *
    26 		 *
    27 		 * @param {string} code - Code.
    27 		 * @param {string} code - Code.
    28 		 * @param {object} params - Params.
    28 		 * @param {object} params - Params.
    66 				}
    66 				}
    67 			}
    67 			}
    68 		}
    68 		}
    69 	});
    69 	});
    70 
    70 
    71 	/**
    71 	api.Notifications = api.Values.extend(/** @lends wp.customize.Notifications.prototype */{
    72 	 * A collection of observable notifications.
       
    73 	 *
       
    74 	 * @since 4.9.0
       
    75 	 * @class
       
    76 	 * @augments wp.customize.Values
       
    77 	 */
       
    78 	api.Notifications = api.Values.extend({
       
    79 
    72 
    80 		/**
    73 		/**
    81 		 * Whether the alternative style should be used.
    74 		 * Whether the alternative style should be used.
    82 		 *
    75 		 *
    83 		 * @since 4.9.0
    76 		 * @since 4.9.0
    92 		 * @type {object}
    85 		 * @type {object}
    93 		 */
    86 		 */
    94 		defaultConstructor: api.Notification,
    87 		defaultConstructor: api.Notification,
    95 
    88 
    96 		/**
    89 		/**
    97 		 * Initialize notifications area.
    90 		 * A collection of observable notifications.
    98 		 *
    91 		 *
    99 		 * @since 4.9.0
    92 		 * @since 4.9.0
   100 		 * @constructor
    93 		 *
       
    94 		 * @constructs wp.customize.Notifications
       
    95 		 * @augments   wp.customize.Values
       
    96 		 *
   101 		 * @param {object}  options - Options.
    97 		 * @param {object}  options - Options.
   102 		 * @param {jQuery}  [options.container] - Container element for notifications. This can be injected later.
    98 		 * @param {jQuery}  [options.container] - Container element for notifications. This can be injected later.
   103 		 * @param {boolean} [options.alt] - Whether alternative style should be used when rendering notifications.
    99 		 * @param {boolean} [options.alt] - Whether alternative style should be used when rendering notifications.
       
   100 		 *
   104 		 * @returns {void}
   101 		 * @returns {void}
   105 		 * @this {wp.customize.Notifications}
       
   106 		 */
   102 		 */
   107 		initialize: function( options ) {
   103 		initialize: function( options ) {
   108 			var collection = this;
   104 			var collection = this;
   109 
   105 
   110 			api.Values.prototype.initialize.call( collection, options );
   106 			api.Values.prototype.initialize.call( collection, options );
   179 		 *
   175 		 *
   180 		 * @since 4.9.0
   176 		 * @since 4.9.0
   181 		 * @param {object}  args - Args.
   177 		 * @param {object}  args - Args.
   182 		 * @param {boolean} [args.sort=false] - Whether to return the notifications sorted.
   178 		 * @param {boolean} [args.sort=false] - Whether to return the notifications sorted.
   183 		 * @return {Array.<wp.customize.Notification>} Notifications.
   179 		 * @return {Array.<wp.customize.Notification>} Notifications.
   184 		 * @this {wp.customize.Notifications}
       
   185 		 */
   180 		 */
   186 		get: function( args ) {
   181 		get: function( args ) {
   187 			var collection = this, notifications, errorTypePriorities, params;
   182 			var collection = this, notifications, errorTypePriorities, params;
   188 			notifications = _.values( collection._value );
   183 			notifications = _.values( collection._value );
   189 
   184 
   215 		/**
   210 		/**
   216 		 * Render notifications area.
   211 		 * Render notifications area.
   217 		 *
   212 		 *
   218 		 * @since 4.9.0
   213 		 * @since 4.9.0
   219 		 * @returns {void}
   214 		 * @returns {void}
   220 		 * @this {wp.customize.Notifications}
       
   221 		 */
   215 		 */
   222 		render: function() {
   216 		render: function() {
   223 			var collection = this,
   217 			var collection = this,
   224 				notifications, hadOverlayNotification = false, hasOverlayNotification, overlayNotifications = [],
   218 				notifications, hadOverlayNotification = false, hasOverlayNotification, overlayNotifications = [],
   225 				previousNotificationsByCode = {},
   219 				previousNotificationsByCode = {},
   338 				focusableElements.last().focus();
   332 				focusableElements.last().focus();
   339 			}
   333 			}
   340 		}
   334 		}
   341 	});
   335 	});
   342 
   336 
   343 	/**
   337 	api.Setting = api.Value.extend(/** @lends wp.customize.Setting.prototype */{
   344 	 * A Customizer Setting.
       
   345 	 *
       
   346 	 * A setting is WordPress data (theme mod, option, menu, etc.) that the user can
       
   347 	 * draft changes to in the Customizer.
       
   348 	 *
       
   349 	 * @see PHP class WP_Customize_Setting.
       
   350 	 *
       
   351 	 * @since 3.4.0
       
   352 	 * @class
       
   353 	 * @augments wp.customize.Value
       
   354 	 * @augments wp.customize.Class
       
   355 	 */
       
   356 	api.Setting = api.Value.extend({
       
   357 
   338 
   358 		/**
   339 		/**
   359 		 * Default params.
   340 		 * Default params.
   360 		 *
   341 		 *
   361 		 * @since 4.9.0
   342 		 * @since 4.9.0
   365 			transport: 'refresh',
   346 			transport: 'refresh',
   366 			dirty: false
   347 			dirty: false
   367 		},
   348 		},
   368 
   349 
   369 		/**
   350 		/**
   370 		 * Initialize.
   351 		 * A Customizer Setting.
       
   352 		 *
       
   353 		 * A setting is WordPress data (theme mod, option, menu, etc.) that the user can
       
   354 		 * draft changes to in the Customizer.
       
   355 		 *
       
   356 		 * @see PHP class WP_Customize_Setting.
       
   357 		 *
       
   358 		 * @constructs wp.customize.Setting
       
   359 		 * @augments   wp.customize.Value
   371 		 *
   360 		 *
   372 		 * @since 3.4.0
   361 		 * @since 3.4.0
   373 		 *
   362 		 *
   374 		 * @param {string}  id                          - The setting ID.
   363 		 * @param {string}  id                          - The setting ID.
   375 		 * @param {*}       value                       - The initial value of the setting.
   364 		 * @param {*}       value                       - The initial value of the setting.
   446 	});
   435 	});
   447 
   436 
   448 	/**
   437 	/**
   449 	 * Current change count.
   438 	 * Current change count.
   450 	 *
   439 	 *
       
   440 	 * @alias wp.customize._latestRevision
       
   441 	 *
   451 	 * @since 4.7.0
   442 	 * @since 4.7.0
   452 	 * @type {number}
   443 	 * @type {number}
   453 	 * @protected
   444 	 * @protected
   454 	 */
   445 	 */
   455 	api._latestRevision = 0;
   446 	api._latestRevision = 0;
   456 
   447 
   457 	/**
   448 	/**
   458 	 * Last revision that was saved.
   449 	 * Last revision that was saved.
   459 	 *
   450 	 *
       
   451 	 * @alias wp.customize._lastSavedRevision
       
   452 	 *
   460 	 * @since 4.7.0
   453 	 * @since 4.7.0
   461 	 * @type {number}
   454 	 * @type {number}
   462 	 * @protected
   455 	 * @protected
   463 	 */
   456 	 */
   464 	api._lastSavedRevision = 0;
   457 	api._lastSavedRevision = 0;
   465 
   458 
   466 	/**
   459 	/**
   467 	 * Latest revisions associated with the updated setting.
   460 	 * Latest revisions associated with the updated setting.
       
   461 	 *
       
   462 	 * @alias wp.customize._latestSettingRevisions
   468 	 *
   463 	 *
   469 	 * @since 4.7.0
   464 	 * @since 4.7.0
   470 	 * @type {object}
   465 	 * @type {object}
   471 	 * @protected
   466 	 * @protected
   472 	 */
   467 	 */
   493 	} );
   488 	} );
   494 
   489 
   495 	/**
   490 	/**
   496 	 * Get the dirty setting values.
   491 	 * Get the dirty setting values.
   497 	 *
   492 	 *
       
   493 	 * @alias wp.customize.dirtyValues
       
   494 	 *
   498 	 * @since 4.7.0
   495 	 * @since 4.7.0
   499 	 * @access public
   496 	 * @access public
   500 	 *
   497 	 *
   501 	 * @param {object} [options] Options.
   498 	 * @param {object} [options] Options.
   502 	 * @param {boolean} [options.unsaved=false] Whether only values not saved yet into a changeset will be returned (differential changes).
   499 	 * @param {boolean} [options.unsaved=false] Whether only values not saved yet into a changeset will be returned (differential changes).
   523 		return values;
   520 		return values;
   524 	};
   521 	};
   525 
   522 
   526 	/**
   523 	/**
   527 	 * Request updates to the changeset.
   524 	 * Request updates to the changeset.
       
   525 	 *
       
   526 	 * @alias wp.customize.requestChangesetUpdate
   528 	 *
   527 	 *
   529 	 * @since 4.7.0
   528 	 * @since 4.7.0
   530 	 * @access public
   529 	 * @access public
   531 	 *
   530 	 *
   532 	 * @param {object}  [changes] - Mapping of setting IDs to setting params each normally including a value property, or mapping to null.
   531 	 * @param {object}  [changes] - Mapping of setting IDs to setting params each normally including a value property, or mapping to null.
   659 	};
   658 	};
   660 
   659 
   661 	/**
   660 	/**
   662 	 * Watch all changes to Value properties, and bubble changes to parent Values instance
   661 	 * Watch all changes to Value properties, and bubble changes to parent Values instance
   663 	 *
   662 	 *
       
   663 	 * @alias wp.customize.utils.bubbleChildValueChanges
       
   664 	 *
   664 	 * @since 4.1.0
   665 	 * @since 4.1.0
   665 	 *
   666 	 *
   666 	 * @param {wp.customize.Class} instance
   667 	 * @param {wp.customize.Class} instance
   667 	 * @param {Array}              properties  The names of the Value instances to watch.
   668 	 * @param {Array}              properties  The names of the Value instances to watch.
   668 	 */
   669 	 */
   676 		} );
   677 		} );
   677 	};
   678 	};
   678 
   679 
   679 	/**
   680 	/**
   680 	 * Expand a panel, section, or control and focus on the first focusable element.
   681 	 * Expand a panel, section, or control and focus on the first focusable element.
       
   682 	 *
       
   683 	 * @alias wp.customize~focus
   681 	 *
   684 	 *
   682 	 * @since 4.1.0
   685 	 * @since 4.1.0
   683 	 *
   686 	 *
   684 	 * @param {Object}   [params]
   687 	 * @param {Object}   [params]
   685 	 * @param {Function} [params.completeCallback]
   688 	 * @param {Function} [params.completeCallback]
   724 	/**
   727 	/**
   725 	 * Stable sort for Panels, Sections, and Controls.
   728 	 * Stable sort for Panels, Sections, and Controls.
   726 	 *
   729 	 *
   727 	 * If a.priority() === b.priority(), then sort by their respective params.instanceNumber.
   730 	 * If a.priority() === b.priority(), then sort by their respective params.instanceNumber.
   728 	 *
   731 	 *
       
   732 	 * @alias wp.customize.utils.prioritySort
       
   733 	 *
   729 	 * @since 4.1.0
   734 	 * @since 4.1.0
   730 	 *
   735 	 *
   731 	 * @param {(wp.customize.Panel|wp.customize.Section|wp.customize.Control)} a
   736 	 * @param {(wp.customize.Panel|wp.customize.Section|wp.customize.Control)} a
   732 	 * @param {(wp.customize.Panel|wp.customize.Section|wp.customize.Control)} b
   737 	 * @param {(wp.customize.Panel|wp.customize.Section|wp.customize.Control)} b
   733 	 * @returns {Number}
   738 	 * @returns {Number}
   741 	};
   746 	};
   742 
   747 
   743 	/**
   748 	/**
   744 	 * Return whether the supplied Event object is for a keydown event but not the Enter key.
   749 	 * Return whether the supplied Event object is for a keydown event but not the Enter key.
   745 	 *
   750 	 *
       
   751 	 * @alias wp.customize.utils.isKeydownButNotEnterEvent
       
   752 	 *
   746 	 * @since 4.1.0
   753 	 * @since 4.1.0
   747 	 *
   754 	 *
   748 	 * @param {jQuery.Event} event
   755 	 * @param {jQuery.Event} event
   749 	 * @returns {boolean}
   756 	 * @returns {boolean}
   750 	 */
   757 	 */
   752 		return ( 'keydown' === event.type && 13 !== event.which );
   759 		return ( 'keydown' === event.type && 13 !== event.which );
   753 	};
   760 	};
   754 
   761 
   755 	/**
   762 	/**
   756 	 * Return whether the two lists of elements are the same and are in the same order.
   763 	 * Return whether the two lists of elements are the same and are in the same order.
       
   764 	 *
       
   765 	 * @alias wp.customize.utils.areElementListsEqual
   757 	 *
   766 	 *
   758 	 * @since 4.1.0
   767 	 * @since 4.1.0
   759 	 *
   768 	 *
   760 	 * @param {Array|jQuery} listA
   769 	 * @param {Array|jQuery} listA
   761 	 * @param {Array|jQuery} listB
   770 	 * @param {Array|jQuery} listB
   778 	 * Highlight the existence of a button.
   787 	 * Highlight the existence of a button.
   779 	 *
   788 	 *
   780 	 * This function reminds the user of a button represented by the specified
   789 	 * This function reminds the user of a button represented by the specified
   781 	 * UI element, after an optional delay. If the user focuses the element
   790 	 * UI element, after an optional delay. If the user focuses the element
   782 	 * before the delay passes, the reminder is canceled.
   791 	 * before the delay passes, the reminder is canceled.
       
   792 	 *
       
   793 	 * @alias wp.customize.utils.highlightButton
   783 	 *
   794 	 *
   784 	 * @since 4.9.0
   795 	 * @since 4.9.0
   785 	 *
   796 	 *
   786 	 * @param {jQuery} button - The element to highlight.
   797 	 * @param {jQuery} button - The element to highlight.
   787 	 * @param {object} [options] - Options.
   798 	 * @param {object} [options] - Options.
   832 	/**
   843 	/**
   833 	 * Get current timestamp adjusted for server clock time.
   844 	 * Get current timestamp adjusted for server clock time.
   834 	 *
   845 	 *
   835 	 * Same functionality as the `current_time( 'mysql', false )` function in PHP.
   846 	 * Same functionality as the `current_time( 'mysql', false )` function in PHP.
   836 	 *
   847 	 *
       
   848 	 * @alias wp.customize.utils.getCurrentTimestamp
       
   849 	 *
   837 	 * @since 4.9.0
   850 	 * @since 4.9.0
   838 	 *
   851 	 *
   839 	 * @returns {int} Current timestamp.
   852 	 * @returns {int} Current timestamp.
   840 	 */
   853 	 */
   841 	api.utils.getCurrentTimestamp = function getCurrentTimestamp() {
   854 	api.utils.getCurrentTimestamp = function getCurrentTimestamp() {
   848 		return currentDate.getTime();
   861 		return currentDate.getTime();
   849 	};
   862 	};
   850 
   863 
   851 	/**
   864 	/**
   852 	 * Get remaining time of when the date is set.
   865 	 * Get remaining time of when the date is set.
       
   866 	 *
       
   867 	 * @alias wp.customize.utils.getRemainingTime
   853 	 *
   868 	 *
   854 	 * @since 4.9.0
   869 	 * @since 4.9.0
   855 	 *
   870 	 *
   856 	 * @param {string|int|Date} datetime - Date time or timestamp of the future date.
   871 	 * @param {string|int|Date} datetime - Date time or timestamp of the future date.
   857 	 * @return {int} remainingTime - Remaining time in milliseconds.
   872 	 * @return {int} remainingTime - Remaining time in milliseconds.
   873 
   888 
   874 	/**
   889 	/**
   875 	 * Return browser supported `transitionend` event name.
   890 	 * Return browser supported `transitionend` event name.
   876 	 *
   891 	 *
   877 	 * @since 4.7.0
   892 	 * @since 4.7.0
       
   893 	 *
       
   894 	 * @ignore
   878 	 *
   895 	 *
   879 	 * @returns {string|null} Normalized `transitionend` event name or null if CSS transitions are not supported.
   896 	 * @returns {string|null} Normalized `transitionend` event name or null if CSS transitions are not supported.
   880 	 */
   897 	 */
   881 	normalizedTransitionendEventName = (function () {
   898 	normalizedTransitionendEventName = (function () {
   882 		var el, transitions, prop;
   899 		var el, transitions, prop;
   895 		} else {
   912 		} else {
   896 			return null;
   913 			return null;
   897 		}
   914 		}
   898 	})();
   915 	})();
   899 
   916 
   900 	/**
   917 	Container = api.Class.extend(/** @lends wp.customize~Container.prototype */{
   901 	 * Base class for Panel and Section.
       
   902 	 *
       
   903 	 * @since 4.1.0
       
   904 	 *
       
   905 	 * @class
       
   906 	 * @augments wp.customize.Class
       
   907 	 */
       
   908 	Container = api.Class.extend({
       
   909 		defaultActiveArguments: { duration: 'fast', completeCallback: $.noop },
   918 		defaultActiveArguments: { duration: 'fast', completeCallback: $.noop },
   910 		defaultExpandedArguments: { duration: 'fast', completeCallback: $.noop },
   919 		defaultExpandedArguments: { duration: 'fast', completeCallback: $.noop },
   911 		containerType: 'container',
   920 		containerType: 'container',
   912 		defaults: {
   921 		defaults: {
   913 			title: '',
   922 			title: '',
   918 			active: true,
   927 			active: true,
   919 			instanceNumber: null
   928 			instanceNumber: null
   920 		},
   929 		},
   921 
   930 
   922 		/**
   931 		/**
       
   932 		 * Base class for Panel and Section.
       
   933 		 *
       
   934 		 * @constructs wp.customize~Container
       
   935 		 * @augments   wp.customize.Class
       
   936 		 *
   923 		 * @since 4.1.0
   937 		 * @since 4.1.0
   924 		 *
   938 		 *
   925 		 * @param {string}         id - The ID for the container.
   939 		 * @borrows wp.customize~focus as focus
   926 		 * @param {object}         options - Object containing one property: params.
   940 		 *
   927 		 * @param {string}         options.title - Title shown when panel is collapsed and expanded.
   941 		 * @param {string}  id - The ID for the container.
   928 		 * @param {string=}        [options.description] - Description shown at the top of the panel.
   942 		 * @param {object}  options - Object containing one property: params.
   929 		 * @param {number=100}     [options.priority] - The sort priority for the panel.
   943 		 * @param {string}  options.title - Title shown when panel is collapsed and expanded.
   930 		 * @param {string}         [options.templateId] - Template selector for container.
   944 		 * @param {string}  [options.description] - Description shown at the top of the panel.
   931 		 * @param {string=default} [options.type] - The type of the panel. See wp.customize.panelConstructor.
   945 		 * @param {number}  [options.priority=100] - The sort priority for the panel.
   932 		 * @param {string=}        [options.content] - The markup to be used for the panel container. If empty, a JS template is used.
   946 		 * @param {string}  [options.templateId] - Template selector for container.
   933 		 * @param {boolean=true}   [options.active] - Whether the panel is active or not.
   947 		 * @param {string}  [options.type=default] - The type of the panel. See wp.customize.panelConstructor.
   934 		 * @param {object}         [options.params] - Deprecated wrapper for the above properties.
   948 		 * @param {string}  [options.content] - The markup to be used for the panel container. If empty, a JS template is used.
       
   949 		 * @param {boolean} [options.active=true] - Whether the panel is active or not.
       
   950 		 * @param {object}  [options.params] - Deprecated wrapper for the above properties.
   935 		 */
   951 		 */
   936 		initialize: function ( id, options ) {
   952 		initialize: function ( id, options ) {
   937 			var container = this;
   953 			var container = this;
   938 			container.id = id;
   954 			container.id = id;
   939 
   955 
   997 		/**
  1013 		/**
   998 		 * Get the element that will contain the notifications.
  1014 		 * Get the element that will contain the notifications.
   999 		 *
  1015 		 *
  1000 		 * @since 4.9.0
  1016 		 * @since 4.9.0
  1001 		 * @returns {jQuery} Notification container element.
  1017 		 * @returns {jQuery} Notification container element.
  1002 		 * @this {wp.customize.Control}
       
  1003 		 */
  1018 		 */
  1004 		getNotificationsContainerElement: function() {
  1019 		getNotificationsContainerElement: function() {
  1005 			var container = this;
  1020 			var container = this;
  1006 			return container.contentContainer.find( '.customize-control-notifications-container:first' );
  1021 			return container.contentContainer.find( '.customize-control-notifications-container:first' );
  1007 		},
  1022 		},
  1303 					container.scrollTop( previousScrollTop );
  1318 					container.scrollTop( previousScrollTop );
  1304 				}
  1319 				}
  1305 			} );
  1320 			} );
  1306 		},
  1321 		},
  1307 
  1322 
  1308 		/**
  1323 		/*
  1309 		 * Bring the container into view and then expand this and bring it into view
  1324 		 * is documented using @borrows in the constructor.
  1310 		 * @param {Object} [params]
       
  1311 		 */
  1325 		 */
  1312 		focus: focus,
  1326 		focus: focus,
  1313 
  1327 
  1314 		/**
  1328 		/**
  1315 		 * Return the container html, generated from its JS template, if it exists.
  1329 		 * Return the container html, generated from its JS template, if it exists.
  1368 				'class': 'customize-pane-child ' + content.attr( 'class' ) + ' ' + container.attr( 'class' )
  1382 				'class': 'customize-pane-child ' + content.attr( 'class' ) + ' ' + container.attr( 'class' )
  1369 			} );
  1383 			} );
  1370 		}
  1384 		}
  1371 	});
  1385 	});
  1372 
  1386 
  1373 	/**
  1387 	api.Section = Container.extend(/** @lends wp.customize.Section.prototype */{
  1374 	 * @since 4.1.0
       
  1375 	 *
       
  1376 	 * @class
       
  1377 	 * @augments wp.customize.Class
       
  1378 	 */
       
  1379 	api.Section = Container.extend({
       
  1380 		containerType: 'section',
  1388 		containerType: 'section',
  1381 		containerParent: '#customize-theme-controls',
  1389 		containerParent: '#customize-theme-controls',
  1382 		containerPaneParent: '.customize-pane-parent',
  1390 		containerPaneParent: '.customize-pane-parent',
  1383 		defaults: {
  1391 		defaults: {
  1384 			title: '',
  1392 			title: '',
  1391 			panel: null,
  1399 			panel: null,
  1392 			customizeAction: ''
  1400 			customizeAction: ''
  1393 		},
  1401 		},
  1394 
  1402 
  1395 		/**
  1403 		/**
       
  1404 		 * @constructs wp.customize.Section
       
  1405 		 * @augments   wp.customize~Container
       
  1406 		 *
  1396 		 * @since 4.1.0
  1407 		 * @since 4.1.0
  1397 		 *
  1408 		 *
  1398 		 * @param {string}         id - The ID for the section.
  1409 		 * @param {string}  id - The ID for the section.
  1399 		 * @param {object}         options - Options.
  1410 		 * @param {object}  options - Options.
  1400 		 * @param {string}         options.title - Title shown when section is collapsed and expanded.
  1411 		 * @param {string}  options.title - Title shown when section is collapsed and expanded.
  1401 		 * @param {string=}        [options.description] - Description shown at the top of the section.
  1412 		 * @param {string}  [options.description] - Description shown at the top of the section.
  1402 		 * @param {number=100}     [options.priority] - The sort priority for the section.
  1413 		 * @param {number}  [options.priority=100] - The sort priority for the section.
  1403 		 * @param {string=default} [options.type] - The type of the section. See wp.customize.sectionConstructor.
  1414 		 * @param {string}  [options.type=default] - The type of the section. See wp.customize.sectionConstructor.
  1404 		 * @param {string=}        [options.content] - The markup to be used for the section container. If empty, a JS template is used.
  1415 		 * @param {string}  [options.content] - The markup to be used for the section container. If empty, a JS template is used.
  1405 		 * @param {boolean=true}   [options.active] - Whether the section is active or not.
  1416 		 * @param {boolean} [options.active=true] - Whether the section is active or not.
  1406 		 * @param {string}         options.panel - The ID for the panel this section is associated with.
  1417 		 * @param {string}  options.panel - The ID for the panel this section is associated with.
  1407 		 * @param {string=}        [options.customizeAction] - Additional context information shown before the section title when expanded.
  1418 		 * @param {string}  [options.customizeAction] - Additional context information shown before the section title when expanded.
  1408 		 * @param {object}         [options.params] - Deprecated wrapper for the above properties.
  1419 		 * @param {object}  [options.params] - Deprecated wrapper for the above properties.
  1409 		 */
  1420 		 */
  1410 		initialize: function ( id, options ) {
  1421 		initialize: function ( id, options ) {
  1411 			var section = this, params;
  1422 			var section = this, params;
  1412 			params = options.params || options;
  1423 			params = options.params || options;
  1413 
  1424 
  1652 				}
  1663 				}
  1653 			}
  1664 			}
  1654 		}
  1665 		}
  1655 	});
  1666 	});
  1656 
  1667 
  1657 	/**
  1668 	api.ThemesSection = api.Section.extend(/** @lends wp.customize.ThemesSection.prototype */{
  1658 	 * wp.customize.ThemesSection
       
  1659 	 *
       
  1660 	 * Custom section for themes that loads themes by category, and also
       
  1661 	 * handles the theme-details view rendering and navigation.
       
  1662 	 *
       
  1663 	 * @constructor
       
  1664 	 * @augments wp.customize.Section
       
  1665 	 * @augments wp.customize.Container
       
  1666 	 */
       
  1667 	api.ThemesSection = api.Section.extend({
       
  1668 		currentTheme: '',
  1669 		currentTheme: '',
  1669 		overlay: '',
  1670 		overlay: '',
  1670 		template: '',
  1671 		template: '',
  1671 		screenshotQueue: null,
  1672 		screenshotQueue: null,
  1672 		$window: null,
  1673 		$window: null,
  1681 		filtersHeight: 0,
  1682 		filtersHeight: 0,
  1682 		headerContainer: null,
  1683 		headerContainer: null,
  1683 		updateCountDebounced: null,
  1684 		updateCountDebounced: null,
  1684 
  1685 
  1685 		/**
  1686 		/**
  1686 		 * Initialize.
  1687 		 * wp.customize.ThemesSection
       
  1688 		 *
       
  1689 		 * Custom section for themes that loads themes by category, and also
       
  1690 		 * handles the theme-details view rendering and navigation.
       
  1691 		 *
       
  1692 		 * @constructs wp.customize.ThemesSection
       
  1693 		 * @augments   wp.customize.Section
  1687 		 *
  1694 		 *
  1688 		 * @since 4.9.0
  1695 		 * @since 4.9.0
  1689 		 *
  1696 		 *
  1690 		 * @param {string} id - ID.
  1697 		 * @param {string} id - ID.
  1691 		 * @param {object} options - Options.
  1698 		 * @param {object} options - Options.
  2625 				}
  2632 				}
  2626 			});
  2633 			});
  2627 		}
  2634 		}
  2628 	});
  2635 	});
  2629 
  2636 
  2630 	/**
  2637 	api.OuterSection = api.Section.extend(/** @lends wp.customize.OuterSection.prototype */{
  2631 	 * Class wp.customize.OuterSection.
  2638 
  2632 	 *
  2639 		/**
  2633 	 * Creates section outside of the sidebar, there is no ui to trigger collapse/expand so
  2640 		 * Class wp.customize.OuterSection.
  2634 	 * it would require custom handling.
  2641 		 *
  2635 	 *
  2642 		 * Creates section outside of the sidebar, there is no ui to trigger collapse/expand so
  2636 	 * @since 4.9
  2643 		 * it would require custom handling.
  2637 	 *
  2644 		 *
  2638 	 * @constructor
  2645 		 * @constructs wp.customize.OuterSection
  2639 	 * @augments wp.customize.Section
  2646 		 * @augments   wp.customize.Section
  2640 	 * @augments wp.customize.Container
       
  2641 	 */
       
  2642 	api.OuterSection = api.Section.extend({
       
  2643 
       
  2644 		/**
       
  2645 		 * Initialize.
       
  2646 		 *
  2647 		 *
  2647 		 * @since 4.9.0
  2648 		 * @since 4.9.0
  2648 		 *
  2649 		 *
  2649 		 * @returns {void}
  2650 		 * @returns {void}
  2650 		 */
  2651 		 */
  2744 				}
  2745 				}
  2745 			}
  2746 			}
  2746 		}
  2747 		}
  2747 	});
  2748 	});
  2748 
  2749 
  2749 	/**
  2750 	api.Panel = Container.extend(/** @lends wp.customize.Panel.prototype */{
  2750 	 * @since 4.1.0
       
  2751 	 *
       
  2752 	 * @class
       
  2753 	 * @augments wp.customize.Class
       
  2754 	 */
       
  2755 	api.Panel = Container.extend({
       
  2756 		containerType: 'panel',
  2751 		containerType: 'panel',
  2757 
  2752 
  2758 		/**
  2753 		/**
       
  2754 		 * @constructs wp.customize.Panel
       
  2755 		 * @augments   wp.customize~Container
       
  2756 		 *
  2759 		 * @since 4.1.0
  2757 		 * @since 4.1.0
  2760 		 *
  2758 		 *
  2761 		 * @param {string}         id - The ID for the panel.
  2759 		 * @param {string}  id - The ID for the panel.
  2762 		 * @param {object}         options - Object containing one property: params.
  2760 		 * @param {object}  options - Object containing one property: params.
  2763 		 * @param {string}         options.title - Title shown when panel is collapsed and expanded.
  2761 		 * @param {string}  options.title - Title shown when panel is collapsed and expanded.
  2764 		 * @param {string=}        [options.description] - Description shown at the top of the panel.
  2762 		 * @param {string}  [options.description] - Description shown at the top of the panel.
  2765 		 * @param {number=100}     [options.priority] - The sort priority for the panel.
  2763 		 * @param {number}  [options.priority=100] - The sort priority for the panel.
  2766 		 * @param {string=default} [options.type] - The type of the panel. See wp.customize.panelConstructor.
  2764 		 * @param {string}  [options.type=default] - The type of the panel. See wp.customize.panelConstructor.
  2767 		 * @param {string=}        [options.content] - The markup to be used for the panel container. If empty, a JS template is used.
  2765 		 * @param {string}  [options.content] - The markup to be used for the panel container. If empty, a JS template is used.
  2768 		 * @param {boolean=true}   [options.active] - Whether the panel is active or not.
  2766 		 * @param {boolean} [options.active=true] - Whether the panel is active or not.
  2769 		 * @param {object}         [options.params] - Deprecated wrapper for the above properties.
  2767 		 * @param {object}  [options.params] - Deprecated wrapper for the above properties.
  2770 		 */
  2768 		 */
  2771 		initialize: function ( id, options ) {
  2769 		initialize: function ( id, options ) {
  2772 			var panel = this, params;
  2770 			var panel = this, params;
  2773 			params = options.params || options;
  2771 			params = options.params || options;
  2774 
  2772 
  3018 				) ) );
  3016 				) ) );
  3019 			}
  3017 			}
  3020 		}
  3018 		}
  3021 	});
  3019 	});
  3022 
  3020 
  3023 	/**
  3021 	api.ThemesPanel = api.Panel.extend(/** @lends wp.customize.ThemsPanel.prototype */{
  3024 	 * Class wp.customize.ThemesPanel.
  3022 
  3025 	 *
  3023 		/**
  3026 	 * Custom section for themes that displays without the customize preview.
  3024 		 *  Class wp.customize.ThemesPanel.
  3027 	 *
  3025 		 *
  3028 	 * @constructor
  3026 		 * Custom section for themes that displays without the customize preview.
  3029 	 * @augments wp.customize.Panel
  3027 		 *
  3030 	 * @augments wp.customize.Container
  3028 		 * @constructs wp.customize.ThemesPanel
  3031 	 */
  3029 		 * @augments   wp.customize.Panel
  3032 	api.ThemesPanel = api.Panel.extend({
       
  3033 
       
  3034 		/**
       
  3035 		 * Initialize.
       
  3036 		 *
  3030 		 *
  3037 		 * @since 4.9.0
  3031 		 * @since 4.9.0
  3038 		 *
  3032 		 *
  3039 		 * @param {string} id - The ID for the panel.
  3033 		 * @param {string} id - The ID for the panel.
  3040 		 * @param {object} options - Options.
  3034 		 * @param {object} options - Options.
  3449 			section.closeDetails();
  3443 			section.closeDetails();
  3450 			section.focus();
  3444 			section.focus();
  3451 		}
  3445 		}
  3452 	});
  3446 	});
  3453 
  3447 
  3454 	/**
  3448 	api.Control = api.Class.extend(/** @lends wp.customize.Control.prototype */{
  3455 	 * A Customizer Control.
       
  3456 	 *
       
  3457 	 * A control provides a UI element that allows a user to modify a Customizer Setting.
       
  3458 	 *
       
  3459 	 * @see PHP class WP_Customize_Control.
       
  3460 	 *
       
  3461 	 * @class
       
  3462 	 * @augments wp.customize.Class
       
  3463 	 */
       
  3464 	api.Control = api.Class.extend({
       
  3465 		defaultActiveArguments: { duration: 'fast', completeCallback: $.noop },
  3449 		defaultActiveArguments: { duration: 'fast', completeCallback: $.noop },
  3466 
  3450 
  3467 		/**
  3451 		/**
  3468 		 * Default params.
  3452 		 * Default params.
  3469 		 *
  3453 		 *
  3476 			active: true,
  3460 			active: true,
  3477 			priority: 10
  3461 			priority: 10
  3478 		},
  3462 		},
  3479 
  3463 
  3480 		/**
  3464 		/**
  3481 		 * Initialize.
  3465 		 * A Customizer Control.
       
  3466 		 *
       
  3467 		 * A control provides a UI element that allows a user to modify a Customizer Setting.
       
  3468 		 *
       
  3469 		 * @see PHP class WP_Customize_Control.
       
  3470 		 *
       
  3471 		 * @constructs wp.customize.Control
       
  3472 		 * @augments   wp.customize.Class
       
  3473 		 *
       
  3474 		 * @borrows wp.customize~focus as this#focus
       
  3475 		 * @borrows wp.customize~Container#activate as this#activate
       
  3476 		 * @borrows wp.customize~Container#deactivate as this#deactivate
       
  3477 		 * @borrows wp.customize~Container#_toggleActive as this#_toggleActive
  3482 		 *
  3478 		 *
  3483 		 * @param {string} id                       - Unique identifier for the control instance.
  3479 		 * @param {string} id                       - Unique identifier for the control instance.
  3484 		 * @param {object} options                  - Options hash for the control instance.
  3480 		 * @param {object} options                  - Options hash for the control instance.
  3485 		 * @param {object} options.type             - Type of control (e.g. text, radio, dropdown-pages, etc.)
  3481 		 * @param {object} options.type             - Type of control (e.g. text, radio, dropdown-pages, etc.)
  3486 		 * @param {string} [options.content]        - The HTML content for the control or at least its container. This should normally be left blank and instead supplying a templateId.
  3482 		 * @param {string} [options.content]        - The HTML content for the control or at least its container. This should normally be left blank and instead supplying a templateId.
  3742 		 * Injects the notification container for existing controls that lack the necessary container,
  3738 		 * Injects the notification container for existing controls that lack the necessary container,
  3743 		 * including special handling for nav menu items and widgets.
  3739 		 * including special handling for nav menu items and widgets.
  3744 		 *
  3740 		 *
  3745 		 * @since 4.6.0
  3741 		 * @since 4.6.0
  3746 		 * @returns {jQuery} Setting validation message element.
  3742 		 * @returns {jQuery} Setting validation message element.
  3747 		 * @this {wp.customize.Control}
       
  3748 		 */
  3743 		 */
  3749 		getNotificationsContainerElement: function() {
  3744 		getNotificationsContainerElement: function() {
  3750 			var control = this, controlTitle, notificationsContainer;
  3745 			var control = this, controlTitle, notificationsContainer;
  3751 
  3746 
  3752 			notificationsContainer = control.container.find( '.customize-control-notifications-container:first' );
  3747 			notificationsContainer = control.container.find( '.customize-control-notifications-container:first' );
  3886 		 */
  3881 		 */
  3887 		expand: function ( params ) {
  3882 		expand: function ( params ) {
  3888 			api.section( this.section() ).expand( params );
  3883 			api.section( this.section() ).expand( params );
  3889 		},
  3884 		},
  3890 
  3885 
  3891 		/**
  3886 		/*
  3892 		 * Bring the containing section and panel into view and then
  3887 		 * Documented using @borrows in the constructor.
  3893 		 * this control into view, focusing on the first input.
       
  3894 		 */
  3888 		 */
  3895 		focus: focus,
  3889 		focus: focus,
  3896 
  3890 
  3897 		/**
  3891 		/**
  3898 		 * Update UI in response to a change in the control's active state.
  3892 		 * Update UI in response to a change in the control's active state.
  3932 		 */
  3926 		 */
  3933 		toggle: function ( active ) {
  3927 		toggle: function ( active ) {
  3934 			return this.onChangeActive( active, this.defaultActiveArguments );
  3928 			return this.onChangeActive( active, this.defaultActiveArguments );
  3935 		},
  3929 		},
  3936 
  3930 
  3937 		/**
  3931 		/*
  3938 		 * Shorthand way to enable the active state.
  3932 		 * Documented using @borrows in the constructor
  3939 		 *
       
  3940 		 * @since 4.1.0
       
  3941 		 *
       
  3942 		 * @param {Object} [params]
       
  3943 		 * @returns {Boolean} false if already active
       
  3944 		 */
  3933 		 */
  3945 		activate: Container.prototype.activate,
  3934 		activate: Container.prototype.activate,
  3946 
  3935 
  3947 		/**
  3936 		/*
  3948 		 * Shorthand way to disable the active state.
  3937 		 * Documented using @borrows in the constructor
  3949 		 *
       
  3950 		 * @since 4.1.0
       
  3951 		 *
       
  3952 		 * @param {Object} [params]
       
  3953 		 * @returns {Boolean} false if already inactive
       
  3954 		 */
  3938 		 */
  3955 		deactivate: Container.prototype.deactivate,
  3939 		deactivate: Container.prototype.deactivate,
  3956 
  3940 
  3957 		/**
  3941 		/*
  3958 		 * Re-use _toggleActive from Container class.
  3942 		 * Documented using @borrows in the constructor
  3959 		 *
       
  3960 		 * @access private
       
  3961 		 */
  3943 		 */
  3962 		_toggleActive: Container.prototype._toggleActive,
  3944 		_toggleActive: Container.prototype._toggleActive,
  3963 
  3945 
  3964 		// @todo This function appears to be dead code and can be removed.
  3946 		// @todo This function appears to be dead code and can be removed.
  3965 		dropdownInit: function() {
  3947 		dropdownInit: function() {
  4129 	});
  4111 	});
  4130 
  4112 
  4131 	/**
  4113 	/**
  4132 	 * A colorpicker control.
  4114 	 * A colorpicker control.
  4133 	 *
  4115 	 *
  4134 	 * @class
  4116 	 * @class    wp.customize.ColorControl
  4135 	 * @augments wp.customize.Control
  4117 	 * @augments wp.customize.Control
  4136 	 * @augments wp.customize.Class
       
  4137 	 */
  4118 	 */
  4138 	api.ColorControl = api.Control.extend({
  4119 	api.ColorControl = api.Control.extend(/** @lends wp.customize.ColorControl.prototype */{
  4139 		ready: function() {
  4120 		ready: function() {
  4140 			var control = this,
  4121 			var control = this,
  4141 				isHueSlider = this.params.mode === 'hue',
  4122 				isHueSlider = this.params.mode === 'hue',
  4142 				updating = false,
  4123 				updating = false,
  4143 				picker;
  4124 				picker;
  4193 	});
  4174 	});
  4194 
  4175 
  4195 	/**
  4176 	/**
  4196 	 * A control that implements the media modal.
  4177 	 * A control that implements the media modal.
  4197 	 *
  4178 	 *
  4198 	 * @class
  4179 	 * @class    wp.customize.MediaControl
  4199 	 * @augments wp.customize.Control
  4180 	 * @augments wp.customize.Control
  4200 	 * @augments wp.customize.Class
       
  4201 	 */
  4181 	 */
  4202 	api.MediaControl = api.Control.extend({
  4182 	api.MediaControl = api.Control.extend(/** @lends wp.customize.MediaControl.prototype */{
  4203 
  4183 
  4204 		/**
  4184 		/**
  4205 		 * When the control's DOM structure is ready,
  4185 		 * When the control's DOM structure is ready,
  4206 		 * set up internal event bindings.
  4186 		 * set up internal event bindings.
  4207 		 */
  4187 		 */
  4382 	});
  4362 	});
  4383 
  4363 
  4384 	/**
  4364 	/**
  4385 	 * An upload control, which utilizes the media modal.
  4365 	 * An upload control, which utilizes the media modal.
  4386 	 *
  4366 	 *
  4387 	 * @class
  4367 	 * @class    wp.customize.UploadControl
  4388 	 * @augments wp.customize.MediaControl
  4368 	 * @augments wp.customize.MediaControl
  4389 	 * @augments wp.customize.Control
       
  4390 	 * @augments wp.customize.Class
       
  4391 	 */
  4369 	 */
  4392 	api.UploadControl = api.MediaControl.extend({
  4370 	api.UploadControl = api.MediaControl.extend(/** @lends wp.customize.UploadControl.prototype */{
  4393 
  4371 
  4394 		/**
  4372 		/**
  4395 		 * Callback handler for when an attachment is selected in the media modal.
  4373 		 * Callback handler for when an attachment is selected in the media modal.
  4396 		 * Gets the selected image information, and sets it within the control.
  4374 		 * Gets the selected image information, and sets it within the control.
  4397 		 */
  4375 		 */
  4426 	 * A control for uploading images.
  4404 	 * A control for uploading images.
  4427 	 *
  4405 	 *
  4428 	 * This control no longer needs to do anything more
  4406 	 * This control no longer needs to do anything more
  4429 	 * than what the upload control does in JS.
  4407 	 * than what the upload control does in JS.
  4430 	 *
  4408 	 *
  4431 	 * @class
  4409 	 * @class    wp.customize.ImageControl
  4432 	 * @augments wp.customize.UploadControl
  4410 	 * @augments wp.customize.UploadControl
  4433 	 * @augments wp.customize.MediaControl
       
  4434 	 * @augments wp.customize.Control
       
  4435 	 * @augments wp.customize.Class
       
  4436 	 */
  4411 	 */
  4437 	api.ImageControl = api.UploadControl.extend({
  4412 	api.ImageControl = api.UploadControl.extend(/** @lends wp.customize.ImageControl.prototype */{
  4438 		// @deprecated
  4413 		// @deprecated
  4439 		thumbnailSrc: function() {}
  4414 		thumbnailSrc: function() {}
  4440 	});
  4415 	});
  4441 
  4416 
  4442 	/**
  4417 	/**
  4443 	 * A control for uploading background images.
  4418 	 * A control for uploading background images.
  4444 	 *
  4419 	 *
  4445 	 * @class
  4420 	 * @class    wp.customize.BackgroundControl
  4446 	 * @augments wp.customize.UploadControl
  4421 	 * @augments wp.customize.UploadControl
  4447 	 * @augments wp.customize.MediaControl
       
  4448 	 * @augments wp.customize.Control
       
  4449 	 * @augments wp.customize.Class
       
  4450 	 */
  4422 	 */
  4451 	api.BackgroundControl = api.UploadControl.extend({
  4423 	api.BackgroundControl = api.UploadControl.extend(/** @lends wp.customize.BackgroundControl.prototype */{
  4452 
  4424 
  4453 		/**
  4425 		/**
  4454 		 * When the control's DOM structure is ready,
  4426 		 * When the control's DOM structure is ready,
  4455 		 * set up internal event bindings.
  4427 		 * set up internal event bindings.
  4456 		 */
  4428 		 */
  4477 	/**
  4449 	/**
  4478 	 * A control for positioning a background image.
  4450 	 * A control for positioning a background image.
  4479 	 *
  4451 	 *
  4480 	 * @since 4.7.0
  4452 	 * @since 4.7.0
  4481 	 *
  4453 	 *
  4482 	 * @class
  4454 	 * @class    wp.customize.BackgroundPositionControl
  4483 	 * @augments wp.customize.Control
  4455 	 * @augments wp.customize.Control
  4484 	 * @augments wp.customize.Class
       
  4485 	 */
  4456 	 */
  4486 	api.BackgroundPositionControl = api.Control.extend( {
  4457 	api.BackgroundPositionControl = api.Control.extend(/** @lends wp.customize.BackgroundPositionControl.prototype */{
  4487 
  4458 
  4488 		/**
  4459 		/**
  4489 		 * Set up control UI once embedded in DOM and settings are created.
  4460 		 * Set up control UI once embedded in DOM and settings are created.
  4490 		 *
  4461 		 *
  4491 		 * @since 4.7.0
  4462 		 * @since 4.7.0
  4516 	} );
  4487 	} );
  4517 
  4488 
  4518 	/**
  4489 	/**
  4519 	 * A control for selecting and cropping an image.
  4490 	 * A control for selecting and cropping an image.
  4520 	 *
  4491 	 *
  4521 	 * @class
  4492 	 * @class    wp.customize.CroppedImageControl
  4522 	 * @augments wp.customize.MediaControl
  4493 	 * @augments wp.customize.MediaControl
  4523 	 * @augments wp.customize.Control
       
  4524 	 * @augments wp.customize.Class
       
  4525 	 */
  4494 	 */
  4526 	api.CroppedImageControl = api.MediaControl.extend({
  4495 	api.CroppedImageControl = api.MediaControl.extend(/** @lends wp.customize.CroppedImageControl.prototype */{
  4527 
  4496 
  4528 		/**
  4497 		/**
  4529 		 * Open the media modal to the library state.
  4498 		 * Open the media modal to the library state.
  4530 		 */
  4499 		 */
  4531 		openFrame: function( event ) {
  4500 		openFrame: function( event ) {
  4718 	});
  4687 	});
  4719 
  4688 
  4720 	/**
  4689 	/**
  4721 	 * A control for selecting and cropping Site Icons.
  4690 	 * A control for selecting and cropping Site Icons.
  4722 	 *
  4691 	 *
  4723 	 * @class
  4692 	 * @class    wp.customize.SiteIconControl
  4724 	 * @augments wp.customize.CroppedImageControl
  4693 	 * @augments wp.customize.CroppedImageControl
  4725 	 * @augments wp.customize.MediaControl
       
  4726 	 * @augments wp.customize.Control
       
  4727 	 * @augments wp.customize.Class
       
  4728 	 */
  4694 	 */
  4729 	api.SiteIconControl = api.CroppedImageControl.extend({
  4695 	api.SiteIconControl = api.CroppedImageControl.extend(/** @lends wp.customize.SiteIconControl.prototype */{
  4730 
  4696 
  4731 		/**
  4697 		/**
  4732 		 * Create a media modal select frame, and store it so the instance can be reused when needed.
  4698 		 * Create a media modal select frame, and store it so the instance can be reused when needed.
  4733 		 */
  4699 		 */
  4734 		initFrame: function() {
  4700 		initFrame: function() {
  4839 			$( 'link[rel="icon"][sizes="32x32"]' ).attr( 'href', '/favicon.ico' ); // Set to default.
  4805 			$( 'link[rel="icon"][sizes="32x32"]' ).attr( 'href', '/favicon.ico' ); // Set to default.
  4840 		}
  4806 		}
  4841 	});
  4807 	});
  4842 
  4808 
  4843 	/**
  4809 	/**
  4844 	 * @class
  4810 	 * @class    wp.customize.HeaderControl
  4845 	 * @augments wp.customize.Control
  4811 	 * @augments wp.customize.Control
  4846 	 * @augments wp.customize.Class
       
  4847 	 */
  4812 	 */
  4848 	api.HeaderControl = api.Control.extend({
  4813 	api.HeaderControl = api.Control.extend(/** @lends wp.customize.HeaderControl.prototype */{
  4849 		ready: function() {
  4814 		ready: function() {
  4850 			this.btnRemove = $('#customize-control-header_image .actions .remove');
  4815 			this.btnRemove = $('#customize-control-header_image .actions .remove');
  4851 			this.btnNew    = $('#customize-control-header_image .actions .new');
  4816 			this.btnNew    = $('#customize-control-header_image .actions .new');
  4852 
  4817 
  4853 			_.bindAll(this, 'openMedia', 'removeImage');
  4818 			_.bindAll(this, 'openMedia', 'removeImage');
  5109 	});
  5074 	});
  5110 
  5075 
  5111 	/**
  5076 	/**
  5112 	 * wp.customize.ThemeControl
  5077 	 * wp.customize.ThemeControl
  5113 	 *
  5078 	 *
  5114 	 * @constructor
  5079 	 * @class    wp.customize.ThemeControl
  5115 	 * @augments wp.customize.Control
  5080 	 * @augments wp.customize.Control
  5116 	 * @augments wp.customize.Class
       
  5117 	 */
  5081 	 */
  5118 	api.ThemeControl = api.Control.extend({
  5082 	api.ThemeControl = api.Control.extend(/** @lends wp.customize.ThemeControl.prototype */{
  5119 
  5083 
  5120 		touchDrag: false,
  5084 		touchDrag: false,
  5121 		screenshotRendered: false,
  5085 		screenshotRendered: false,
  5122 
  5086 
  5123 		/**
  5087 		/**
  5261 	/**
  5225 	/**
  5262 	 * Class wp.customize.CodeEditorControl
  5226 	 * Class wp.customize.CodeEditorControl
  5263 	 *
  5227 	 *
  5264 	 * @since 4.9.0
  5228 	 * @since 4.9.0
  5265 	 *
  5229 	 *
  5266 	 * @constructor
  5230 	 * @class    wp.customize.CodeEditorControl
  5267 	 * @augments wp.customize.Control
  5231 	 * @augments wp.customize.Control
  5268 	 * @augments wp.customize.Class
       
  5269 	 */
  5232 	 */
  5270 	api.CodeEditorControl = api.Control.extend({
  5233 	api.CodeEditorControl = api.Control.extend(/** @lends wp.customize.CodeEditorControl.prototype */{
  5271 
  5234 
  5272 		/**
  5235 		/**
  5273 		 * Initialize.
  5236 		 * Initialize.
  5274 		 *
  5237 		 *
  5275 		 * @since 4.9.0
  5238 		 * @since 4.9.0
  5582 
  5545 
  5583 	/**
  5546 	/**
  5584 	 * Class wp.customize.DateTimeControl.
  5547 	 * Class wp.customize.DateTimeControl.
  5585 	 *
  5548 	 *
  5586 	 * @since 4.9.0
  5549 	 * @since 4.9.0
  5587 	 * @constructor
  5550 	 * @class    wp.customize.DateTimeControl
  5588 	 * @augments wp.customize.Control
  5551 	 * @augments wp.customize.Control
  5589 	 * @augments wp.customize.Class
       
  5590 	 */
  5552 	 */
  5591 	api.DateTimeControl = api.Control.extend({
  5553 	api.DateTimeControl = api.Control.extend(/** @lends wp.customize.DateTimeControl.prototype */{
  5592 
  5554 
  5593 		/**
  5555 		/**
  5594 		 * Initialize behaviors.
  5556 		 * Initialize behaviors.
  5595 		 *
  5557 		 *
  5596 		 * @since 4.9.0
  5558 		 * @since 4.9.0
  5937 
  5899 
  5938 	/**
  5900 	/**
  5939 	 * Class PreviewLinkControl.
  5901 	 * Class PreviewLinkControl.
  5940 	 *
  5902 	 *
  5941 	 * @since 4.9.0
  5903 	 * @since 4.9.0
  5942 	 * @constructor
  5904 	 * @class    wp.customize.PreviewLinkControl
  5943 	 * @augments wp.customize.Control
  5905 	 * @augments wp.customize.Control
  5944 	 * @augments wp.customize.Class
       
  5945 	 */
  5906 	 */
  5946 	api.PreviewLinkControl = api.Control.extend({
  5907 	api.PreviewLinkControl = api.Control.extend(/** @lends wp.customize.PreviewLinkControl.prototype */{
  5947 
  5908 
  5948 		defaults: _.extend( {}, api.Control.prototype.defaults, {
  5909 		defaults: _.extend( {}, api.Control.prototype.defaults, {
  5949 			templateId: 'customize-preview-link-control'
  5910 			templateId: 'customize-preview-link-control'
  5950 		} ),
  5911 		} ),
  5951 
  5912 
  6055 				control.notifications.remove( notificationCode );
  6016 				control.notifications.remove( notificationCode );
  6056 			}
  6017 			}
  6057 		}
  6018 		}
  6058 	});
  6019 	});
  6059 
  6020 
  6060 	// Change objects contained within the main customize object to Settings.
  6021 	/**
       
  6022 	 * Change objects contained within the main customize object to Settings.
       
  6023 	 *
       
  6024 	 * @alias wp.customize.defaultConstructor
       
  6025 	 */
  6061 	api.defaultConstructor = api.Setting;
  6026 	api.defaultConstructor = api.Setting;
  6062 
  6027 
  6063 	/**
  6028 	/**
  6064 	 * Callback for resolved controls.
  6029 	 * Callback for resolved controls.
  6065 	 *
  6030 	 *
  6066 	 * @callback deferredControlsCallback
  6031 	 * @callback wp.customize.deferredControlsCallback
  6067 	 * @param {wp.customize.Control[]} Resolved controls.
  6032 	 * @param {wp.customize.Control[]} controls Resolved controls.
  6068 	 */
  6033 	 */
  6069 
  6034 
  6070 	/**
  6035 	/**
  6071 	 * Collection of all registered controls.
  6036 	 * Collection of all registered controls.
       
  6037 	 *
       
  6038 	 * @alias wp.customize.control
  6072 	 *
  6039 	 *
  6073 	 * @since 3.4.0
  6040 	 * @since 3.4.0
  6074 	 *
  6041 	 *
  6075 	 * @type {Function}
  6042 	 * @type {Function}
  6076 	 * @param {...string} ids - One or more ids for controls to obtain.
  6043 	 * @param {...string} ids - One or more ids for controls to obtain.
  6120 	api.control = new api.Values({ defaultConstructor: api.Control });
  6087 	api.control = new api.Values({ defaultConstructor: api.Control });
  6121 
  6088 
  6122 	/**
  6089 	/**
  6123 	 * Callback for resolved sections.
  6090 	 * Callback for resolved sections.
  6124 	 *
  6091 	 *
  6125 	 * @callback deferredSectionsCallback
  6092 	 * @callback wp.customize.deferredSectionsCallback
  6126 	 * @param {wp.customize.Section[]} Resolved sections.
  6093 	 * @param {wp.customize.Section[]} sections Resolved sections.
  6127 	 */
  6094 	 */
  6128 
  6095 
  6129 	/**
  6096 	/**
  6130 	 * Collection of all registered sections.
  6097 	 * Collection of all registered sections.
       
  6098 	 *
       
  6099 	 * @alias wp.customize.section
  6131 	 *
  6100 	 *
  6132 	 * @since 3.4.0
  6101 	 * @since 3.4.0
  6133 	 *
  6102 	 *
  6134 	 * @type {Function}
  6103 	 * @type {Function}
  6135 	 * @param {...string} ids - One or more ids for sections to obtain.
  6104 	 * @param {...string} ids - One or more ids for sections to obtain.
  6152 	api.section = new api.Values({ defaultConstructor: api.Section });
  6121 	api.section = new api.Values({ defaultConstructor: api.Section });
  6153 
  6122 
  6154 	/**
  6123 	/**
  6155 	 * Callback for resolved panels.
  6124 	 * Callback for resolved panels.
  6156 	 *
  6125 	 *
  6157 	 * @callback deferredPanelsCallback
  6126 	 * @callback wp.customize.deferredPanelsCallback
  6158 	 * @param {wp.customize.Panel[]} Resolved panels.
  6127 	 * @param {wp.customize.Panel[]} panels Resolved panels.
  6159 	 */
  6128 	 */
  6160 
  6129 
  6161 	/**
  6130 	/**
  6162 	 * Collection of all registered panels.
  6131 	 * Collection of all registered panels.
       
  6132 	 *
       
  6133 	 * @alias wp.customize.panel
  6163 	 *
  6134 	 *
  6164 	 * @since 4.0.0
  6135 	 * @since 4.0.0
  6165 	 *
  6136 	 *
  6166 	 * @type {Function}
  6137 	 * @type {Function}
  6167 	 * @param {...string} ids - One or more ids for panels to obtain.
  6138 	 * @param {...string} ids - One or more ids for panels to obtain.
  6184 	api.panel = new api.Values({ defaultConstructor: api.Panel });
  6155 	api.panel = new api.Values({ defaultConstructor: api.Panel });
  6185 
  6156 
  6186 	/**
  6157 	/**
  6187 	 * Callback for resolved notifications.
  6158 	 * Callback for resolved notifications.
  6188 	 *
  6159 	 *
  6189 	 * @callback deferredNotificationsCallback
  6160 	 * @callback wp.customize.deferredNotificationsCallback
  6190 	 * @param {wp.customize.Notification[]} Resolved notifications.
  6161 	 * @param {wp.customize.Notification[]} notifications Resolved notifications.
  6191 	 */
  6162 	 */
  6192 
  6163 
  6193 	/**
  6164 	/**
  6194 	 * Collection of all global notifications.
  6165 	 * Collection of all global notifications.
       
  6166 	 *
       
  6167 	 * @alias wp.customize.notifications
  6195 	 *
  6168 	 *
  6196 	 * @since 4.9.0
  6169 	 * @since 4.9.0
  6197 	 *
  6170 	 *
  6198 	 * @type {Function}
  6171 	 * @type {Function}
  6199 	 * @param {...string} codes - One or more codes for notifications to obtain.
  6172 	 * @param {...string} codes - One or more codes for notifications to obtain.
  6221 	 *
  6194 	 *
  6222 	 * @see {@link wp.customize.control} for further examples of how to interact with {@link wp.customize.Values} instances.
  6195 	 * @see {@link wp.customize.control} for further examples of how to interact with {@link wp.customize.Values} instances.
  6223 	 */
  6196 	 */
  6224 	api.notifications = new api.Notifications();
  6197 	api.notifications = new api.Notifications();
  6225 
  6198 
  6226 	/**
  6199 	api.PreviewFrame = api.Messenger.extend(/** @lends wp.customize.PreviewFrame.prototype */{
  6227 	 * An object that fetches a preview in the background of the document, which
       
  6228 	 * allows for seamless replacement of an existing preview.
       
  6229 	 *
       
  6230 	 * @class
       
  6231 	 * @augments wp.customize.Messenger
       
  6232 	 * @augments wp.customize.Class
       
  6233 	 * @mixes wp.customize.Events
       
  6234 	 */
       
  6235 	api.PreviewFrame = api.Messenger.extend({
       
  6236 		sensitivity: null, // Will get set to api.settings.timeouts.previewFrameSensitivity.
  6200 		sensitivity: null, // Will get set to api.settings.timeouts.previewFrameSensitivity.
  6237 
  6201 
  6238 		/**
  6202 		/**
  6239 		 * Initialize the PreviewFrame.
  6203 		 * An object that fetches a preview in the background of the document, which
       
  6204 		 * allows for seamless replacement of an existing preview.
       
  6205 		 *
       
  6206 		 * @constructs wp.customize.PreviewFrame
       
  6207 		 * @augments   wp.customize.Messenger
  6240 		 *
  6208 		 *
  6241 		 * @param {object} params.container
  6209 		 * @param {object} params.container
  6242 		 * @param {object} params.previewUrl
  6210 		 * @param {object} params.previewUrl
  6243 		 * @param {object} params.query
  6211 		 * @param {object} params.query
  6244 		 * @param {object} options
  6212 		 * @param {object} options
  6319 			previewFrame.iframe = $( '<iframe />', {
  6287 			previewFrame.iframe = $( '<iframe />', {
  6320 				title: api.l10n.previewIframeTitle,
  6288 				title: api.l10n.previewIframeTitle,
  6321 				name: 'customize-' + previewFrame.channel()
  6289 				name: 'customize-' + previewFrame.channel()
  6322 			} );
  6290 			} );
  6323 			previewFrame.iframe.attr( 'onmousewheel', '' ); // Workaround for Safari bug. See WP Trac #38149.
  6291 			previewFrame.iframe.attr( 'onmousewheel', '' ); // Workaround for Safari bug. See WP Trac #38149.
       
  6292 			previewFrame.iframe.attr( 'sandbox', 'allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' );
  6324 
  6293 
  6325 			if ( ! hasPendingChangesetUpdate ) {
  6294 			if ( ! hasPendingChangesetUpdate ) {
  6326 				previewFrame.iframe.attr( 'src', urlParser.href );
  6295 				previewFrame.iframe.attr( 'src', urlParser.href );
  6327 			} else {
  6296 			} else {
  6328 				previewFrame.iframe.attr( 'data-src', urlParser.href ); // For debugging purposes.
  6297 				previewFrame.iframe.attr( 'data-src', urlParser.href ); // For debugging purposes.
  6452 	}());
  6421 	}());
  6453 
  6422 
  6454 	/**
  6423 	/**
  6455 	 * Set the document title of the customizer.
  6424 	 * Set the document title of the customizer.
  6456 	 *
  6425 	 *
       
  6426 	 * @alias wp.customize.setDocumentTitle
       
  6427 	 *
  6457 	 * @since 4.1.0
  6428 	 * @since 4.1.0
  6458 	 *
  6429 	 *
  6459 	 * @param {string} documentTitle
  6430 	 * @param {string} documentTitle
  6460 	 */
  6431 	 */
  6461 	api.setDocumentTitle = function ( documentTitle ) {
  6432 	api.setDocumentTitle = function ( documentTitle ) {
  6464 		title = tmpl.replace( '%s', documentTitle );
  6435 		title = tmpl.replace( '%s', documentTitle );
  6465 		document.title = title;
  6436 		document.title = title;
  6466 		api.trigger( 'title', title );
  6437 		api.trigger( 'title', title );
  6467 	};
  6438 	};
  6468 
  6439 
  6469 	/**
  6440 	api.Previewer = api.Messenger.extend(/** @lends wp.customize.Previewer.prototype */{
  6470 	 * @class
       
  6471 	 * @augments wp.customize.Messenger
       
  6472 	 * @augments wp.customize.Class
       
  6473 	 * @mixes wp.customize.Events
       
  6474 	 */
       
  6475 	api.Previewer = api.Messenger.extend({
       
  6476 		refreshBuffer: null, // Will get set to api.settings.timeouts.windowRefresh.
  6441 		refreshBuffer: null, // Will get set to api.settings.timeouts.windowRefresh.
  6477 
  6442 
  6478 		/**
  6443 		/**
       
  6444 		 * @constructs wp.customize.Previewer
       
  6445 		 * @augments   wp.customize.Messenger
       
  6446 		 *
  6479 		 * @param {array}  params.allowedUrls
  6447 		 * @param {array}  params.allowedUrls
  6480 		 * @param {string} params.container   A selector or jQuery element for the preview
  6448 		 * @param {string} params.container   A selector or jQuery element for the preview
  6481 		 *                                    frame to be placed.
  6449 		 *                                    frame to be placed.
  6482 		 * @param {string} params.form
  6450 		 * @param {string} params.form
  6483 		 * @param {string} params.previewUrl  The URL to preview.
  6451 		 * @param {string} params.previewUrl  The URL to preview.
  6927 	/**
  6895 	/**
  6928 	 * Handle setting_validities in an error response for the customize-save request.
  6896 	 * Handle setting_validities in an error response for the customize-save request.
  6929 	 *
  6897 	 *
  6930 	 * Add notifications to the settings and focus on the first control that has an invalid setting.
  6898 	 * Add notifications to the settings and focus on the first control that has an invalid setting.
  6931 	 *
  6899 	 *
       
  6900 	 * @alias wp.customize._handleSettingValidities
       
  6901 	 *
  6932 	 * @since 4.6.0
  6902 	 * @since 4.6.0
  6933 	 * @private
  6903 	 * @private
  6934 	 *
  6904 	 *
  6935 	 * @param {object}  args
  6905 	 * @param {object}  args
  6936 	 * @param {object}  args.settingValidities
  6906 	 * @param {object}  args.settingValidities
  7002 	};
  6972 	};
  7003 
  6973 
  7004 	/**
  6974 	/**
  7005 	 * Find all controls associated with the given settings.
  6975 	 * Find all controls associated with the given settings.
  7006 	 *
  6976 	 *
       
  6977 	 * @alias wp.customize.findControlsForSettings
       
  6978 	 *
  7007 	 * @since 4.6.0
  6979 	 * @since 4.6.0
  7008 	 * @param {string[]} settingIds Setting IDs.
  6980 	 * @param {string[]} settingIds Setting IDs.
  7009 	 * @returns {object<string, wp.customize.Control>} Mapping setting ids to arrays of controls.
  6981 	 * @returns {object<string, wp.customize.Control>} Mapping setting ids to arrays of controls.
  7010 	 */
  6982 	 */
  7011 	api.findControlsForSettings = function findControlsForSettings( settingIds ) {
  6983 	api.findControlsForSettings = function findControlsForSettings( settingIds ) {
  7022 		return controls;
  6994 		return controls;
  7023 	};
  6995 	};
  7024 
  6996 
  7025 	/**
  6997 	/**
  7026 	 * Sort panels, sections, controls by priorities. Hide empty sections and panels.
  6998 	 * Sort panels, sections, controls by priorities. Hide empty sections and panels.
       
  6999 	 *
       
  7000 	 * @alias wp.customize.reflowPaneContents
  7027 	 *
  7001 	 *
  7028 	 * @since 4.1.0
  7002 	 * @since 4.1.0
  7029 	 */
  7003 	 */
  7030 	api.reflowPaneContents = _.bind( function () {
  7004 	api.reflowPaneContents = _.bind( function () {
  7031 
  7005 
  7387 				section.toggleClass( 'open' );
  7361 				section.toggleClass( 'open' );
  7388 				$( this ).attr( 'aria-expanded', true );
  7362 				$( this ).attr( 'aria-expanded', true );
  7389 			}
  7363 			}
  7390 		});
  7364 		});
  7391 
  7365 
  7392 		// Initialize Previewer
  7366 		/**
       
  7367 		 * Initialize Previewer
       
  7368 		 *
       
  7369 		 * @alias wp.customize.previewer
       
  7370 		 */
  7393 		api.previewer = new api.Previewer({
  7371 		api.previewer = new api.Previewer({
  7394 			container:   '#customize-preview',
  7372 			container:   '#customize-preview',
  7395 			form:        '#customize-controls',
  7373 			form:        '#customize-controls',
  7396 			previewUrl:  api.settings.url.preview,
  7374 			previewUrl:  api.settings.url.preview,
  7397 			allowedUrls: api.settings.url.allowed
  7375 			allowedUrls: api.settings.url.allowed
  7398 		}, {
  7376 		},/** @lends wp.customize.previewer */{
  7399 
  7377 
  7400 			nonce: api.settings.nonce,
  7378 			nonce: api.settings.nonce,
  7401 
  7379 
  7402 			/**
  7380 			/**
  7403 			 * Build the query to send along with the Preview request.
  7381 			 * Build the query to send along with the Preview request.
  8096 		 *
  8074 		 *
  8097 		 * @since 4.9.0
  8075 		 * @since 4.9.0
  8098 		 */
  8076 		 */
  8099 		( function checkAndDisplayLockNotice() {
  8077 		( function checkAndDisplayLockNotice() {
  8100 
  8078 
  8101 			/**
  8079 			var LockedNotification = api.OverlayNotification.extend(/** @lends wp.customize~LockedNotification.prototype */{
  8102 			 * A notification that is displayed in a full-screen overlay with information about the locked changeset.
       
  8103 			 *
       
  8104 			 * @since 4.9.0
       
  8105 			 * @class
       
  8106 			 * @augments wp.customize.Notification
       
  8107 			 * @augments wp.customize.OverlayNotification
       
  8108 			 */
       
  8109 			var LockedNotification = api.OverlayNotification.extend({
       
  8110 
  8080 
  8111 				/**
  8081 				/**
  8112 				 * Template ID.
  8082 				 * Template ID.
  8113 				 *
  8083 				 *
  8114 				 * @type {string}
  8084 				 * @type {string}
  8121 				 * @type {object}
  8091 				 * @type {object}
  8122 				 */
  8092 				 */
  8123 				lockUser: null,
  8093 				lockUser: null,
  8124 
  8094 
  8125 				/**
  8095 				/**
  8126 				 * Initialize.
  8096 				 * A notification that is displayed in a full-screen overlay with information about the locked changeset.
       
  8097 				 *
       
  8098 				 * @constructs wp.customize~LockedNotification
       
  8099 				 * @augments   wp.customize.OverlayNotification
  8127 				 *
  8100 				 *
  8128 				 * @since 4.9.0
  8101 				 * @since 4.9.0
  8129 				 *
  8102 				 *
  8130 				 * @param {string} [code] - Code.
  8103 				 * @param {string} [code] - Code.
  8131 				 * @param {object} [params] - Params.
  8104 				 * @param {object} [params] - Params.