Widgets: Clear dirty flag on widgets admin screen when widget is deleted to prevent irrelevant confirmation prompt when leaving.

Props hazimayesh, felipeelia.
Amends [41352], [41813].
See #23120, #42127.
Fixes #41894.

Built from https://develop.svn.wordpress.org/trunk@41814


git-svn-id: http://core.svn.wordpress.org/trunk@41648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-10-10 20:39:47 +00:00
parent 7cb66a5353
commit 6c05b7bef2
3 changed files with 13 additions and 7 deletions

View File

@ -550,12 +550,14 @@ wpWidgets = {
if ( animate ) { if ( animate ) {
order = 0; order = 0;
widget.slideUp('fast', function(){ widget.slideUp( 'fast', function() {
$(this).remove(); $( this ).remove();
wpWidgets.saveOrder(); wpWidgets.saveOrder();
delete self.dirtyWidgets[ id ];
}); });
} else { } else {
widget.remove(); widget.remove();
delete self.dirtyWidgets[ id ];
if ( sidebarId === 'wp_inactive_widgets' ) { if ( sidebarId === 'wp_inactive_widgets' ) {
$( '#inactive-widgets-control-remove' ).prop( 'disabled' , ! $( '#wp_inactive_widgets .widget' ).length ); $( '#inactive-widgets-control-remove' ).prop( 'disabled' , ! $( '#wp_inactive_widgets .widget' ).length );
@ -590,7 +592,7 @@ wpWidgets = {
}, },
removeInactiveWidgets : function() { removeInactiveWidgets : function() {
var $element = $( '.remove-inactive-widgets' ), a, data; var $element = $( '.remove-inactive-widgets' ), self = this, a, data;
$( '.spinner', $element ).addClass( 'is-active' ); $( '.spinner', $element ).addClass( 'is-active' );
@ -602,8 +604,12 @@ wpWidgets = {
data = $.param( a ); data = $.param( a );
$.post( ajaxurl, data, function() { $.post( ajaxurl, data, function() {
$( '#wp_inactive_widgets .widget' ).remove(); $( '#wp_inactive_widgets .widget' ).each(function() {
$( '#inactive-widgets-control-remove' ).prop( 'disabled' , true ); var $widget = $( this );
delete self.dirtyWidgets[ $widget.find( 'input.widget-id' ).val() ];
$widget.remove();
});
$( '#inactive-widgets-control-remove' ).prop( 'disabled', true );
$( '.spinner', $element ).removeClass( 'is-active' ); $( '.spinner', $element ).removeClass( 'is-active' );
} ); } );
}, },

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.9-beta1-41813'; $wp_version = '4.9-beta1-41814';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.