Added an icon to each login input of a closed eye when input type is set to password.
If you click the icon it switches to an open eye and the input type is set to text.
It's a pretty standard way to allow people to view their password before submitting it.
Signed-off-by: Scott Angel <scottangel@mobiusconsortium.org>
Signed-off-by: Stephanie Leary <stephanie.leary@equinoxoli.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
<div class="row row-cols-auto mt-3">
<label class="form-label col-form-label fw-bold col-4 text-end" for="password" i18n>Password</label>
<div class="col-8">
- <input
- type="password"
- class="form-control"
- id="password"
- name="password"
- required
- autocomplete="current-password"
- i18n-placeholder
- placeholder="Password"
- [(ngModel)]="args.password"/>
+ <input
+ [type]="passwordVisible ? 'text' : 'password'"
+ class="form-control"
+ id="password"
+ name="password"
+ required
+ autocomplete="current-password"
+ i18n-placeholder
+ placeholder="Password"
+ spellcheck="false"
+ [(ngModel)]="args.password"/>
+ <span id="show_password" class="input-group-text pointer" (click)="togglePasswordVisibility()">
+ <span class="material-icons">{{ passwordVisible ? 'visibility' : 'visibility_off' }}</span>
+ </span>
</div>
</div>
loginFailed: boolean;
routeTo: string;
pendingXactsDate: Date;
+ passwordVisible: boolean;
args = {
username : '',
}
);
}
+
+ togglePasswordVisibility() {
+ this.passwordVisible = !this.passwordVisible;
+ }
+
}
.popover-body {
padding: 0;
-}
\ No newline at end of file
+}
+
+/*
+ CSS Cursor classes
+*/
+.pointer {
+ cursor: pointer;
+}
.form-control {
border: 1px solid [% css_colors.border_standard %];
}
+
+.pointer {
+ cursor: pointer;
+}
$("#loginModal").on('shown.bs.modal', function(){
$(this).find('#username_field').focus();
});
+ // password visibility eye
+ let btn = document.getElementById('show_password');
+ let input = document.getElementById('password_field');
+ let icon = btn.querySelector('i');
+ btn.addEventListener('click', () => {
+ input.type == 'password' ? [input.type = 'text', icon.setAttribute('class','fas fa-eye')] : [input.type = 'password', icon.setAttribute('class', 'fas fa-eye-slash')];
+ input.focus();
+ });
});
</script>
<input class="form-control" type='text' id="username_field" name="username" autofocus />
</div>
<div class="col-sm w-50">
- <input class="form-control" id="password_field" name="password" type="password"/>
+ <div class="input-group">
+ <input class="form-control" id="password_field" name="password" type="password" spellcheck="false"/>
+ <span id="show_password" class="input-group-text pointer"><i class="fas fa-eye-slash"></i></span>
+ </div>
</div>
</div>
<div class="row">
<input class="form-control" type='text' id="username_field" name="username"/>
</div>
<div class="col-sm w-50">
- <input class="form-control" id="password_field" name="password" type="password"/>
+ <div class="input-group">
+ <input class="form-control" id="password_field" name="password" type="password" spellcheck="false"/>
+ <span id="show_password" class="input-group-text pointer"><i class="fas fa-eye-slash"></i></span>
+ </div>
</div>
</div>
<div class="row">
*/
+.pointer {
+ cursor: pointer;
+}
}
</script>
+<!-- Password Visibility Checkbox -->
+<script>
+ let checkbox = document.getElementById('password_visibility_checkbox');
+ let input = document.getElementById('password_field');
+ checkbox.addEventListener('change', () => {
+ if(checkbox.checked) input.type = 'text';
+ else input.type = 'password';
+ input.focus();
+ });
+</script>
+
[%- IF ctx.use_stripe %]
<script type="text/javascript">unHideMe($("pay_fines_now"));[%# the DOM is loaded now, right? %]</script>
[% END -%]
<div class='float-left'>
<label for="password_field" class="lbl1" >[% l('PIN Number or Password') %]</label>
<div class="input_bg">
- <input id="password_field" name="password" type="password" />
+ <input id="password_field" name="password" type="password" spellcheck="false"/>
+ </div>
+ <div class="input_bg">
+ <input id="password_visibility_checkbox" type="checkbox" />
+ <label for="password_visibility_checkbox">Show Password</label>
</div>
[% INCLUDE "opac/parts/login/password_hint.tt2" %]
[% IF reset_password == 'true' %]
<div class="form-group">
<label class="col-md-4 control-label" for="login-password">[% l('Password') %]</label>
<div class="col-md-8">
- <input type="password" id="login-password" class="form-control"
- placeholder="Password" ng-model="args.password"/>
+ <div class="input-group">
+ <input type="password" id="login-password" class="form-control"
+ placeholder="Password" spellcheck="false" ng-model="args.password"/>
+ <span id="show_password" class="input-group-addon pointer"><i class="glyphicon glyphicon-eye-close"></i></span>
+ </div>
</div>
</div>
<div class="col-md-3"></div><!-- offset? -->
</div>
</div>
+<script>
+ // password visibility eye
+ let btn = document.getElementById('show_password');
+ let input = document.getElementById('login-password');
+ let icon = btn.querySelector('i');
+ btn.addEventListener('click', () => {
+ input.type == 'password' ? [input.type = 'text', icon.setAttribute('class', 'glyphicon glyphicon-eye-open')] : [input.type = 'password', icon.setAttribute('class', 'glyphicon glyphicon-eye-close')];
+ input.focus();
+ });
+</script>
\ No newline at end of file