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.


git-svn-id: https://develop.svn.wordpress.org/trunk@41814 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter 2017-10-10 20:38:22 +00:00
parent 6bbf13852b
commit 89aef850c2
1 changed files with 11 additions and 5 deletions

View File

@ -553,9 +553,11 @@ wpWidgets = {
widget.slideUp( 'fast', function() {
$( this ).remove();
wpWidgets.saveOrder();
delete self.dirtyWidgets[ id ];
});
} else {
widget.remove();
delete self.dirtyWidgets[ id ];
if ( sidebarId === 'wp_inactive_widgets' ) {
$( '#inactive-widgets-control-remove' ).prop( 'disabled' , ! $( '#wp_inactive_widgets .widget' ).length );
@ -590,7 +592,7 @@ wpWidgets = {
},
removeInactiveWidgets : function() {
var $element = $( '.remove-inactive-widgets' ), a, data;
var $element = $( '.remove-inactive-widgets' ), self = this, a, data;
$( '.spinner', $element ).addClass( 'is-active' );
@ -602,7 +604,11 @@ wpWidgets = {
data = $.param( a );
$.post( ajaxurl, data, function() {
$( '#wp_inactive_widgets .widget' ).remove();
$( '#wp_inactive_widgets .widget' ).each(function() {
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' );
} );