Skip to content

Commit 5d44abd

Browse files
committed
Version 2.2.0
- #53 - #52 - #51 - #46
1 parent ff4c54c commit 5d44abd

17 files changed

+86
-67
lines changed

.dev/dev-allinone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* All In One Generator
33
*
44
* Description: Creates "kioskboard-aio.js" file automatically from "kioskboard.js" and "kioskboard.css" files.
5-
* Version: 2.1.0
5+
* Version: 2.2.0
66
* Author: Furkan MT ('https://github.com/furcan')
77
* Copyright 2022 All In One Generator, MIT Licence ('https://opensource.org/licenses/MIT')
88
*/

.dev/dev-constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* Constants
33
* Description: Constants for the development.
4-
* Version: 2.1.0
4+
* Version: 2.2.0
55
* Author: Furkan MT ('https://github.com/furcan')
66
* Copyright 2022 Constants, MIT Licence ('https://opensource.org/licenses/MIT')
77
*/

.dev/dev-minifier.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Minifier
33
*
44
* Description: Minify the KioskBoard scripts, and clean the KioskBoard styles to the distribution. (Used "Babel Minify", and "Clean CSS")
5-
* Version: 2.1.0
5+
* Version: 2.2.0
66
* Author: Furkan MT ('https://github.com/furcan')
77
* Copyright 2022 Minifier, MIT Licence ('https://opensource.org/licenses/MIT')
88
*/
@@ -126,6 +126,5 @@ if (existsSync(Constants.dirInputDev) && existsSync(Constants.dirOutputDev)) { /
126126
// Script (All In One): end
127127
} else {
128128
Constants.terminalError(`The "${!existsSync(Constants.dirInputDev) ? Constants.dirInputDev : Constants.dirOutputDev}" directory does not exist in the root directory.`, `${thisFilePath} => Line: 128`);
129-
return false;
130129
}
131130
// Minify: end

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
@2.2.0
2+
* **Added:** Using KioskBoard in embedded webview - https://github.com/furcan/KioskBoard/pull/51 (Thanks [surexxx](https://github.com/surexxx))
3+
* **Added:** Add long press feature - https://github.com/furcan/KioskBoard/pull/53 (Thanks [surexxx](https://github.com/surexxx))
4+
* **Fixed:** Fix the autofocus behavior - https://github.com/furcan/KioskBoard/pull/52 (Thanks [surexxx](https://github.com/surexxx))
5+
* **Fixed:** Avoiding CORS in Electron - https://github.com/furcan/KioskBoard/issues/46
6+
* **Changed:** Refactor.
7+
8+
-----
9+
110
@2.1.0
211
* **Added:** Input based `data-kioskboard-placement` data attribute option has been added. This option sets the placement of the keyboard on `top` or `bottom` for each input/textarea element. The default value is `bottom`.
312

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ A pure JavaScript library for using virtual keyboards.
2222
---------
2323

2424
## Current Version
25-
2.1.0 [*](https://github.com/furcan/KioskBoard/blob/main/CHANGELOG.md)
25+
2.2.0 [*](https://github.com/furcan/KioskBoard/blob/main/CHANGELOG.md)
2626

2727
---------
2828

@@ -59,15 +59,15 @@ import KioskBoard from 'kioskboard';
5959
### CSS and JS
6060

6161
```html
62-
<link rel="stylesheet" href="dist/kioskboard-2.1.0.min.css" />
62+
<link rel="stylesheet" href="dist/kioskboard-2.2.0.min.css" />
6363

64-
<script src="dist/kioskboard-2.1.0.min.js"></script>
64+
<script src="dist/kioskboard-2.2.0.min.js"></script>
6565
```
6666

6767
### Or only JS (All in One - Internal CSS)
6868

6969
```html
70-
<script src="dist/kioskboard-aio-2.1.0.min.js"></script>
70+
<script src="dist/kioskboard-aio-2.2.0.min.js"></script>
7171
```
7272

7373
---------

build/kioskboard-aio.js

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* KioskBoard - Virtual Keyboard ('https://github.com/furcan/KioskBoard')
33
* Description: This file contains the KioskBoard CSS codes as internal to use the KioskBoard as one file. This file has been created automatically from using the "kioskboard.js", and "kioskboard.css" files.
4-
* Version: 2.1.0
4+
* Version: 2.2.0
55
* Author: Furkan MT ('https://github.com/furcan')
66
* Copyright 2022 KioskBoard - Virtual Keyboard, MIT Licence ('https://opensource.org/licenses/MIT')*
77
*/
@@ -572,14 +572,31 @@
572572
}, false);
573573
// input element keypress listener: end
574574

575+
// keys event listeners: begin
576+
var keysEventListeners = function (keyElement, onClickHandler) {
577+
if (keyElement) {
578+
var isTouchableDevice = 'ontouchend' in window || window.navigator.maxTouchPoints > 0;
579+
580+
if (isTouchableDevice) {
581+
keyElement.addEventListener('contextmenu', function (event) {
582+
event.preventDefault();
583+
}, false);
584+
keyElement.addEventListener('touchend', onClickHandler);
585+
}
586+
587+
keyElement.addEventListener('click', onClickHandler);
588+
}
589+
};
590+
// keys event listeners: end
591+
575592
// keys click listeners: begin
576593
var keysClickListeners = function (input) {
577594
// each key click listener: begin
578595
var eachKeyElm = window.document.getElementById(kioskBoardVirtualKeyboard.id).getElementsByClassName('kioskboard-key');
579596
if (eachKeyElm && eachKeyElm.length > 0) {
580597
for (var ekIndex = 0; ekIndex < eachKeyElm.length; ekIndex++) {
581598
var keyElm = eachKeyElm[ekIndex];
582-
keyElm.addEventListener('click', function (e) {
599+
keysEventListeners(keyElm, function (e) {
583600
e.preventDefault();
584601

585602
// check input max & maxlength
@@ -621,15 +638,15 @@
621638
// input trigger change event for update the value
622639
input.dispatchEvent(changeEvent);
623640
}
624-
}, false);
641+
});
625642
}
626643
}
627644
// each key click listener: end
628645

629646
// capslock key click listener: begin
630647
var capsLockKeyElm = window.document.getElementById(kioskBoardVirtualKeyboard.id).getElementsByClassName('kioskboard-key-capslock')[0];
631648
if (capsLockKeyElm) {
632-
capsLockKeyElm.addEventListener('click', function (e) {
649+
keysEventListeners(capsLockKeyElm, function (e) {
633650
e.preventDefault();
634651
// focus the input
635652
input.focus();
@@ -645,14 +662,14 @@
645662
kioskBoardVirtualKeyboard.classList.add('kioskboard-touppercase');
646663
isCapsLockActive = true;
647664
}
648-
}, false);
665+
});
649666
}
650667
// capslock key click listener: end
651668

652669
// backspace key click listener: begin
653670
var backspaceKeyElm = window.document.getElementById(kioskBoardVirtualKeyboard.id).getElementsByClassName('kioskboard-key-backspace')[0];
654671
if (backspaceKeyElm) {
655-
backspaceKeyElm.addEventListener('click', function (e) {
672+
keysEventListeners(backspaceKeyElm, function (e) {
656673
e.preventDefault();
657674

658675
// update the selectionStart
@@ -675,7 +692,7 @@
675692
// input trigger change event for update the value
676693
input.dispatchEvent(changeEvent);
677694

678-
}, false);
695+
});
679696
}
680697
// backspace key click listener: end
681698

@@ -684,7 +701,7 @@
684701
var specialCharactersRowElm = window.document.getElementById(kioskBoardVirtualKeyboard.id).getElementsByClassName('kioskboard-row-specialcharacters')[0];
685702
// open
686703
if (specialCharacterKeyElm && specialCharactersRowElm) {
687-
specialCharacterKeyElm.addEventListener('click', function (e) {
704+
keysEventListeners(specialCharacterKeyElm, function (e) {
688705
e.preventDefault();
689706
input.focus(); // focus the input
690707
if (e.currentTarget.classList.contains('specialcharacter-active')) {
@@ -694,17 +711,17 @@
694711
e.currentTarget.classList.add('specialcharacter-active');
695712
specialCharactersRowElm.classList.add('kioskboard-specialcharacter-show');
696713
}
697-
}, false);
714+
});
698715
}
699716
// close
700717
var specialCharCloseElm = window.document.getElementById(kioskBoardVirtualKeyboard.id).getElementsByClassName('kioskboard-specialcharacter-close')[0];
701718
if (specialCharCloseElm && specialCharacterKeyElm && specialCharactersRowElm) {
702-
specialCharCloseElm.addEventListener('click', function (e) {
719+
keysEventListeners(specialCharCloseElm, function (e) {
703720
e.preventDefault();
704721
input.focus(); // focus the input
705722
specialCharacterKeyElm.classList.remove('specialcharacter-active');
706723
specialCharactersRowElm.classList.remove('kioskboard-specialcharacter-show');
707-
}, false);
724+
});
708725
}
709726
// specialcharacter key click listener: end
710727

@@ -737,7 +754,7 @@
737754
var docTop = window.document.documentElement.scrollTop || 0;
738755
var inputThreshold = isPlacementTop ? (theInput.clientHeight + 20) : 50;
739756
var theInputOffsetTop = Math.round(inputTop + docTop) - inputThreshold;
740-
var isPaddingTop = theInputOffsetTop < keyboardHeight;
757+
var isPaddingTop = (theInputOffsetTop < keyboardHeight) && isPlacementTop;
741758
var isPaddingBottom = documentHeight <= (theInputOffsetTop + keyboardHeight);
742759

743760
if (isPaddingTop || isPaddingBottom) {
@@ -760,11 +777,20 @@
760777
if (autoScroll) {
761778
var scrollBehavior = opt.cssAnimations === true ? 'smooth' : 'auto';
762779
var scrollDelay = opt.cssAnimations === true && typeof opt.cssAnimationsDuration === 'number' ? opt.cssAnimationsDuration : 0;
763-
var userAgent = navigator.userAgent.toLocaleLowerCase('en');
764780
var scrollTop = theInputOffsetTop - (isPlacementTop ? keyboardHeight : 0);
765-
if (userAgent.indexOf('edge') < 0 && userAgent.indexOf('.net4') < 0) {
781+
782+
var userAgent = window.navigator.userAgent.toLocaleLowerCase('en');
783+
var isBrowserInternetExplorer = userAgent.indexOf('.net4') > -1;
784+
var isBrowserEdgeLegacy = userAgent.indexOf('edge') > -1;
785+
var isBrowserEdgeWebView = isBrowserEdgeLegacy && userAgent.indexOf('webview') > -1;
786+
787+
if ((!isBrowserEdgeLegacy || isBrowserEdgeWebView) && !isBrowserInternetExplorer) {
766788
var scrollTimeout = setTimeout(function () {
767-
window.scrollTo({ top: scrollTop, left: 0, behavior: scrollBehavior });
789+
if (isBrowserEdgeWebView) {
790+
window.scrollBy(0, theInputOffsetTop);
791+
} else {
792+
window.scrollTo({ top: scrollTop, left: 0, behavior: scrollBehavior });
793+
}
768794
clearTimeout(scrollTimeout);
769795
}, scrollDelay);
770796
} else {
@@ -835,14 +861,6 @@
835861

836862
// Functions: Get the Keys from JSON by XMLHttpRequest and AppendTo: begin
837863
var getKeysViaXmlHttpRequest = function (jsonUrl, input) {
838-
// check the protocol
839-
var protocolSchemes = ['http:', 'data:', 'chrome:', 'chrome-extension:', 'https:'];
840-
var protocol = (window.location || {}).protocol;
841-
if (protocolSchemes.indexOf(protocol) <= -1) {
842-
kioskBoardConsoleError('The Browser has blocked this request by CORS policy.');
843-
return false;
844-
}
845-
846864
// if "kioskBoardCachedKeys" is undefined || null => send XMLHttpRequest
847865
if (!kioskBoardCachedKeys) {
848866
var xmlHttp = new XMLHttpRequest();
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* KioskBoard - Virtual Keyboard ('https://github.com/furcan/KioskBoard')
3-
* Version: 2.1.0
3+
* Version: 2.2.0
44
* Author: Furkan MT ('https://github.com/furcan')
55
* Copyright 2022 KioskBoard - Virtual Keyboard, MIT Licence ('https://opensource.org/licenses/MIT')*
66
*/

0 commit comments

Comments
 (0)