Plugin Directory

Changeset 3353046


Ignore:
Timestamp:
08/30/2025 09:49:53 AM (6 months ago)
Author:
authorkit
Message:

Add Password Visibility Option

Location:
author-kit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • author-kit/tags/1.0.16/admin/assets/js/author-kit-user.js

    r3326187 r3353046  
    1414    author_kit_add_or_edit_user();
    1515    display_name_on_fields_change();
     16    togglePassword();
    1617
    1718
     
    7475            }
    7576        });
     77    }
     78
     79    // Function to toggle password visibility
     80    function togglePassword() {
     81        // Get the password input field
     82        const passwordField = document.getElementById("password");
     83        // Get the eye icon element
     84        const toggleIcon = document.querySelector(".toggle-password");
     85
     86        toggleIcon.addEventListener("click", function () {
     87
     88            // If input is currently of type "password", change it to "text"
     89            if (passwordField.type === "password") {
     90                passwordField.type = "text";    // Show the password
     91                toggleIcon.innerHTML = '<i class="fa-solid fa-eye-slash"></i>';  // Change icon to "hide" state
     92            } else {
     93                passwordField.type = "password"; // Hide the password
     94                toggleIcon.innerHTML = '<i class="fa-solid fa-eye"></i>';  // Change icon back to "show" state
     95            }
     96        });
     97
    7698    }
    7799
  • author-kit/tags/1.0.16/admin/views/author-kit-user.php

    r3326187 r3353046  
    204204                <span style="color: red;"><?php echo 'add-new' === $action_selected ? '*' : ''; ?></span>
    205205            </label>
    206             <input type="password" id="password" <?php echo 'add-new' === $action_selected ? 'required' : ''; ?> minlength="8" pattern="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$">
     206            <!-- Wrapper around the input so we can position the toggle icon inside it -->
     207            <div class="password-wrapper" style="position: relative;">
     208                <!-- Password input field -->
     209                <input
     210                    type="password"
     211                    id="password"
     212                    <?php echo 'add-new' === $action_selected ? 'required' : ''; ?>
     213                    minlength="8"
     214                    pattern="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$"
     215                    style="padding-right: 35px;"
     216                >
     217               
     218                <!-- Toggle icon (eye). It's placed absolutely inside the input wrapper -->
     219                <span
     220                    class="toggle-password"
     221                    style="position: absolute; right: 10px; top: 50%; transform: translateY(-50%); cursor: pointer; user-select: none;">
     222                    <i class="fa-solid fa-eye"></i>
     223                </span>
     224            </div>
    207225            <div class="feedback error" id="password-error" style="display: none;">
    208226            </div>
  • author-kit/trunk/admin/assets/js/author-kit-user.js

    r3315954 r3353046  
    1414    author_kit_add_or_edit_user();
    1515    display_name_on_fields_change();
     16    togglePassword();
    1617
    1718
     
    7475            }
    7576        });
     77    }
     78
     79    // Function to toggle password visibility
     80    function togglePassword() {
     81        // Get the password input field
     82        const passwordField = document.getElementById("password");
     83        // Get the eye icon element
     84        const toggleIcon = document.querySelector(".toggle-password");
     85
     86        toggleIcon.addEventListener("click", function () {
     87
     88            // If input is currently of type "password", change it to "text"
     89            if (passwordField.type === "password") {
     90                passwordField.type = "text";    // Show the password
     91                toggleIcon.innerHTML = '<i class="fa-solid fa-eye-slash"></i>';  // Change icon to "hide" state
     92            } else {
     93                passwordField.type = "password"; // Hide the password
     94                toggleIcon.innerHTML = '<i class="fa-solid fa-eye"></i>';  // Change icon back to "show" state
     95            }
     96        });
     97
    7698    }
    7799
  • author-kit/trunk/admin/views/author-kit-user.php

    r3315954 r3353046  
    204204                <span style="color: red;"><?php echo 'add-new' === $action_selected ? '*' : ''; ?></span>
    205205            </label>
    206             <input type="password" id="password" <?php echo 'add-new' === $action_selected ? 'required' : ''; ?> minlength="8" pattern="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$">
     206            <!-- Wrapper around the input so we can position the toggle icon inside it -->
     207            <div class="password-wrapper" style="position: relative;">
     208                <!-- Password input field -->
     209                <input
     210                    type="password"
     211                    id="password"
     212                    <?php echo 'add-new' === $action_selected ? 'required' : ''; ?>
     213                    minlength="8"
     214                    pattern="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$"
     215                    style="padding-right: 35px;"
     216                >
     217               
     218                <!-- Toggle icon (eye). It's placed absolutely inside the input wrapper -->
     219                <span
     220                    class="toggle-password"
     221                    style="position: absolute; right: 10px; top: 50%; transform: translateY(-50%); cursor: pointer; user-select: none;">
     222                    <i class="fa-solid fa-eye"></i>
     223                </span>
     224            </div>
    207225            <div class="feedback error" id="password-error" style="display: none;">
    208226            </div>
Note: See TracChangeset for help on using the changeset viewer.