Fix the logic of apply and cancel actions
* Refactored the Cancel button handler code to cancel method in display settings and input settings. * When the user makes changes in multiple modules and clicks the Cancel button or closes the language settings after that, cancel the changes in all the modules. See bug 50564. * The Apply button was always active in input methods module. Fixed the logic for that. * Renamed the enableApplyButton method to markDirty in both modules. * Introduced isDirty attribute to the modules for optimizing the Cancel method to avoid unnecessary restore actions. * More minor cleanup and documentation. Bug: 50564 Change-Id: I71f527bfb7dd7f6724e4365371ac3e4fc0723ed6
This commit is contained in:
committed by
Amir E. Aharoni
parent
2159822145
commit
f11ef736a4
@@ -49,6 +49,7 @@
|
||||
this.initialized = false;
|
||||
this.left = this.options.left;
|
||||
this.top = this.options.top;
|
||||
this.modules = {},
|
||||
this.$settingsPanel = this.$window.find( '#languagesettings-settings-panel' );
|
||||
this.init();
|
||||
this.listen();
|
||||
@@ -72,8 +73,8 @@
|
||||
$( 'html' ).click( $.proxy( this.hide, this ) );
|
||||
|
||||
// ... but when clicked on window do not hide.
|
||||
this.$window.on( 'click', function ( e ) {
|
||||
e.stopPropagation();
|
||||
this.$window.on( 'click', function ( event ) {
|
||||
event.stopPropagation();
|
||||
} );
|
||||
},
|
||||
|
||||
@@ -141,6 +142,7 @@
|
||||
module.render();
|
||||
$settingsLink.addClass( 'active' );
|
||||
}
|
||||
this.modules[moduleName] = module;
|
||||
},
|
||||
|
||||
position: function () {
|
||||
@@ -204,11 +206,24 @@
|
||||
* call onClose if defined from the previous context.
|
||||
*/
|
||||
close: function () {
|
||||
if ( !this.shown ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.hide();
|
||||
|
||||
// optional callback
|
||||
if ( this.options.onClose ) {
|
||||
this.options.onClose();
|
||||
}
|
||||
|
||||
// We are closing language settings. That also means we are cancelling
|
||||
// any changes the user did, but not saved, in all registered modules.
|
||||
$.each( this.modules, function( id, module ) {
|
||||
// Modules should make sure to return early if no changes were made
|
||||
// They can use some kind of 'dirty bits' to implement this.
|
||||
module.cancel();
|
||||
} );
|
||||
},
|
||||
|
||||
click: function ( e ) {
|
||||
|
||||
Reference in New Issue
Block a user