Changeset 41872
- Timestamp:
- 10/16/2017 06:45:09 AM (7 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/widgets/media-gallery-widget.js
r41590 r41872 101 101 control.selectedAttachments.on( 'reset', control.renderPreview ); 102 102 control.updateSelectedAttachments(); 103 104 /* 105 * Refresh a Gallery widget partial when the user modifies one of the selected attachments. 106 * This ensures that when an attachment's caption is updated in the media modal the Gallery 107 * widget in the preview will then be refreshed to show the change. Normally doing this 108 * would not be necessary because all of the state should be contained inside the changeset, 109 * as everything done in the Customizer should not make a change to the site unless the 110 * changeset itself is published. Attachments are a current exception to this rule. 111 * For a proposal to include attachments in the customized state, see #37887. 112 */ 113 if ( wp.customize && wp.customize.previewer ) { 114 control.selectedAttachments.on( 'change', function() { 115 wp.customize.previewer.send( 'refresh-widget-partial', control.model.get( 'widget_id' ) ); 116 } ); 117 } 103 118 }, 104 119 -
trunk/src/wp-includes/js/customize-preview-widgets.js
r41726 r41872 39 39 api.preview.bind( 'active', function() { 40 40 self.highlightControls(); 41 } ); 42 43 /* 44 * Refresh a partial when the controls pane requests it. This is used currently just by the 45 * Gallery widget so that when an attachment's caption is updated in the media modal, 46 * the widget in the preview will then be refreshed to show the change. Normally doing this 47 * would not be necessary because all of the state should be contained inside the changeset, 48 * as everything done in the Customizer should not make a change to the site unless the 49 * changeset itself is published. Attachments are a current exception to this rule. 50 * For a proposal to include attachments in the customized state, see #37887. 51 */ 52 api.preview.bind( 'refresh-widget-partial', function( widgetId ) { 53 var partialId = 'widget[' + widgetId + ']'; 54 if ( api.selectiveRefresh.partial.has( partialId ) ) { 55 api.selectiveRefresh.partial( partialId ).refresh(); 56 } else if ( self.renderedWidgets[ widgetId ] ) { 57 api.preview.send( 'refresh' ); // Fallback in case theme does not support 'customize-selective-refresh-widgets'. 58 } 41 59 } ); 42 60 }; … … 452 470 } ); 453 471 } 472 delete self.renderedWidgets[ removedWidgetId ]; 454 473 } ); 455 474 … … 459 478 var widgetPartial = sidebarPartial.ensureWidgetPlacementContainers( addedWidgetId ); 460 479 addedWidgetPartials.push( widgetPartial ); 480 self.renderedWidgets[ addedWidgetId ] = true; 461 481 } ); 462 482
Note: See TracChangeset
for help on using the changeset viewer.