Skip to content

Commit

Permalink
MDL-16115 strict fixes for admin settings unmask field too
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Aug 26, 2008
1 parent ed3afff commit 633239f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
30 changes: 27 additions & 3 deletions lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2161,12 +2161,36 @@ function output_html($data, $query='') {
$unmask = get_string('unmaskpassword', 'form');
$unmaskjs = '<script type="text/javascript">
//<![CDATA[
document.write(\'<span class="unmask"><input id="'.$id.'unmask" value="1" type="checkbox" onclick="unmaskPassword(\\\''.$id.'\\\')"/><label for="'.$id.'unmask">'.addslashes_js($unmask).'<\/label><\/span>\');
document.getElementById("'.$this->get_id().'").setAttribute("autocomplete", "off");
var is_ie = (navigator.userAgent.toLowerCase().indexOf("msie") != -1);
document.getElementById("'.$id.'").setAttribute("autocomplete", "off");
var unmaskdiv = document.getElementById("'.$id.'unmaskdiv");
var unmaskchb = document.createElement("input");
unmaskchb.setAttribute("type", "checkbox");
unmaskchb.setAttribute("id", "'.$id.'unmask");
unmaskchb.onchange = function() {unmaskPassword("'.$id.'");};
unmaskdiv.appendChild(unmaskchb);
var unmasklbl = document.createElement("label");
unmasklbl.innerHTML = "'.addslashes_js($unmask).'";
if (is_ie) {
unmasklbl.setAttribute("htmlFor", "'.$id.'unmask");
} else {
unmasklbl.setAttribute("for", "'.$id.'unmask");
}
unmaskdiv.appendChild(unmasklbl);
if (is_ie) {
// ugly hack to work around the famous onchange IE bug
unmaskchb.onclick = function() {this.blur();};
unmaskdiv.onclick = function() {this.blur();};
}
//]]>
</script>';
return format_admin_setting($this, $this->visiblename,
'<div class="form-password"><input type="password" size="'.$this->size.'" id="'.$this->get_id().'" name="'.$this->get_full_name().'" value="'.s($data).'" />'.$unmaskjs.'</div>',
'<div class="form-password"><input type="password" size="'.$this->size.'" id="'.$id.'" name="'.$this->get_full_name().'" value="'.s($data).'" /><div class="unmask" id="'.$id.'unmaskdiv"></div>'.$unmaskjs.'</div>',
$this->description, true, '', NULL, $query);
}
}
Expand Down
4 changes: 4 additions & 0 deletions theme/standard/styles_layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,10 @@ body#admin-modules table.generaltable td.c0
text-align: left;
}

#adminsettings div.form-password div.unmask {
display: inline;
}

#adminsettings fieldset {
margin-top: 1em;
padding: 1em 0.5em;
Expand Down

0 comments on commit 633239f

Please sign in to comment.