Skip to content

Commit beb83d7

Browse files
authored
Migrate password fields to .form-control (hestiacp#2966)
1 parent a34bbf7 commit beb83d7

22 files changed

+193
-202
lines changed

web/css/src/themes/dark.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,8 +854,6 @@ a.vst-text:active b {
854854

855855
.additional-control.remove-ns {}
856856

857-
.hide-password {}
858-
859857
.toggle-psw-visibility-icon {}
860858

861859
.show-passwords-enabled-action {}

web/css/src/themes/default.css

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,11 +2538,12 @@ a.vst-text:active b {
25382538
display: none;
25392539
}
25402540

2541-
.hide-password {
2541+
.toggle-password {
25422542
color: #aaa;
2543-
margin-left: -36px;
2544-
padding-left: 3px;
25452543
z-index: 1;
2544+
position: absolute;
2545+
top: 9px;
2546+
right: 12px;
25462547
}
25472548

25482549
.toggle-psw-visibility-icon {
@@ -3829,35 +3830,33 @@ li[aria-expanded="true"] a {
38293830
}
38303831
}
38313832

3832-
meter {
3833-
/* Reset the default appearance */
3833+
.password-meter {
38343834
appearance: none;
3835-
margin: 0 auto 1em;
3836-
width: 373px;
3835+
display: block;
3836+
width: 100%;
38373837
background-color: #e7e7e7;
38383838
height: 3px;
3839-
border-bottom-left-radius: 5px;
3840-
border-bottom-right-radius: 5px;
3841-
margin-left: 3px;
3839+
border-bottom-left-radius: 3px;
3840+
border-bottom-right-radius: 3px;
38423841
box-shadow: 0 1px 2px rgb(0 0 0 / 25%);
38433842
}
38443843

3845-
meter[value="1"] { background: red; }
3846-
meter[value="2"] { background: orange; }
3847-
meter[value="3"] { background: yellow; }
3848-
meter[value="4"] { background: green; }
3844+
.password-meter[value="1"] { background: red; }
3845+
.password-meter[value="2"] { background: orange; }
3846+
.password-meter[value="3"] { background: yellow; }
3847+
.password-meter[value="4"] { background: green; }
38493848

38503849
/* Webkit based browsers */
3851-
meter[value="1"]::-webkit-meter-optimum-value { background: red; }
3852-
meter[value="2"]::-webkit-meter-optimum-value { background: orange; }
3853-
meter[value="3"]::-webkit-meter-optimum-value { background: yellow; }
3854-
meter[value="4"]::-webkit-meter-optimum-value { background: green; }
3850+
.password-meter[value="1"]::-webkit-meter-optimum-value { background: red; }
3851+
.password-meter[value="2"]::-webkit-meter-optimum-value { background: orange; }
3852+
.password-meter[value="3"]::-webkit-meter-optimum-value { background: yellow; }
3853+
.password-meter[value="4"]::-webkit-meter-optimum-value { background: green; }
38553854

38563855
/* Gecko based browsers */
3857-
meter[value="1"]::-moz-meter-bar { background: red; }
3858-
meter[value="2"]::-moz-meter-bar { background: orange; }
3859-
meter[value="3"]::-moz-meter-bar { background: yellow; }
3860-
meter[value="4"]::-moz-meter-bar { background: green; }
3856+
.password-meter[value="1"]::-moz-meter-bar { background: red; }
3857+
.password-meter[value="2"]::-moz-meter-bar { background: orange; }
3858+
.password-meter[value="3"]::-moz-meter-bar { background: yellow; }
3859+
.password-meter[value="4"]::-moz-meter-bar { background: green; }
38613860

38623861
/* Global utilities
38633862
========================================================================== */
@@ -3900,6 +3899,10 @@ meter[value="4"]::-moz-meter-bar { background: green; }
39003899
margin-left: 10px !important;
39013900
}
39023901

3902+
.u-mb10 {
3903+
margin-bottom: 10px !important;
3904+
}
3905+
39033906
.u-mb20 {
39043907
margin-bottom: 20px !important;
39053908
}
@@ -3924,6 +3927,10 @@ meter[value="4"]::-moz-meter-bar { background: green; }
39243927
padding-left: 50px !important;
39253928
}
39263929

3930+
.u-pos-relative {
3931+
position: relative !important;
3932+
}
3933+
39273934
.u-input-width {
39283935
width: 380px !important;
39293936
}

web/css/src/themes/vestia.css

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,9 @@ a.vst-text:hover b,
496496
border-radius: 4px !important;
497497
}
498498

499-
meter {
500-
width: 379px !important;
501-
border-radius: 0 !important;
502-
box-shadow: none !important;
503-
margin-left: 0 !important;
499+
.password-meter {
500+
border-radius: 0;
501+
box-shadow: none;
504502
}
505503

506504
.vst-input,

web/css/themes/default.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/css/themes/vestia.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/js/events.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ VE.helpers.warn = function(msg) {
166166
}
167167

168168
VE.helpers.extendPasswordFields = function() {
169-
var references = ['.password'];
169+
var references = ['.js-password-input'];
170170

171171
$(document).ready(function() {
172172
$(references).each(function(i, ref) {
@@ -184,7 +184,7 @@ VE.helpers.initAdditionalPasswordFieldElements = function(ref) {
184184
$(ref).prop('autocomplete', 'off');
185185

186186
var enabled_html = enabled ? '' : 'show-passwords-enabled-action';
187-
var html = '<span class="hide-password"><i class="toggle-psw-visibility-icon fas fa-eye-slash ' + enabled_html + '" onClick="VE.helpers.toggleHiddenPasswordText(\'' + ref + '\', this)"></i></span>';
187+
var html = '<span class="toggle-password"><i class="toggle-psw-visibility-icon fas fa-eye-slash ' + enabled_html + '" onClick="VE.helpers.toggleHiddenPasswordText(\'' + ref + '\', this)"></i></span>';
188188
$(ref).after(html);
189189
}
190190

web/js/pages/add_db.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
App.Actions.DB.update_db_username_hint = function(elm, hint) {
55
if (hint.trim() == '') {
66
$(elm).parent().find('.hint').text('');
7-
}
7+
}
88
$(elm).parent().find('.hint').text(GLOBAL.DB_USER_PREFIX + hint);
99
}
1010

@@ -14,7 +14,7 @@ App.Actions.DB.update_db_username_hint = function(elm, hint) {
1414
App.Actions.DB.update_db_databasename_hint = function(elm, hint) {
1515
if (hint.trim() == '') {
1616
$(elm).parent().find('.hint').text('');
17-
}
17+
}
1818
$(elm).parent().find('.hint').text(GLOBAL.DB_DBNAME_PREFIX + hint);
1919
}
2020

@@ -26,7 +26,7 @@ App.Listeners.DB.keypress_db_username = function() {
2626
if (current_val.trim() != '') {
2727
App.Actions.DB.update_db_username_hint(ref, current_val);
2828
}
29-
29+
3030
ref.bind('keypress input', function(evt) {
3131
clearTimeout(window.frp_usr_tmt);
3232
window.frp_usr_tmt = setTimeout(function() {
@@ -44,7 +44,7 @@ App.Listeners.DB.keypress_db_databasename = function() {
4444
if (current_val.trim() != '') {
4545
App.Actions.DB.update_db_databasename_hint(ref, current_val);
4646
}
47-
47+
4848
ref.bind('keypress input', function(evt) {
4949
clearTimeout(window.frp_dbn_tmt);
5050
window.frp_dbn_tmt = setTimeout(function() {
@@ -54,19 +54,19 @@ App.Listeners.DB.keypress_db_databasename = function() {
5454
});
5555
}
5656

57-
App.Actions.DB.update_v_password = function (){
57+
App.Actions.DB.update_password_meter = function (){
5858
var password = $('input[name="v_password"]').val();
5959
var min_small = new RegExp(/^(?=.*[a-z]).+$/);
6060
var min_cap = new RegExp(/^(?=.*[A-Z]).+$/);
61-
var min_num = new RegExp(/^(?=.*\d).+$/);
61+
var min_num = new RegExp(/^(?=.*\d).+$/);
6262
var min_length = 8;
6363
var score = 0;
64-
64+
6565
if(password.length >= min_length) { score = score + 1; }
6666
if(min_small.test(password)) { score = score + 1;}
6767
if(min_cap.test(password)) { score = score + 1;}
6868
if(min_num.test(password)) { score = score+ 1; }
69-
$('#meter').val(score);
69+
$('.password-meter').val(score);
7070
}
7171

7272
App.Listeners.DB.keypress_v_password = function() {
@@ -75,7 +75,7 @@ App.Listeners.DB.keypress_v_password = function() {
7575
clearTimeout(window.frp_usr_tmt);
7676
window.frp_usr_tmt = setTimeout(function() {
7777
var elm = $(evt.target);
78-
App.Actions.DB.update_v_password(elm, $(elm).val());
78+
App.Actions.DB.update_password_meter(elm, $(elm).val());
7979
}, 100);
8080
});
8181
}
@@ -88,7 +88,7 @@ App.Listeners.DB.keypress_v_password();
8888
App.Listeners.DB.keypress_db_username();
8989
App.Listeners.DB.keypress_db_databasename();
9090

91-
randomString = function(min_length = 16) {
92-
$('input[name=v_password]').val(randomString2(min_length));
93-
App.Actions.DB.update_v_password();
91+
applyRandomString = function(min_length = 16) {
92+
$('input[name=v_password]').val(randomString2(min_length));
93+
App.Actions.DB.update_password_meter();
9494
}

web/js/pages/add_mail_acc.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ $('#v_blackhole').on('click', function(evt){
7373
$('#id_fwd_for').hide();
7474
}else{
7575
$('#v_fwd').prop('disabled', false);
76-
$('#id_fwd_for').show();
76+
$('#id_fwd_for').show();
7777
}
7878
});
7979
$('form[name="v_quota"]').on('submit', function(evt) {
@@ -85,19 +85,19 @@ $('form[name="v_quota"]').on('submit', function(evt) {
8585
});
8686
});
8787

88-
App.Actions.MAIL_ACC.update_v_password = function (){
88+
App.Actions.MAIL_ACC.update_password_meter = function (){
8989
var password = $('input[name="v_password"]').val();
9090
var min_small = new RegExp(/^(?=.*[a-z]).+$/);
9191
var min_cap = new RegExp(/^(?=.*[A-Z]).+$/);
92-
var min_num = new RegExp(/^(?=.*\d).+$/);
92+
var min_num = new RegExp(/^(?=.*\d).+$/);
9393
var min_length = 8;
9494
var score = 0;
95-
95+
9696
if(password.length >= min_length) { score = score + 1; }
9797
if(min_small.test(password)) { score = score + 1;}
9898
if(min_cap.test(password)) { score = score + 1;}
9999
if(min_num.test(password)) { score = score+ 1; }
100-
$('#meter').val(score);
100+
$('.password-meter').val(score);
101101
}
102102

103103
App.Listeners.MAIL_ACC.keypress_v_password = function() {
@@ -106,22 +106,22 @@ App.Listeners.MAIL_ACC.keypress_v_password = function() {
106106
clearTimeout(window.frp_usr_tmt);
107107
window.frp_usr_tmt = setTimeout(function() {
108108
var elm = $(evt.target);
109-
App.Actions.MAIL_ACC.update_v_password(elm, $(elm).val());
109+
App.Actions.MAIL_ACC.update_password_meter(elm, $(elm).val());
110110
}, 100);
111111
});
112112
}
113113

114114
App.Listeners.MAIL_ACC.keypress_v_password();
115115

116116

117-
randomString = function(min_length = 16) {
118-
var randomstring = randomString2(min_length);
119-
$('input[name=v_password]').val(randomstring);
117+
applyRandomString = function(min_length = 16) {
118+
var randomString = randomString2(min_length);
119+
$('input[name=v_password]').val(randomString);
120120
if($('input[name=v_password]').attr('type') == 'text')
121-
$('#v_password').text(randomstring);
121+
$('#v_password').text(randomString);
122122
else
123-
$('#v_password').text(Array(randomstring.length+1).join('*'));
124-
App.Actions.MAIL_ACC.update_v_password();
123+
$('#v_password').text(Array(randomString.length+1).join('*'));
124+
App.Actions.MAIL_ACC.update_password_meter();
125125
generate_mail_credentials();
126126
}
127127

web/js/pages/add_user.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@ $(function() {
1010
}else{
1111
document.getElementById('v_notify').value = '';
1212
}
13-
});
13+
});
1414
});
1515

1616

17-
randomString = function (min_length = 16) {
17+
applyRandomString = function (min_length = 16) {
1818
$("input[name=v_password]").val(randomString2(min_length));
19-
App.Actions.WEB.update_v_password();
19+
App.Actions.WEB.update_password_meter();
2020
};
2121

22-
App.Actions.WEB.update_v_password = function (){
22+
App.Actions.WEB.update_password_meter = function (){
2323
var password = $('input[name="v_password"]').val();
2424
var min_small = new RegExp(/^(?=.*[a-z]).+$/);
2525
var min_cap = new RegExp(/^(?=.*[A-Z]).+$/);
26-
var min_num = new RegExp(/^(?=.*\d).+$/);
26+
var min_num = new RegExp(/^(?=.*\d).+$/);
2727
var min_length = 8;
2828
var score = 0;
29-
29+
3030
if(password.length >= min_length) { score = score + 1; }
3131
if(min_small.test(password)) { score = score + 1;}
3232
if(min_cap.test(password)) { score = score + 1;}
3333
if(min_num.test(password)) { score = score+ 1; }
34-
$('#meter').val(score);
34+
$('.password-meter').val(score);
3535
}
3636

3737
App.Listeners.WEB.keypress_v_password = function() {
@@ -40,9 +40,9 @@ App.Listeners.WEB.keypress_v_password = function() {
4040
clearTimeout(window.frp_usr_tmt);
4141
window.frp_usr_tmt = setTimeout(function() {
4242
var elm = $(evt.target);
43-
App.Actions.WEB.update_v_password(elm, $(elm).val());
43+
App.Actions.WEB.update_password_meter(elm, $(elm).val());
4444
}, 100);
4545
});
4646
}
4747

48-
App.Listeners.WEB.keypress_v_password();
48+
App.Listeners.WEB.keypress_v_password();

0 commit comments

Comments
 (0)