mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 04:33:13 +01:00
mod-chat MDL-21534 Added documentation, revised namespace, fixed non-namespaced function call.
This commit is contained in:
parent
579a4976cc
commit
c5f1fdb451
@ -36,7 +36,7 @@ $module = array(
|
||||
'fullpath' => '/mod/chat/gui_header_js/module.js',
|
||||
'requires' => array('base', 'node')
|
||||
);
|
||||
$PAGE->requires->js_init_call('M.mod_chat_js.init', array(false), false, $module);
|
||||
$PAGE->requires->js_init_call('M.mod_chat.js.init', array(false), false, $module);
|
||||
|
||||
//Setup course, lang and theme
|
||||
$PAGE->set_course($course);
|
||||
|
@ -63,10 +63,15 @@ if (!empty($chat_message)) {
|
||||
}
|
||||
|
||||
if ($chatuser->version == 'header_js') {
|
||||
|
||||
/// force msg referesh ASAP
|
||||
$PAGE->requires->js('/mod/chat/gui_header_js/chat_gui_header.js');
|
||||
if ($CFG->chat_normal_updatemode != 'jsupdated') { // See bug MDL-6791
|
||||
$PAGE->requires->js_function_call('insert_redirect');
|
||||
$module = array(
|
||||
'name' => 'mod_chat_js',
|
||||
'fullpath' => '/mod/chat/gui_header_js/module.js',
|
||||
'requires' => array('base', 'node')
|
||||
);
|
||||
$PAGE->requires->js_init_call('M.mod_chat.js.insert_redirect', array(false), false, $module);
|
||||
}
|
||||
$PAGE->requires->js_function_call('parent.input.enableForm');
|
||||
}
|
||||
|
@ -1,12 +1,31 @@
|
||||
/**
|
||||
* Module for the general JavaScript chat module
|
||||
*/
|
||||
YUI.add('mod_chat_js', function(Y){
|
||||
/**
|
||||
* @namespace M.mod_chat
|
||||
*/
|
||||
M.mod_chat = M.mod_chat || {};
|
||||
/**
|
||||
* @namespace M.mod_chat.js
|
||||
*/
|
||||
M.mod_chat.js = {
|
||||
|
||||
M.mod_chat_js = {
|
||||
|
||||
waitflag : false,
|
||||
timer : null,
|
||||
timeout : 1,
|
||||
users : [],
|
||||
waitflag : false, // True when a submission is in progress
|
||||
timer : null, // Stores the timer object
|
||||
timeout : 1, // The seconds between updates
|
||||
users : [], // An array of users
|
||||
|
||||
/**
|
||||
* Function that kicks everything off depending on what is available
|
||||
* within the page, this means we can call it from within each frame and it
|
||||
* will set up correctly
|
||||
*
|
||||
* @function
|
||||
* @this {M.mod_chat.js}
|
||||
* @param {YUI} Y
|
||||
* @param {Array|null} users
|
||||
*/
|
||||
init : function(Y, users) {
|
||||
if (users) {
|
||||
this.users = users;
|
||||
@ -18,17 +37,30 @@ YUI.add('mod_chat_js', function(Y){
|
||||
inputform.on('submit', this.submit, this);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Starts the update timeout
|
||||
*
|
||||
* @function
|
||||
* @this {M.mod_chat.js}
|
||||
*/
|
||||
start : function() {
|
||||
this.timer = setTimeout(function(self){
|
||||
self.update();
|
||||
}, this.timeout*1000, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Stops the update timeout
|
||||
* @function
|
||||
* @this {M.mod_chat.js}
|
||||
*/
|
||||
stop : function() {
|
||||
clearTimeout(this.timer);
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the user information
|
||||
* @function
|
||||
* @this {M.mod_chat.js}
|
||||
*/
|
||||
update : function() {
|
||||
for (var i in this.users) {
|
||||
var el = Y.one('#uidle'+this.users[i]);
|
||||
@ -42,17 +74,26 @@ YUI.add('mod_chat_js', function(Y){
|
||||
}
|
||||
this.start();
|
||||
},
|
||||
|
||||
/**
|
||||
* Redirects the frames parent
|
||||
*/
|
||||
insert_redirect : function() {
|
||||
parent.jsupdate.location.href = parent.jsupdate.document.anchors[0].href;
|
||||
},
|
||||
|
||||
enable_form : function(el) {
|
||||
/**
|
||||
* Enables the input form
|
||||
* @this {M.mod_chat.js}
|
||||
*/
|
||||
enable_form : function() {
|
||||
var el = Y.one('#input_chat_message');
|
||||
this.waitflag = false;
|
||||
el.set('className','');
|
||||
el.focus();
|
||||
},
|
||||
|
||||
/**
|
||||
* Submits the entered message
|
||||
* @param {Event} e
|
||||
*/
|
||||
submit : function(e) {
|
||||
e.halt();
|
||||
if(this.waitflag) {
|
||||
@ -64,10 +105,9 @@ YUI.add('mod_chat_js', function(Y){
|
||||
inputchatmessage.set('value', '');
|
||||
inputchatmessage.addClass('wait');
|
||||
Y.one('#sendForm').submit();
|
||||
this.enable_form(inputchatmessage);
|
||||
this.enable_form();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}, '2.0.0', {requires:['base','node']});
|
@ -72,7 +72,7 @@ $module = array(
|
||||
'fullpath' => '/mod/chat/gui_header_js/module.js',
|
||||
'requires' => array('base', 'node')
|
||||
);
|
||||
$PAGE->requires->js_init_call('M.mod_chat_js.init', array($uidles), false, $module);
|
||||
$PAGE->requires->js_init_call('M.mod_chat.js.init', array($uidles), false, $module);
|
||||
|
||||
/// Print user panel body
|
||||
$timenow = time();
|
||||
@ -92,7 +92,6 @@ foreach ($chatusers as $chatuser) {
|
||||
|
||||
|
||||
$row = array();
|
||||
//$popupid = $OUTPUT->add_action_handler(new component_action('click', 'openpopup', array('url'=>'/user/view.php?id=$chatuser->id&course=$courseid', 'name'=>'user'.$chatuser->id, 'options'=>'')));
|
||||
$row[0] = $OUTPUT->user_picture($chatuser, array('courseid'=>$courseid, 'popup'=>true));
|
||||
$row[1] = html_writer::start_tag('p');
|
||||
$row[1] .= html_writer::start_tag('font', array('size'=>'1'));
|
||||
|
Loading…
x
Reference in New Issue
Block a user