MDL-30438 Lesson Module: improve password field to disabled when password protect is set to no.
This commit is contained in:
@@ -80,8 +80,11 @@ class MoodleQuickForm_passwordunmask extends MoodleQuickForm_password {
|
||||
} 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) . ' />';
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -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);});
|
||||
|
||||
@@ -133,6 +133,7 @@ class mod_lesson_mod_form extends moodleform_mod {
|
||||
$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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user