mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-31 04:32:06 +08:00
Add show icon for password [SCI-6791]
This commit is contained in:
parent
98efcc04b5
commit
3856fd9cf1
1 changed files with 17 additions and 0 deletions
17
app/assets/javascripts/sitewide/show_password.js
Normal file
17
app/assets/javascripts/sitewide/show_password.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
$(document).on('turbolinks:load', function() {
|
||||
$.each($('input[type="password"]'), function(i, e) {
|
||||
$('<i class="fas fa-eye show-password" style="cursor: pointer; z-index: 10"></i>').insertAfter(e);
|
||||
$(e).parent().addClass('right-icon');
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.show-password', function() {
|
||||
let $icon = $(this);
|
||||
if ($icon.hasClass('fa-eye')) {
|
||||
$icon.removeClass('fa-eye').addClass('fa-eye-slash');
|
||||
$icon.parent().find('input[type=password]').attr('type', 'text');
|
||||
} else {
|
||||
$icon.removeClass('fa-eye-slash').addClass('fa-eye');
|
||||
$icon.parent().find('input[type=text]').attr('type', 'password');
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue