mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-11-27 17:50:50 -05:00
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:
parent
8a8afb96da
commit
d50231a531
6 changed files with 43 additions and 66 deletions
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue