Commit b611147a authored by NikulinR's avatar NikulinR

.js -component now, fix arrow function problems while compile

parent 8a0d4a5d
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
</template> </template>
<script> <script>
import MaskedInput from './MaskedInput.vue' import MaskedInput from './MaskedInput.js'
import Vue from 'vue' import Vue from 'vue'
import 'babel-polyfill' import 'babel-polyfill'
......
<template>
<input ref="input"
:value="value"
@keydown="keyDown(arguments[0])"
@keypress="keyPress(arguments[0])"
@keyup="keyUp(arguments[0])"
@textInput="textInput(arguments[0])"
@mouseup="mouseUp(arguments[0])"
@focus.prevent="focusin(arguments[0])"
@focusout="focusout(arguments[0])"
@cut="cut(arguments[0])"
@copy="copy(arguments[0])"
@paste="paste(arguments[0])"
:disabled="mask_core===null || disabled"
/>
</template>
<script>
import InputMask from 'inputmask-core' import InputMask from 'inputmask-core'
import ffpoly from './ff-polyfill.js' //Firefox Polyfill for focus events import ffpoly from './ff-polyfill.js' //Firefox Polyfill for focus events
ffpoly() ffpoly()
export default { export default {
template: `
<input ref="input"
:value="value"
@keydown="keyDown(arguments[0])"
@keypress="keyPress(arguments[0])"
@keyup="keyUp(arguments[0])"
@textInput="textInput(arguments[0])"
@mouseup="mouseUp(arguments[0])"
@focus.prevent="focusin(arguments[0])"
@focusout="focusout(arguments[0])"
@cut="cut(arguments[0])"
@copy="copy(arguments[0])"
@paste="paste(arguments[0])"
:disabled="mask_core===null || disabled"
/>
`,
name: 'MaskedInput', name: 'MaskedInput',
data: () => ({ data: () => ({
...@@ -67,7 +66,6 @@ export default { ...@@ -67,7 +66,6 @@ export default {
initMask() { initMask() {
try { try {
this.mask_core = new InputMask({ this.mask_core = new InputMask({
pattern: this.mask, pattern: this.mask,
value: '', value: '',
...@@ -92,9 +90,8 @@ export default { ...@@ -92,9 +90,8 @@ export default {
}, },
} }
}) })
for (let i = 0; i < this.$refs.input.value.length; ++i) {
for (const char of this.$refs.input.value) { this.mask_core.input(this.$refs.input.value[i])
this.mask_core.input(char)
} }
this.mask_core.setSelection({ this.mask_core.setSelection({
start: 0, start: 0,
...@@ -110,7 +107,7 @@ export default { ...@@ -110,7 +107,7 @@ export default {
} }
catch (e) { catch (e) {
console.error(e); console.error(e.message);
this.mask_core = null this.mask_core = null
this.$refs.input.value = 'Error, see console' this.$refs.input.value = 'Error, see console'
this.$emit('input', this.$refs.input.value, '') this.$emit('input', this.$refs.input.value, '')
...@@ -224,8 +221,8 @@ export default { ...@@ -224,8 +221,8 @@ export default {
/* /*
IE & FF are not trigger textInput event, so we have to force it IE & FF are not trigger textInput event, so we have to force it
*/ */
const isIE = /*@cc_on!@*/false || !!document.documentMode; //by http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser let isIE = /*@cc_on!@*/false || !!document.documentMode; //by http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
const isFirefox = typeof InstallTrigger !== 'undefined'; let isFirefox = typeof InstallTrigger !== 'undefined';
if (isIE || isFirefox) { if (isIE || isFirefox) {
...@@ -269,9 +266,9 @@ export default { ...@@ -269,9 +266,9 @@ export default {
paste(e) { paste(e) {
e.preventDefault() e.preventDefault()
const pasteText = e.clipboardData.getData('text') let text = e.clipboardData.getData('text')
for (const char of pasteText) { for (let i = 0; i < text.length; ++i) {
this.mask_core.input(char) this.mask_core.input(text[i])
} }
this.updateToCoreState() this.updateToCoreState()
}, },
...@@ -333,4 +330,3 @@ export default { ...@@ -333,4 +330,3 @@ export default {
} }
} }
</script>
//https://gist.github.com/nuxodin/9250e56a3ce6c0446efa //https://gist.github.com/nuxodin/9250e56a3ce6c0446efa
export default () => { export default function() {
var w = window, var w = window,
d = w.document; d = w.document;
......
...@@ -4,7 +4,7 @@ var webpack = require('webpack') ...@@ -4,7 +4,7 @@ var webpack = require('webpack')
module.exports = { module.exports = {
entry: { entry: {
demo: './src/main.js', demo: './src/main.js',
component: './src/MaskedInput.vue' component: './src/MaskedInput.js'
}, },
output: { output: {
path: path.resolve(__dirname, './dist'), path: path.resolve(__dirname, './dist'),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment