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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -347,7 +347,15 @@
*/ this.simpleKeyboardInstance = simpleKeyboardInstance;
/**
* 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);
}
/**
* Adds default classes to a given button
@ -660,14 +668,12 @@
return "ontouchstart" in window || navigator.maxTouchPoints;
}
/**
* Bind all methods in a given class
*/ }, {
key: "camelCase",
/**
* Transforms an arbitrary string to camelCase
*
* @param {string} string The string to transform.
*/ value: function camelCase(string) {
*/ }, {
key: "camelCase",
value: function camelCase(string) {
return string.toLowerCase().trim().split(/[.\-_\s]/g).reduce(function(string, word) {
return word.length ? string + word[0].toUpperCase() + word.slice(1) : string;
});
@ -684,35 +690,6 @@
return n + (x === value);
}, 0);
}
} ], [ {
key: "bindMethods",
value: function bindMethods(myClass, instance) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = Object.getOwnPropertyNames(myClass.prototype)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var myMethod = _step.value;
var excludeMethod = myMethod === "constructor" || myMethod === "bindMethods";
if (!excludeMethod) {
instance[myMethod] = instance[myMethod].bind(instance);
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
} ]);
return Utilities;
}();
@ -852,7 +829,33 @@
*/ this.keyboardPluginClasses = "";
/**
* Bindings
*/ services_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`).
* This removes any dependency to input DOM elements. You can type and directly display the value in a div element, for example.

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();
}

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();

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
*