Build update

This commit is contained in:
Francisco Hodge
2019-03-06 20:00:48 -05:00
parent 0d82696868
commit ec983bf82b
6 changed files with 102 additions and 56 deletions
+27 -4
View File
@@ -79,7 +79,33 @@ class SimpleKeyboard {
/**
* Bindings
*/
Utilities.bindMethods(SimpleKeyboard, this);
this.handleButtonClicked = this.handleButtonClicked.bind(this);
this.syncInstanceInputs = this.syncInstanceInputs.bind(this);
this.clearInput = this.clearInput.bind(this);
this.getInput = this.getInput.bind(this);
this.setInput = this.setInput.bind(this);
this.replaceInput = this.replaceInput.bind(this);
this.clear = this.clear.bind(this);
this.dispatch = this.dispatch.bind(this);
this.addButtonTheme = this.addButtonTheme.bind(this);
this.removeButtonTheme = this.removeButtonTheme.bind(this);
this.getButtonElement = this.getButtonElement.bind(this);
this.handleCaret = this.handleCaret.bind(this);
this.caretEventHandler = this.caretEventHandler.bind(this);
this.onInit = this.onInit.bind(this);
this.onRender = this.onRender.bind(this);
this.render = this.render.bind(this);
this.loadModules = this.loadModules.bind(this);
this.handleButtonMouseUp = this.handleButtonMouseUp.bind(this);
this.handleButtonMouseDown = this.handleButtonMouseDown.bind(this);
this.handleButtonHold = this.handleButtonHold.bind(this);
this.onModulesLoaded = this.onModulesLoaded.bind(this);
this.inputPatternIsValid = this.inputPatternIsValid.bind(this);
this.beforeFirstRender = this.beforeFirstRender.bind(this);
this.beforeRender = this.beforeRender.bind(this);
this.disableContextualWindow = this.disableContextualWindow.bind(this);
this.onTouchDeviceDetected = this.onTouchDeviceDetected.bind(this);
this.processAutoTouchEvents = this.processAutoTouchEvents.bind(this);
/**
* simple-keyboard uses a non-persistent internal input to keep track of the entered string (the variable `keyboard.input`).
@@ -647,7 +673,6 @@ class SimpleKeyboard {
return buttonThemesParsed;
}
/* istanbul ignore next */
onTouchDeviceDetected() {
/**
* Processing autoTouchEvents
@@ -677,7 +702,6 @@ class SimpleKeyboard {
/**
* Process autoTouchEvents option
*/
/* istanbul ignore next */
processAutoTouchEvents() {
if (this.options.autoUseTouchEvents) {
this.options.useTouchEvents = true;
@@ -713,7 +737,6 @@ class SimpleKeyboard {
/**
* Performing actions when touch device detected
*/
/* istanbul ignore next */
if (this.utilities.isTouchDevice()) {
this.onTouchDeviceDetected();
}
+25
View File
@@ -977,6 +977,31 @@ it('Keyboard inputPattern will work by input name', () => {
expect(keyboard.getInput()).toBe("q1");
});
it('Keyboard processAutoTouchEvents will work', () => {
testUtil.setDOM();
navigator.maxTouchPoints = true;
let keyboard = new Keyboard({
autoUseTouchEvents: true
});
expect(keyboard.options.useTouchEvents).toBeTruthy();
});
it('Keyboard processAutoTouchEvents will work with debugging enabled', () => {
testUtil.setDOM();
navigator.maxTouchPoints = true;
let keyboard = new Keyboard({
autoUseTouchEvents: true,
debug: true
});
expect(keyboard.options.useTouchEvents).toBeTruthy();
});
it('Keyboard beforeFirstRender method will work', () => {
testUtil.setDOM();
+9 -14
View File
@@ -14,7 +14,15 @@ class Utilities {
/**
* Bindings
*/
Utilities.bindMethods(Utilities, this);
this.getButtonClass = this.getButtonClass.bind(this);
this.getButtonDisplayName = this.getButtonDisplayName.bind(this);
this.getUpdatedInput = this.getUpdatedInput.bind(this);
this.updateCaretPos = this.updateCaretPos.bind(this);
this.updateCaretPosAction = this.updateCaretPosAction.bind(this);
this.isMaxLengthReached = this.isMaxLengthReached.bind(this);
this.camelCase = this.camelCase.bind(this);
this.countInArray = this.countInArray.bind(this);
this.isTouchDevice = this.isTouchDevice.bind(this);
}
/**
@@ -372,19 +380,6 @@ class Utilities {
return "ontouchstart" in window || navigator.maxTouchPoints;
}
/**
* Bind all methods in a given class
*/
static bindMethods(myClass, instance) {
for (let myMethod of Object.getOwnPropertyNames(myClass.prototype)) {
let excludeMethod =
myMethod === "constructor" || myMethod === "bindMethods";
if (!excludeMethod) {
instance[myMethod] = instance[myMethod].bind(instance);
}
}
}
/**
* Transforms an arbitrary string to camelCase
*