mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-03-16 08:21:07 +08:00
Adding Multiple Input support
This commit is contained in:
parent
276a478eb6
commit
f8ebb30d76
@ -17,9 +17,12 @@ class SimpleKeyboard {
|
|||||||
*/
|
*/
|
||||||
this.keyboardDOM = document.querySelector(keyboardDOMQuery);
|
this.keyboardDOM = document.querySelector(keyboardDOMQuery);
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.input = '';
|
|
||||||
this.options.layoutName = this.options.layoutName || "default";
|
this.options.layoutName = this.options.layoutName || "default";
|
||||||
this.options.theme = this.options.theme || "hg-theme-default";
|
this.options.theme = this.options.theme || "hg-theme-default";
|
||||||
|
this.options.inputName = this.options.inputName || "default";
|
||||||
|
this.input = {};
|
||||||
|
this.input[this.options.inputName] = '';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rendering keyboard
|
* Rendering keyboard
|
||||||
@ -52,10 +55,13 @@ class SimpleKeyboard {
|
|||||||
newLineOnEnter: (this.options.newLineOnEnter === true)
|
newLineOnEnter: (this.options.newLineOnEnter === true)
|
||||||
}
|
}
|
||||||
|
|
||||||
let updatedInput = Utilities.getUpdatedInput(button, this.input, options);
|
if(!this.input[this.options.inputName])
|
||||||
|
this.input[this.options.inputName] = '';
|
||||||
|
|
||||||
if(this.input !== updatedInput){
|
let updatedInput = Utilities.getUpdatedInput(button, this.input[this.options.inputName], options);
|
||||||
this.input = updatedInput;
|
|
||||||
|
if(this.input[this.options.inputName] !== updatedInput){
|
||||||
|
this.input[this.options.inputName] = updatedInput;
|
||||||
|
|
||||||
if(debug)
|
if(debug)
|
||||||
console.log('Input changed:', this.input);
|
console.log('Input changed:', this.input);
|
||||||
@ -64,7 +70,7 @@ class SimpleKeyboard {
|
|||||||
* Calling onChange
|
* Calling onChange
|
||||||
*/
|
*/
|
||||||
if(typeof this.options.onChange === "function")
|
if(typeof this.options.onChange === "function")
|
||||||
this.options.onChange(this.input);
|
this.options.onChange(this.input[this.options.inputName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(debug){
|
if(debug){
|
||||||
@ -72,16 +78,19 @@ class SimpleKeyboard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clearInput = () => {
|
clearInput = (inputName) => {
|
||||||
this.input = '';
|
inputName = inputName || this.options.inputName;
|
||||||
|
this.input[this.options.inputName] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
getInput = () => {
|
getInput = (inputName) => {
|
||||||
return this.input;
|
inputName = inputName || this.options.inputName;
|
||||||
|
return this.input[this.options.inputName];
|
||||||
}
|
}
|
||||||
|
|
||||||
setInput = input => {
|
setInput = (input, inputName) => {
|
||||||
this.input = input;
|
inputName = inputName || this.options.inputName;
|
||||||
|
this.input[inputName] = input;
|
||||||
}
|
}
|
||||||
|
|
||||||
setOptions = option => {
|
setOptions = option => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user