Skip to content

Commit

Permalink
group MDL-21533 Replaced overlib usage within Group with YUI3 equivil…
Browse files Browse the repository at this point in the history
…ant JavaScript code
  • Loading branch information
Sam Hemelryk committed Feb 24, 2010
1 parent 4f5b5ca commit c248959
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 9 deletions.
42 changes: 42 additions & 0 deletions group/module.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
}

17 changes: 9 additions & 8 deletions group/overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@
$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);

Expand Down Expand Up @@ -161,6 +158,7 @@

/// Print table
$printed = false;
$hoverevents = array();
foreach ($members as $gpgid=>$groupdata) {
if ($groupingid and $groupingid != $gpgid) {
continue; // do not show
Expand All @@ -180,14 +178,12 @@
$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) {
Expand Down Expand Up @@ -215,4 +211,9 @@
$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();
5 changes: 5 additions & 0 deletions lib/outputrequirementslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,11 @@ protected function find_module($name) {
'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 {
Expand Down
15 changes: 14 additions & 1 deletion theme/base/style/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -151,4 +164,4 @@ a.skip-block {
vertical-align:middle;
height:16px;
width:16px;
}
}

0 comments on commit c248959

Please sign in to comment.