MDL-29992 filters - move js popup from mod/glossary to filter/glossary
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Sat, 29 Oct 2011 16:40:56 +0000 (18:40 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Sat, 29 Oct 2011 17:02:07 +0000 (19:02 +0200)
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.

filter/glossary/filter.php
filter/glossary/yui/autolinker/autolinker.js [moved from mod/glossary/yui/autolinker/autolinker.js with 90% similarity]

index 197a02d..8592626 100644 (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;
             }
         }
similarity index 90%
rename from mod/glossary/yui/autolinker/autolinker.js
rename to filter/glossary/yui/autolinker/autolinker.js
index e8935f3..46d04bc 100644 (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']});
\ No newline at end of file
+}, '@VERSION@', {requires:['base','node','event-delegate','overlay','moodle-enrol-notification']});