mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
group MDL-21533 Replaced overlib usage within Group with YUI3 equivilant JavaScript code
This commit is contained in:
parent
4f5b5ca15e
commit
c24895978f
42
group/module.js
Normal file
42
group/module.js
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
M.core_group = {
|
||||
hoveroverlay : null
|
||||
};
|
||||
|
||||
M.core_group.init_hover_events = function(Y, events) {
|
||||
// Prepare the overlay if it hasn't already been created
|
||||
this.hoveroverlay = this.hoveroverlay || (function(){
|
||||
// New Y.Overlay
|
||||
var overlay = new Y.Overlay({
|
||||
bodyContent : 'Loading',
|
||||
visible : false,
|
||||
zIndex : 2
|
||||
});
|
||||
// Render it against the page
|
||||
overlay.render(Y.one('#page'));
|
||||
return overlay;
|
||||
})();
|
||||
|
||||
// Iterate over the events and attach an event to display the description on
|
||||
// hover
|
||||
for (var id in events) {
|
||||
var node = Y.one('#'+id);
|
||||
if (node) {
|
||||
node = node.ancestor();
|
||||
node.on('mouseenter', function(e, content){
|
||||
M.core_group.hoveroverlay.set('xy', [this.getX()+(this.get('offsetWidth')/2),this.getY()+this.get('offsetHeight')-5]);
|
||||
M.core_group.hoveroverlay.set("bodyContent", content);
|
||||
M.core_group.hoveroverlay.show();
|
||||
M.core_group.hoveroverlay.get('boundingBox').setStyle('visibility', 'visible');
|
||||
}, node, events[id]);
|
||||
node.on('mouseleave', function(e){
|
||||
M.core_group.hoveroverlay.hide();
|
||||
M.core_group.hoveroverlay.get('boundingBox').setStyle('visibility', 'hidden');
|
||||
}, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,9 +115,6 @@ if ($rs = $DB->get_recordset_sql($sql, $params)) {
|
||||
$rs->close();
|
||||
}
|
||||
|
||||
$PAGE->requires->js('/lib/overlib/overlib.js', true);
|
||||
$PAGE->requires->js('/lib/overlib/overlib_cssstyle.js', true);
|
||||
|
||||
$PAGE->navbar->add($strparticipants, new moodle_url('/user/index.php', array('id'=>$courseid)));
|
||||
$PAGE->navbar->add($strgroups);
|
||||
|
||||
@ -161,6 +158,7 @@ echo $OUTPUT->render($select);
|
||||
|
||||
/// Print table
|
||||
$printed = false;
|
||||
$hoverevents = array();
|
||||
foreach ($members as $gpgid=>$groupdata) {
|
||||
if ($groupingid and $groupingid != $gpgid) {
|
||||
continue; // do not show
|
||||
@ -180,14 +178,12 @@ foreach ($members as $gpgid=>$groupdata) {
|
||||
$description = file_rewrite_pluginfile_urls($groups[$gpid]->description, 'pluginfile.php', $context->id, 'course_group_description', $gpid);
|
||||
$options = new stdClass;
|
||||
$options->noclean = true;
|
||||
$jsdescription = addslashes_js(trim(format_text($description, $groups[$gpid]->descriptionformat, $options)));
|
||||
$jsdescription = trim(format_text($description, $groups[$gpid]->descriptionformat, $options));
|
||||
if (empty($jsdescription)) {
|
||||
$line[] = $name;
|
||||
} else {
|
||||
$jsstrdescription = addslashes_js($strdescription);
|
||||
$overlib = "return overlib('$jsdescription', BORDER, 0, FGCLASS, 'description', "
|
||||
."CAPTIONFONTCLASS, 'caption', CAPTION, '$jsstrdescription');";
|
||||
$line[] = '<span onmouseover="'.s($overlib).'" onmouseout="return nd();">'.$name.'</span>';
|
||||
$line[] = html_writer::tag('span', $name, array('id'=>'group_'.$gpid));
|
||||
$hoverevents['group_'.$gpid] = $jsdescription;
|
||||
}
|
||||
$fullnames = array();
|
||||
foreach ($users as $user) {
|
||||
@ -215,4 +211,9 @@ foreach ($members as $gpgid=>$groupdata) {
|
||||
$printed = true;
|
||||
}
|
||||
|
||||
if (count($hoverevents)>0) {
|
||||
$PAGE->requires->string_for_js('description', 'moodle');
|
||||
$PAGE->requires->js_init_call('M.core_group.init_hover_events', array($hoverevents));
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -393,6 +393,11 @@ class page_requirements_manager {
|
||||
'fullpath' => '/lib/flashdetect/flashdetect.js',
|
||||
'requires' => array('io'));
|
||||
break;
|
||||
case 'core_group':
|
||||
$module = array('name' => 'core_group',
|
||||
'fullpath' => '/group/module.js',
|
||||
'requires' => array('node', 'overlay', 'event-mouseenter'));
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -58,6 +58,19 @@ a.skip-block {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.yui-overlay .yui-widget-bd {
|
||||
background-color:#FFEE69;
|
||||
border-color:#D4C237 #A6982B #A6982B;
|
||||
border-style:solid;
|
||||
border-width:1px;
|
||||
color:#000000;
|
||||
left:0;
|
||||
padding:2px 5px;
|
||||
position:relative;
|
||||
top:0;
|
||||
z-index:1;
|
||||
}
|
||||
|
||||
.clearer {
|
||||
clear:both;
|
||||
margin:0;
|
||||
@ -151,4 +164,4 @@ a.skip-block {
|
||||
vertical-align:middle;
|
||||
height:16px;
|
||||
width:16px;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user