Ticket #40974: 40974.3.diff
File 40974.3.diff, 3.2 KB (added by , 7 years ago) |
---|
-
src/wp-admin/js/widgets.js
41 41 $(document.body).bind('click.widgets-toggle', function(e) { 42 42 var target = $(e.target), 43 43 css = { 'z-index': 100 }, 44 widget, inside, targetWidth, widgetWidth, margin, 44 inside, targetWidth, widgetWidth, margin, 45 widget = target.closest('div.widget'), 45 46 toggleBtn = target.closest( '.widget' ).find( '.widget-top button.widget-action' ); 46 47 47 48 if ( target.parents('.widget-top').length && ! target.parents('#available-widgets').length ) { 48 widget = target.closest('div.widget');49 49 inside = widget.children('.widget-inside'); 50 50 targetWidth = parseInt( widget.find('input.widget-width').val(), 10 ), 51 51 widgetWidth = widget.parent().width(); … … 82 82 } 83 83 e.preventDefault(); 84 84 } else if ( target.hasClass('widget-control-save') ) { 85 $document.trigger( 'wp-widget-before-save', widget ); 85 86 wpWidgets.save( target.closest('div.widget'), 0, 1, 0 ); 86 87 e.preventDefault(); 87 88 } else if ( target.hasClass('widget-control-remove') ) { -
src/wp-admin/js/widgets/text-widgets.js
230 230 231 231 // If a prior mce instance was replaced, and it was in text mode, toggle to text mode. 232 232 if ( restoreTextMode ) { 233 switchEditors.go( id, ' toggle' );233 switchEditors.go( id, 'html' ); 234 234 } 235 235 236 236 // Show the pointer. … … 269 269 } 270 270 271 271 control.editorFocused = false; 272 triggerChangeIfDirty = function() { 272 273 triggerChangeIfDirty = function( event ) { 273 274 var updateWidgetBuffer = 300; // See wp.customize.Widgets.WidgetControl._setupUpdateUI() which uses 250ms for updateWidgetDebounced. 274 if ( editor.isDirty() ) {275 if ( editor.isDirty() || ( event && event.type === 'paste' ) ) { 275 276 276 277 /* 277 278 * Account for race condition in customizer where user clicks Save & Publish while … … 296 297 textarea.trigger( 'change' ); 297 298 } 298 299 }; 299 editor.on( 'focus', function () {300 editor.on( 'focus', function onEditorFocus() { 300 301 control.editorFocused = true; 301 302 }); 303 editor.on( 'paste', function onEditorPaste( event ) { 304 triggerChangeIfDirty( event ); 305 }); 302 306 editor.on( 'NodeChange', _.debounce( triggerChangeIfDirty, changeDebounceDelay ) ); 303 editor.on( 'blur ', function() {307 editor.on( 'blur hide', function onEditorBlur( event ) { 304 308 control.editorFocused = false; 305 triggerChangeIfDirty( );309 triggerChangeIfDirty( event ); 306 310 }); 307 311 308 312 control.editor = editor; … … 309 313 } 310 314 311 315 buildEditor(); 316 317 // Force-update the hidden input fields. 318 $( document ).on( 'wp-widget-before-save', function( event, widget ) { 319 var $widget = $( widget ); 320 321 $widget.find( '.widget-content input.title' ).val( control.fields.title.val() ); 322 $widget.find( '.widget-content input.text' ).val( control.fields.text.val() ); 323 }); 312 324 } 313 325 }); 314 326