simple-keyboard/build/index.js

13 lines
14 KiB
JavaScript
Raw Normal View History

2018-09-10 10:47:01 +08:00
/*!
*
2018-10-06 14:34:06 +08:00
* simple-keyboard v2.5.0
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-06 14:34:06 +08:00
!function(t,n){"object"===typeof exports&&"object"===typeof module?module.exports=n():"function"===typeof define&&define.amd?define([],n):"object"===typeof exports?exports.SimpleKeyboard=n():t.SimpleKeyboard=n()}(this,function(){return function(t){function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}var e={};return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=0)}([function(t,n,e){t.exports=e(1)},function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=e(2);n.default=o.a},function(t,n,e){"use strict";function o(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}var i=e(3),s=(e.n(i),e(4)),a=e(5),r=e(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 n=this;o(this,t),this.handleButtonClicked=function(t){var e=n.options.debug;if("{//}"===t)return!1;"function"===typeof n.options.onKeyPress&&n.options.onKeyPress(t),n.input[n.options.inputName]||(n.input[n.options.inputName]="");var o=n.utilities.getUpdatedInput(t,n.input[n.options.inputName],n.options,n.caretPosition);if(n.input[n.options.inputName]!==o){if(n.options.maxLength&&n.utilities.handleMaxLength(n.input,n.options,o))return!1;n.input[n.options.inputName]=o,e&&console.log("Input changed:",n.input),n.options.syncInstanceInputs&&n.syncInstanceInputs(n.input),"function"===typeof n.options.onChange&&n.options.onChange(n.input[n.options.inputName])}e&&console.log("Key pressed:",t)},this.syncInstanceInputs=function(){n.dispatch(function(t){t.replaceInput(n.input)})},this.clearInput=function(t){t=t||n.options.inputName,n.input[n.options.inputName]="",n.options.syncInstanceInputs&&n.syncInstanceInputs(n.input)},this.getInput=function(t){return t=t||n.options.inputName,n.options.syncInstanceInputs&&n.syncInstanceInputs(n.input),n.input[n.options.inputName]},this.setInput=function(t,e){e=e||n.options.inputName,n.input[e]=t,n.options.syncInstanceInputs&&n.syncInstanceInputs(n.input)},this.replaceInput=function(t){n.input=t},this.setOptions=function(t){t=t||{},n.options=Object.assign(n.options,t),n.render()},this.clear=function(){n.keyboardDOM.innerHTML="",n.keyboardDOM.className=n.keyboardDOMClass,n.buttonElements={},n.caretPosition=null},this.dispatch=function(t){return window.SimpleKeyboardInstances?Object.keys(window.SimpleKeyboardInstances).forEach(function(n){t(window.SimpleKeyboardInstances[n],n)}):(console.error("SimpleKeyboardInstances is not defined. Dispatch cannot be called."),!1)},this.addButtonTheme=function(t,e){if(!e||!t)return!1;t.split(" ").forEach(function(o){e.split(" ").forEach(function(e){n.options.buttonTheme||(n.options.buttonTheme=[]);var i=!1;n.options.buttonTheme.map(function(t){if(t.class.split(" ").includes(e)){i=!0;var n=t.buttons.split(" ");n.includes(o)||(i=!0,n.push(o),t.buttons=n.join(" "))}return t}),i||n.options.buttonTheme.push({class:e,buttons:t})})}),n.render()},this.removeButtonTheme=function(t,e){if(!t&&!e)return n.options.buttonTheme=[],n.render(),!1;if(t&&Array.isArray(n.options.buttonTheme)&&n.options.buttonTheme.length){var o=t.split(" ");o.forEach(function(t,i){n.options.buttonTheme.map(function(i,s){if(e&&e.includes(i.class)||!e){var a=void 0;o.includes(t)&&(a=i.buttons.split(" ").filter(function(n){return n!==t})),a.length?i.buttons=a.join(" "):(n.options.buttonTheme.splice(s,1),i=null)}return i})}),n.render()}},this.getButtonElement=function(t){var e=void 0,o=n.buttonElements[t];return o&&(e=o.length>1?o:o[0]),e},this.handleCaret=function(){n.options.debug&&console.log("Caret handling started");var t=function(t){var e=t.target.tagName.toLowerCase();"textarea"!==e&&"inpu
//# sourceMappingURL=index.js.map