Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Update save button disable condition for 4.6.x when theme is changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
mohdsayed committed Mar 15, 2017
1 parent cc2f54d commit 26f7316
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions js/compat/customize-snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@
addButtons: function addButtons() {
var snapshot = this,
header = $( '#customize-header-actions' ),
templateData = {}, setPreviewLinkHref;
disableButton = true,
templateData = {}, setPreviewLinkHref, currentTheme,
savedPreviewingTheme, themeNotActiveOrSaved;

snapshot.publishButton = header.find( '#save' );
snapshot.spinner = header.find( '.spinner' );
Expand All @@ -270,12 +272,17 @@
snapshot.snapshotButton.attr( 'title', api.state( 'snapshot-exists' ).get() ? snapshot.data.i18n.permsMsg.update : snapshot.data.i18n.permsMsg.save );
}

if ( api.state( 'activated' ).get() ) {
snapshot.snapshotButton.prop( 'disabled', true );
} else if ( ! api.state( 'activated' ).get() && snapshot.data.previewingTheme ) {
snapshot.snapshotButton.prop( 'disabled', true );
currentTheme = api.settings.theme.stylesheet; // Or previewing theme.
savedPreviewingTheme = snapshot.data.previewingTheme;
themeNotActiveOrSaved = ! api.state( 'activated' ).get() && ! savedPreviewingTheme;
snapshot.isNotSavedPreviewingTheme = savedPreviewingTheme && savedPreviewingTheme !== currentTheme;

if ( themeNotActiveOrSaved || snapshot.isNotSavedPreviewingTheme ) {
disableButton = false;
}

snapshot.snapshotButton.prop( 'disabled', disableButton );

snapshot.snapshotButton.on( 'click', function( event ) {
var status;
event.preventDefault();
Expand Down

0 comments on commit 26f7316

Please sign in to comment.