From 3856fd9cf1fb48f20b3374a53fb291845b22e575 Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 6 May 2022 16:14:21 +0200 Subject: [PATCH] Add show icon for password [SCI-6791] --- .../javascripts/sitewide/show_password.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 app/assets/javascripts/sitewide/show_password.js diff --git a/app/assets/javascripts/sitewide/show_password.js b/app/assets/javascripts/sitewide/show_password.js new file mode 100644 index 000000000..4f3bd21ec --- /dev/null +++ b/app/assets/javascripts/sitewide/show_password.js @@ -0,0 +1,17 @@ +$(document).on('turbolinks:load', function() { + $.each($('input[type="password"]'), function(i, e) { + $('').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'); + } +});