2022-11-22 23:06:47 +08:00
|
|
|
function initShowPassword() {
|
2023-06-16 18:38:09 +08:00
|
|
|
$('.sn-icon.sn-icon-visibility-show.show-password').remove();
|
2022-05-06 22:14:21 +08:00
|
|
|
$.each($('input[type="password"]'), function(i, e) {
|
2023-06-08 14:33:37 +08:00
|
|
|
$(`<i class="sn-icon sn-icon-visibility-show show-password"
|
2022-10-18 17:54:10 +08:00
|
|
|
style="
|
|
|
|
cursor: pointer;
|
|
|
|
z-index: 10;
|
|
|
|
"></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);
|
2023-06-16 18:38:09 +08:00
|
|
|
if ($icon.hasClass('sn-icon-visibility-show')) {
|
|
|
|
$icon.removeClass('sn-icon-visibility-show').addClass('sn-icon-visibility-hide');
|
2022-05-06 22:14:21 +08:00
|
|
|
$icon.parent().find('input[type=password]').attr('type', 'text');
|
|
|
|
} else {
|
2023-06-16 18:38:09 +08:00
|
|
|
$icon.removeClass('sn-icon-visibility-hide').addClass('sn-icon-visibility-show');
|
2022-05-06 22:14:21 +08:00
|
|
|
$icon.parent().find('input[type=text]').attr('type', 'password');
|
|
|
|
}
|
|
|
|
});
|