Handle Apply button little bit more sanely

Change-Id: I55d48de703662f139549d764bf7c1f235111d5ab
This commit is contained in:
Niklas Laxström
2020-10-28 09:41:11 +01:00
committed by jenkins-bot
parent 740ff490e0
commit 79a038f166
3 changed files with 11 additions and 8 deletions

View File

@@ -60,6 +60,7 @@
this.top = this.options.top;
this.modules = {};
this.$settingsPanel = this.$window.find( '#languagesettings-settings-panel' );
this.$applyButton = this.$window.find( '.uls-settings-apply' );
this.init();
this.listen();
}
@@ -78,7 +79,7 @@
this.$window.find( '#languagesettings-close, button.uls-settings-cancel' )
.on( 'click', mw.hook( 'mw.uls.settings.cancel' ).fire.bind( this ) );
this.$window.find( 'button.uls-settings-apply' )
this.$applyButton
.on( 'click', mw.hook( 'mw.uls.settings.apply' ).fire.bind( this ) );
// Hide the window when clicked outside
$( document.documentElement ).on( 'click', this.hide.bind( this ) );
@@ -240,16 +241,14 @@
* false to unset the busy mode.
*/
setBusy: function ( busy ) {
var $applyButton = this.$window.find( 'button.uls-settings-apply' );
if ( busy ) {
this.$window.addClass( 'waiting' );
$applyButton
this.$applyButton
.text( $.i18n( 'ext-uls-language-settings-applying' ) )
.prop( 'disabled', true );
} else {
this.$window.removeClass( 'waiting' );
$applyButton.text( $.i18n( 'ext-uls-language-settings-apply' ) );
this.$applyButton.text( $.i18n( 'ext-uls-language-settings-apply' ) );
}
},
@@ -282,8 +281,12 @@
}
},
enableApplyButton: function () {
this.$applyButton.prop( 'disabled', false );
},
disableApplyButton: function () {
this.$window.find( 'button.uls-settings-apply' ).prop( 'disabled', true );
this.$applyButton.prop( 'disabled', true );
}
};