mirror of
https://github.com/moodle/moodle.git
synced 2025-08-11 11:56:40 +02:00
MDL-9239 New fromslib password element with reveal option
This commit is contained in:
parent
da586c3430
commit
0d4f86ce4b
5 changed files with 71 additions and 0 deletions
33
lib/form/passwordreveal.php
Normal file
33
lib/form/passwordreveal.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->libdir.'/form/password.php');
|
||||
|
||||
/**
|
||||
* HTML class for a password type element with reveal option
|
||||
*
|
||||
* @author Petr Skoda
|
||||
* @access public
|
||||
*/
|
||||
class MoodleQuickForm_passwordreveal extends MoodleQuickForm_password {
|
||||
|
||||
function toHtml() {
|
||||
if ($this->_flagFrozen) {
|
||||
return $this->getFrozenHtml();
|
||||
} else {
|
||||
$id = $this->getAttribute('id');
|
||||
$reveal = get_string('revealpassword', 'form');
|
||||
$revealjs = '<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
document.write(\'<div class="reveal"><input id="'.$id.'reveal" value="1" type="checkbox" onclick="revealPassword(\\\''.$id.'\\\')"/><label for="'.$id.'reveal">'.addslashes_js($reveal).'<\/label><\/div>\');
|
||||
//]]>
|
||||
</script>';
|
||||
return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' />'.$revealjs;
|
||||
}
|
||||
} //end func toHtml
|
||||
|
||||
}
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue