mod-chat MDL-16706 Removed inline JS and replaced with new PAGE methods

This commit is contained in:
samhemelryk
2009-06-26 06:53:23 +00:00
parent bd257031a9
commit 0763ab2c65
2 changed files with 17 additions and 23 deletions
+14
View File
@@ -0,0 +1,14 @@
scroll_active = true;
function empty_field_and_submit() {
var cf = document.getElementById('sendform');
var inpf = document.getElementById('inputform');
cf.chat_msgidnr.value = parseInt(cf.chat_msgidnr.value) + 1;
cf.chat_message.value = inpf.chat_message.value;
inpf.chat_message.value='';
cf.submit();
inpf.chat_message.focus();
return false;
}
function setfocus() {
document.getElementsByName("chat_message")[0].focus();
}
+3 -23
View File
@@ -16,30 +16,10 @@
//Setup course, lang and theme
$PAGE->set_course($DB->get_record('course', array('id' => $chatuser->course)));
ob_start();
?>
<script type="text/javascript">
scroll_active = true;
function empty_field_and_submit() {
var cf = document.getElementById('sendform');
var inpf = document.getElementById('inputform');
cf.chat_msgidnr.value = parseInt(cf.chat_msgidnr.value) + 1;
cf.chat_message.value = inpf.chat_message.value;
inpf.chat_message.value='';
cf.submit();
inpf.chat_message.focus();
return false;
}
function setfocus() {
document.getElementsByName("chat_message")[0].focus();
}
</script>
<?php
$meta = ob_get_clean();
$PAGE->requires->js('mod/chat/gui_sockets/chat_gui_sockets.js')->in_head();
$PAGE->requires->js_function_call('setfocus');
// TODO: there will be two onload in body tag, does it matter?
print_header('', '', '', 'inputform.chat_message', $meta, false, '&nbsp;', '', false, 'onload="setfocus();"');
print_header('', '', '', 'inputform.chat_message', '', false, '&nbsp;', '', false);
?>