Customize: Prevent drawing attention to save button if status unchanged from publish; account for changes to status/date when alerting about unsaved changes.

Also fix malformed ESLint directive from [41933].

Amends [41932].
See #39896, #42211.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41781 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-10-19 17:42:54 +00:00
parent 609da14d59
commit b1a9139b46
4 changed files with 33 additions and 5 deletions

View File

@ -6986,12 +6986,21 @@
} ); } );
section.expanded.bind( function( isExpanded ) { section.expanded.bind( function( isExpanded ) {
var defaultChangesetStatus;
publishSettingsBtn.attr( 'aria-expanded', String( isExpanded ) ); publishSettingsBtn.attr( 'aria-expanded', String( isExpanded ) );
publishSettingsBtn.toggleClass( 'active', isExpanded ); publishSettingsBtn.toggleClass( 'active', isExpanded );
if ( isExpanded ) { if ( isExpanded ) {
cancelHighlightScheduleButton(); cancelHighlightScheduleButton();
} else if ( api.state( 'selectedChangesetStatus' ).get() !== api.state( 'changesetStatus' ).get() ) { return;
}
defaultChangesetStatus = api.state( 'changesetStatus' ).get();
if ( '' === defaultChangesetStatus || 'auto-draft' === defaultChangesetStatus ) {
defaultChangesetStatus = 'publish';
}
if ( api.state( 'selectedChangesetStatus' ).get() !== defaultChangesetStatus ) {
highlightScheduleButton(); highlightScheduleButton();
} else if ( 'future' === api.state( 'selectedChangesetStatus' ).get() && api.state( 'selectedChangesetDate' ).get() !== api.state( 'changesetDate' ).get() ) { } else if ( 'future' === api.state( 'selectedChangesetStatus' ).get() && api.state( 'selectedChangesetDate' ).get() !== api.state( 'changesetDate' ).get() ) {
highlightScheduleButton(); highlightScheduleButton();
@ -8479,6 +8488,7 @@
var isInsideIframe = false; var isInsideIframe = false;
function isCleanState() { function isCleanState() {
var defaultChangesetStatus;
/* /*
* Handle special case of previewing theme switch since some settings (for nav menus and widgets) * Handle special case of previewing theme switch since some settings (for nav menus and widgets)
@ -8488,6 +8498,20 @@
return 0 === api._latestRevision; return 0 === api._latestRevision;
} }
// Dirty if the changeset status has been changed but not saved yet.
defaultChangesetStatus = api.state( 'changesetStatus' ).get();
if ( '' === defaultChangesetStatus || 'auto-draft' === defaultChangesetStatus ) {
defaultChangesetStatus = 'publish';
}
if ( api.state( 'selectedChangesetStatus' ).get() !== defaultChangesetStatus ) {
return false;
}
// Dirty if scheduled but the changeset date hasn't been saved yet.
if ( 'future' === api.state( 'selectedChangesetStatus' ).get() && api.state( 'selectedChangesetDate' ).get() !== api.state( 'changesetDate' ).get() ) {
return false;
}
return api.state( 'saved' ).get() && 'auto-draft' !== api.state( 'changesetStatus' ).get(); return api.state( 'saved' ).get() && 'auto-draft' !== api.state( 'changesetStatus' ).get();
} }
@ -8501,6 +8525,8 @@
function startPromptingBeforeUnload() { function startPromptingBeforeUnload() {
api.unbind( 'change', startPromptingBeforeUnload ); api.unbind( 'change', startPromptingBeforeUnload );
api.state( 'selectedChangesetStatus' ).unbind( startPromptingBeforeUnload );
api.state( 'selectedChangesetDate' ).unbind( startPromptingBeforeUnload );
// Prompt user with AYS dialog if leaving the Customizer with unsaved changes // Prompt user with AYS dialog if leaving the Customizer with unsaved changes
$( window ).on( 'beforeunload.customize-confirm', function() { $( window ).on( 'beforeunload.customize-confirm', function() {
@ -8513,6 +8539,8 @@
}); });
} }
api.bind( 'change', startPromptingBeforeUnload ); api.bind( 'change', startPromptingBeforeUnload );
api.state( 'selectedChangesetStatus' ).bind( startPromptingBeforeUnload );
api.state( 'selectedChangesetDate' ).bind( startPromptingBeforeUnload );
function requestClose() { function requestClose() {
var clearedToClose = $.Deferred(), dismissAutoSave = false, dismissLock = false; var clearedToClose = $.Deferred(), dismissAutoSave = false, dismissLock = false;

File diff suppressed because one or more lines are too long

View File

@ -93,7 +93,7 @@ wp.mediaWidgets = ( function( $ ) {
* @returns {void} * @returns {void}
*/ */
initialize: function( options ) { initialize: function( options ) {
var view = this, embedController; // eslint-disable-line consistent-thi var view = this, embedController; // eslint-disable-line consistent-this
wp.media.view.Embed.prototype.initialize.call( view, options ); wp.media.view.Embed.prototype.initialize.call( view, options );
if ( 'image' !== view.controller.options.mimeType ) { if ( 'image' !== view.controller.options.mimeType ) {
embedController = view.controller.states.get( 'embed' ); embedController = view.controller.states.get( 'embed' );

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.9-beta3-41946'; $wp_version = '4.9-beta3-41947';
/** /**
* 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.