simple-keyboard/build/index.js

13 lines
14 KiB
JavaScript
Raw Normal View History

2018-09-10 10:47:01 +08:00
/*!
*
2018-10-09 07:16:10 +08:00
* simple-keyboard v2.5.7
2018-09-10 10:47:01 +08:00
* https://github.com/hodgef/simple-keyboard
*
* Copyright (c) Francisco Hodge (https://github.com/hodgef)
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
2018-10-08 10:17:35 +08:00
!function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports.SimpleKeyboard=e():t.SimpleKeyboard=e()}(this,function(){return function(t){function e(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){t.exports=n(1)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(2);e.default=o.a},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=n(3),a=(n.n(i),n(4)),s=n(5),r=n(6),u="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c=function t(){var e=this;o(this,t),this.handleButtonClicked=function(t){var n=e.options.debug;if("{//}"===t)return!1;"function"===typeof e.options.onKeyPress&&e.options.onKeyPress(t),e.input[e.options.inputName]||(e.input[e.options.inputName]="");var o=e.utilities.getUpdatedInput(t,e.input[e.options.inputName],e.options,e.caretPosition);if(e.input[e.options.inputName]!==o){if(e.options.maxLength&&e.utilities.handleMaxLength(e.input,e.options,o))return!1;e.input[e.options.inputName]=o,n&&console.log("Input changed:",e.input),e.options.syncInstanceInputs&&e.syncInstanceInputs(e.input),"function"===typeof e.options.onChange&&e.options.onChange(e.input[e.options.inputName])}n&&console.log("Key pressed:",t)},this.syncInstanceInputs=function(){e.dispatch(function(t){t.replaceInput(e.input)})},this.clearInput=function(t){t=t||e.options.inputName,e.input[e.options.inputName]="",e.options.syncInstanceInputs&&e.syncInstanceInputs(e.input)},this.getInput=function(t){return t=t||e.options.inputName,e.options.syncInstanceInputs&&e.syncInstanceInputs(e.input),e.input[e.options.inputName]},this.setInput=function(t,n){n=n||e.options.inputName,e.input[n]=t,e.options.syncInstanceInputs&&e.syncInstanceInputs(e.input)},this.replaceInput=function(t){e.input=t},this.setOptions=function(t){t=t||{},e.options=Object.assign(e.options,t),e.render()},this.clear=function(){e.keyboardDOM.innerHTML="",e.keyboardDOM.className=e.keyboardDOMClass,e.buttonElements={}},this.dispatch=function(t){return window.SimpleKeyboardInstances?Object.keys(window.SimpleKeyboardInstances).forEach(function(e){t(window.SimpleKeyboardInstances[e],e)}):(console.error("SimpleKeyboardInstances is not defined. Dispatch cannot be called."),!1)},this.addButtonTheme=function(t,n){if(!n||!t)return!1;t.split(" ").forEach(function(o){n.split(" ").forEach(function(n){e.options.buttonTheme||(e.options.buttonTheme=[]);var i=!1;e.options.buttonTheme.map(function(t){if(t.class.split(" ").includes(n)){i=!0;var e=t.buttons.split(" ");e.includes(o)||(i=!0,e.push(o),t.buttons=e.join(" "))}return t}),i||e.options.buttonTheme.push({class:n,buttons:t})})}),e.render()},this.removeButtonTheme=function(t,n){if(!t&&!n)return e.options.buttonTheme=[],e.render(),!1;if(t&&Array.isArray(e.options.buttonTheme)&&e.options.buttonTheme.length){var o=t.split(" ");o.forEach(function(t,i){e.options.buttonTheme.map(function(i,a){if(n&&n.includes(i.class)||!n){var s=void 0;o.includes(t)&&(s=i.buttons.split(" ").filter(function(e){return e!==t})),s.length?i.buttons=s.join(" "):(e.options.buttonTheme.splice(a,1),i=null)}return i})}),e.render()}},this.getButtonElement=function(t){var n=void 0,o=e.buttonElements[t];return o&&(n=o.length>1?o:o[0]),n},this.handleCaret=function(){e.options.debug&&console.log("Caret handling started");var t=function(t){var n=t.target.tagName.toLowerCase();"textarea"!==n&&"input"!==n||(e.caretPosit
//# sourceMappingURL=index.js.map