wp/wp-includes/js/customize-selective-refresh.js
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 21 48c4eec2b7e6
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    57 		/**
    57 		/**
    58 		 * Constructor.
    58 		 * Constructor.
    59 		 *
    59 		 *
    60 		 * @since 4.5.0
    60 		 * @since 4.5.0
    61 		 *
    61 		 *
    62 		 * @param {string} id                      - Unique identifier for the partial instance.
    62 		 * @param {string}  id                      - Unique identifier for the partial instance.
    63 		 * @param {object} options                 - Options hash for the partial instance.
    63 		 * @param {Object}  options                 - Options hash for the partial instance.
    64 		 * @param {string} options.type            - Type of partial (e.g. nav_menu, widget, etc)
    64 		 * @param {string}  options.type            - Type of partial (e.g. nav_menu, widget, etc)
    65 		 * @param {string} options.selector        - jQuery selector to find the container element in the page.
    65 		 * @param {string}  options.selector        - jQuery selector to find the container element in the page.
    66 		 * @param {array}  options.settings        - The IDs for the settings the partial relates to.
    66 		 * @param {Array}   options.settings        - The IDs for the settings the partial relates to.
    67 		 * @param {string} options.primarySetting  - The ID for the primary setting the partial renders.
    67 		 * @param {string}  options.primarySetting  - The ID for the primary setting the partial renders.
    68 		 * @param {bool}   options.fallbackRefresh - Whether to refresh the entire preview in case of a partial refresh failure.
    68 		 * @param {boolean} options.fallbackRefresh - Whether to refresh the entire preview in case of a partial refresh failure.
    69 		 * @param {object} [options.params]        - Deprecated wrapper for the above properties.
    69 		 * @param {Object}  [options.params]        - Deprecated wrapper for the above properties.
    70 		 */
    70 		 */
    71 		initialize: function( id, options ) {
    71 		initialize: function( id, options ) {
    72 			var partial = this;
    72 			var partial = this;
    73 			options = options || {};
    73 			options = options || {};
    74 			partial.id = id;
    74 			partial.id = id;
   118 		 *
   118 		 *
   119 		 * @since 4.7.0
   119 		 * @since 4.7.0
   120 		 * @access public
   120 		 * @access public
   121 		 *
   121 		 *
   122 		 * @param {Placement} placement The placement container element.
   122 		 * @param {Placement} placement The placement container element.
   123 		 * @returns {void}
   123 		 * @return {void}
   124 		 */
   124 		 */
   125 		createEditShortcutForPlacement: function( placement ) {
   125 		createEditShortcutForPlacement: function( placement ) {
   126 			var partial = this, $shortcut, $placementContainer, illegalAncestorSelector, illegalContainerSelector;
   126 			var partial = this, $shortcut, $placementContainer, illegalAncestorSelector, illegalContainerSelector;
   127 			if ( ! placement.container ) {
   127 			if ( ! placement.container ) {
   128 				return;
   128 				return;
   148 		 * @since 4.7.0
   148 		 * @since 4.7.0
   149 		 * @access public
   149 		 * @access public
   150 		 *
   150 		 *
   151 		 * @param {Placement} placement The placement for the partial.
   151 		 * @param {Placement} placement The placement for the partial.
   152 		 * @param {jQuery} $editShortcut The shortcut element as a jQuery object.
   152 		 * @param {jQuery} $editShortcut The shortcut element as a jQuery object.
   153 		 * @returns {void}
   153 		 * @return {void}
   154 		 */
   154 		 */
   155 		addEditShortcutToPlacement: function( placement, $editShortcut ) {
   155 		addEditShortcutToPlacement: function( placement, $editShortcut ) {
   156 			var $placementContainer = $( placement.container );
   156 			var $placementContainer = $( placement.container );
   157 			$placementContainer.prepend( $editShortcut );
   157 			$placementContainer.prepend( $editShortcut );
   158 			if ( ! $placementContainer.is( ':visible' ) || 'none' === $placementContainer.css( 'display' ) ) {
   158 			if ( ! $placementContainer.is( ':visible' ) || 'none' === $placementContainer.css( 'display' ) ) {
   283 		/**
   283 		/**
   284 		 * Get list of setting IDs related to this partial.
   284 		 * Get list of setting IDs related to this partial.
   285 		 *
   285 		 *
   286 		 * @since 4.5.0
   286 		 * @since 4.5.0
   287 		 *
   287 		 *
   288 		 * @return {String[]}
   288 		 * @return {string[]}
   289 		 */
   289 		 */
   290 		settings: function() {
   290 		settings: function() {
   291 			var partial = this;
   291 			var partial = this;
   292 			if ( partial.params.settings && 0 !== partial.params.settings.length ) {
   292 			if ( partial.params.settings && 0 !== partial.params.settings.length ) {
   293 				return partial.params.settings;
   293 				return partial.params.settings;
   404 		 *
   404 		 *
   405 		 * @since 4.5.0
   405 		 * @since 4.5.0
   406 		 *
   406 		 *
   407 		 * @param {Placement}             placement
   407 		 * @param {Placement}             placement
   408 		 * @param {Element|jQuery}        [placement.container]  - This param will be empty if there was no element matching the selector.
   408 		 * @param {Element|jQuery}        [placement.container]  - This param will be empty if there was no element matching the selector.
   409 		 * @param {string|object|boolean} placement.addedContent - Rendered HTML content, a data object for JS templates to render, or false if no render.
   409 		 * @param {string|Object|boolean} placement.addedContent - Rendered HTML content, a data object for JS templates to render, or false if no render.
   410 		 * @param {object}                [placement.context]    - Optional context information about the container.
   410 		 * @param {Object}                [placement.context]    - Optional context information about the container.
   411 		 * @returns {boolean} Whether the rendering was successful and the fallback was not invoked.
   411 		 * @return {boolean} Whether the rendering was successful and the fallback was not invoked.
   412 		 */
   412 		 */
   413 		renderContent: function( placement ) {
   413 		renderContent: function( placement ) {
   414 			var partial = this, content, newContainerElement;
   414 			var partial = this, content, newContainerElement;
   415 			if ( ! placement.container ) {
   415 			if ( ! placement.container ) {
   416 				partial.fallback( new Error( 'no_container' ), [ placement ] );
   416 				partial.fallback( new Error( 'no_container' ), [ placement ] );
   440 					content = wp.emoji.parse( content );
   440 					content = wp.emoji.parse( content );
   441 				}
   441 				}
   442 
   442 
   443 				if ( partial.params.containerInclusive ) {
   443 				if ( partial.params.containerInclusive ) {
   444 
   444 
   445 					// Note that content may be an empty string, and in this case jQuery will just remove the oldContainer
   445 					// Note that content may be an empty string, and in this case jQuery will just remove the oldContainer.
   446 					newContainerElement = $( content );
   446 					newContainerElement = $( content );
   447 
   447 
   448 					// Merge the new context on top of the old context.
   448 					// Merge the new context on top of the old context.
   449 					placement.context = _.extend(
   449 					placement.context = _.extend(
   450 						placement.context,
   450 						placement.context,
   600 		/**
   600 		/**
   601 		 * Constructor.
   601 		 * Constructor.
   602 		 *
   602 		 *
   603 		 * @since 4.5.0
   603 		 * @since 4.5.0
   604 		 *
   604 		 *
   605 		 * @param {object}                   args
   605 		 * @param {Object}                   args
   606 		 * @param {Partial}                  args.partial
   606 		 * @param {Partial}                  args.partial
   607 		 * @param {jQuery|Element}           [args.container]
   607 		 * @param {jQuery|Element}           [args.container]
   608 		 * @param {Node}                     [args.startNode]
   608 		 * @param {Node}                     [args.startNode]
   609 		 * @param {Node}                     [args.endNode]
   609 		 * @param {Node}                     [args.endNode]
   610 		 * @param {object}                   [args.context]
   610 		 * @param {Object}                   [args.context]
   611 		 * @param {string}                   [args.addedContent]
   611 		 * @param {string}                   [args.addedContent]
   612 		 * @param {jQuery|DocumentFragment}  [args.removedNodes]
   612 		 * @param {jQuery|DocumentFragment}  [args.removedNodes]
   613 		 */
   613 		 */
   614 		initialize: function( args ) {
   614 		initialize: function( args ) {
   615 			var placement = this;
   615 			var placement = this;
   643 	 * Get the POST vars for a Customizer preview request.
   643 	 * Get the POST vars for a Customizer preview request.
   644 	 *
   644 	 *
   645 	 * @since 4.5.0
   645 	 * @since 4.5.0
   646 	 * @see wp.customize.previewer.query()
   646 	 * @see wp.customize.previewer.query()
   647 	 *
   647 	 *
   648 	 * @return {object}
   648 	 * @return {Object}
   649 	 */
   649 	 */
   650 	self.getCustomizeQuery = function() {
   650 	self.getCustomizeQuery = function() {
   651 		var dirtyCustomized = {};
   651 		var dirtyCustomized = {};
   652 		api.each( function( value, key ) {
   652 		api.each( function( value, key ) {
   653 			if ( value._dirty ) {
   653 			if ( value._dirty ) {