Improve password prompt UI

This commit is contained in:
yflory
2019-11-18 10:56:24 +01:00
parent c9c19b8395
commit 2fd31e8d89
3 changed files with 51 additions and 16 deletions

View File

@@ -590,9 +590,10 @@ define([
}, opts);
var input = h('input.cp-password-input', attributes);
var reveal = UI.createCheckbox('cp-password-reveal', Messages.password_show);
//var reveal = UI.createCheckbox('cp-password-reveal', Messages.password_show);
var eye = h('span.fa.fa-eye.cp-password-reveal');
/*
$(reveal).find('input').on('change', function () {
if($(this).is(':checked')) {
$(input).prop('type', 'text');
@@ -602,26 +603,41 @@ define([
$(input).prop('type', 'password');
$(input).focus();
});
*/
$(eye).mousedown(function () {
$(input).prop('type', 'text');
$(input).focus();
}).mouseup(function(){
$(input).prop('type', 'password');
$(input).focus();
}).mouseout(function(){
$(input).prop('type', 'password');
$(input).focus();
});
if (displayEye) {
$(eye).mousedown(function () {
$(input).prop('type', 'text');
$(input).focus();
}).mouseup(function(){
$(input).prop('type', 'password');
$(input).focus();
}).mouseout(function(){
$(input).prop('type', 'password');
$(input).focus();
});
} else {
$(eye).click(function () {
if ($(this).hasClass('fa-eye')) {
$(input).prop('type', 'text');
$(input).focus();
$(this).removeClass('fa-eye').addClass('fa-eye-slash');
return;
}
$(input).prop('type', 'password');
$(input).focus();
$(this).removeClass('fa-eye-slash').addClass('fa-eye');
});
}
/*if (displayEye) {
$(reveal).hide();
} else {
$(eye).hide();
}
}*/
return h('span.cp-password-container', [
input,
reveal,
//reveal,
eye
]);
};