* Fri Jan 17 2025 Brian Read <brianr@koozali.org> 11.0.0-42.sme

- Implement password visibility icon - [SME: 12803]
This commit is contained in:
2025-01-17 12:04:36 +00:00
parent 9b03d377e2
commit ec4f515012
12 changed files with 75 additions and 22 deletions

View File

@@ -0,0 +1,31 @@
// js/sme-password.js
$(document).ready(function() {
// For each password input
$('.sme-password').each(function() {
// Create a new container
//alert("sme-password");
var $inputContainer = $('<div class="input-container"></div>');
// Move the input into the new container
$(this).wrap($inputContainer);
// Create the toggle image
var $togglePassword = $('<img src="images/visible.png" alt="Show Password" class="toggle-password" />');
// Append the toggle image to the container
$(this).after($togglePassword);
});
$('.toggle-password').on('click', function() {
// Find the associated password field
var input = $(this).siblings('.sme-password');
// Toggle the type attribute between password and text
var inputType = input.attr('type') === 'password' ? 'text' : 'password';
input.attr('type', inputType);
// Toggle the icon source based on the input type
var iconSrc = inputType === 'password' ? 'images/visible.png' : 'images/visible-slash.png';
$(this).attr('src', iconSrc);
});
});