car-plate-keyboard
Version:
car-plate-keyboard;车牌号键盘;
1 lines • 8.91 kB
JavaScript
(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["carPlateKeyboard"]=e():t["carPlateKeyboard"]=e()})("undefined"!==typeof self?self:this,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(i,o,function(e){return t[e]}.bind(null,o));return i},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,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="fb15")}({"56d5":function(t,e,n){"use strict";n("f074")},8875:function(t,e,n){var i,o,r;(function(n,s){o=[],i=s,r="function"===typeof i?i.apply(e,o):i,void 0===r||(t.exports=r)})("undefined"!==typeof self&&self,(function(){function t(){var e=Object.getOwnPropertyDescriptor(document,"currentScript");if(!e&&"currentScript"in document&&document.currentScript)return document.currentScript;if(e&&e.get!==t&&document.currentScript)return document.currentScript;try{throw new Error}catch(f){var n,i,o,r=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,s=/@([^@]*):(\d+):(\d+)\s*$/gi,c=r.exec(f.stack)||s.exec(f.stack),l=c&&c[1]||!1,a=c&&c[2]||!1,u=document.location.href.replace(document.location.hash,""),d=document.getElementsByTagName("script");l===u&&(n=document.documentElement.outerHTML,i=new RegExp("(?:[^\\n]+?\\n){0,"+(a-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),o=n.replace(i,"$1").trim());for(var p=0;p<d.length;p++){if("interactive"===d[p].readyState)return d[p];if(d[p].src===l)return d[p];if(l===u&&d[p].innerHTML&&d[p].innerHTML.trim()===o)return d[p]}return null}}return t}))},f074:function(t,e,n){},fb15:function(t,e,n){"use strict";if(n.r(e),"undefined"!==typeof window){var i=window.document.currentScript,o=n("8875");i=o(),"currentScript"in document||Object.defineProperty(document,"currentScript",{get:o});var r=i&&i.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);r&&(n.p=r[1])}var s=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[t._overlay?n("div",{staticClass:"back-bord",on:{click:function(e){return t.closeByClickOverlay()}}}):t._e(),n("div",{ref:"inputBlock",on:{click:function(e){return t.open()}}},[t._t("default",[n("div",{staticClass:"data-show"},[t._l(8,(function(e){return[n("div",{key:e,class:["data-show-block",{active:t.isActive(e)},{"new-energy":t.isLastBlock(e)}]},[t._v(" "+t._s(t.inputValue[e-1])+" ")])]}))],2)],{value:t.inputValue})],2),n("transition",{attrs:{name:"keybordSlide"}},[t.visible?n("div",{staticClass:"keybord-wrap"},[n("header",{staticClass:"keybord-header"},[n("span",{on:{click:function(e){return e.stopPropagation(),t.cancel()}}},[t._v("取消")]),t.previewOnKeyboard?n("span",{class:["preview",{"new-energy":t.newEnergy}]},[t._v(t._s(t.inputValue.join("")))]):t._e(),n("span",{class:[{gray:t.inputValue.length<7}],on:{click:function(e){return e.stopPropagation(),t.submit()}}},[t._v("完成")])]),n("div",{staticClass:"keybord-keys"},["字"===t.keybordType?n("ul",{staticClass:"keybord-keys-word-wrap"},t._l(t.wordList.slice(0,30),(function(e){return n("li",{key:e,staticClass:"button",on:{click:function(n){return n.stopPropagation(),t.inputWord(e)}}},[t._v(" "+t._s(e)+" ")])})),0):n("div",[n("ul",{staticClass:"keybord-keys-abc-wrap"},t._l(t.abcList.slice(0,10),(function(e){return n("li",{key:e,staticClass:"button",on:{click:function(n){return n.stopPropagation(),t.inputWord(e)}}},[t._v(" "+t._s(e)+" ")])})),0),n("ul",{staticClass:"keybord-keys-abc-wrap"},t._l(t.abcList.slice(10,20),(function(e){return n("li",{key:e,staticClass:"button",on:{click:function(n){return n.stopPropagation(),t.inputWord(e)}}},[t._v(" "+t._s(e)+" ")])})),0),n("ul",{staticClass:"keybord-keys-abc-wrap-short"},t._l(t.abcList.slice(20,29),(function(e){return n("li",{key:e,staticClass:"button",on:{click:function(n){return n.stopPropagation(),t.inputWord(e)}}},[t._v(" "+t._s(e)+" ")])})),0)]),n("div",{staticClass:"keybord-keys-bottom"},[n("div",{staticClass:"big-button",on:{click:function(e){return e.stopPropagation(),t.toggle()}}},[t._v(" "+t._s(t.keybordType)+" ")]),n("ul",{staticClass:"keybord-keys-bottom-line"},t._l(t.judgeList,(function(e){return n("li",{key:e,staticClass:"button",on:{click:function(n){return n.stopPropagation(),t.inputWord(e)}}},[t._v(" "+t._s(e)+" ")])})),0),n("div",{staticClass:"big-button",on:{click:function(e){return e.stopPropagation(),t.deleteOne()}}},[t._t("backspace",[n("span",{staticClass:"icon-delete"},[t._v("⇦")])])],2)])])]):t._e()])],1)},c=[],l={name:"car-plate-keyboard",props:{value:{type:String,default:""},openKeyboardOnInit:{type:Boolean,default:!1},closeOnClickOverlay:{type:Boolean,default:!0},overlay:{type:Boolean,default:!0},previewOnKeyboard:{type:Boolean,default:!0},checkInputBlocked:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1}},data:function(){return{placeholderDom:null,keybordType:"字",inputValue:[],visible:!1,wordList:["京","津","渝","沪","冀","晋","辽","吉","黑","苏","浙","皖","闽","赣","鲁","豫","鄂","湘","粤","琼","川","贵","云","陕","甘","青","蒙","桂","宁","新","藏","使","领","警","学","港","澳"],abcList:[1,2,3,4,5,6,7,8,9,0,"Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L","Z","X","C","V","B","N","M"]}},computed:{_overlay(){return this.visible&&this.overlay},judgeList(){return"ABC"===this.keybordType?this.abcList.slice(29,36):this.wordList.slice(30,37)},newEnergy(){return 8===this.inputValue.length}},methods:{init(){this.visible=this.openKeyboardOnInit,this.inputValue=this.value.split("")},isActive(t){return this.inputValue.length===t-1},isLastBlock(t){return 8===t&&this.isActive(t)},toggle(){0===this.inputValue.length||this.inputValue.length>0&&this.inputValue.length<=8||(this.keybordType="ABC"===this.keybordType?"字":"ABC")},inputWord(t){8!==this.inputValue.length&&this.inputValue.push(t)},deleteOne(){this.inputValue.pop()},closeByClickOverlay(){this.closeOnClickOverlay&&this.cancel()},cancel(){this.visible=!1,this.$emit("cancel",this.inputValue.join(""))},submit(){this.inputValue.length<7||(this.visible=!1,this.$emit("submit",this.inputValue.join("")))},open(){this.readonly||(this.visible=!0)},checkInputLocation(t){if(this.checkInputBlocked)if(t){const t=document.documentElement.clientHeight,e=document.documentElement.scrollHeight,n=this.$refs.inputBlock.getBoundingClientRect().top,i=this.$refs.inputBlock.scrollHeight;i+250+n>=t&&e===t&&(this.placeholderDom.style.display="block"),window.scrollTo(0,250)}else document.body.scrollIntoView({block:"start",behavior:"smooth"}),this.placeholderDom.style.display="none"},createPlaceholderDom(){this.checkInputBlocked&&(this.placeholderDom=document.createElement("div"),this.placeholderDom.className="placeholder",this.placeholderDom.style.cssText="height: 260px;width: 100%;background: red;opacity:0",this.placeholderDom.style.display="none",document.body.appendChild(this.placeholderDom))}},created(){this.init(),this.createPlaceholderDom()},watch:{value(t=""){this.inputValue=t.split("")},inputValue(t){0===this.inputValue.length&&(this.keybordType="字"),this.inputValue.length>0&&this.inputValue.length<=7&&(this.keybordType="ABC")},visible(t){this.checkInputLocation(t)}}},a=l;n("56d5");function u(t,e,n,i,o,r,s,c){var l,a="function"===typeof t?t.options:t;if(e&&(a.render=e,a.staticRenderFns=n,a._compiled=!0),i&&(a.functional=!0),r&&(a._scopeId="data-v-"+r),s?(l=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)},a._ssrRegister=l):o&&(l=c?function(){o.call(this,(a.functional?this.parent:this).$root.$options.shadowRoot)}:o),l)if(a.functional){a._injectStyles=l;var u=a.render;a.render=function(t,e){return l.call(e),u(t,e)}}else{var d=a.beforeCreate;a.beforeCreate=d?[].concat(d,l):[l]}return{exports:t,options:a}}var d=u(a,s,c,!1,null,"1f26570f",null),p=d.exports;p.install=function(t){t.component(p.name,p)};var f=p;const h=[f],y=function(t){y.installed||h.map(e=>t.component(e.name,e))};"undefined"!==typeof window&&window.Vue&&y(window.Vue);var b={install:y,carPlateKeyboard:f};e["default"]=b}})}));