diff --git a/admin/auth_config.php b/admin/auth_config.php index 50bcfc97db8..ed5fb413be9 100644 --- a/admin/auth_config.php +++ b/admin/auth_config.php @@ -78,6 +78,9 @@ echo '

\n"; echo "\n"; +$PAGE->requires->string_for_js('unmaskpassword', 'core_form'); +$PAGE->requires->yui_module('moodle-auth-passwordunmask', 'M.auth.passwordunmask'); + echo $OUTPUT->footer(); exit; diff --git a/auth/cas/config.html b/auth/cas/config.html index ff9c8636aa8..13c29899dc1 100644 --- a/auth/cas/config.html +++ b/auth/cas/config.html @@ -321,7 +321,7 @@ if (!ldap_paged_results_supported($config->ldap_version)) { - + error_text($err['bind_pw']); } ?> diff --git a/auth/db/config.html b/auth/db/config.html index 6ae71405b9a..9366967b048 100644 --- a/auth/db/config.html +++ b/auth/db/config.html @@ -124,7 +124,7 @@ - + - + error_text($err["passwd"]); ?> diff --git a/auth/ldap/config.html b/auth/ldap/config.html index 0b5de31d127..7c0593773d0 100644 --- a/auth/ldap/config.html +++ b/auth/ldap/config.html @@ -227,7 +227,7 @@ if (!ldap_paged_results_supported($config->ldap_version)) { - + error_text($err['bind_pw']); } ?> diff --git a/auth/yui/passwordunmask/passwordunmask.js b/auth/yui/passwordunmask/passwordunmask.js new file mode 100644 index 00000000000..6e85f9eee38 --- /dev/null +++ b/auth/yui/passwordunmask/passwordunmask.js @@ -0,0 +1,42 @@ +YUI.add('moodle-auth-passwordunmask', function(Y) { + var PASSWORDUNMASK = function() { + PASSWORDUNMASK.superclass.constructor.apply(this, arguments); + } + + Y.extend(PASSWORDUNMASK, Y.Base, { + // Initialize checkboxes. + initializer : function(params) { + this.add_checkboxes(); + }, + // Create checkboxes for all unmasking passwords. + add_checkboxes : function() { + Y.all('#authmenu input[type=password]').each(function(node) { + var checkboxlabel = M.util.get_string('unmaskpassword', 'core_form'); + var elementid = node.get('id'); + var elementname = node.get('name'); + + // Retain unmask div from previous implementation. + var unmaskdiv = Y.Node.create('

'); + + // Add checkbox for unmasking to unmaskdiv. + var unmaskchb = Y.Node.create(''); + unmaskdiv.appendChild(unmaskchb); + //Attach event using static javascript function for unmasking password. + unmaskchb.on('click', function() {unmaskPassword(elementid);}); + + // Add label for checkbox to unmaskdiv. + var unmasklabel = Y.Node.create(''); + unmaskdiv.appendChild(unmasklabel); + + // Insert unmask div in the same div as password input. + node.get('parentNode').insert(unmaskdiv, node.get('lastNode')); + }); + return; + } + }); + + M.auth = M.auth || {}; + M.auth.passwordunmask = function(params) { + return new PASSWORDUNMASK(params); + } +}, '@VERSION@', {requires:['base', 'node']});