diff --git a/web/source/keyboards/kmwkeyboards.ts b/web/source/keyboards/kmwkeyboards.ts
index c244dd59b0..dfafc541cd 100644
--- a/web/source/keyboards/kmwkeyboards.ts
+++ b/web/source/keyboards/kmwkeyboards.ts
@@ -59,6 +59,8 @@ namespace com.keyman.keyboards {
'KFont': KeyboardFont;
'KOskFont': KeyboardFont;
+ 'displayName': string; // Display name as shown on spacebar
+
// Used when loading a stub's keyboard.
asyncLoader?: any;
@@ -271,6 +273,7 @@ namespace com.keyman.keyboards {
sp['KR'] = (typeof sp['KR'] === 'undefined') ? KeyboardManager.regions[rIndex] : sp['KR'];
sp['KRC'] = (typeof sp['KRC'] === 'undefined') ? KeyboardManager.regionCodes[rIndex] : sp['KRC'];
sp['KN'] = (typeof sp['KN'] === 'undefined') ? kp['name'] : sp['KN'];
+ sp['displayName'] = (typeof sp['displayName'] === 'undefined') ? kp['displayName'] : sp['displayName'];
if(typeof(sp['KF']) == 'undefined') {
rx=RegExp('^(([\\.]/)|([\\.][\\.]/)|(/))|(:)');
@@ -658,7 +661,7 @@ namespace com.keyman.keyboards {
manager.keymanweb.uiManager.justActivated = true; // TODO: Resolve without need for the cast.
manager.keymanweb.domManager._SetTargDir(manager.keymanweb.domManager.getLastActiveElement());
}
-
+
manager.saveCurrentKeyboard(kbd['KI'], kbdStub['KLC']);
// Prepare and show the OSK for this keyboard
diff --git a/web/source/kmwbase.ts b/web/source/kmwbase.ts
index 08e35c3d19..950577c318 100644
--- a/web/source/kmwbase.ts
+++ b/web/source/kmwbase.ts
@@ -24,10 +24,18 @@
///
/***
- KeymanWeb 11.0
- Copyright 2017-2019 SIL International
+ KeymanWeb 14.0
+ Copyright 2017-2021 SIL International
***/
namespace com.keyman {
+
+ export enum SpacebarText {
+ KEYBOARD = 'keyboard',
+ LANGUAGE = 'language',
+ LANGUAGE_KEYBOARD = 'languageKeyboard',
+ BLANK = 'blank'
+ };
+
export class KeymanBase {
_TitleElement = null; // I1972 - KeymanWeb Titlebar should not be a link
_IE = 0; // browser version identification
@@ -80,7 +88,8 @@ namespace com.keyman {
'fonts':'',
'attachType':'',
'ui':null,
- 'setActiveOnRegister':'true'
+ 'setActiveOnRegister':'true',
+ 'spacebarText':SpacebarText.LANGUAGE_KEYBOARD
};
diff --git a/web/source/osk/visualKeyboard.ts b/web/source/osk/visualKeyboard.ts
index 9a7b493448..ef8e266bfc 100644
--- a/web/source/osk/visualKeyboard.ts
+++ b/web/source/osk/visualKeyboard.ts
@@ -124,7 +124,7 @@ namespace com.keyman.osk {
}
// re-use canvas object for better performance
- var canvas: HTMLCanvasElement = OSKKey.getTextMetrics['canvas'] ||
+ var canvas: HTMLCanvasElement = OSKKey.getTextMetrics['canvas'] ||
(OSKKey.getTextMetrics['canvas'] = document.createElement("canvas"));
var context = canvas.getContext("2d");
context.font = fontSize + " " + fontFamily;
@@ -748,8 +748,8 @@ namespace com.keyman.osk {
} else if(newWidth > 0.9*screen.width) {
newWidth=0.9*screen.width;
}
-
- // Default height decision made here:
+
+ // Default height decision made here:
// https://github.com/keymanapp/keyman/pull/4279#discussion_r560453929
newHeight=util.toNumber(c['height'], 0.333 * newWidth);
@@ -764,8 +764,8 @@ namespace com.keyman.osk {
/**
* Sets & tracks the size of the VisualKeyboard's primary element.
- * @param width
- * @param height
+ * @param width
+ * @param height
* @param pending Set to `true` if called during a resizing interaction
*/
public setSize(width: number, height: number, pending?: boolean) {
@@ -1839,7 +1839,7 @@ namespace com.keyman.osk {
// Preference order:
// #1: if a default subkey has been specified, select it. (pending, for 15.0+)
- // #2: if no default subkey is specified, default to a subkey with the same
+ // #2: if no default subkey is specified, default to a subkey with the same
// key ID and layer / modifier spec.
//if(skSpec.isDefault) { TODO for 15.0
// bk = skElement;
@@ -1870,16 +1870,36 @@ namespace com.keyman.osk {
showLanguage() {
let keyman = com.keyman.singleton;
- var lgName='',kbdName='';
- var activeStub = keyman.keyboardManager.activeStub;
+ let displayName: string = undefined;
+ let activeStub = keyman.keyboardManager.activeStub;
if(activeStub) {
- lgName=activeStub['KL'];
- kbdName=activeStub['KN'];
- } else if(keyman.getActiveLanguage(true)) {
- lgName=keyman.getActiveLanguage(true);
+ if(activeStub['displayName']) {
+ displayName = activeStub['displayName'];
+ } else {
+ let
+ lgName: string = activeStub['KL'],
+ kbdName: string = activeStub['KN'];
+ kbdName = kbdName.replace(/\s*keyboard\s*/i,'');
+ switch(keyman.options['spacebarText']) {
+ case SpacebarText.KEYBOARD:
+ displayName = kbdName;
+ break;
+ case SpacebarText.LANGUAGE:
+ displayName = lgName;
+ break;
+ case SpacebarText.LANGUAGE_KEYBOARD:
+ displayName = (kbdName == lgName) ? lgName : lgName + ' - ' + kbdName;
+ break;
+ case SpacebarText.BLANK:
+ displayName = '';
+ break;
+ default:
+ displayName = kbdName;
+ }
+ }
} else {
- lgName='(System keyboard)';
+ displayName = '(System keyboard)';
}
try {
@@ -1891,19 +1911,13 @@ namespace com.keyman.osk {
tParent.className +=' kmw-spacebar';
}
- t.className='kmw-spacebar-caption';
- kbdName=kbdName.replace(/\s*keyboard\s*/i,'');
-
- // We use a separate variable here to keep down on MutationObserver messages in keymanweb.js code.
- var keyboardName = "";
- if(kbdName == lgName) {
- keyboardName=lgName;
- } else {
- keyboardName=lgName+' ('+kbdName+')';
+ if(t.className != 'kmw-spacebar-caption') {
+ t.className='kmw-spacebar-caption';
}
+
// It sounds redundant, but this dramatically cuts down on browser DOM processing.
- if(t.innerHTML != keyboardName) {
- t.innerHTML = keyboardName;
+ if(t.innerText != displayName) {
+ t.innerText = displayName;
}
}
catch(ex){}
diff --git a/web/testing/index.html b/web/testing/index.html
index 458afdc8ba..712d921bed 100644
--- a/web/testing/index.html
+++ b/web/testing/index.html
@@ -53,6 +53,7 @@
+
Return to main index.