|
1 | 1 | /*! |
2 | 2 | * KioskBoard - Virtual Keyboard ('https://github.com/furcan/KioskBoard') |
3 | 3 | * 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 |
5 | 5 | * Author: Furkan MT ('https://github.com/furcan') |
6 | 6 | * Copyright 2022 KioskBoard - Virtual Keyboard, MIT Licence ('https://opensource.org/licenses/MIT')* |
7 | 7 | */ |
|
572 | 572 | }, false); |
573 | 573 | // input element keypress listener: end |
574 | 574 |
|
| 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 | + |
575 | 592 | // keys click listeners: begin |
576 | 593 | var keysClickListeners = function (input) { |
577 | 594 | // each key click listener: begin |
578 | 595 | var eachKeyElm = window.document.getElementById(kioskBoardVirtualKeyboard.id).getElementsByClassName('kioskboard-key'); |
579 | 596 | if (eachKeyElm && eachKeyElm.length > 0) { |
580 | 597 | for (var ekIndex = 0; ekIndex < eachKeyElm.length; ekIndex++) { |
581 | 598 | var keyElm = eachKeyElm[ekIndex]; |
582 | | - keyElm.addEventListener('click', function (e) { |
| 599 | + keysEventListeners(keyElm, function (e) { |
583 | 600 | e.preventDefault(); |
584 | 601 |
|
585 | 602 | // check input max & maxlength |
|
621 | 638 | // input trigger change event for update the value |
622 | 639 | input.dispatchEvent(changeEvent); |
623 | 640 | } |
624 | | - }, false); |
| 641 | + }); |
625 | 642 | } |
626 | 643 | } |
627 | 644 | // each key click listener: end |
628 | 645 |
|
629 | 646 | // capslock key click listener: begin |
630 | 647 | var capsLockKeyElm = window.document.getElementById(kioskBoardVirtualKeyboard.id).getElementsByClassName('kioskboard-key-capslock')[0]; |
631 | 648 | if (capsLockKeyElm) { |
632 | | - capsLockKeyElm.addEventListener('click', function (e) { |
| 649 | + keysEventListeners(capsLockKeyElm, function (e) { |
633 | 650 | e.preventDefault(); |
634 | 651 | // focus the input |
635 | 652 | input.focus(); |
|
645 | 662 | kioskBoardVirtualKeyboard.classList.add('kioskboard-touppercase'); |
646 | 663 | isCapsLockActive = true; |
647 | 664 | } |
648 | | - }, false); |
| 665 | + }); |
649 | 666 | } |
650 | 667 | // capslock key click listener: end |
651 | 668 |
|
652 | 669 | // backspace key click listener: begin |
653 | 670 | var backspaceKeyElm = window.document.getElementById(kioskBoardVirtualKeyboard.id).getElementsByClassName('kioskboard-key-backspace')[0]; |
654 | 671 | if (backspaceKeyElm) { |
655 | | - backspaceKeyElm.addEventListener('click', function (e) { |
| 672 | + keysEventListeners(backspaceKeyElm, function (e) { |
656 | 673 | e.preventDefault(); |
657 | 674 |
|
658 | 675 | // update the selectionStart |
|
675 | 692 | // input trigger change event for update the value |
676 | 693 | input.dispatchEvent(changeEvent); |
677 | 694 |
|
678 | | - }, false); |
| 695 | + }); |
679 | 696 | } |
680 | 697 | // backspace key click listener: end |
681 | 698 |
|
|
684 | 701 | var specialCharactersRowElm = window.document.getElementById(kioskBoardVirtualKeyboard.id).getElementsByClassName('kioskboard-row-specialcharacters')[0]; |
685 | 702 | // open |
686 | 703 | if (specialCharacterKeyElm && specialCharactersRowElm) { |
687 | | - specialCharacterKeyElm.addEventListener('click', function (e) { |
| 704 | + keysEventListeners(specialCharacterKeyElm, function (e) { |
688 | 705 | e.preventDefault(); |
689 | 706 | input.focus(); // focus the input |
690 | 707 | if (e.currentTarget.classList.contains('specialcharacter-active')) { |
|
694 | 711 | e.currentTarget.classList.add('specialcharacter-active'); |
695 | 712 | specialCharactersRowElm.classList.add('kioskboard-specialcharacter-show'); |
696 | 713 | } |
697 | | - }, false); |
| 714 | + }); |
698 | 715 | } |
699 | 716 | // close |
700 | 717 | var specialCharCloseElm = window.document.getElementById(kioskBoardVirtualKeyboard.id).getElementsByClassName('kioskboard-specialcharacter-close')[0]; |
701 | 718 | if (specialCharCloseElm && specialCharacterKeyElm && specialCharactersRowElm) { |
702 | | - specialCharCloseElm.addEventListener('click', function (e) { |
| 719 | + keysEventListeners(specialCharCloseElm, function (e) { |
703 | 720 | e.preventDefault(); |
704 | 721 | input.focus(); // focus the input |
705 | 722 | specialCharacterKeyElm.classList.remove('specialcharacter-active'); |
706 | 723 | specialCharactersRowElm.classList.remove('kioskboard-specialcharacter-show'); |
707 | | - }, false); |
| 724 | + }); |
708 | 725 | } |
709 | 726 | // specialcharacter key click listener: end |
710 | 727 |
|
|
737 | 754 | var docTop = window.document.documentElement.scrollTop || 0; |
738 | 755 | var inputThreshold = isPlacementTop ? (theInput.clientHeight + 20) : 50; |
739 | 756 | var theInputOffsetTop = Math.round(inputTop + docTop) - inputThreshold; |
740 | | - var isPaddingTop = theInputOffsetTop < keyboardHeight; |
| 757 | + var isPaddingTop = (theInputOffsetTop < keyboardHeight) && isPlacementTop; |
741 | 758 | var isPaddingBottom = documentHeight <= (theInputOffsetTop + keyboardHeight); |
742 | 759 |
|
743 | 760 | if (isPaddingTop || isPaddingBottom) { |
|
760 | 777 | if (autoScroll) { |
761 | 778 | var scrollBehavior = opt.cssAnimations === true ? 'smooth' : 'auto'; |
762 | 779 | var scrollDelay = opt.cssAnimations === true && typeof opt.cssAnimationsDuration === 'number' ? opt.cssAnimationsDuration : 0; |
763 | | - var userAgent = navigator.userAgent.toLocaleLowerCase('en'); |
764 | 780 | 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) { |
766 | 788 | 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 | + } |
768 | 794 | clearTimeout(scrollTimeout); |
769 | 795 | }, scrollDelay); |
770 | 796 | } else { |
|
835 | 861 |
|
836 | 862 | // Functions: Get the Keys from JSON by XMLHttpRequest and AppendTo: begin |
837 | 863 | 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 | | - |
846 | 864 | // if "kioskBoardCachedKeys" is undefined || null => send XMLHttpRequest |
847 | 865 | if (!kioskBoardCachedKeys) { |
848 | 866 | var xmlHttp = new XMLHttpRequest(); |
|
0 commit comments