lib-form MDL-16706 Changed inline JS to use PAGE methods
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
function updatefile(client_id, obj) {
|
||||
document.getElementById('repo_info_'+client_id).innerHTML = obj['file'];
|
||||
}
|
||||
function callpicker(client_id, id) {
|
||||
var picker = document.createElement('DIV');
|
||||
picker.id = 'file-picker-'+client_id;
|
||||
picker.className = 'file-picker';
|
||||
document.body.appendChild(picker);
|
||||
var el=document.getElementById(id);
|
||||
var params = {};
|
||||
params.env = 'filepicker';
|
||||
params.itemid = itemid;
|
||||
params.maxbytes = filepicker.maxbytes;
|
||||
params.maxfiles = filepicker.maxfiles;
|
||||
params.target = el;
|
||||
params.callback = updatefile;
|
||||
open_filepicker(client_id, params);
|
||||
return false;
|
||||
}
|
||||
alert('here');
|
||||
+3
-22
@@ -62,7 +62,7 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
|
||||
}
|
||||
|
||||
function toHtml() {
|
||||
global $CFG, $COURSE, $USER;
|
||||
global $CFG, $COURSE, $USER, $PAGE;
|
||||
|
||||
if ($this->_flagFrozen) {
|
||||
return $this->getFrozenHtml();
|
||||
@@ -96,30 +96,11 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
|
||||
$str .= '<input type="hidden" name="'.$elname.'" id="'.$id.'" '.$draftvalue.' />';
|
||||
$str .= $repojs;
|
||||
|
||||
$str .= $PAGE->requires->data_for_js('filepicker', Array('maxbytes'=>$this->_options['maxbytes'],'maxfiles'=>$this->_options['maxfiles']))->asap();
|
||||
$str .= $PAGE->requires->js('lib/form/filepicker.js')->asap();
|
||||
$str .= <<<EOD
|
||||
<a href="#nonjsfp" class="btnaddfile" onclick="return callpicker('$client_id', '$id', '$draftvalue')">$straddfile</a>
|
||||
<span id="repo_info_{$client_id}" class="notifysuccess">$currentfile</span>
|
||||
<script type="text/javascript">
|
||||
function updatefile(client_id, obj) {
|
||||
document.getElementById('repo_info_'+client_id).innerHTML = obj['file'];
|
||||
}
|
||||
function callpicker(client_id, id) {
|
||||
var picker = document.createElement('DIV');
|
||||
picker.id = 'file-picker-'+client_id;
|
||||
picker.className = 'file-picker';
|
||||
document.body.appendChild(picker);
|
||||
var el=document.getElementById(id);
|
||||
var params = {};
|
||||
params.env = 'filepicker';
|
||||
params.itemid = itemid;
|
||||
params.maxbytes = $this->_options['maxbytes'];
|
||||
params.maxfiles = $this->_options['maxfiles'];
|
||||
params.target = el;
|
||||
params.callback = updatefile;
|
||||
open_filepicker(client_id, params);
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
<noscript>
|
||||
<a name="nonjsfp"></a>
|
||||
<object type="text/html" data="{$CFG->httpswwwroot}/repository/filepicker.php?action=embedded&itemid={$draftitemid}&ctx_id=$context->id" height="300" width="800" style="border:1px solid #000">Error</object>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
var is_ie = (navigator.userAgent.toLowerCase().indexOf("msie") != -1);
|
||||
|
||||
document.getElementById(punmask.id).setAttribute("autocomplete", "off");
|
||||
|
||||
var unmaskdiv = document.getElementById(punmask.id+"unmaskdiv");
|
||||
|
||||
var unmaskchb = document.createElement("input");
|
||||
unmaskchb.setAttribute("type", "checkbox");
|
||||
unmaskchb.setAttribute("id", punmask.id+"unmask");
|
||||
unmaskchb.onchange = function() {unmaskPassword(punmask.id);};
|
||||
unmaskdiv.appendChild(unmaskchb);
|
||||
|
||||
var unmasklbl = document.createElement("label");
|
||||
unmasklbl.innerHTML = punmask.unmaskstr;
|
||||
if (is_ie) {
|
||||
unmasklbl.setAttribute("htmlFor", punmask.id+"unmask");
|
||||
} else {
|
||||
unmasklbl.setAttribute("for", punmask.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();};
|
||||
}
|
||||
@@ -19,42 +19,14 @@ class MoodleQuickForm_passwordunmask extends MoodleQuickForm_password {
|
||||
}
|
||||
|
||||
function toHtml() {
|
||||
global $PAGE;
|
||||
if ($this->_flagFrozen) {
|
||||
return $this->getFrozenHtml();
|
||||
} else {
|
||||
$id = $this->getAttribute('id');
|
||||
$unmask = get_string('unmaskpassword', 'form');
|
||||
$unmaskjs = '<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
|
||||
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>';
|
||||
$unmaskjs = $PAGE->requires->data_for_js('punmask',Array('id'=>$id, 'unmaskstr'=>$unmask))->asap();
|
||||
$unmaskjs .= $PAGE->requires->js('lib/form/passwordunmask.js')->asap();
|
||||
return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' /><div class="unmask" id="'.$id.'unmaskdiv"></div>'.$unmaskjs;
|
||||
}
|
||||
} //end func toHtml
|
||||
|
||||
@@ -48,16 +48,11 @@ class MoodleQuickForm_recaptcha extends HTML_QuickForm_input {
|
||||
* @return string
|
||||
*/
|
||||
function toHtml() {
|
||||
global $CFG;
|
||||
global $CFG, $PAGE;
|
||||
require_once $CFG->libdir . '/recaptchalib.php';
|
||||
|
||||
$html = '<script type="text/javascript">
|
||||
var RecaptchaOptions = {
|
||||
theme : \'custom\',
|
||||
tabindex : 2,
|
||||
custom_theme_widget : \'recaptcha_widget\'
|
||||
};
|
||||
</script>' . "\n";
|
||||
$recaptureoptions = Array('theme'=>'custom', 'tabindex'=>2, 'custom_theme_widget'=>'recaptcha_widget');
|
||||
$html = $PAGE->requires->data_for_js('RecaptchaOptions', $recaptureoptions)->asap();
|
||||
|
||||
$attributes = $this->getAttributes();
|
||||
if (empty($attributes['error_message'])) {
|
||||
|
||||
Reference in New Issue
Block a user