Permalink
Browse files

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

…word protect is set to no.
  • Loading branch information...
1 parent 373a8e0 commit 41e2a9591fd4a73c64630cbf46843513d3fb33a2 @rwijaya rwijaya committed Mar 11, 2013
Showing with 9 additions and 4 deletions.
  1. +4 −1 lib/form/passwordunmask.php
  2. +4 −3 lib/form/yui/passwordunmask/passwordunmask.js
  3. +1 −0 mod/lesson/mod_form.php
@@ -80,8 +80,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) . ' />';
}
}
@@ -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);});
View
@@ -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 41e2a95

Please sign in to comment.