apply suggestions to use existing bootstrap icons

as per discussion in https://github.com/PrivateBin/PrivateBin/pull/1647#discussion_r2345917795
This commit is contained in:
El RIDO 2025-10-05 09:47:39 +02:00
parent 8a8afb96da
commit d50231a531
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
6 changed files with 43 additions and 66 deletions

View file

@ -5690,15 +5690,40 @@ jQuery.PrivateBin = (function($) {
* @function
*/
function handleRevealButtonClick() {
const passwordInput = $(this).siblings('.input-password');
const element = $(this);
const passwordInput = element.siblings('.input-password');
const isHidden = passwordInput.attr('type') === 'password';
passwordInput.attr('type', isHidden ? 'text' : 'password');
const tooltip = I18n._(isHidden ? 'Hide password' : 'Show password as plain text. Warning: this will display your password on the screen.');
$(this).attr('title', tooltip);
$(this).attr('aria-label', tooltip);
element.attr('title', tooltip);
element.attr('aria-label', tooltip);
// handle bootstrap 5 icons: eye & eye-slash
const buttonSvg = element.find('use');
if (buttonSvg.length) {
const iconHref = buttonSvg.attr('href');
if (isHidden) {
buttonSvg.attr('href', iconHref + '-slash');
} else {
buttonSvg.attr('href', iconHref.substring(0, iconHref.length - 6));
}
return;
}
// handle bootstrap 3 icons: eye-open & eye-close
const buttonSpan = element.find('span');
if (buttonSpan.length) {
if (isHidden) {
buttonSpan.addClass('glyphicon-eye-close');
buttonSpan.removeClass('glyphicon-eye-open');
} else {
buttonSpan.addClass('glyphicon-eye-open');
buttonSpan.removeClass('glyphicon-eye-close');
}
}
}
/**