Skip to content
Browse files

MDL-30438 Lesson Module: improve password field to disabled when pass…

…word protect is set to no.
  • Loading branch information...
1 parent 1bfc006 commit f1192522c824b52f97490a32a835697cb73a70cb @rwijaya rwijaya committed
Showing with 10 additions and 5 deletions.
  1. +4 −1 lib/form/passwordunmask.php
  2. +5 −4 lib/form/yui/passwordunmask/passwordunmask.js
  3. +1 −0 mod/lesson/mod_form.php
View
5 lib/form/passwordunmask.php
@@ -82,8 +82,11 @@ function toHtml() {
} else {
$unmask = get_string('unmaskpassword', 'form');
//Pass id of the element, so that unmask checkbox can be attached.
+ $attributes = array('formid' => $this->getAttribute('id'),
+ 'checkboxlabel' => $unmask,
+ 'checkboxname' => $this->getAttribute('name'));
$PAGE->requires->yui_module('moodle-form-passwordunmask', 'M.form.passwordunmask',
- array(array('formid' => $this->getAttribute('id'), 'checkboxname' => $unmask)));
+ array($attributes));
return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' />';
}
}
View
9 lib/form/yui/passwordunmask/passwordunmask.js
@@ -7,18 +7,19 @@ YUI.add('moodle-form-passwordunmask', function(Y) {
//Initialize checkbox if id is passed
initializer : function(params) {
if (params && params.formid) {
- this.add_checkbox(params.formid, params.checkboxname);
+ this.add_checkbox(params.formid, params.checkboxlabel, params.checkboxname);
}
},
//Create checkbox for unmasking password
- add_checkbox : function(elementid, checkboxlabel) {
+ add_checkbox : function(elementid, checkboxlabel, checkboxname) {
var node = Y.one('#'+elementid);
//retaining unmask div from previous implementation.
var unmaskdiv = Y.Node.create('<div id="'+elementid+'unmaskdiv" class="unmask"></div>');
//Add checkbox for unmasking to unmaskdiv
- var unmaskchb = Y.Node.create('<input id="'+elementid+'unmask" type="checkbox">');
+ var unmaskchb = Y.Node.create('<input id="'+elementid+'unmask" type="checkbox" name="'+
+ checkboxname+'unmask">');
unmaskdiv.appendChild(unmaskchb);
//Attach event using static javascript function for unmasking password.
unmaskchb.on('click', function() {unmaskPassword(elementid);});
@@ -36,4 +37,4 @@ YUI.add('moodle-form-passwordunmask', function(Y) {
M.form.passwordunmask = function(params) {
return new PASSWORDUNMASK(params);
}
-}, '@VERSION@', {requires:['base', 'node']});
+}, '@VERSION@', {requires:['base', 'node']});
View
1 mod/lesson/mod_form.php
@@ -133,6 +133,7 @@ function definition() {
$mform->setType('password', PARAM_RAW);
$mform->setAdvanced('password');
$mform->disabledIf('password', 'usepassword', 'eq', 0);
+ $mform->disabledIf('passwordunmask', 'usepassword', 'eq', 0);
$this->standard_grading_coursemodule_elements();

0 comments on commit f119252

Please sign in to comment.
Something went wrong with that request. Please try again.