mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2026-02-03 00:06:50 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd909cffa8 | ||
|
|
92d2b381db | ||
|
|
96206d1b47 | ||
|
|
19f6ac9ac1 | ||
|
|
90b67ec416 | ||
|
|
6208d5f7e1 | ||
|
|
bd0274415b | ||
|
|
30941f4ba0 | ||
|
|
48a15e6715 | ||
|
|
f8ee859bb0 |
@@ -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&utm_medium=referral&utm_content=hodgef/simple-keyboard&utm_campaign=Badge_Grade" target="_blank"><img src="https://api.codacy.com/project/badge/Grade/5778fccc6a894701853d9a1f2fb44a76" alt="Codacy Badge"></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -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,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
build/index.d.ts
vendored
10
build/index.d.ts
vendored
@@ -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}").
|
||||
*/
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -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 keyboard’s 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) {
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -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,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
src/lib/@types/index.d.ts
vendored
10
src/lib/@types/index.d.ts
vendored
@@ -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}").
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user