Skip to content

Commit e7477d5

Browse files
committed
Fix the password eye problem
1 parent 14117a9 commit e7477d5

File tree

6 files changed

+37
-41
lines changed

6 files changed

+37
-41
lines changed

frontend/src/app/components/login/change-password-form/change-password-form.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class ChangePasswordFormViewModel extends BaseViewModel {
2525

2626
this.newPassword = ko.observable()
2727
.extend({
28-
validation: {
29-
validator: pass => pass && (pass.length >= 5),
30-
message: 'Use at least 5 characters'
28+
minLength: {
29+
params: 5,
30+
message: 'At least 5 characters'
3131
},
3232
includesUppercase: true,
3333
includesLowercase: true,
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
<!-- Copyright (C) 2016 NooBaa -->
22

3-
<div class="row content-middle" data-bind="
4-
validationOptions: { insertMessages: false }
5-
">
6-
<input class="password-input" type="password" autocomplete="off" data-bind="
7-
textInput: value,
8-
disable: disabled,
9-
attr: { type: type, placeholder: placeholder }
10-
"/>
11-
12-
<button class="eye-button icon-btn btn-flat no-outline" type="button" tabindex="-1" data-bind="
13-
click: toogleType,
14-
tooltip: tooltip,
15-
visible: value
16-
">
17-
<svg-icon params="name: icon"></svg-icon>
18-
</button>
3+
<div class="input" ko.css.focus="hasFocus">
4+
<div class="row content-middle" data-bind="validationOptions: { insertMessages: false }">
5+
<input class="password-input" type="password" autocomplete="off"
6+
ko.textInput="value"
7+
ko.disable="disabled"
8+
ko.attr.type="type"
9+
ko.attr.placeholder="placeholder",
10+
ko.hasFocus="hasFocus"
11+
/>
12+
<button class="icon-btn btn-flat no-outline push-prev" type="button" tabindex="-1"
13+
ko.click="toogleType"
14+
ko.tooltip="tooltip"
15+
ko.visible="value"
16+
>
17+
<svg-icon params="name: icon"></svg-icon>
18+
</button>
19+
</div>
1920

21+
<!-- ko if: isStrengthVisible -->
22+
<bar params="values: barValues, emptyColor: emptyColor"></bar>
23+
<!-- /ko -->
2024
</div>
2125

22-
<!-- ko if: isStrengthVisible -->
23-
<bar params="values: barValues, emptyColor: emptyColor"></bar>
24-
<!-- /ko -->
25-
2626
<!-- Adding hidden input to control placement of validaiton message -->
27-
<input type="hidden" data-bind="value: value"></input>
27+
<input type="hidden" ko.value="value"/>

frontend/src/app/components/shared/password-field/password-field.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class PasswordFieldViewModel extends BaseViewModel {
2828
this.disabled = disabled;
2929
this.type = ko.observable('password');
3030
this.placeholder = placeholder;
31+
this.hasFocus = ko.observable();
3132

3233
this.icon = ko.pureComputed(
3334
() => iconMapping[this.type()].icon
Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
11
/* Copyright (C) 2016 NooBaa */
22

33
password-field {
4-
position: relative;
5-
display: block;
6-
7-
&.no-validation-highlight input[type=password] {
8-
.no-validation-highlight();
9-
}
4+
display: inline-block;
105

116
/* Must add the :not selectros to get proirity over rules in input.less */;
12-
.password-input:not([type=checkbox]):not([type=radio]) {
7+
/* .password-input:not([type=checkbox]):not([type=radio]) {
138
padding-right: 1.5 * @gutter + 24px;
14-
}
9+
}*/
1510

16-
.eye-button {
17-
position: absolute;
18-
right: @gutter/4;
19-
top: 0;
20-
margin: @gutter/2;
11+
input[type="password"],
12+
input[type="text"] {
13+
padding: 0;
14+
border: none;
2115
}
2216

2317
bar {
2418
height: 4px;
25-
margin-top: -4px;
19+
margin: -5px -@gutter 0 -@gutter;
2620
border-radius: 0;
2721
}
2822
}

frontend/src/app/styles/input.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
.placeholder(@color7);
4747

4848
width: @width;
49+
height: 42px;
4950
line-height: 40px;
5051
border: 1px solid @color7;
5152
background: none;

frontend/src/app/validations.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,17 @@ export default function register(ko) {
162162

163163
includesUppercase:{
164164
validator: includesUppercase,
165-
message: 'Use at least one uppercased letter'
165+
message: 'At least one uppercased letter'
166166
},
167167

168168
includesLowercase:{
169169
validator: includesLowercase,
170-
message: 'Use at least one lowercased letter'
170+
message: 'At least one lowercased letter'
171171
},
172172

173173
includesDigit:{
174174
validator: includesDigit,
175-
message: 'Use at least one digit'
175+
message: 'At least one digit'
176176
},
177177

178178
isJSON: {

0 commit comments

Comments
 (0)