mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-01-19 16:52:59 +08:00
getButtonElement functionality
This commit is contained in:
parent
e95ebc1b9e
commit
282e84941a
@ -30,6 +30,7 @@ class SimpleKeyboard {
|
||||
this.input[this.options.inputName] = '';
|
||||
this.keyboardDOMClass = keyboardDOMQuery.split('.').join("");
|
||||
this.timers = {};
|
||||
this.buttonElements = {};
|
||||
|
||||
/**
|
||||
* Rendering keyboard
|
||||
@ -171,6 +172,22 @@ class SimpleKeyboard {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
getButtonElement = (button) => {
|
||||
let output;
|
||||
|
||||
let buttonArr = this.buttonElements[button];
|
||||
if(buttonArr){
|
||||
if(buttonArr.length > 1){
|
||||
output = buttonArr;
|
||||
} else {
|
||||
output = buttonArr[0];
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
render = () => {
|
||||
/**
|
||||
* Clear keyboard
|
||||
@ -245,9 +262,12 @@ class SimpleKeyboard {
|
||||
buttonDOM.appendChild(buttonSpanDOM);
|
||||
|
||||
/**
|
||||
* Appending button to row
|
||||
* Adding to buttonElements
|
||||
*/
|
||||
rowDOM.appendChild(buttonDOM);
|
||||
if(!this.buttonElements[button])
|
||||
this.buttonElements[button] = [];
|
||||
|
||||
this.buttonElements[button].push(buttonDOM);
|
||||
|
||||
/**
|
||||
* Calling onInit
|
||||
|
Loading…
Reference in New Issue
Block a user