mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-02-22 01:29:39 +08:00
Adding utilities as instance
This commit is contained in:
parent
0dffe921ff
commit
e95ebc1b9e
@ -13,6 +13,11 @@ class SimpleKeyboard {
|
|||||||
if(!options)
|
if(!options)
|
||||||
options = {};
|
options = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializing Utilities
|
||||||
|
*/
|
||||||
|
this.utilities = new Utilities(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processing options
|
* Processing options
|
||||||
*/
|
*/
|
||||||
@ -41,7 +46,7 @@ class SimpleKeyboard {
|
|||||||
if(!window['SimpleKeyboardInstances'])
|
if(!window['SimpleKeyboardInstances'])
|
||||||
window['SimpleKeyboardInstances'] = {};
|
window['SimpleKeyboardInstances'] = {};
|
||||||
|
|
||||||
window['SimpleKeyboardInstances'][Utilities.camelCase(this.keyboardDOMClass)] = this;
|
window['SimpleKeyboardInstances'][this.utilities.camelCase(this.keyboardDOMClass)] = this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Physical Keyboard support
|
* Physical Keyboard support
|
||||||
@ -221,10 +226,9 @@ class SimpleKeyboard {
|
|||||||
/**
|
/**
|
||||||
* Iterating through each button in row
|
* Iterating through each button in row
|
||||||
*/
|
*/
|
||||||
rowArray.forEach((button) => {
|
let fctBtnClass = this.utilities.getButtonClass(button);
|
||||||
let fctBtnClass = Utilities.getButtonClass(button);
|
|
||||||
let buttonThemeClass = buttonThemesParsed[button];
|
let buttonThemeClass = buttonThemesParsed[button];
|
||||||
let buttonDisplayName = Utilities.getButtonDisplayName(button, this.options.display, this.options.mergeDisplay);
|
let buttonDisplayName = this.utilities.getButtonDisplayName(button, this.options.display, this.options.mergeDisplay);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creating button
|
* Creating button
|
||||||
|
@ -48,7 +48,7 @@ class Utilities {
|
|||||||
|
|
||||||
let buttonNormalized =
|
let buttonNormalized =
|
||||||
buttonTypeClass === "standardBtn" ?
|
buttonTypeClass === "standardBtn" ?
|
||||||
Utilities.normalizeString(buttonWithoutBraces) : ` hg-button-${buttonWithoutBraces}`;
|
this.normalizeString(buttonWithoutBraces) : ` hg-button-${buttonWithoutBraces}`;
|
||||||
|
|
||||||
return `hg-${buttonTypeClass}${buttonNormalized}`;
|
return `hg-${buttonTypeClass}${buttonNormalized}`;
|
||||||
}
|
}
|
||||||
@ -119,9 +119,9 @@ class Utilities {
|
|||||||
|
|
||||||
static getButtonDisplayName = (button, display, mergeDisplay) => {
|
static getButtonDisplayName = (button, display, mergeDisplay) => {
|
||||||
if(mergeDisplay){
|
if(mergeDisplay){
|
||||||
display = Object.assign({}, Utilities.getDefaultDiplay(), display);
|
display = Object.assign({}, this.getDefaultDiplay(), display);
|
||||||
} else {
|
} else {
|
||||||
display = display || Utilities.getDefaultDiplay();
|
display = display || this.getDefaultDiplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
return display[button] || button;
|
return display[button] || button;
|
||||||
|
Loading…
Reference in New Issue
Block a user