1/** 2 * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> 3 * @license GNU General Public License version 2 or later; see LICENSE.txt 4 */ 5(document => { 6 7 function togglePassword() { 8 [].slice.call(document.querySelectorAll('input[type="password"]')).forEach(input => { 9 const toggleButton = input.parentNode.querySelector('.input-password-toggle'); 10 if (toggleButton) { 11 const hasClickListener = toggleButton.getAttribute('clickListener') === 'true'; 12 if (!hasClickListener) { 13 toggleButton.setAttribute('clickListener', 'true'); 14 toggleButton.addEventListener('click', () => { 15 const icon = toggleButton.firstElementChild; 16 const srText = toggleButton.lastElementChild; 17 if (input.type === 'password') { 18 // Update the icon class 19 icon.classList.remove('icon-eye'); 20 icon.classList.add('icon-eye-slash'); 21 22 // Update the input type 23 input.type = 'text'; 24 25 // Focus the input field 26 input.focus(); 27 28 // Update the text for screenreaders 29 srText.innerText = Joomla.Text._('JHIDEPASSWORD'); 30 } else if (input.type === 'text') { 31 // Update the icon class 32 icon.classList.add('icon-eye'); 33 icon.classList.remove('icon-eye-slash'); 34 35 // Update the input type 36 input.type = 'password'; 37 38 // Focus the input field 39 input.focus(); 40 41 // Update the text for screenreaders 42 srText.innerText = Joomla.Text._('JSHOWPASSWORD'); 43 } 44 }); 45 } 46 } 47 const modifyButton = input.parentNode.querySelector('.input-password-modify'); 48 if (modifyButton) { 49 modifyButton.addEventListener('click', () => { 50 const lock = !modifyButton.classList.contains('locked'); 51 if (lock === true) { 52 // Add lock 53 modifyButton.classList.add('locked'); 54 55 // Reset value to empty string 56 input.value = ''; 57 58 // Disable the field 59 input.setAttribute('disabled', ''); 60 61 // Update the text 62 modifyButton.innerText = Joomla.Text._('JMODIFY'); 63 } else { 64 // Remove lock 65 modifyButton.classList.remove('locked'); 66 67 // Enable the field 68 input.removeAttribute('disabled'); 69 70 // Focus the input field 71 input.focus(); 72 73 // Update the text 74 modifyButton.innerText = Joomla.Text._('JCANCEL'); 75 } 76 }); 77 } 78 }); 79 } 80 document.addEventListener('joomla:updated', togglePassword); 81 document.addEventListener('DOMContentLoaded', togglePassword); 82})(document);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.