Compare commits

...
10 Commits
13 changed files with 72 additions and 17 deletions
-1
View File
@@ -6,7 +6,6 @@
<a href="https://travis-ci.org/hodgef/simple-keyboard" target="_blank"><img src="https://travis-ci.org/hodgef/simple-keyboard.svg?branch=master" alt="Build Status"></a>
<a href="https://codecov.io/gh/hodgef/simple-keyboard" target="_blank"><img src="https://img.shields.io/codecov/c/github/hodgef/simple-keyboard/master.svg?style=flat" alt="Coverage Status"></a>
<a href="https://doc.esdoc.org/github.com/hodgef/simple-keyboard" target="_blank"><img src="https://doc.esdoc.org/github.com/hodgef/simple-keyboard/badge.svg" alt="Documentation Status"></a>
<img src="https://img.shields.io/david/dev/hodgef/simple-keyboard.svg" alt="Dev dependencies">
<a href="https://www.codacy.com/app/hodgef/simple-keyboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=hodgef/simple-keyboard&amp;utm_campaign=Badge_Grade" target="_blank"><img src="https://api.codacy.com/project/badge/Grade/5778fccc6a894701853d9a1f2fb44a76" alt="Codacy Badge"></a>
</p>
</div>
+1 -1
View File
@@ -1,6 +1,6 @@
/*!
*
* simple-keyboard v2.17.0
* simple-keyboard v2.18.1
* https://github.com/hodgef/simple-keyboard
*
* Copyright (c) Francisco Hodge (https://github.com/hodgef)
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
/*!
*
* simple-keyboard v2.17.0 (Non-minified build)
* simple-keyboard v2.18.1 (Non-minified build)
* https://github.com/hodgef/simple-keyboard
*
* Copyright (c) Francisco Hodge (https://github.com/hodgef)
+10
View File
@@ -10,6 +10,11 @@ declare module 'simple-keyboard' {
}
interface KeyboardOptions {
/**
* Utilities
*/
utilities?: any;
/**
* Modify the keyboard layout.
*/
@@ -121,6 +126,11 @@ declare module 'simple-keyboard' {
*/
autoUseTouchEvents?: boolean;
/**
* Opt out of PointerEvents handling, falling back to the prior mouse event logic.
*/
useMouseEvents?: boolean;
/**
* Executes the callback function on key press. Returns button layout name (i.e.: "{shift}").
*/
+2 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+11 -4
View File
@@ -1,6 +1,6 @@
/*!
*
* simple-keyboard v2.17.0 (Non-minified build)
* simple-keyboard v2.18.1 (Non-minified build)
* https://github.com/hodgef/simple-keyboard
*
* Copyright (c) Francisco Hodge (https://github.com/hodgef)
@@ -849,6 +849,7 @@
* @property {object} inputPattern Restrains input(s) change to the defined regular expression pattern.
* @property {boolean} useTouchEvents Instructs simple-keyboard to use touch events instead of click events.
* @property {boolean} autoUseTouchEvents Enable useTouchEvents automatically when touch device is detected.
* @property {boolean} useMouseEvents Opt out of PointerEvents handling, falling back to the prior mouse event logic.
*/ this.options = options;
this.options.layoutName = this.options.layoutName || "default";
this.options.theme = this.options.theme || "hg-theme-default";
@@ -948,6 +949,11 @@
*/ }
if (typeof this.options.onChange === "function") {
this.options.onChange(this.input[this.options.inputName]);
/**
* Calling onChangeAll
*/ }
if (typeof this.options.onChangeAll === "function") {
this.options.onChangeAll(this.input);
}
}
if (debug) {
@@ -1047,7 +1053,7 @@
*/ if (this.options.syncInstanceInputs) {
this.syncInstanceInputs(this.input);
}
return this.input[this.options.inputName];
return this.input[inputName];
}
/**
* Set the keyboards input.
@@ -1373,7 +1379,7 @@
/**
* Notify about PointerEvents usage
*/ }
if (this.utilities.pointerEventsSupported() && !this.options.useTouchEvents) {
if (this.utilities.pointerEventsSupported() && !this.options.useTouchEvents && !this.options.useMouseEvents) {
if (this.options.debug) {
console.log("Using PointerEvents as it is supported by this browser");
}
@@ -1458,6 +1464,7 @@
var layout = this.options.layout || services_KeyboardLayout.getDefaultLayout();
var useTouchEvents = this.options.useTouchEvents || false;
var useTouchEventsClass = useTouchEvents ? "hg-touch-events" : "";
var useMouseEvents = this.options.useMouseEvents || false;
/**
* Account for buttonTheme, if set
*/ var buttonThemesParsed = Array.isArray(this.options.buttonTheme) ? this.getButtonTheme() : {};
@@ -1485,7 +1492,7 @@
buttonDOM.className += "hg-button ".concat(fctBtnClass).concat(buttonThemeClass ? " " + buttonThemeClass : "");
/**
* Handle button click event
*/ /* istanbul ignore next */ if (_this9.utilities.pointerEventsSupported() && !useTouchEvents) {
*/ /* istanbul ignore next */ if (_this9.utilities.pointerEventsSupported() && !useTouchEvents && !useMouseEvents) {
/**
* PointerEvents support
*/ buttonDOM.onpointerdown = function(e) {
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "simple-keyboard",
"version": "2.17.0",
"version": "2.18.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -5312,7 +5312,7 @@
},
"duplexer": {
"version": "0.1.1",
"resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
"resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
"integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=",
"dev": true
},
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "simple-keyboard",
"version": "2.17.0",
"version": "2.18.1",
"description": "On-screen Javascript Virtual Keyboard",
"main": "build/index.js",
"types": "build/index.d.ts",
+10
View File
@@ -10,6 +10,11 @@ declare module 'simple-keyboard' {
}
interface KeyboardOptions {
/**
* Utilities
*/
utilities?: any;
/**
* Modify the keyboard layout.
*/
@@ -121,6 +126,11 @@ declare module 'simple-keyboard' {
*/
autoUseTouchEvents?: boolean;
/**
* Opt out of PointerEvents handling, falling back to the prior mouse event logic.
*/
useMouseEvents?: boolean;
/**
* Executes the callback function on key press. Returns button layout name (i.e.: "{shift}").
*/
+16 -3
View File
@@ -63,6 +63,7 @@ class SimpleKeyboard {
* @property {object} inputPattern Restrains input(s) change to the defined regular expression pattern.
* @property {boolean} useTouchEvents Instructs simple-keyboard to use touch events instead of click events.
* @property {boolean} autoUseTouchEvents Enable useTouchEvents automatically when touch device is detected.
* @property {boolean} useMouseEvents Opt out of PointerEvents handling, falling back to the prior mouse event logic.
*/
this.options = options;
this.options.layoutName = this.options.layoutName || "default";
@@ -207,6 +208,12 @@ class SimpleKeyboard {
*/
if (typeof this.options.onChange === "function")
this.options.onChange(this.input[this.options.inputName]);
/**
* Calling onChangeAll
*/
if (typeof this.options.onChangeAll === "function")
this.options.onChangeAll(this.input);
}
if (debug) {
@@ -312,7 +319,7 @@ class SimpleKeyboard {
*/
if (this.options.syncInstanceInputs) this.syncInstanceInputs(this.input);
return this.input[this.options.inputName];
return this.input[inputName];
}
/**
@@ -723,7 +730,8 @@ class SimpleKeyboard {
*/
if (
this.utilities.pointerEventsSupported() &&
!this.options.useTouchEvents
!this.options.useTouchEvents &&
!this.options.useMouseEvents
) {
if (this.options.debug) {
console.log("Using PointerEvents as it is supported by this browser");
@@ -843,6 +851,7 @@ class SimpleKeyboard {
let layout = this.options.layout || KeyboardLayout.getDefaultLayout();
let useTouchEvents = this.options.useTouchEvents || false;
let useTouchEventsClass = useTouchEvents ? "hg-touch-events" : "";
let useMouseEvents = this.options.useMouseEvents || false;
/**
* Account for buttonTheme, if set
@@ -895,7 +904,11 @@ class SimpleKeyboard {
* Handle button click event
*/
/* istanbul ignore next */
if (this.utilities.pointerEventsSupported() && !useTouchEvents) {
if (
this.utilities.pointerEventsSupported() &&
!useTouchEvents &&
!useMouseEvents
) {
/**
* PointerEvents support
*/
+16
View File
@@ -186,6 +186,22 @@ it('Keyboard onChange will work', () => {
expect(output).toBe("q");
});
it('Keyboard onChangeAll will work', () => {
testUtil.setDOM();
let output;
let keyboard = new Keyboard({
onChangeAll: (input) => {
output = input ? input.default : null;
}
});
keyboard.getButtonElement("q").onclick();
expect(output).toBe("q");
});
it('Keyboard clearInput will work', () => {
testUtil.setDOM();