Refactor Password
parent
cdc029e472
commit
271fd62d8d
|
@ -200,12 +200,13 @@ export default {
|
|||
return level;
|
||||
},
|
||||
onInput(event) {
|
||||
this.$emit('update:modelValue', event.target.value)
|
||||
this.$emit('update:modelValue', event.target.value);
|
||||
},
|
||||
onFocus(event) {
|
||||
this.focused = true;
|
||||
|
||||
if (this.feedback) {
|
||||
this.setPasswordMeter(this.modelValue)
|
||||
this.setPasswordMeter(this.modelValue);
|
||||
this.overlayVisible = true;
|
||||
}
|
||||
|
||||
|
@ -223,14 +224,12 @@ export default {
|
|||
onKeyUp(event) {
|
||||
if (this.feedback) {
|
||||
const value = event.target.value;
|
||||
|
||||
const { meter, label } = this.checkPasswordStrength(value);
|
||||
|
||||
this.meter = meter;
|
||||
this.infoText = label;
|
||||
|
||||
//escape
|
||||
if (event.which === 27) {
|
||||
if (event.code === 'Escape') {
|
||||
this.overlayVisible && (this.overlayVisible = false);
|
||||
return;
|
||||
}
|
||||
|
@ -241,11 +240,13 @@ export default {
|
|||
}
|
||||
},
|
||||
setPasswordMeter() {
|
||||
if(!this.feedback || !this.modelValue) return;
|
||||
if (!this.modelValue) return;
|
||||
|
||||
const { meter, label } = this.checkPasswordStrength(this.modelValue);
|
||||
|
||||
this.meter = meter;
|
||||
this.infoText = label;
|
||||
|
||||
if (!this.overlayVisible) {
|
||||
this.overlayVisible = true;
|
||||
}
|
||||
|
@ -253,6 +254,7 @@ export default {
|
|||
checkPasswordStrength(value) {
|
||||
let label = null;
|
||||
let meter = null;
|
||||
|
||||
switch (this.testStrength(value)) {
|
||||
case 1:
|
||||
label = this.weakText;
|
||||
|
@ -261,6 +263,7 @@ export default {
|
|||
width: '33.33%'
|
||||
};
|
||||
break;
|
||||
|
||||
case 2:
|
||||
label = this.mediumText;
|
||||
meter = {
|
||||
|
@ -268,6 +271,7 @@ export default {
|
|||
width: '66.66%'
|
||||
};
|
||||
break;
|
||||
|
||||
case 3:
|
||||
label = this.strongText;
|
||||
meter = {
|
||||
|
@ -275,6 +279,7 @@ export default {
|
|||
width: '100%'
|
||||
};
|
||||
break;
|
||||
|
||||
default:
|
||||
label = this.promptText;
|
||||
meter = null;
|
||||
|
@ -309,6 +314,7 @@ export default {
|
|||
this.overlayVisible = false;
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('resize', this.resizeListener);
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue