File "customize-preview-widgets-20250305184837.js"
Full Path: /home2/sdektunc/cepali.edu.mx/wp-includes/blocks/classic/customize-preview-widgets-20250305184837.js
File size: 4 KB
MIME-type: text/plain
Charset: utf-8
/**
* @output wp-includes/js/customize-preview-widgets.js
*/
/* global _wpWidgetCustomizerPreviewSettings */
/**
* Handles the initialization, refreshing and rendering of widget partials and sidebar widgets.
*
* @since 4.5.0
*
* @namespace wp.customize.widgetsPreview
*
* @param {jQuery} $ The jQuery object.
* @param {Object} _ The utilities library.
* @param {Object} wp Current WordPress environment instance.
* @param {Object} api Information from the API.
*
* @return {Object} Widget-related variables.
*/
wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function( $, _, wp, api ) {
var self;
self = {
renderedSidebars: {},
renderedWidgets: {},
registeredSidebars: [],
registeredWidgets: {},
widgetSelectors: [],
preview: null,
l10n: {
widgetTooltip: ''
},
selectiveRefreshableWidgets: {}
};
/**
* Initializes the widgets preview.
*
* @since 4.5.0
*
* @memberOf wp.customize.widgetsPreview
*
* @return {void}
*/
self.init = function() {
var self = this;
self.preview = api.preview;
if ( ! _.isEmpty( self.selectiveRefreshableWidgets ) ) {
self.addPartials();
}
self.buildWidgetSelectors();
self.highlightControls();
self.preview.bind( 'highlight-widget', self.highlightWidget );
api.preview.bind( 'active', function() {
self.highlightControls();
} );
/*
* Refresh a partial when the controls pane requests it. This is used currently just by the
* Gallery widget so that when an attachment's caption is updated in the media modal,
* the widget in the preview will then be refreshed to show the change. Normally doing this
* would not be necessary because all of the state should be contained inside the changeset,
* as everything done in the Customizer should not make a change to the site unless the
* changeset itself is published. Attachments are a current exception to this rule.
* For a proposal to include attachments in the customized state, see #37887.
*/
api.preview.bind( 'refresh-widget-partial', function( widgetId ) {
var partialId = 'widget[' + widgetId + ']';
if ( api.selectiveRefresh.partial.has( partialId ) ) {
api.selectiveRefresh.partial( partialId ).refresh();
} else if ( self.renderedWidgets[ widgetId ] ) {
api.preview.send( 'refresh' ); // Fallback in case theme does not support 'customize-selective-refresh-widgets'.
}
} );
};
self.WidgetPartial = api.selectiveRefresh.Partial.extend(/** @lends wp.customize.widgetsPreview.WidgetPartial.prototype */{
/**
* Represents a partial widget instance.
*
* @since 4.5.0
*
* @constructs
* @augments wp.customize.selectiveRefresh.Partial
*
* @alias wp.customize.widgetsPreview.WidgetPartial
* @memberOf wp.customize.widgetsPreview
*
* @param {string} id The partial's ID.
* @param {Object} options Options used to initialize the partial's
* instance.
* @param {Object} options.params The options parameters.
*/
initialize: function( id, options ) {
var partial = this, matches;
matches = id.match( /^widget\[(.+)]$/ );
if ( ! matches ) {
throw new Error( 'Illegal id for widget partial.' );
}
partial.widgetId = matches[1];
partial.widgetIdParts = self.parseWidgetId( partial.widgetId );
options = options || {};
options.params = _.extend(
{
settings: [ self.getWidgetSettingId( partial.widgetId ) ],
containerInclusive: true
},
options.params || {}
);
api.selectiveRefresh.Partial.prototype.initialize.call( partial, id, options );
},
/**
* Refreshes the widget partial.
*
* @since 4.5.0
*
* @return {Promise|void} Either a promise postponing the refresh, or void.
*/
refresh: function() {
var partial = this, refreshDeferred;
if ( ! self.selectiveRefreshableWidgets[ partial.widgetIdParts.idBase ] ) {
refreshDeferred = $.Deferred();
refreshDeferred.reject();
partial.fallback();
return refreshDeferred.promise();
} else {
return api.select