add addon to all password fields to make password visible

This commit is contained in:
Uwe Steinmann 2025-12-02 13:55:05 +01:00
parent 5db0744bf6
commit e5724e449a
2 changed files with 14 additions and 13 deletions

View File

@ -1252,12 +1252,12 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
break;
default:
if(!empty($value['addon']))
echo '<div class="input-group date">';
echo '<div class="input-group date'.($value["type"]=='password' ? ' show-hide-password' : '').'">';
echo '<input'.
(!empty($value['type']) ? ' type="'.$value['type'].'"' : '').
(!empty($value['id']) ? ' id="'.$value['id'].'"' : '').
(!empty($value['name']) ? ' name="'.$value['name'].'"' : '').
(empty($value['class']) ? ' class="form-control"' : ' class="form-control '.$value['class'].'"').
' class="'.(empty($value['class']) ? 'form-control' : 'form-control '.$value['class']).'"'.
((isset($value['value']) && is_string($value['value'])) || !empty($value['value']) ? ' value="'.$value['value'].'"' : '').
(!empty($value['placeholder']) ? ' placeholder="'.$value['placeholder'].'"' : '').
(!empty($value['autocomplete']) ? ' autocomplete="'.$value['autocomplete'].'"' : '').

View File

@ -403,18 +403,19 @@ $(document).ready( function() {
$($(this).data("target")+' .modal-header h3').html($(this).data("modal-title"));
}); /* }}} */
$('body').on('click', '.show-hide-password a', function(ev) { /* {{{ */
$('body').on('click', 'div.show-hide-password span', function(ev) { /* {{{ */
ev.preventDefault();
// console.log($(this).closest('input'));
// console.log($(ev.target).parent().parent().children('input'));
if($('.show-hide-password input').attr("type") == "text"){
$('.show-hide-password input').attr('type', 'password');
$('.show-hide-password i').addClass( "fa-eye-slash" );
$('.show-hide-password i').removeClass( "fa-eye" );
}else if($('.show-hide-password input').attr("type") == "password"){
$('.show-hide-password input').attr('type', 'text');
$('.show-hide-password i').removeClass( "fa-eye-slash" );
$('.show-hide-password i').addClass( "fa-eye" );
div = $(this).closest('div.show-hide-password');
icon = $(this).children(":first");
input = div.children(":first");
if (input.attr("type") == "text") {
input.attr('type', 'password');
icon.addClass( "fa-eye-slash" );
icon.removeClass( "fa-eye" );
} else if (input.attr("type") == "password") {
input.attr('type', 'text');
icon.removeClass( "fa-eye-slash" );
icon.addClass( "fa-eye" );
}
}); /* }}} */