kioskboard
Advanced tools
Comparing version 1.3.3 to 1.4.0
@@ -0,1 +1,12 @@ | ||
@1.4.0 | ||
* **Fixed:** The dispatcher issue on the input change event has been fixed: ([#11](https://github.com/furcan/KioskBoard/issues/11)) | ||
* **Fixed:** The current text selection issue has been fixed: ([#19](https://github.com/furcan/KioskBoard/issues/19)) | ||
* **Added:** The `max` and `maxlength` attribute controls have been added: ([#17](https://github.com/furcan/KioskBoard/issues/17)) | ||
* **Added:** The `options` parameter has been added to the `Run()` function to set the initialize options. => `KioskBoard.Run(selector, options);` | ||
* **Changed:** The `selector` parameter has been changed to `selectorOrElement` that also can use an element instead of the query selector. => `KioskBoard.Run(selectorOrElement);` | ||
* **Changed:** The `Merge()` function has been deprecated. | ||
* **Changed:** Code Review. | ||
----- | ||
@1.3.3 | ||
@@ -2,0 +13,0 @@ * **Fixed:** `AllowMobileKeyboard` option was not working properly on iOS devices. ([#7](https://github.com/furcan/KioskBoard/issues/7)) |
{ | ||
"name": "kioskboard", | ||
"main": "dist/kioskboard-aio-1.3.3.min.js", | ||
"version": "1.3.3", | ||
"main": "dist/kioskboard-aio-1.4.0.min.js", | ||
"version": "1.4.0", | ||
"description": "A pure JavaScript library for using the Virtual Keyboard.", | ||
@@ -34,4 +34,4 @@ "homepage": "https://github.com/furcan/KioskBoard", | ||
"clean-css": "^4.2.3", | ||
"eslint": "^7.6.0", | ||
"stylelint": "^13.6.1", | ||
"eslint": "^7.24.0", | ||
"stylelint": "^13.12.0", | ||
"stylelint-config-standard": "^20.0.0" | ||
@@ -38,0 +38,0 @@ }, |
@@ -22,3 +22,3 @@ <p align="center"> | ||
### Current Version | ||
1.3.3 [*](https://github.com/furcan/KioskBoard/blob/master/CHANGELOG.md) | ||
1.4.0 [*](https://github.com/furcan/KioskBoard/blob/master/CHANGELOG.md) | ||
@@ -60,5 +60,5 @@ --------- | ||
```html | ||
<link rel="stylesheet" href="dist/kioskboard-1.3.3.min.css" /> | ||
<link rel="stylesheet" href="dist/kioskboard-1.4.0.min.css" /> | ||
<script src="dist/kioskboard-1.3.3.min.js"></script> | ||
<script src="dist/kioskboard-1.4.0.min.js"></script> | ||
``` | ||
@@ -69,3 +69,3 @@ | ||
```html | ||
<script src="dist/kioskboard-aio-1.3.3.min.js"></script> | ||
<script src="dist/kioskboard-aio-1.4.0.min.js"></script> | ||
``` | ||
@@ -102,3 +102,4 @@ | ||
##### JS => (Initialize & Run) | ||
##### JS => (Step1: Initialize) | ||
```js | ||
@@ -178,20 +179,34 @@ // Initialize KioskBoard (default/all options) | ||
}); | ||
``` | ||
##### JS => (Step2: Run) | ||
// Run KioskBoard | ||
// Select any input or textarea element(s) to run KioskBoard | ||
```js | ||
// Select the input or the textarea element(s) to run the KioskBoard | ||
KioskBoard.Run('.virtual-keyboard'); | ||
``` | ||
##### OR | ||
##### JS => (Run with Init - v1.4.0 and the next versions) | ||
```js | ||
// Select the input or the textarea element(s) to run the KioskBoard | ||
KioskBoard.Run('.virtual-keyboard', { | ||
// ...init options | ||
}); | ||
``` | ||
--------- | ||
### Merge | ||
`KioskBoard.Merge({});` function can be used to extend the Initialize function via using a specific action or event. | ||
`KioskBoard.Merge({});` function has been deprecated. (v1.4.0 and the next versions) | ||
```js | ||
// The Merge function extends the initialize function for a specific action or event. | ||
KioskBoard.Merge({ | ||
theme: 'dark', | ||
}); | ||
// KioskBoard.Merge({ | ||
// theme: 'dark', | ||
// }); | ||
``` | ||
@@ -204,3 +219,3 @@ | ||
Additionally, KioskBoard includes 6 different language packages: `English` `Turkish` `Spanish` `German` `French` `Hungarian` | ||
Additionally, KioskBoard includes 7 different language packages: `English` `Turkish` `Spanish` `German` `French` `Hungarian` `Russian` | ||
@@ -251,5 +266,5 @@ An example of a JSON file (for custom keys) is as below. | ||
#### Copyright | ||
Copyright © 2020 KioskBoard - Virtual Keyboard | ||
Copyright © 2021 KioskBoard - Virtual Keyboard | ||
#### License | ||
MIT license - https://opensource.org/licenses/MIT |
/*! | ||
* KioskBoard - Virtual Keyboard ('https://github.com/furcan/KioskBoard') | ||
* 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. | ||
* Version: 1.3.3 | ||
* Version: 1.4.0 | ||
* Author: Furkan MT ('https://github.com/furcan') | ||
* Copyright 2020 KioskBoard - Virtual Keyboard, MIT Licence ('https://opensource.org/licenses/MIT')* | ||
* Copyright 2021 KioskBoard - Virtual Keyboard, MIT Licence ('https://opensource.org/licenses/MIT')* | ||
*/ | ||
@@ -202,25 +202,58 @@ | ||
Merge: function (userMergeOptions) { | ||
userMergeOptions = typeof userMergeOptions === 'object' && !Array.isArray(userMergeOptions) ? userMergeOptions : {}; | ||
// if: initialized | ||
if (kioskBoardNewOptions) { | ||
kioskBoardNewOptions = kioskBoardExtendObjects(true, kioskBoardNewOptions, userMergeOptions); | ||
// The Merge function has been deprecated. (v1.4.0 and the next versions). | ||
kioskBoardConsoleLog('The Merge function has been deprecated. (v1.4.0 and the next versions). \n\n' + JSON.stringify(userMergeOptions || {})); | ||
return false; | ||
}, | ||
// Run | ||
Run: function (selectorOrElement, options) { | ||
// Element(s) | ||
var kbElements = []; | ||
// Allowed Element Types | ||
var allowedElementTypes = ['input', 'textarea']; | ||
// If: Check the selector is an element | ||
var isElement = allowedElementTypes.indexOf((selectorOrElement.nodeName || '').toLocaleLowerCase('en')) > -1; | ||
if (isElement) { | ||
kbElements.push(selectorOrElement); | ||
} | ||
// else: initialize first | ||
// Else: Check the selector is valid for the querySelector | ||
else { | ||
kioskBoardConsoleError('You have to initialize KioskBoard before call the Merge function.'); | ||
return false; | ||
// Check the selector | ||
var selectorIsValid = typeof selectorOrElement === 'string' && selectorOrElement.length > 0; | ||
if (!selectorIsValid) { | ||
kioskBoardConsoleError('"' + selectorOrElement + '" is not a valid selector.'); | ||
return false; | ||
} | ||
// Get the element(s) | ||
kbElements = window.document.querySelectorAll(selectorOrElement); | ||
if (kbElements.length < 1) { | ||
kioskBoardConsoleError('You called the KioskBoard with the "' + selectorOrElement + '" selector, but there is no such element on the document.'); | ||
return false; | ||
} | ||
} | ||
}, | ||
// Run | ||
Run: function (selector) { | ||
// Check the initialize | ||
if (!kioskBoardNewOptions) { | ||
kioskBoardConsoleError('You have to initialize KioskBoard first. \n\nVisit to learn more: ' + kioskBoardGithubUrl); | ||
// If: Check the options to initialize or extend | ||
if (typeof options === 'object' && Object.keys(options).length > 0) { | ||
if (!kioskBoardNewOptions) { | ||
KioskBoard.Init(options); | ||
} else { | ||
// extend the new options by the default options | ||
kioskBoardNewOptions = kioskBoardExtendObjects(true, kioskBoardDefaultOptions, options); | ||
} | ||
} | ||
// Else If: Check the initialize | ||
else if (!kioskBoardNewOptions) { | ||
kioskBoardConsoleError('You have to initialize the KioskBoard first. \n\nVisit to learn more: ' + kioskBoardGithubUrl); | ||
return false; | ||
} | ||
// Keys Array | ||
var keysArrayOfObjects = kioskBoardNewOptions.keysArrayOfObjects; | ||
// The final options for each | ||
var opt = kioskBoardNewOptions; | ||
// Keys Array Object has keys | ||
// Keys: Array of Objects | ||
var keysArrayOfObjects = opt.keysArrayOfObjects; | ||
// Keys: Array of Objects has keys | ||
var objectHasKeys = false; | ||
@@ -239,6 +272,6 @@ | ||
if (!objectHasKeys) { | ||
// keys json url | ||
var keysJsonUrl = kioskBoardNewOptions.keysJsonUrl; | ||
// keys json url is valid | ||
var keysJsonUrlIsValid = typeof opt.keysJsonUrl === 'string' && opt.keysJsonUrl.length > 0; | ||
// check the "keysJsonUrl" | ||
if (!keysJsonUrl) { | ||
if (!keysJsonUrlIsValid) { | ||
kioskBoardConsoleError('You have to set the path of KioskBoard Keys JSON file to "keysJsonUrl" option. \n\nVisit to learn more: ' + kioskBoardGithubUrl); | ||
@@ -258,9 +291,6 @@ return false; | ||
var getReadOnlyAttr = input.getAttribute('readonly') !== null; | ||
var allowMobileKeyboard = kioskBoardNewOptions.allowMobileKeyboard === true; | ||
var allowMobileKeyboard = opt.allowMobileKeyboard === true; | ||
// each input focus listener: begin | ||
var inputFocusListener = function () { | ||
// new options | ||
var opt = kioskBoardNewOptions; | ||
// input element variables: begin | ||
@@ -515,3 +545,3 @@ var theInput = this; | ||
// input element trigger change: begin | ||
// event for input element trigger change: begin | ||
var changeEvent = new Event('change', { | ||
@@ -521,3 +551,3 @@ 'bubbles': true, | ||
}); | ||
// input element trigger change: end | ||
// event for input element trigger change: end | ||
@@ -543,10 +573,2 @@ // input element keypress listener: begin | ||
// input element change listener: begin | ||
theInput.addEventListener('change', function () { | ||
var thisValLen = (this.value || '').length; | ||
// update selectionStart | ||
theInputSelIndex = this.selectionStart || thisValLen; | ||
}, false); | ||
// input element change listener: end | ||
// keys click listeners: begin | ||
@@ -557,10 +579,17 @@ var keysClickListeners = function (input) { | ||
if (eachKeyElm && eachKeyElm.length > 0) { | ||
for (var i = 0; i < eachKeyElm.length; i++) { | ||
var keyElm = eachKeyElm[i]; | ||
for (var ekIndex = 0; ekIndex < eachKeyElm.length; ekIndex++) { | ||
var keyElm = eachKeyElm[ekIndex]; | ||
keyElm.addEventListener('click', function (e) { | ||
e.preventDefault(); | ||
// input trigger change for selectionStart | ||
input.dispatchEvent(changeEvent); | ||
// check input max & maxlength | ||
var maxLength = (input.getAttribute('maxlength') || '') * 1; | ||
var max = (input.getAttribute('max') || '') * 1; | ||
var liveValueLength = (input.value || '').length || 0; | ||
if (maxLength > 0 && liveValueLength >= maxLength) { return false; } | ||
if (max > 0 && liveValueLength >= max) { return false; } | ||
// update the selectionStart | ||
theInputSelIndex = input.selectionStart || (input.value || '').length; | ||
// input trigger focus | ||
@@ -585,2 +614,8 @@ input.focus(); | ||
// set next selection index | ||
input.setSelectionRange(theInputSelIndex + 1, theInputSelIndex + 1); | ||
// input trigger change event for update the value | ||
input.dispatchEvent(changeEvent); | ||
}, false); | ||
@@ -620,4 +655,4 @@ } | ||
// trigger for selectionStart | ||
input.dispatchEvent(changeEvent); | ||
// update the selectionStart | ||
theInputSelIndex = input.selectionStart || (input.value || '').length; | ||
@@ -633,2 +668,8 @@ // input trigger focus | ||
// set next selection index | ||
input.setSelectionRange(theInputSelIndex - 1, theInputSelIndex - 1); | ||
// input trigger change event for update the value | ||
input.dispatchEvent(changeEvent); | ||
}, false); | ||
@@ -683,3 +724,3 @@ } | ||
var keyboardWrapper = window.document.getElementById(kioskBoardVirtualKeyboard.id).getElementsByClassName('kioskboard-wrapper')[0]; | ||
keyboardWrapper.style.maxHeight = Math.round((windowHeight / 5) * 3) + 'px'; | ||
keyboardWrapper.style.maxHeight = Math.round((windowHeight / 5) * 4) + 'px'; | ||
keyboardWrapper.style.overflowX = 'hidden'; | ||
@@ -817,47 +858,31 @@ keyboardWrapper.style.overflowY = 'auto'; | ||
// Step 3: Select the element(s): begin | ||
// if: selector is valid | ||
if (typeof selector === 'string' && selector.length > 0) { | ||
var kbElements = window.document.querySelectorAll(selector); | ||
// if: elements exist on the document | ||
if (kbElements && kbElements.length > 0) { | ||
for (var i = 0; i < kbElements.length; i++) { | ||
// each element | ||
var eachElement = kbElements[i]; | ||
for (var kbIndex = 0; kbIndex < kbElements.length; kbIndex++) { | ||
// each element | ||
var eachElement = kbElements[kbIndex]; | ||
// each element tag name | ||
var getTagName = ((eachElement || {}).tagName || '').toLocaleLowerCase('en'); | ||
// each element tag name | ||
var getTagName = ((eachElement || {}).tagName || '').toLocaleLowerCase('en'); | ||
// if: an input or textarea element | ||
if (getTagName === 'input' || getTagName === 'textarea') { | ||
// if: has cached keys => create the keyboard by using cached keys | ||
if (kioskBoardCachedKeys) { | ||
createKeyboardAndAppendTo(kioskBoardCachedKeys, eachElement); | ||
} | ||
// else: try to get the keys from the JSON file via XmlHttpRequest | ||
else { | ||
getKeysViaXmlHttpRequest(keysJsonUrl, eachElement); | ||
} | ||
} | ||
// else: other elements | ||
else { | ||
kioskBoardConsoleLog('You have to call the "KioskBoard" with an ID/ClassName of an Input or a TextArea element. Your element\'s tag name is: "' + getTagName + '". \n\nYou can visit the Documentation page to learn more. \n\nVisit: ' + kioskBoardGithubUrl); | ||
} | ||
// if: an input or textarea element | ||
if (allowedElementTypes.indexOf(getTagName) > -1) { | ||
// if: has cached keys => create the keyboard by using cached keys | ||
if (kioskBoardCachedKeys) { | ||
createKeyboardAndAppendTo(kioskBoardCachedKeys, eachElement); | ||
} | ||
// else: try to get the keys from the JSON file via XmlHttpRequest | ||
else { | ||
getKeysViaXmlHttpRequest(opt.keysJsonUrl, eachElement); | ||
} | ||
} | ||
// else: there is no such element... | ||
// else: other elements | ||
else { | ||
kioskBoardConsoleError('You called the KioskBoard with the "' + selector + '" selector, but there is no such element on the document.'); | ||
return false; | ||
kioskBoardConsoleLog('You have to call the "KioskBoard" with an ID/ClassName of an Input or a TextArea element. Your element\'s tag name is: "' + getTagName + '". \n\nYou can visit the Documentation page to learn more. \n\nVisit: ' + kioskBoardGithubUrl); | ||
} | ||
} | ||
// else: selector is not valid | ||
else { | ||
kioskBoardConsoleError('"' + selector + '" is not a valid selector.'); | ||
return false; | ||
} | ||
// Step 3: Select the element(s): end | ||
}, | ||
}; | ||
return KioskBoard; | ||
// KioskBoard: end | ||
}); |
/*! | ||
* KioskBoard - Virtual Keyboard ('https://github.com/furcan/KioskBoard') | ||
* Version: 1.3.3 | ||
* Version: 1.4.0 | ||
* Author: Furkan MT ('https://github.com/furcan') | ||
* Copyright 2020 KioskBoard - Virtual Keyboard, MIT Licence ('https://opensource.org/licenses/MIT')* | ||
* Copyright 2021 KioskBoard - Virtual Keyboard, MIT Licence ('https://opensource.org/licenses/MIT')* | ||
*/ | ||
@@ -201,25 +201,58 @@ | ||
Merge: function (userMergeOptions) { | ||
userMergeOptions = typeof userMergeOptions === 'object' && !Array.isArray(userMergeOptions) ? userMergeOptions : {}; | ||
// if: initialized | ||
if (kioskBoardNewOptions) { | ||
kioskBoardNewOptions = kioskBoardExtendObjects(true, kioskBoardNewOptions, userMergeOptions); | ||
// The Merge function has been deprecated. (v1.4.0 and the next versions). | ||
kioskBoardConsoleLog('The Merge function has been deprecated. (v1.4.0 and the next versions). \n\n' + JSON.stringify(userMergeOptions || {})); | ||
return false; | ||
}, | ||
// Run | ||
Run: function (selectorOrElement, options) { | ||
// Element(s) | ||
var kbElements = []; | ||
// Allowed Element Types | ||
var allowedElementTypes = ['input', 'textarea']; | ||
// If: Check the selector is an element | ||
var isElement = allowedElementTypes.indexOf((selectorOrElement.nodeName || '').toLocaleLowerCase('en')) > -1; | ||
if (isElement) { | ||
kbElements.push(selectorOrElement); | ||
} | ||
// else: initialize first | ||
// Else: Check the selector is valid for the querySelector | ||
else { | ||
kioskBoardConsoleError('You have to initialize KioskBoard before call the Merge function.'); | ||
return false; | ||
// Check the selector | ||
var selectorIsValid = typeof selectorOrElement === 'string' && selectorOrElement.length > 0; | ||
if (!selectorIsValid) { | ||
kioskBoardConsoleError('"' + selectorOrElement + '" is not a valid selector.'); | ||
return false; | ||
} | ||
// Get the element(s) | ||
kbElements = window.document.querySelectorAll(selectorOrElement); | ||
if (kbElements.length < 1) { | ||
kioskBoardConsoleError('You called the KioskBoard with the "' + selectorOrElement + '" selector, but there is no such element on the document.'); | ||
return false; | ||
} | ||
} | ||
}, | ||
// Run | ||
Run: function (selector) { | ||
// Check the initialize | ||
if (!kioskBoardNewOptions) { | ||
kioskBoardConsoleError('You have to initialize KioskBoard first. \n\nVisit to learn more: ' + kioskBoardGithubUrl); | ||
// If: Check the options to initialize or extend | ||
if (typeof options === 'object' && Object.keys(options).length > 0) { | ||
if (!kioskBoardNewOptions) { | ||
KioskBoard.Init(options); | ||
} else { | ||
// extend the new options by the default options | ||
kioskBoardNewOptions = kioskBoardExtendObjects(true, kioskBoardDefaultOptions, options); | ||
} | ||
} | ||
// Else If: Check the initialize | ||
else if (!kioskBoardNewOptions) { | ||
kioskBoardConsoleError('You have to initialize the KioskBoard first. \n\nVisit to learn more: ' + kioskBoardGithubUrl); | ||
return false; | ||
} | ||
// Keys Array | ||
var keysArrayOfObjects = kioskBoardNewOptions.keysArrayOfObjects; | ||
// The final options for each | ||
var opt = kioskBoardNewOptions; | ||
// Keys Array Object has keys | ||
// Keys: Array of Objects | ||
var keysArrayOfObjects = opt.keysArrayOfObjects; | ||
// Keys: Array of Objects has keys | ||
var objectHasKeys = false; | ||
@@ -238,6 +271,6 @@ | ||
if (!objectHasKeys) { | ||
// keys json url | ||
var keysJsonUrl = kioskBoardNewOptions.keysJsonUrl; | ||
// keys json url is valid | ||
var keysJsonUrlIsValid = typeof opt.keysJsonUrl === 'string' && opt.keysJsonUrl.length > 0; | ||
// check the "keysJsonUrl" | ||
if (!keysJsonUrl) { | ||
if (!keysJsonUrlIsValid) { | ||
kioskBoardConsoleError('You have to set the path of KioskBoard Keys JSON file to "keysJsonUrl" option. \n\nVisit to learn more: ' + kioskBoardGithubUrl); | ||
@@ -257,9 +290,6 @@ return false; | ||
var getReadOnlyAttr = input.getAttribute('readonly') !== null; | ||
var allowMobileKeyboard = kioskBoardNewOptions.allowMobileKeyboard === true; | ||
var allowMobileKeyboard = opt.allowMobileKeyboard === true; | ||
// each input focus listener: begin | ||
var inputFocusListener = function () { | ||
// new options | ||
var opt = kioskBoardNewOptions; | ||
// input element variables: begin | ||
@@ -514,3 +544,3 @@ var theInput = this; | ||
// input element trigger change: begin | ||
// event for input element trigger change: begin | ||
var changeEvent = new Event('change', { | ||
@@ -520,3 +550,3 @@ 'bubbles': true, | ||
}); | ||
// input element trigger change: end | ||
// event for input element trigger change: end | ||
@@ -542,10 +572,2 @@ // input element keypress listener: begin | ||
// input element change listener: begin | ||
theInput.addEventListener('change', function () { | ||
var thisValLen = (this.value || '').length; | ||
// update selectionStart | ||
theInputSelIndex = this.selectionStart || thisValLen; | ||
}, false); | ||
// input element change listener: end | ||
// keys click listeners: begin | ||
@@ -556,10 +578,17 @@ var keysClickListeners = function (input) { | ||
if (eachKeyElm && eachKeyElm.length > 0) { | ||
for (var i = 0; i < eachKeyElm.length; i++) { | ||
var keyElm = eachKeyElm[i]; | ||
for (var ekIndex = 0; ekIndex < eachKeyElm.length; ekIndex++) { | ||
var keyElm = eachKeyElm[ekIndex]; | ||
keyElm.addEventListener('click', function (e) { | ||
e.preventDefault(); | ||
// input trigger change for selectionStart | ||
input.dispatchEvent(changeEvent); | ||
// check input max & maxlength | ||
var maxLength = (input.getAttribute('maxlength') || '') * 1; | ||
var max = (input.getAttribute('max') || '') * 1; | ||
var liveValueLength = (input.value || '').length || 0; | ||
if (maxLength > 0 && liveValueLength >= maxLength) { return false; } | ||
if (max > 0 && liveValueLength >= max) { return false; } | ||
// update the selectionStart | ||
theInputSelIndex = input.selectionStart || (input.value || '').length; | ||
// input trigger focus | ||
@@ -584,2 +613,8 @@ input.focus(); | ||
// set next selection index | ||
input.setSelectionRange(theInputSelIndex + 1, theInputSelIndex + 1); | ||
// input trigger change event for update the value | ||
input.dispatchEvent(changeEvent); | ||
}, false); | ||
@@ -619,4 +654,4 @@ } | ||
// trigger for selectionStart | ||
input.dispatchEvent(changeEvent); | ||
// update the selectionStart | ||
theInputSelIndex = input.selectionStart || (input.value || '').length; | ||
@@ -632,2 +667,8 @@ // input trigger focus | ||
// set next selection index | ||
input.setSelectionRange(theInputSelIndex - 1, theInputSelIndex - 1); | ||
// input trigger change event for update the value | ||
input.dispatchEvent(changeEvent); | ||
}, false); | ||
@@ -682,3 +723,3 @@ } | ||
var keyboardWrapper = window.document.getElementById(kioskBoardVirtualKeyboard.id).getElementsByClassName('kioskboard-wrapper')[0]; | ||
keyboardWrapper.style.maxHeight = Math.round((windowHeight / 5) * 3) + 'px'; | ||
keyboardWrapper.style.maxHeight = Math.round((windowHeight / 5) * 4) + 'px'; | ||
keyboardWrapper.style.overflowX = 'hidden'; | ||
@@ -816,47 +857,31 @@ keyboardWrapper.style.overflowY = 'auto'; | ||
// Step 3: Select the element(s): begin | ||
// if: selector is valid | ||
if (typeof selector === 'string' && selector.length > 0) { | ||
var kbElements = window.document.querySelectorAll(selector); | ||
// if: elements exist on the document | ||
if (kbElements && kbElements.length > 0) { | ||
for (var i = 0; i < kbElements.length; i++) { | ||
// each element | ||
var eachElement = kbElements[i]; | ||
for (var kbIndex = 0; kbIndex < kbElements.length; kbIndex++) { | ||
// each element | ||
var eachElement = kbElements[kbIndex]; | ||
// each element tag name | ||
var getTagName = ((eachElement || {}).tagName || '').toLocaleLowerCase('en'); | ||
// each element tag name | ||
var getTagName = ((eachElement || {}).tagName || '').toLocaleLowerCase('en'); | ||
// if: an input or textarea element | ||
if (getTagName === 'input' || getTagName === 'textarea') { | ||
// if: has cached keys => create the keyboard by using cached keys | ||
if (kioskBoardCachedKeys) { | ||
createKeyboardAndAppendTo(kioskBoardCachedKeys, eachElement); | ||
} | ||
// else: try to get the keys from the JSON file via XmlHttpRequest | ||
else { | ||
getKeysViaXmlHttpRequest(keysJsonUrl, eachElement); | ||
} | ||
} | ||
// else: other elements | ||
else { | ||
kioskBoardConsoleLog('You have to call the "KioskBoard" with an ID/ClassName of an Input or a TextArea element. Your element\'s tag name is: "' + getTagName + '". \n\nYou can visit the Documentation page to learn more. \n\nVisit: ' + kioskBoardGithubUrl); | ||
} | ||
// if: an input or textarea element | ||
if (allowedElementTypes.indexOf(getTagName) > -1) { | ||
// if: has cached keys => create the keyboard by using cached keys | ||
if (kioskBoardCachedKeys) { | ||
createKeyboardAndAppendTo(kioskBoardCachedKeys, eachElement); | ||
} | ||
// else: try to get the keys from the JSON file via XmlHttpRequest | ||
else { | ||
getKeysViaXmlHttpRequest(opt.keysJsonUrl, eachElement); | ||
} | ||
} | ||
// else: there is no such element... | ||
// else: other elements | ||
else { | ||
kioskBoardConsoleError('You called the KioskBoard with the "' + selector + '" selector, but there is no such element on the document.'); | ||
return false; | ||
kioskBoardConsoleLog('You have to call the "KioskBoard" with an ID/ClassName of an Input or a TextArea element. Your element\'s tag name is: "' + getTagName + '". \n\nYou can visit the Documentation page to learn more. \n\nVisit: ' + kioskBoardGithubUrl); | ||
} | ||
} | ||
// else: selector is not valid | ||
else { | ||
kioskBoardConsoleError('"' + selector + '" is not a valid selector.'); | ||
return false; | ||
} | ||
// Step 3: Select the element(s): end | ||
}, | ||
}; | ||
return KioskBoard; | ||
// KioskBoard: end | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
215671
17
2599
264