Hello!
When one clicks on an autolinked word or phrase in a resource text, a "Glossary entry" popup window is displayed. This popup window is created with the following parameters:
menubar=0,location=0,scrollbars,resizable,width=600,height=450
For all types of text resources created online & residing within the Moodle database, i.e. text page, web page & label, the popup window is indeed displayed with those parameters.
However, the appearance of that popup window is not correct when the resource text is an uploaded HTML file.
The reason is as follows: both types of resources are parsed for the detection of terms present in the glossaries and autolink links are then dynamically created, including the parameters mentioned above. So far, so good. But only the resources of "online type" are output as HTML with the appropriate javascript function openpopup(). That function is not added to the <head></head> section of an uploaded HTML file. Consequently, the popup window opens as a "normal" window, complete with menubar, not located in the top-left corner and not sized 600x450.
I posted this as a bug report some time ago but it has not been answered. For anyone irritated by this glossary entry popup window wrong behavior, I can propose 2 workarounds.
Workaround 1: modifying Moodle file \lib\filterlib.php
using latest version 1.5.2, around line 220, just before returning the modified text with autolinks in it, add this:
if (!empty($ignoretags)) {
$text = str_replace(array_keys($ignoretags),$ignoretags,$text);
}
//MODIFIED JOSEPH REZEAU 22 JULY 2005
$nopopupfunction = '</head>';
$popupfunction = '<script language="javascript" type="text/javascript">function openpopup(url,name,options,fullscreen) {var _url = top.location.href;var _start =_url.indexOf("/mod/");var startUrl = _url.substring(0,_start);fullUrl = startUrl + url;windowobj = window.open(fullUrl,name, options);windowobj.moveTo(0,0);windowobj.focus();return false;}</script></head>';
$text = str_replace($nopopupfunction, $popupfunction, $text);
//END MODIF JR
return $text;
caveat: this relies on the presence of a <head></head> section in the uploaded HTML file, i.e. we suppose it is "correct" HTML
Workaround 2: modifying your HTML files
simply add the script for the missing openpopup() function in the head of your HTML FILES before uploading them to your Moodle course; if you have a large number of such files, that function could of course reside in an external *.js file and you would refer to it in the head of all your HTML files. Here is the script:
<script language="javascript"
type="text/javascript">
function
openpopup(url,name,options,fullscreen) {
var _url =
top.location.href;
var _start =_url.indexOf("/mod/");
var startUrl =
_url.substring(0,_start);
fullUrl = startUrl + url;
windowobj =
window.open(fullUrl,name,options);windowobj.moveTo(0,0);
windowobj.focus();
return
false;
}
</script>
I hope this will be useful and am looking forward to your testing it...
Joseph
NOTE: in the scripts above, you will notice that the HTML editor has replaced language with Xlanguage; please remove the superfluous X to make the scripts work...