MDL-29992 filters - move js popup from mod/glossary to filter/glossary

This commit moves the js popup to the new location of the filter. Also
it fixes one bug, with the js processing also glossary category links
leading to error, so now the categories are working again.
This commit is contained in:
Eloy Lafuente (stronk7) 2011-10-29 18:40:56 +02:00
parent 85a69ce123
commit d307a1a70d
2 changed files with 14 additions and 11 deletions

View File

@ -32,7 +32,6 @@ defined('MOODLE_INTERNAL') || die();
*
* TODO: erase the $GLOSSARY_EXCLUDECONCEPTS global => require format_text()
* to be able to pass arbitrary $options['filteroptions']['glossary'] to filter_text()
* TODO: fix linking to glossary categories
*/
class filter_glossary extends moodle_text_filter {
@ -151,8 +150,9 @@ class filter_glossary extends moodle_text_filter {
foreach ($concepts as $concept) {
$glossaryname = str_replace(':', '-', $glossaries[$concept->glossaryid]);
if ($concept->category) { // Link to a category
// TODO: Fix this string usage
$title = strip_tags($glossaryname.': '.$strcategory.' '.$concept->concept);
$href_tag_begin = '<a class="glossary autolink glossaryid'.$concept->glossaryid.'" title="'.$title.'" '.
$href_tag_begin = '<a class="glossary autolink category glossaryid'.$concept->glossaryid.'" title="'.$title.'" '.
'href="'.$CFG->wwwroot.'/mod/glossary/view.php?g='.$concept->glossaryid.
'&amp;mode=cat&amp;hook='.$concept->id.'">';
} else { // Link to entry or alias
@ -170,7 +170,7 @@ class filter_glossary extends moodle_text_filter {
$attributes = array(
'href' => $link,
'title'=> $title,
'class'=> 'glossary autolink glossaryid'.$concept->glossaryid);
'class'=> 'glossary autolink concept glossaryid'.$concept->glossaryid);
// this flag is optionally set by resource_pluginfile()
// if processing an embedded file use target to prevent getting nested Moodles
@ -189,7 +189,10 @@ class filter_glossary extends moodle_text_filter {
if (empty($jsinitialised)) {
// Add a JavaScript event to open popup's here. This only ever need to be
// added once!
$PAGE->requires->yui_module('moodle-mod_glossary-autolinker', 'M.mod_glossary.init_filter_autolinking', array(array('courseid'=>$courseid)));
$PAGE->requires->yui_module(
'moodle-filter_glossary-autolinker',
'M.filter_glossary.init_filter_autolinking',
array(array('courseid' => $courseid)));
$jsinitialised = true;
}
}

View File

@ -1,6 +1,6 @@
YUI.add('moodle-mod_glossary-autolinker', function(Y) {
YUI.add('moodle-filter_glossary-autolinker', function(Y) {
var AUTOLINKERNAME = 'Glossary autolinker',
var AUTOLINKERNAME = 'Glossary filter autolinker',
URL = 'url',
POPUPNAME = 'name',
POPUPOPTIONS = 'options',
@ -33,7 +33,7 @@ YUI.add('moodle-mod_glossary-autolinker', function(Y) {
//display a progress indicator
var title = '';
var content = Y.Node.create('<div id="glossaryoverlayprogress"><img src="'+M.cfg.loadingicon+'" class="spinner" /></div>');
var content = Y.Node.create('<div id="glossaryfilteroverlayprogress"><img src="'+M.cfg.loadingicon+'" class="spinner" /></div>');
var o = new Y.Overlay({
headerContent : title,
bodyContent : content
@ -61,7 +61,7 @@ YUI.add('moodle-mod_glossary-autolinker', function(Y) {
};
Y.io(fullurl, cfg);
}, Y.one(document.body), 'a.glossary.autolink');
}, Y.one(document.body), 'a.glossary.autolink.concept');
},
display_callback : function(content) {
try {
@ -126,9 +126,9 @@ YUI.add('moodle-mod_glossary-autolinker', function(Y) {
}
});
M.mod_glossary = M.mod_glossary || {};
M.mod_glossary.init_filter_autolinking = function(config) {
M.filter_glossary = M.filter_glossary || {};
M.filter_glossary.init_filter_autolinking = function(config) {
return new AUTOLINKER(config);
}
}, '@VERSION@', {requires:['base','node','event-delegate','overlay','moodle-enrol-notification']});
}, '@VERSION@', {requires:['base','node','event-delegate','overlay','moodle-enrol-notification']});