diff --git a/mod/glossary/showentry.php b/mod/glossary/showentry.php index 9045c2115d6..f6e0b27b5fd 100644 --- a/mod/glossary/showentry.php +++ b/mod/glossary/showentry.php @@ -8,6 +8,11 @@ $courseid = optional_param('courseid', 0, PARAM_INT); $eid = optional_param('eid', 0, PARAM_INT); // glossary entry id $displayformat = optional_param('displayformat',-1, PARAM_SAFEDIR); $popup = optional_param('popup',0, PARAM_INT); +$ajax = optional_param('ajax',0, PARAM_INT); + +if ($ajax && !defined('AJAX_SCRIPT')) { + define('AJAX_SCRIPT', true); +} $url = new moodle_url('/mod/glossary/showentry.php'); $url->param('concept', $concept); @@ -42,6 +47,8 @@ if ($eid) { if ($popup) { $PAGE->set_pagelayout('popup'); +} else if (!$ajax) { + $PAGE->set_pagelayout('course'); } if ($entries) { @@ -70,6 +77,14 @@ if ($entries) { } } +if ($ajax) { + $result = new stdClass; + $result->success = true; + $result->entries = $entries; + echo json_encode($result); + die(); +} + if (!empty($courseid)) { $strglossaries = get_string('modulenameplural', 'glossary'); $strsearch = get_string('search'); diff --git a/mod/glossary/styles.css b/mod/glossary/styles.css index 0ac192f2511..d7c005bcff1 100644 --- a/mod/glossary/styles.css +++ b/mod/glossary/styles.css @@ -26,4 +26,6 @@ #page-mod-glossary-view table.glossarycategoryheader {margin-bottom:0em;} #page-mod-glossary-view table.glossarycategoryheader th {padding:0px;} -#page-mod-glossary-showentry #page-content {min-width:600px;} \ No newline at end of file +#page-mod-glossary-showentry #page-content {min-width:600px;} + +#glossaryoverlayprogress {position:fixed;top:50%;width:100%;text-align:center;} \ No newline at end of file diff --git a/mod/glossary/yui/autolinker/autolinker.js b/mod/glossary/yui/autolinker/autolinker.js index 56e014d26fc..dcd5915da1c 100644 --- a/mod/glossary/yui/autolinker/autolinker.js +++ b/mod/glossary/yui/autolinker/autolinker.js @@ -22,16 +22,65 @@ YUI.add('moodle-mod_glossary-autolinker', function(Y) { AUTOLINKER.superclass.constructor.apply(this, arguments); } Y.extend(AUTOLINKER, Y.Base, { + overlay : null, initializer : function(config) { var popupname = this.get(POPUPNAME), - popupoptions = this.get(POPUPOPTIONS); + popupoptions = this.get(POPUPOPTIONS), + self = this; Y.delegate('click', function(e){ - openpopup(e, { - url : this.getAttribute('href')+'&popup=1', - name : popupname, - options : build_windowoptionsstring(popupoptions) - }) + + e.preventDefault(); + + //display a progress indicator + var title = ''; + var content = Y.Node.create('
'); + var o = new Y.Overlay({ + headerContent : title, + bodyContent : content + }); + self.overlay = o; + o.render(Y.one(document.body)); + + //fetch the glossary item + var fullurl = this.getAttribute('href')+'&ajax=1'; + var cfg = { + method: 'get', + context : self, + on: { + success: function(id, o, node) { + this.display_callback(o.responseText); + }, + failure: function(id, o, node) { + var debuginfo = o.statusText; + if (M.cfg.developerdebug) { + o.statusText += ' (' + fullurl + ')'; + } + this.display_callback('bodyContent',debuginfo); + } + } + }; + Y.io(fullurl, cfg); + }, Y.one(document.body), 'a.glossary.autolink'); + }, + display_callback : function(content) { + try { + var data = Y.JSON.parse(content); + if (data.success){ + this.overlay.hide(); //hide progress indicator + + for (key in data.entries) { + new M.core.alert({title:data.entries[key].concept, message:data.entries[key].definition, lightbox:false}); + } + + return true; + } else if (data.error) { + alert(data.error); + } + }catch(ex) { + alert(ex.message+" "+content); + } + return false; } }, { NAME : AUTOLINKERNAME, @@ -82,4 +131,4 @@ YUI.add('moodle-mod_glossary-autolinker', function(Y) { return new AUTOLINKER(config); } -}, '@VERSION@', {requires:['base','node','event-delegate']}); \ No newline at end of file +}, '@VERSION@', {requires:['base','node','event-delegate','overlay','moodle-enrol-notification']}); \ No newline at end of file