fix(web): Use util.internalAlert() wrapper

This commit is contained in:
Darcy Wong 2021-06-24 13:02:49 +07:00
parent e5e1ccff4e
commit c8f7a4cdf4
3 changed files with 18 additions and 16 deletions

View file

@ -570,11 +570,9 @@ namespace com.keyman.keyboards {
// Thanks, Closure errors.
if(!this.keymanweb.isEmbedded) {
util.wait(false);
if (this.keymanweb.options.useAlerts) {
util.alert(altString || msg, function() {
util.internalAlert(altString || msg, function() {
this.keymanweb['setActiveKeyboard'](''); // The API call!
}.bind(this));
}
}.bind(this));
}
switch(msgType) { // in case we extend this later.
@ -949,9 +947,7 @@ namespace com.keyman.keyboards {
if(typeof(x[i]['filename']) == 'string') {
if(!this.addStub(x[i])) {
if (this.keymanweb.options.useAlerts) {
this.keymanweb.util.alert('To use a custom keyboard, you must specify file name, keyboard name, language, language code and region code.');
}
this.keymanweb.util.internalAlert('To use a custom keyboard, you must specify file name, keyboard name, language, language code and region code.');
}
} else {
if(x[i]['language']) {
@ -1331,9 +1327,7 @@ namespace com.keyman.keyboards {
private alertLanguageUnavailable(languageName: string): string {
let msg = 'No keyboards are available for '+ languageName + '. '
+'Does it have another language name?';
if (this.keymanweb.options.useAlerts) {
this.keymanweb.util.alert(msg);
}
this.keymanweb.util.internalAlert(msg);
return msg;
}
@ -1344,9 +1338,7 @@ namespace com.keyman.keyboards {
*
**/
private serverUnavailable(cmd) {
if (this.keymanweb.options.useAlerts) {
this.keymanweb.util.alert(cmd == '' ? 'Unable to connect to Keyman Cloud server!' : cmd);
}
this.keymanweb.util.internalAlert(cmd == '' ? 'Unable to connect to Keyman Cloud server!' : cmd);
this.keymanweb.warned=true;
}

View file

@ -971,6 +971,18 @@ namespace com.keyman {
}
/**
* Customized internal alert. This is enabled/disabled by the option flag 'useAlerts'
*
* @param {string} s alert text
* @param {function()=} fn function to call when alert dismissed
*/
internalAlert(s: string, fn?: () => void): void {
if (this.keyman.options.useAlerts) {
this.alert(s, fn);
}
}
/**
* Prepare the background and keyboard loading wait message box
* Should not be called before options are defined during initialization

View file

@ -465,10 +465,8 @@ namespace com.keyman.osk {
*/
showBuild() {
let keymanweb = com.keyman.singleton;
if (keymanweb.options.useAlerts) {
keymanweb.util.alert('KeymanWeb Version '+keymanweb['version']+'.'+keymanweb['build']+'<br /><br />'
keymanweb.util.internalAlert('KeymanWeb Version '+keymanweb['version']+'.'+keymanweb['build']+'<br /><br />'
+'<span style="font-size:0.8em">Copyright &copy; 2017 SIL International</span>');
}
}
/**