2022-11-22 23:06:47 +08:00
|
|
|
function initShowPassword() {
|
|
|
|
$('.fas.fa-eye.show-password').remove();
|
2022-05-06 22:14:21 +08:00
|
|
|
$.each($('input[type="password"]'), function(i, e) {
|
2022-10-18 17:54:10 +08:00
|
|
|
$(`<i class="fas fa-eye show-password"
|
|
|
|
style="
|
|
|
|
cursor: pointer;
|
|
|
|
z-index: 10;
|
|
|
|
top: ${$(e).position().top}px
|
|
|
|
"></i>`).insertAfter(e);
|
2022-05-06 22:14:21 +08:00
|
|
|
$(e).parent().addClass('right-icon');
|
|
|
|
});
|
2022-11-22 23:06:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
$(document).on('turbolinks:load', function() {
|
2022-11-23 18:57:52 +08:00
|
|
|
initShowPassword();
|
2022-05-06 22:14:21 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
$(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');
|
|
|
|
}
|
|
|
|
});
|