Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL 38508 JavaScript: Split out AJAX and non-AJAX help

We need to keep these two separate as scripts which define AJAX_SCRIPT
before loading config.php will use a different default renderer and will
return appropriate exceptions which can be parsed by M.core.exception and
M.core.ajaxException correctly.

This also addresses an issue whereby a missing heading could break the
tooltip.
  • Loading branch information...
commit 56d465b2d3cdc203e2ed9c9af3a4220d7b72ce75 1 parent 422f68f
Andrew Nicols andrewnicols authored andrewnicols committed
73 help.php
View
@@ -32,73 +32,22 @@
$identifier = required_param('identifier', PARAM_STRINGID);
$component = required_param('component', PARAM_COMPONENT);
-$lang = required_param('lang', PARAM_LANG); // TODO: maybe split into separate scripts
-$ajax = optional_param('ajax', 0, PARAM_BOOL);
+$lang = optional_param('lang', 'en', PARAM_LANG);
-if (!$lang) {
- $lang = 'en';
-}
-$SESSION->lang = $lang; // does not actually modify session because we do not use cookies here
-
-$sm = get_string_manager();
+// We don't actually modify the session here as we have NO_MOODLE_COOKIES set.
+$SESSION->lang = $lang;
$PAGE->set_url('/help.php');
$PAGE->set_pagelayout('popup');
$PAGE->set_context(context_system::instance());
-if ($ajax) {
- @header('Content-Type: text/plain; charset=utf-8');
-}
-
-if (!$sm->string_exists($identifier.'_help', $component)) {
- // strings on disk-cache may be dirty - try to rebuild it and check again
- $sm->load_component_strings($component, current_language(), true);
-}
-
-$data = new stdClass();
-
-if ($sm->string_exists($identifier.'_help', $component)) {
- $options = new stdClass();
- $options->trusted = false;
- $options->noclean = false;
- $options->smiley = false;
- $options->filter = false;
- $options->para = true;
- $options->newlines = false;
- $options->overflowdiv = !$ajax;
-
- $data->heading = format_string(get_string($identifier, $component));
- // Should be simple wiki only MDL-21695
- $data->text = format_text(get_string($identifier.'_help', $component), FORMAT_MARKDOWN, $options);
-
- $helplink = $identifier . '_link';
- if ($sm->string_exists($helplink, $component)) { // Link to further info in Moodle docs
- $link = get_string($helplink, $component);
- $linktext = get_string('morehelp');
-
- $data->doclink = new stdClass();
- $url = new moodle_url(get_docs_url($link));
- $data->doclink->link = $url->out();
- $data->doclink->linktext = $linktext;
- $data->doclink->class = ($CFG->doctonewwindow) ? 'helplinkpopup' : '';
-
- $completedoclink = html_writer::tag('div', $OUTPUT->doc_link($link, $linktext), array('class' => 'helpdoclink'));
- }
-} else {
- $data->text = html_writer::tag('p',
- html_writer::tag('strong', 'TODO') . ": missing help string [{$identifier}_help, {$component}]");
+$data = get_formatted_help_string($identifier, $component, false);
+echo $OUTPUT->header();
+if (!empty($data->heading)) {
+ echo $OUTPUT->heading($data->heading, 1, 'helpheading');
}
-
-if ($ajax) {
- echo json_encode($data);
-} else {
- echo $OUTPUT->header();
- if (isset($data->heading)) {
- echo $OUTPUT->heading($data->heading, 1, 'helpheading');
- }
- echo $data->text;
- if (isset($completedoclink)) {
- echo $completedoclink;
- }
- echo $OUTPUT->footer();
+echo $data->text;
+if (isset($data->completedoclink)) {
+ echo $data->completedoclink;
}
+echo $OUTPUT->footer();
40 help_ajax.php
View
@@ -0,0 +1,40 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Displays help via AJAX call
+ *
+ * @copyright 2013 onwards Andrew Nicols
+ * @package core
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+define('NO_MOODLE_COOKIES', true);
+define('AJAX_SCRIPT', true);
+require_once(__DIR__ . '/config.php');
+
+$identifier = required_param('identifier', PARAM_STRINGID);
+$component = required_param('component', PARAM_COMPONENT);
+$lang = optional_param('lang', 'en', PARAM_LANG);
+
+// We don't actually modify the session here as we have NO_MOODLE_COOKIES set.
+$SESSION->lang = $lang;
+$PAGE->set_url('/help_ajax.php');
+$PAGE->set_context(context_system::instance());
+
+$data = get_formatted_help_string($identifier, $component, true);
+echo json_encode($data);
69 lib/weblib.php
View
@@ -3463,3 +3463,72 @@ function print_password_policy() {
}
return $message;
}
+
+/**
+ * Get the value of a help string fully prepared for display in the current language.
+ *
+ * @param string $identifier The identifier of the string to search for.
+ * @param string $component The module the string is associated with.
+ * @param boolean $ajax Whether this help is called from an AJAX script.
+ * This is used to influence text formatting and determines
+ * which format to output the doclink in.
+ * @return Object An object containing:
+ * - heading: Any heading that there may be for this help string.
+ * - text: The wiki-formatted help string.
+ * - doclink: An object containing a link, the linktext, and any additional
+ * CSS classes to apply to that link. Only present if $ajax = false.
+ * - completedoclink: A text representation of the doclink. Only present if $ajax = true.
+ */
+function get_formatted_help_string($identifier, $component, $ajax = false) {
+ global $CFG, $OUTPUT;
+ $sm = get_string_manager();
+
+ if (!$sm->string_exists($identifier, $component) ||
+ !$sm->string_exists($identifier . '_help', $component)) {
+ // Strings in the on-disk cache may be dirty - try to rebuild it and check again.
+ $sm->load_component_strings($component, current_language(), true);
+ }
+
+ $data = new stdClass();
+
+ if ($sm->string_exists($identifier, $component)) {
+ $data->heading = format_string(get_string($identifier, $component));
+ } else {
+ // Gracefully fall back to an empty string.
+ $data->heading = '';
+ }
+
+ if ($sm->string_exists($identifier . '_help', $component)) {
+ $options = new stdClass();
+ $options->trusted = false;
+ $options->noclean = false;
+ $options->smiley = false;
+ $options->filter = false;
+ $options->para = true;
+ $options->newlines = false;
+ $options->overflowdiv = !$ajax;
+
+ // Should be simple wiki only MDL-21695.
+ $data->text = format_text(get_string($identifier.'_help', $component), FORMAT_MARKDOWN, $options);
+
+ $helplink = $identifier . '_link';
+ if ($sm->string_exists($helplink, $component)) { // Link to further info in Moodle docs
+ $link = get_string($helplink, $component);
+ $linktext = get_string('morehelp');
+
+ $data->doclink = new stdClass();
+ $url = new moodle_url(get_docs_url($link));
+ if ($ajax) {
+ $data->doclink->link = $url->out();
+ $data->doclink->linktext = $linktext;
+ $data->doclink->class = ($CFG->doctonewwindow) ? 'helplinkpopup' : '';
+ } else {
+ $data->completedoclink = html_writer::tag('div', $OUTPUT->doc_link($link, $linktext), array('class' => 'helpdoclink'));
+ }
+ }
+ } else {
+ $data->text = html_writer::tag('p',
+ html_writer::tag('strong', 'TODO') . ": missing help string [{$identifier}_help, {$component}]");
+ }
+ return $data;
+}
203 lib/yui/build/moodle-core-tooltip/moodle-core-tooltip-coverage.js
View
@@ -26,11 +26,11 @@ _yuitest_coverage["build/moodle-core-tooltip/moodle-core-tooltip.js"] = {
path: "build/moodle-core-tooltip/moodle-core-tooltip.js",
code: []
};
-_yuitest_coverage["build/moodle-core-tooltip/moodle-core-tooltip.js"].code=["YUI.add('moodle-core-tooltip', function (Y, NAME) {","","/**"," * Provides the base tooltip class."," *"," * @module moodle-core-tooltip"," */","","/**"," * A base class for a tooltip."," *"," * @param {Object} config Object literal specifying tooltip configuration properties."," * @class M.core.tooltip"," * @constructor"," * @extends M.core.dialogue"," */","function TOOLTIP(config) {"," if (!config) {"," config = {};"," }",""," // Override the default options provided by the parent class."," if (typeof config.draggable === 'undefined') {"," config.draggable = true;"," }",""," if (typeof config.constrain === 'undefined') {"," config.constrain = true;"," }",""," if (typeof config.lightbox === 'undefined') {"," config.lightbox = false;"," }",""," TOOLTIP.superclass.constructor.apply(this, [config]);","}","","var SELECTORS = {"," CLOSEBUTTON: '.closebutton'"," },",""," CSS = {"," PANELTEXT: 'tooltiptext'"," },"," RESOURCES = {"," WAITICON: {"," pix: 'i/loading_small',"," component: 'moodle'"," }"," },"," ATTRS = {};","","/**"," * Static property provides a string to identify the JavaScript class."," *"," * @property NAME"," * @type String"," * @static"," */","TOOLTIP.NAME = 'moodle-core-tooltip';","","/**"," * Static property used to define the CSS prefix applied to tooltip dialogues."," *"," * @property CSS_PREFIX"," * @type String"," * @static"," */","TOOLTIP.CSS_PREFIX = 'moodle-dialogue';","","/**"," * Static property used to define the default attribute configuration for the Tooltip."," *"," * @property ATTRS"," * @type String"," * @static"," */","TOOLTIP.ATTRS = ATTRS;","","/**"," * The initial value of the header region before the content finishes loading."," *"," * @attribute initialheadertext"," * @type String"," * @default ''"," * @writeOnce"," */","ATTRS.initialheadertext = {"," value: ''","};","","/**"," * The initial value of the body region before the content finishes loading."," *"," * The supplid string will be wrapped in a div with the CSS.PANELTEXT class and a standard Moodle spinner"," * appended."," *"," * @attribute initialbodytext"," * @type String"," * @default ''"," * @writeOnce"," */","ATTRS.initialbodytext = {"," value: '',"," setter: function(content) {"," var parentnode,"," spinner;"," parentnode = Y.Node.create('<div />')"," .addClass(CSS.PANELTEXT);",""," spinner = Y.Node.create('<img />')"," .setAttribute('src', M.util.image_url(RESOURCES.WAITICON.pix, RESOURCES.WAITICON.component))"," .addClass('spinner');",""," if (content) {"," // If we have been provided with content, add it to the parent and make"," // the spinner appear correctly inline"," parentnode.set('text', content);"," spinner.addClass('iconsmall');"," } else {"," // If there is no loading message, just make the parent node a lightbox"," parentnode.addClass('content-lightbox');"," }",""," parentnode.append(spinner);"," return parentnode;"," }","};","","/**"," * The initial value of the footer region before the content finishes loading."," *"," * If a value is supplied, it will be wrapped in a <div> first."," *"," * @attribute initialfootertext"," * @type String"," * @default ''"," * @writeOnce"," */","ATTRS.initialfootertext = {"," value: null,"," setter: function(content) {"," if (content) {"," return Y.Node.create('<div />')"," .set('text', content);"," }"," }","};","","/**"," * The function which handles setting the content of the title region."," * The specified function will be called with a context of the tooltip instance."," *"," * The default function will simply set the value of the title to object.heading as returned by the AJAX call."," *"," * @attribute headerhandler"," * @type Function|String|null"," * @default set_header_content"," */","ATTRS.headerhandler = {"," value: 'set_header_content'","};","","/**"," * The function which handles setting the content of the body region."," * The specified function will be called with a context of the tooltip instance."," *"," * The default function will simply set the value of the body area to a div containing object.text as returned"," * by the AJAX call."," *"," * @attribute bodyhandler"," * @type Function|String|null"," * @default set_body_content"," */","ATTRS.bodyhandler = {"," value: 'set_body_content'","};","","/**"," * The function which handles setting the content of the footer region."," * The specified function will be called with a context of the tooltip instance."," *"," * By default, the footer is not set."," *"," * @attribute footerhandler"," * @type Function|String|null"," * @default null"," */","ATTRS.footerhandler = {"," value: null","};","","/**"," * Set the Y.Cache object to use."," *"," * By default a new Y.Cache object will be created for each instance of the tooltip."," *"," * In certain situations, where multiple tooltips may share the same cache, it may be preferable to"," * seed this cache from the calling method."," *"," * @attribute textcache"," * @type Y.Cache|null"," * @default null"," */","ATTRS.textcache = {"," value: null","};","","/**"," * Set the default size of the Y.Cache object."," *"," * This is only used if no textcache is specified."," *"," * @attribute textcachesize"," * @type Number"," * @default 10"," */","ATTRS.textcachesize = {"," value: 10","};","","Y.extend(TOOLTIP, M.core.dialogue, {"," // The bounding box."," bb: null,",""," // Any event listeners we may need to cancel later."," listenevents: [],",""," // Cache of objects we've already retrieved."," textcache: null,",""," // The align position. This differs for RTL languages so we calculate once and store."," alignpoints: ["," Y.WidgetPositionAlign.TL,"," Y.WidgetPositionAlign.RC"," ],",""," initializer: function() {"," // Set the initial values for the handlers."," // These cannot be set in the attributes section as context isn't present at that time."," if (!this.get('headerhandler')) {"," this.set('headerhandler', this.set_header_content);"," }"," if (!this.get('bodyhandler')) {"," this.set('bodyhandler', this.set_body_content);"," }"," if (!this.get('footerhandler')) {"," this.set('footerhandler', function() {});"," }",""," // Set up the dialogue with initial content."," this.setAttrs({"," headerContent: this.get('initialheadertext'),"," bodyContent: this.get('initialbodytext'),"," footerContent: this.get('initialfootertext'),"," zIndex: 150"," });",""," // Hide and then render the dialogue."," this.hide();"," this.render();",""," // Hook into a few useful areas."," this.bb = this.get('boundingBox');",""," // Change the alignment if this is an RTL language."," if (right_to_left()) {"," this.alignpoints = ["," Y.WidgetPositionAlign.TR,"," Y.WidgetPositionAlign.LC"," ];"," }",""," // Set up the text cache if it's not set up already."," if (!this.get('textcache')) {"," this.set('textcache', new Y.Cache({"," // Set a reasonable maximum cache size to prevent memory growth."," max: this.get('textcachesize')"," }));"," }",""," // Disable the textcache when in developerdebug."," if (M.cfg.developerdebug) {"," this.get('textcache').set('max', 0);"," }",""," return this;"," },",""," /**"," * Display the tooltip for the clicked link."," *"," * The anchor for the clicked link is used, additionally appending ajax=1 to the parameters."," *"," * @method display_panel"," * @param {EventFacade} e The event from the clicked link. This is used to determine the clicked URL."," */"," display_panel: function(e) {"," var clickedlink, thisevent, ajaxurl, config, cacheentry;",""," // Prevent the default click action and prevent the event triggering anything else."," e.preventDefault();"," e.stopPropagation();",""," // Cancel any existing listeners and close the panel if it's already open."," this.cancel_events();",""," // Grab the clickedlink - this contains the URL we fetch and we align the panel to it."," clickedlink = e.target.ancestor('a', true);",""," // Align with the link that was clicked."," this.align(clickedlink, this.alignpoints);",""," // Reset the initial text to a spinner while we retrieve the text."," this.setAttrs({"," headerContent: this.get('initialheadertext'),"," bodyContent: this.get('initialbodytext'),"," footerContent: this.get('initialfootertext')"," });",""," // Now that initial setup has begun, show the panel."," this.show();",""," // Add some listen events to close on."," thisevent = this.bb.delegate('click', this.close_panel, SELECTORS.CLOSEBUTTON, this);"," this.listenevents.push(thisevent);",""," thisevent = Y.one('body').on('key', this.close_panel, 'esc', this);"," this.listenevents.push(thisevent);",""," // Listen for mousedownoutside events - clickoutside is broken on IE."," thisevent = this.bb.on('mousedownoutside', this.close_panel, this);"," this.listenevents.push(thisevent);",""," ajaxurl = clickedlink.get('href');",""," cacheentry = this.get('textcache').retrieve(ajaxurl);"," if (cacheentry) {"," // The data from this help call was already cached so use that and avoid an AJAX call."," this._set_panel_contents(cacheentry.response);"," } else {"," // Retrieve the actual help text we should use."," config = {"," method: 'get',"," context: this,"," sync: false,"," data: {"," // We use a slightly different AJAX URL to the one on the anchor to allow non-JS fallback."," ajax: 1"," },"," on: {"," complete: function(tid, response) {"," this._set_panel_contents(response.responseText, ajaxurl);"," }"," }"," };",""," Y.io(clickedlink.get('href'), config);"," }"," },",""," _set_panel_contents: function(response, ajaxurl) {"," var responseobject;",""," // Attempt to parse the response into an object."," try {"," responseobject = Y.JSON.parse(response);"," if (responseobject.error) {"," this.close_panel();"," return new M.core.ajaxException(responseobject);"," }"," } catch (error) {"," this.close_panel();"," return new M.core.exception({"," name: error.name,"," message: \"Unable to retrieve the requested content. The following error was returned: \" + error.message"," });"," }",""," // Set the contents using various handlers."," // We must use Y.bind to ensure that the correct context is used when the default handlers are overridden."," Y.bind(this.get('headerhandler'), this, responseobject)();"," Y.bind(this.get('bodyhandler'), this, responseobject)();"," Y.bind(this.get('footerhandler'), this, responseobject)();",""," if (ajaxurl) {"," // Ensure that this data is added to the cache."," this.get('textcache').add(ajaxurl, response);"," }",""," this.get('buttons').header[0].focus();"," },",""," set_header_content: function(responseobject) {"," this.set('headerContent', responseobject.heading);"," },",""," set_body_content: function(responseobject) {"," var bodycontent = Y.Node.create('<div />')"," .set('innerHTML', responseobject.text)"," .setAttribute('role', 'alert')"," .addClass(CSS.PANELTEXT);"," this.set('bodyContent', bodycontent);"," },",""," close_panel: function(e) {"," // Hide the panel first."," this.hide();",""," // Cancel the listeners that we added in display_panel."," this.cancel_events();",""," // Prevent any default click that the close button may have."," if (e) {"," e.preventDefault();"," }"," },",""," cancel_events: function() {"," // Detach all listen events to prevent duplicate triggers."," var thisevent;"," while (this.listenevents.length) {"," thisevent = this.listenevents.shift();"," thisevent.detach();"," }"," }","});","M.core = M.core || {};","M.core.tooltip = M.core.tooltip = TOOLTIP;","","","}, '@VERSION@', {"," \"requires\": ["," \"base\","," \"node\","," \"io-base\","," \"moodle-core-notification\","," \"json-parse\","," \"widget-position\","," \"widget-position-align\","," \"event-outside\","," \"cache\""," ]","});"];
-_yuitest_coverage["build/moodle-core-tooltip/moodle-core-tooltip.js"].lines = {"1":0,"17":0,"18":0,"19":0,"23":0,"24":0,"27":0,"28":0,"31":0,"32":0,"35":0,"38":0,"60":0,"69":0,"78":0,"88":0,"103":0,"106":0,"108":0,"111":0,"115":0,"118":0,"119":0,"122":0,"125":0,"126":0,"140":0,"143":0,"144":0,"160":0,"175":0,"189":0,"205":0,"218":0,"222":0,"241":0,"242":0,"244":0,"245":0,"247":0,"248":0,"252":0,"260":0,"261":0,"264":0,"267":0,"268":0,"275":0,"276":0,"283":0,"284":0,"287":0,"299":0,"302":0,"303":0,"306":0,"309":0,"312":0,"315":0,"322":0,"325":0,"326":0,"328":0,"329":0,"332":0,"333":0,"335":0,"337":0,"338":0,"340":0,"343":0,"353":0,"358":0,"363":0,"366":0,"367":0,"368":0,"369":0,"370":0,"373":0,"374":0,"382":0,"383":0,"384":0,"386":0,"388":0,"391":0,"395":0,"399":0,"403":0,"408":0,"411":0,"414":0,"415":0,"421":0,"422":0,"423":0,"424":0,"428":0,"429":0};
-_yuitest_coverage["build/moodle-core-tooltip/moodle-core-tooltip.js"].functions = {"TOOLTIP:17":0,"setter:105":0,"setter:142":0,"initializer:238":0,"complete:352":0,"display_panel:298":0,"_set_panel_contents:362":0,"set_header_content:394":0,"set_body_content:398":0,"close_panel:406":0,"cancel_events:419":0,"(anonymous 1):1":0};
-_yuitest_coverage["build/moodle-core-tooltip/moodle-core-tooltip.js"].coveredLines = 100;
-_yuitest_coverage["build/moodle-core-tooltip/moodle-core-tooltip.js"].coveredFunctions = 12;
+_yuitest_coverage["build/moodle-core-tooltip/moodle-core-tooltip.js"].code=["YUI.add('moodle-core-tooltip', function (Y, NAME) {","","/**"," * Provides the base tooltip class."," *"," * @module moodle-core-tooltip"," */","","/**"," * A base class for a tooltip."," *"," * @param {Object} config Object literal specifying tooltip configuration properties."," * @class M.core.tooltip"," * @constructor"," * @extends M.core.dialogue"," */","function TOOLTIP(config) {"," if (!config) {"," config = {};"," }",""," // Override the default options provided by the parent class."," if (typeof config.draggable === 'undefined') {"," config.draggable = true;"," }",""," if (typeof config.constrain === 'undefined') {"," config.constrain = true;"," }",""," if (typeof config.lightbox === 'undefined') {"," config.lightbox = false;"," }",""," TOOLTIP.superclass.constructor.apply(this, [config]);","}","","var SELECTORS = {"," CLOSEBUTTON: '.closebutton'"," },",""," CSS = {"," PANELTEXT: 'tooltiptext'"," },"," RESOURCES = {"," WAITICON: {"," pix: 'i/loading_small',"," component: 'moodle'"," }"," },"," ATTRS = {};","","/**"," * Static property provides a string to identify the JavaScript class."," *"," * @property NAME"," * @type String"," * @static"," */","TOOLTIP.NAME = 'moodle-core-tooltip';","","/**"," * Static property used to define the CSS prefix applied to tooltip dialogues."," *"," * @property CSS_PREFIX"," * @type String"," * @static"," */","TOOLTIP.CSS_PREFIX = 'moodle-dialogue';","","/**"," * Static property used to define the default attribute configuration for the Tooltip."," *"," * @property ATTRS"," * @type String"," * @static"," */","TOOLTIP.ATTRS = ATTRS;","","/**"," * The initial value of the header region before the content finishes loading."," *"," * @attribute initialheadertext"," * @type String"," * @default ''"," * @writeOnce"," */","ATTRS.initialheadertext = {"," value: ''","};","","/**"," * The initial value of the body region before the content finishes loading."," *"," * The supplid string will be wrapped in a div with the CSS.PANELTEXT class and a standard Moodle spinner"," * appended."," *"," * @attribute initialbodytext"," * @type String"," * @default ''"," * @writeOnce"," */","ATTRS.initialbodytext = {"," value: '',"," setter: function(content) {"," var parentnode,"," spinner;"," parentnode = Y.Node.create('<div />')"," .addClass(CSS.PANELTEXT);",""," spinner = Y.Node.create('<img />')"," .setAttribute('src', M.util.image_url(RESOURCES.WAITICON.pix, RESOURCES.WAITICON.component))"," .addClass('spinner');",""," if (content) {"," // If we have been provided with content, add it to the parent and make"," // the spinner appear correctly inline"," parentnode.set('text', content);"," spinner.addClass('iconsmall');"," } else {"," // If there is no loading message, just make the parent node a lightbox"," parentnode.addClass('content-lightbox');"," }",""," parentnode.append(spinner);"," return parentnode;"," }","};","","/**"," * The initial value of the footer region before the content finishes loading."," *"," * If a value is supplied, it will be wrapped in a <div> first."," *"," * @attribute initialfootertext"," * @type String"," * @default ''"," * @writeOnce"," */","ATTRS.initialfootertext = {"," value: null,"," setter: function(content) {"," if (content) {"," return Y.Node.create('<div />')"," .set('text', content);"," }"," }","};","","/**"," * The function which handles setting the content of the title region."," * The specified function will be called with a context of the tooltip instance."," *"," * The default function will simply set the value of the title to object.heading as returned by the AJAX call."," *"," * @attribute headerhandler"," * @type Function|String|null"," * @default set_header_content"," */","ATTRS.headerhandler = {"," value: 'set_header_content'","};","","/**"," * The function which handles setting the content of the body region."," * The specified function will be called with a context of the tooltip instance."," *"," * The default function will simply set the value of the body area to a div containing object.text as returned"," * by the AJAX call."," *"," * @attribute bodyhandler"," * @type Function|String|null"," * @default set_body_content"," */","ATTRS.bodyhandler = {"," value: 'set_body_content'","};","","/**"," * The function which handles setting the content of the footer region."," * The specified function will be called with a context of the tooltip instance."," *"," * By default, the footer is not set."," *"," * @attribute footerhandler"," * @type Function|String|null"," * @default null"," */","ATTRS.footerhandler = {"," value: null","};","","/**"," * The function which handles modifying the URL that was clicked on."," *"," * The default function rewrites '.php' to '_ajax.php'."," *"," * @attribute urlmodifier"," * @type Function|String|null"," * @default null"," */","ATTRS.urlmodifier = {"," value: null","};","","/**"," * Set the Y.Cache object to use."," *"," * By default a new Y.Cache object will be created for each instance of the tooltip."," *"," * In certain situations, where multiple tooltips may share the same cache, it may be preferable to"," * seed this cache from the calling method."," *"," * @attribute textcache"," * @type Y.Cache|null"," * @default null"," */","ATTRS.textcache = {"," value: null","};","","/**"," * Set the default size of the Y.Cache object."," *"," * This is only used if no textcache is specified."," *"," * @attribute textcachesize"," * @type Number"," * @default 10"," */","ATTRS.textcachesize = {"," value: 10","};","","Y.extend(TOOLTIP, M.core.dialogue, {"," // The bounding box."," bb: null,",""," // Any event listeners we may need to cancel later."," listenevents: [],",""," // Cache of objects we've already retrieved."," textcache: null,",""," // The align position. This differs for RTL languages so we calculate once and store."," alignpoints: ["," Y.WidgetPositionAlign.TL,"," Y.WidgetPositionAlign.RC"," ],",""," initializer: function() {"," // Set the initial values for the handlers."," // These cannot be set in the attributes section as context isn't present at that time."," if (!this.get('headerhandler')) {"," this.set('headerhandler', this.set_header_content);"," }"," if (!this.get('bodyhandler')) {"," this.set('bodyhandler', this.set_body_content);"," }"," if (!this.get('footerhandler')) {"," this.set('footerhandler', function() {});"," }"," if (!this.get('urlmodifier')) {"," this.set('urlmodifier', this.modify_url);"," }",""," // Set up the dialogue with initial content."," this.setAttrs({"," headerContent: this.get('initialheadertext'),"," bodyContent: this.get('initialbodytext'),"," footerContent: this.get('initialfootertext'),"," zIndex: 150"," });",""," // Hide and then render the dialogue."," this.hide();"," this.render();",""," // Hook into a few useful areas."," this.bb = this.get('boundingBox');",""," // Change the alignment if this is an RTL language."," if (right_to_left()) {"," this.alignpoints = ["," Y.WidgetPositionAlign.TR,"," Y.WidgetPositionAlign.LC"," ];"," }",""," // Set up the text cache if it's not set up already."," if (!this.get('textcache')) {"," this.set('textcache', new Y.Cache({"," // Set a reasonable maximum cache size to prevent memory growth."," max: this.get('textcachesize')"," }));"," }",""," // Disable the textcache when in developerdebug."," if (M.cfg.developerdebug) {"," this.get('textcache').set('max', 0);"," }",""," return this;"," },",""," /**"," * Display the tooltip for the clicked link."," *"," * The anchor for the clicked link is used."," *"," * @method display_panel"," * @param {EventFacade} e The event from the clicked link. This is used to determine the clicked URL."," */"," display_panel: function(e) {"," var clickedlink, thisevent, ajaxurl, config, cacheentry;",""," // Prevent the default click action and prevent the event triggering anything else."," e.preventDefault();"," e.stopPropagation();",""," // Cancel any existing listeners and close the panel if it's already open."," this.cancel_events();",""," // Grab the clickedlink - this contains the URL we fetch and we align the panel to it."," clickedlink = e.target.ancestor('a', true);",""," // Align with the link that was clicked."," this.align(clickedlink, this.alignpoints);",""," // Reset the initial text to a spinner while we retrieve the text."," this.setAttrs({"," headerContent: this.get('initialheadertext'),"," bodyContent: this.get('initialbodytext'),"," footerContent: this.get('initialfootertext')"," });",""," // Now that initial setup has begun, show the panel."," this.show();",""," // Add some listen events to close on."," thisevent = this.bb.delegate('click', this.close_panel, SELECTORS.CLOSEBUTTON, this);"," this.listenevents.push(thisevent);",""," thisevent = Y.one('body').on('key', this.close_panel, 'esc', this);"," this.listenevents.push(thisevent);",""," // Listen for mousedownoutside events - clickoutside is broken on IE."," thisevent = this.bb.on('mousedownoutside', this.close_panel, this);"," this.listenevents.push(thisevent);",""," // Modify the URL as required."," ajaxurl = Y.bind(this.get('urlmodifier'), this, clickedlink.get('href'))();",""," cacheentry = this.get('textcache').retrieve(ajaxurl);"," if (cacheentry) {"," // The data from this help call was already cached so use that and avoid an AJAX call."," this._set_panel_contents(cacheentry.response);"," } else {"," // Retrieve the actual help text we should use."," config = {"," method: 'get',"," context: this,"," sync: false,"," on: {"," complete: function(tid, response) {"," this._set_panel_contents(response.responseText, ajaxurl);"," }"," }"," };",""," Y.io(ajaxurl, config);"," }"," },",""," _set_panel_contents: function(response, ajaxurl) {"," var responseobject;",""," // Attempt to parse the response into an object."," try {"," responseobject = Y.JSON.parse(response);"," if (responseobject.error) {"," this.close_panel();"," return new M.core.ajaxException(responseobject);"," }"," } catch (error) {"," this.close_panel();"," return new M.core.exception(error);"," }",""," // Set the contents using various handlers."," // We must use Y.bind to ensure that the correct context is used when the default handlers are overridden."," Y.bind(this.get('headerhandler'), this, responseobject)();"," Y.bind(this.get('bodyhandler'), this, responseobject)();"," Y.bind(this.get('footerhandler'), this, responseobject)();",""," if (ajaxurl) {"," // Ensure that this data is added to the cache."," this.get('textcache').add(ajaxurl, response);"," }",""," this.get('buttons').header[0].focus();"," },",""," set_header_content: function(responseobject) {"," this.set('headerContent', responseobject.heading);"," },",""," set_body_content: function(responseobject) {"," var bodycontent = Y.Node.create('<div />')"," .set('innerHTML', responseobject.text)"," .setAttribute('role', 'alert')"," .addClass(CSS.PANELTEXT);"," this.set('bodyContent', bodycontent);"," },",""," modify_url: function(url) {"," return url.replace(/\\.php\\?/, '_ajax.php?');"," },",""," close_panel: function(e) {"," // Hide the panel first."," this.hide();",""," // Cancel the listeners that we added in display_panel."," this.cancel_events();",""," // Prevent any default click that the close button may have."," if (e) {"," e.preventDefault();"," }"," },",""," cancel_events: function() {"," // Detach all listen events to prevent duplicate triggers."," var thisevent;"," while (this.listenevents.length) {"," thisevent = this.listenevents.shift();"," thisevent.detach();"," }"," }","});","M.core = M.core || {};","M.core.tooltip = M.core.tooltip = TOOLTIP;","","","}, '@VERSION@', {"," \"requires\": ["," \"base\","," \"node\","," \"io-base\","," \"moodle-core-notification\","," \"json-parse\","," \"widget-position\","," \"widget-position-align\","," \"event-outside\","," \"cache\""," ]","});"];
+_yuitest_coverage["build/moodle-core-tooltip/moodle-core-tooltip.js"].lines = {"1":0,"17":0,"18":0,"19":0,"23":0,"24":0,"27":0,"28":0,"31":0,"32":0,"35":0,"38":0,"60":0,"69":0,"78":0,"88":0,"103":0,"106":0,"108":0,"111":0,"115":0,"118":0,"119":0,"122":0,"125":0,"126":0,"140":0,"143":0,"144":0,"160":0,"175":0,"189":0,"202":0,"218":0,"231":0,"235":0,"254":0,"255":0,"257":0,"258":0,"260":0,"261":0,"263":0,"264":0,"268":0,"276":0,"277":0,"280":0,"283":0,"284":0,"291":0,"292":0,"299":0,"300":0,"303":0,"315":0,"318":0,"319":0,"322":0,"325":0,"328":0,"331":0,"338":0,"341":0,"342":0,"344":0,"345":0,"348":0,"349":0,"352":0,"354":0,"355":0,"357":0,"360":0,"366":0,"371":0,"376":0,"379":0,"380":0,"381":0,"382":0,"383":0,"386":0,"387":0,"392":0,"393":0,"394":0,"396":0,"398":0,"401":0,"405":0,"409":0,"413":0,"417":0,"422":0,"425":0,"428":0,"429":0,"435":0,"436":0,"437":0,"438":0,"442":0,"443":0};
+_yuitest_coverage["build/moodle-core-tooltip/moodle-core-tooltip.js"].functions = {"TOOLTIP:17":0,"setter:105":0,"setter:142":0,"initializer:251":0,"complete:365":0,"display_panel:314":0,"_set_panel_contents:375":0,"set_header_content:404":0,"set_body_content:408":0,"modify_url:416":0,"close_panel:420":0,"cancel_events:433":0,"(anonymous 1):1":0};
+_yuitest_coverage["build/moodle-core-tooltip/moodle-core-tooltip.js"].coveredLines = 104;
+_yuitest_coverage["build/moodle-core-tooltip/moodle-core-tooltip.js"].coveredFunctions = 13;
_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 1);
YUI.add('moodle-core-tooltip', function (Y, NAME) {
@@ -260,6 +260,20 @@ ATTRS.footerhandler = {
};
/**
+ * The function which handles modifying the URL that was clicked on.
+ *
+ * The default function rewrites '.php' to '_ajax.php'.
+ *
+ * @attribute urlmodifier
+ * @type Function|String|null
+ * @default null
+ */
+_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 202);
+ATTRS.urlmodifier = {
+ value: null
+};
+
+/**
* Set the Y.Cache object to use.
*
* By default a new Y.Cache object will be created for each instance of the tooltip.
@@ -271,7 +285,7 @@ ATTRS.footerhandler = {
* @type Y.Cache|null
* @default null
*/
-_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 205);
+_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 218);
ATTRS.textcache = {
value: null
};
@@ -285,12 +299,12 @@ ATTRS.textcache = {
* @type Number
* @default 10
*/
-_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 218);
+_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 231);
ATTRS.textcachesize = {
value: 10
};
-_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 222);
+_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 235);
Y.extend(TOOLTIP, M.core.dialogue, {
// The bounding box.
bb: null,
@@ -310,25 +324,30 @@ Y.extend(TOOLTIP, M.core.dialogue, {
initializer: function() {
// Set the initial values for the handlers.
// These cannot be set in the attributes section as context isn't present at that time.
- _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "initializer", 238);
-_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 241);
+ _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "initializer", 251);
+_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 254);
if (!this.get('headerhandler')) {
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 242);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 255);
this.set('headerhandler', this.set_header_content);
}
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 244);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 257);
if (!this.get('bodyhandler')) {
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 245);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 258);
this.set('bodyhandler', this.set_body_content);
}
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 247);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 260);
if (!this.get('footerhandler')) {
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 248);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 261);
this.set('footerhandler', function() {});
}
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 263);
+if (!this.get('urlmodifier')) {
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 264);
+this.set('urlmodifier', this.modify_url);
+ }
// Set up the dialogue with initial content.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 252);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 268);
this.setAttrs({
headerContent: this.get('initialheadertext'),
bodyContent: this.get('initialbodytext'),
@@ -337,19 +356,19 @@ this.setAttrs({
});
// Hide and then render the dialogue.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 260);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 276);
this.hide();
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 261);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 277);
this.render();
// Hook into a few useful areas.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 264);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 280);
this.bb = this.get('boundingBox');
// Change the alignment if this is an RTL language.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 267);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 283);
if (right_to_left()) {
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 268);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 284);
this.alignpoints = [
Y.WidgetPositionAlign.TR,
Y.WidgetPositionAlign.LC
@@ -357,9 +376,9 @@ this.alignpoints = [
}
// Set up the text cache if it's not set up already.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 275);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 291);
if (!this.get('textcache')) {
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 276);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 292);
this.set('textcache', new Y.Cache({
// Set a reasonable maximum cache size to prevent memory growth.
max: this.get('textcachesize')
@@ -367,49 +386,49 @@ this.set('textcache', new Y.Cache({
}
// Disable the textcache when in developerdebug.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 283);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 299);
if (M.cfg.developerdebug) {
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 284);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 300);
this.get('textcache').set('max', 0);
}
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 287);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 303);
return this;
},
/**
* Display the tooltip for the clicked link.
*
- * The anchor for the clicked link is used, additionally appending ajax=1 to the parameters.
+ * The anchor for the clicked link is used.
*
* @method display_panel
* @param {EventFacade} e The event from the clicked link. This is used to determine the clicked URL.
*/
display_panel: function(e) {
- _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "display_panel", 298);
-_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 299);
+ _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "display_panel", 314);
+_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 315);
var clickedlink, thisevent, ajaxurl, config, cacheentry;
// Prevent the default click action and prevent the event triggering anything else.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 302);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 318);
e.preventDefault();
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 303);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 319);
e.stopPropagation();
// Cancel any existing listeners and close the panel if it's already open.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 306);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 322);
this.cancel_events();
// Grab the clickedlink - this contains the URL we fetch and we align the panel to it.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 309);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 325);
clickedlink = e.target.ancestor('a', true);
// Align with the link that was clicked.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 312);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 328);
this.align(clickedlink, this.alignpoints);
// Reset the initial text to a spinner while we retrieve the text.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 315);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 331);
this.setAttrs({
headerContent: this.get('initialheadertext'),
bodyContent: this.get('initialbodytext'),
@@ -417,160 +436,160 @@ this.setAttrs({
});
// Now that initial setup has begun, show the panel.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 322);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 338);
this.show();
// Add some listen events to close on.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 325);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 341);
thisevent = this.bb.delegate('click', this.close_panel, SELECTORS.CLOSEBUTTON, this);
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 326);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 342);
this.listenevents.push(thisevent);
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 328);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 344);
thisevent = Y.one('body').on('key', this.close_panel, 'esc', this);
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 329);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 345);
this.listenevents.push(thisevent);
// Listen for mousedownoutside events - clickoutside is broken on IE.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 332);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 348);
thisevent = this.bb.on('mousedownoutside', this.close_panel, this);
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 333);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 349);
this.listenevents.push(thisevent);
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 335);
-ajaxurl = clickedlink.get('href');
+ // Modify the URL as required.
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 352);
+ajaxurl = Y.bind(this.get('urlmodifier'), this, clickedlink.get('href'))();
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 337);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 354);
cacheentry = this.get('textcache').retrieve(ajaxurl);
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 338);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 355);
if (cacheentry) {
// The data from this help call was already cached so use that and avoid an AJAX call.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 340);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 357);
this._set_panel_contents(cacheentry.response);
} else {
// Retrieve the actual help text we should use.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 343);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 360);
config = {
method: 'get',
context: this,
sync: false,
- data: {
- // We use a slightly different AJAX URL to the one on the anchor to allow non-JS fallback.
- ajax: 1
- },
on: {
complete: function(tid, response) {
- _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "complete", 352);
-_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 353);
+ _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "complete", 365);
+_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 366);
this._set_panel_contents(response.responseText, ajaxurl);
}
}
};
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 358);
-Y.io(clickedlink.get('href'), config);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 371);
+Y.io(ajaxurl, config);
}
},
_set_panel_contents: function(response, ajaxurl) {
- _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "_set_panel_contents", 362);
-_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 363);
+ _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "_set_panel_contents", 375);
+_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 376);
var responseobject;
// Attempt to parse the response into an object.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 366);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 379);
try {
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 367);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 380);
responseobject = Y.JSON.parse(response);
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 368);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 381);
if (responseobject.error) {
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 369);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 382);
this.close_panel();
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 370);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 383);
return new M.core.ajaxException(responseobject);
}
} catch (error) {
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 373);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 386);
this.close_panel();
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 374);
-return new M.core.exception({
- name: error.name,
- message: "Unable to retrieve the requested content. The following error was returned: " + error.message
- });
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 387);
+return new M.core.exception(error);
}
// Set the contents using various handlers.
// We must use Y.bind to ensure that the correct context is used when the default handlers are overridden.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 382);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 392);
Y.bind(this.get('headerhandler'), this, responseobject)();
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 383);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 393);
Y.bind(this.get('bodyhandler'), this, responseobject)();
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 384);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 394);
Y.bind(this.get('footerhandler'), this, responseobject)();
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 386);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 396);
if (ajaxurl) {
// Ensure that this data is added to the cache.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 388);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 398);
this.get('textcache').add(ajaxurl, response);
}
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 391);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 401);
this.get('buttons').header[0].focus();
},
set_header_content: function(responseobject) {
- _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "set_header_content", 394);
-_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 395);
+ _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "set_header_content", 404);
+_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 405);
this.set('headerContent', responseobject.heading);
},
set_body_content: function(responseobject) {
- _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "set_body_content", 398);
-_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 399);
+ _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "set_body_content", 408);
+_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 409);
var bodycontent = Y.Node.create('<div />')
.set('innerHTML', responseobject.text)
.setAttribute('role', 'alert')
.addClass(CSS.PANELTEXT);
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 403);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 413);
this.set('bodyContent', bodycontent);
},
+ modify_url: function(url) {
+ _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "modify_url", 416);
+_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 417);
+return url.replace(/\.php\?/, '_ajax.php?');
+ },
+
close_panel: function(e) {
// Hide the panel first.
- _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "close_panel", 406);
-_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 408);
+ _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "close_panel", 420);
+_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 422);
this.hide();
// Cancel the listeners that we added in display_panel.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 411);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 425);
this.cancel_events();
// Prevent any default click that the close button may have.
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 414);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 428);
if (e) {
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 415);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 429);
e.preventDefault();
}
},
cancel_events: function() {
// Detach all listen events to prevent duplicate triggers.
- _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "cancel_events", 419);
-_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 421);
+ _yuitest_coverfunc("build/moodle-core-tooltip/moodle-core-tooltip.js", "cancel_events", 433);
+_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 435);
var thisevent;
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 422);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 436);
while (this.listenevents.length) {
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 423);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 437);
thisevent = this.listenevents.shift();
- _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 424);
+ _yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 438);
thisevent.detach();
}
}
});
-_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 428);
+_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 442);
M.core = M.core || {};
-_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 429);
+_yuitest_coverline("build/moodle-core-tooltip/moodle-core-tooltip.js", 443);
M.core.tooltip = M.core.tooltip = TOOLTIP;
36 lib/yui/build/moodle-core-tooltip/moodle-core-tooltip-debug.js
View
@@ -191,6 +191,19 @@ ATTRS.footerhandler = {
};
/**
+ * The function which handles modifying the URL that was clicked on.
+ *
+ * The default function rewrites '.php' to '_ajax.php'.
+ *
+ * @attribute urlmodifier
+ * @type Function|String|null
+ * @default null
+ */
+ATTRS.urlmodifier = {
+ value: null
+};
+
+/**
* Set the Y.Cache object to use.
*
* By default a new Y.Cache object will be created for each instance of the tooltip.
@@ -247,6 +260,9 @@ Y.extend(TOOLTIP, M.core.dialogue, {
if (!this.get('footerhandler')) {
this.set('footerhandler', function() {});
}
+ if (!this.get('urlmodifier')) {
+ this.set('urlmodifier', this.modify_url);
+ }
// Set up the dialogue with initial content.
this.setAttrs({
@@ -290,7 +306,7 @@ Y.extend(TOOLTIP, M.core.dialogue, {
/**
* Display the tooltip for the clicked link.
*
- * The anchor for the clicked link is used, additionally appending ajax=1 to the parameters.
+ * The anchor for the clicked link is used.
*
* @method display_panel
* @param {EventFacade} e The event from the clicked link. This is used to determine the clicked URL.
@@ -332,7 +348,8 @@ Y.extend(TOOLTIP, M.core.dialogue, {
thisevent = this.bb.on('mousedownoutside', this.close_panel, this);
this.listenevents.push(thisevent);
- ajaxurl = clickedlink.get('href');
+ // Modify the URL as required.
+ ajaxurl = Y.bind(this.get('urlmodifier'), this, clickedlink.get('href'))();
cacheentry = this.get('textcache').retrieve(ajaxurl);
if (cacheentry) {
@@ -344,10 +361,6 @@ Y.extend(TOOLTIP, M.core.dialogue, {
method: 'get',
context: this,
sync: false,
- data: {
- // We use a slightly different AJAX URL to the one on the anchor to allow non-JS fallback.
- ajax: 1
- },
on: {
complete: function(tid, response) {
this._set_panel_contents(response.responseText, ajaxurl);
@@ -355,7 +368,7 @@ Y.extend(TOOLTIP, M.core.dialogue, {
}
};
- Y.io(clickedlink.get('href'), config);
+ Y.io(ajaxurl, config);
}
},
@@ -371,10 +384,7 @@ Y.extend(TOOLTIP, M.core.dialogue, {
}
} catch (error) {
this.close_panel();
- return new M.core.exception({
- name: error.name,
- message: "Unable to retrieve the requested content. The following error was returned: " + error.message
- });
+ return new M.core.exception(error);
}
// Set the contents using various handlers.
@@ -403,6 +413,10 @@ Y.extend(TOOLTIP, M.core.dialogue, {
this.set('bodyContent', bodycontent);
},
+ modify_url: function(url) {
+ return url.replace(/\.php\?/, '_ajax.php?');
+ },
+
close_panel: function(e) {
// Hide the panel first.
this.hide();
2  lib/yui/build/moodle-core-tooltip/moodle-core-tooltip-min.js
View
@@ -1 +1 @@
-YUI.add("moodle-core-tooltip",function(e,t){function n(e){e||(e={}),typeof e.draggable=="undefined"&&(e.draggable=!0),typeof e.constrain=="undefined"&&(e.constrain=!0),typeof e.lightbox=="undefined"&&(e.lightbox=!1),n.superclass.constructor.apply(this,[e])}var r={CLOSEBUTTON:".closebutton"},i={PANELTEXT:"tooltiptext"},s={WAITICON:{pix:"i/loading_small",component:"moodle"}},o={};n.NAME="moodle-core-tooltip",n.CSS_PREFIX="moodle-dialogue",n.ATTRS=o,o.initialheadertext={value:""},o.initialbodytext={value:"",setter:function(t){var n,r;return n=e.Node.create("<div />").addClass(i.PANELTEXT),r=e.Node.create("<img />").setAttribute("src",M.util.image_url(s.WAITICON.pix,s.WAITICON.component)).addClass("spinner"),t?(n.set("text",t),r.addClass("iconsmall")):n.addClass("content-lightbox"),n.append(r),n}},o.initialfootertext={value:null,setter:function(t){if(t)return e.Node.create("<div />").set("text",t)}},o.headerhandler={value:"set_header_content"},o.bodyhandler={value:"set_body_content"},o.footerhandler={value:null},o.textcache={value:null},o.textcachesize={value:10},e.extend(n,M.core.dialogue,{bb:null,listenevents:[],textcache:null,alignpoints:[e.WidgetPositionAlign.TL,e.WidgetPositionAlign.RC],initializer:function(){return this.get("headerhandler")||this.set("headerhandler",this.set_header_content),this.get("bodyhandler")||this.set("bodyhandler",this.set_body_content),this.get("footerhandler")||this.set("footerhandler",function(){}),this.setAttrs({headerContent:this.get("initialheadertext"),bodyContent:this.get("initialbodytext"),footerContent:this.get("initialfootertext"),zIndex:150}),this.hide(),this.render(),this.bb=this.get("boundingBox"),right_to_left()&&(this.alignpoints=[e.WidgetPositionAlign.TR,e.WidgetPositionAlign.LC]),this.get("textcache")||this.set("textcache",new e.Cache({max:this.get("textcachesize")})),M.cfg.developerdebug&&this.get("textcache").set("max",0),this},display_panel:function(t){var n,i,s,o,u;t.preventDefault(),t.stopPropagation(),this.cancel_events(),n=t.target.ancestor("a",!0),this.align(n,this.alignpoints),this.setAttrs({headerContent:this.get("initialheadertext"),bodyContent:this.get("initialbodytext"),footerContent:this.get("initialfootertext")}),this.show(),i=this.bb.delegate("click",this.close_panel,r.CLOSEBUTTON,this),this.listenevents.push(i),i=e.one("body").on("key",this.close_panel,"esc",this),this.listenevents.push(i),i=this.bb.on("mousedownoutside",this.close_panel,this),this.listenevents.push(i),s=n.get("href"),u=this.get("textcache").retrieve(s),u?this._set_panel_contents(u.response):(o={method:"get",context:this,sync:!1,data:{ajax:1},on:{complete:function(e,t){this._set_panel_contents(t.responseText,s)}}},e.io(n.get("href"),o))},_set_panel_contents:function(t,n){var r;try{r=e.JSON.parse(t);if(r.error)return this.close_panel(),new M.core.ajaxException(r)}catch(i){return this.close_panel(),new M.core.exception({name:i.name,message:"Unable to retrieve the requested content. The following error was returned: "+i.message})}e.bind(this.get("headerhandler"),this,r)(),e.bind(this.get("bodyhandler"),this,r)(),e.bind(this.get("footerhandler"),this,r)(),n&&this.get("textcache").add(n,t),this.get("buttons").header[0].focus()},set_header_content:function(e){this.set("headerContent",e.heading)},set_body_content:function(t){var n=e.Node.create("<div />").set("innerHTML",t.text).setAttribute("role","alert").addClass(i.PANELTEXT);this.set("bodyContent",n)},close_panel:function(e){this.hide(),this.cancel_events(),e&&e.preventDefault()},cancel_events:function(){var e;while(this.listenevents.length)e=this.listenevents.shift(),e.detach()}}),M.core=M.core||{},M.core.tooltip=M.core.tooltip=n},"@VERSION@",{requires:["base","node","io-base","moodle-core-notification","json-parse","widget-position","widget-position-align","event-outside","cache"]});
+YUI.add("moodle-core-tooltip",function(e,t){function n(e){e||(e={}),typeof e.draggable=="undefined"&&(e.draggable=!0),typeof e.constrain=="undefined"&&(e.constrain=!0),typeof e.lightbox=="undefined"&&(e.lightbox=!1),n.superclass.constructor.apply(this,[e])}var r={CLOSEBUTTON:".closebutton"},i={PANELTEXT:"tooltiptext"},s={WAITICON:{pix:"i/loading_small",component:"moodle"}},o={};n.NAME="moodle-core-tooltip",n.CSS_PREFIX="moodle-dialogue",n.ATTRS=o,o.initialheadertext={value:""},o.initialbodytext={value:"",setter:function(t){var n,r;return n=e.Node.create("<div />").addClass(i.PANELTEXT),r=e.Node.create("<img />").setAttribute("src",M.util.image_url(s.WAITICON.pix,s.WAITICON.component)).addClass("spinner"),t?(n.set("text",t),r.addClass("iconsmall")):n.addClass("content-lightbox"),n.append(r),n}},o.initialfootertext={value:null,setter:function(t){if(t)return e.Node.create("<div />").set("text",t)}},o.headerhandler={value:"set_header_content"},o.bodyhandler={value:"set_body_content"},o.footerhandler={value:null},o.urlmodifier={value:null},o.textcache={value:null},o.textcachesize={value:10},e.extend(n,M.core.dialogue,{bb:null,listenevents:[],textcache:null,alignpoints:[e.WidgetPositionAlign.TL,e.WidgetPositionAlign.RC],initializer:function(){return this.get("headerhandler")||this.set("headerhandler",this.set_header_content),this.get("bodyhandler")||this.set("bodyhandler",this.set_body_content),this.get("footerhandler")||this.set("footerhandler",function(){}),this.get("urlmodifier")||this.set("urlmodifier",this.modify_url),this.setAttrs({headerContent:this.get("initialheadertext"),bodyContent:this.get("initialbodytext"),footerContent:this.get("initialfootertext"),zIndex:150}),this.hide(),this.render(),this.bb=this.get("boundingBox"),right_to_left()&&(this.alignpoints=[e.WidgetPositionAlign.TR,e.WidgetPositionAlign.LC]),this.get("textcache")||this.set("textcache",new e.Cache({max:this.get("textcachesize")})),M.cfg.developerdebug&&this.get("textcache").set("max",0),this},display_panel:function(t){var n,i,s,o,u;t.preventDefault(),t.stopPropagation(),this.cancel_events(),n=t.target.ancestor("a",!0),this.align(n,this.alignpoints),this.setAttrs({headerContent:this.get("initialheadertext"),bodyContent:this.get("initialbodytext"),footerContent:this.get("initialfootertext")}),this.show(),i=this.bb.delegate("click",this.close_panel,r.CLOSEBUTTON,this),this.listenevents.push(i),i=e.one("body").on("key",this.close_panel,"esc",this),this.listenevents.push(i),i=this.bb.on("mousedownoutside",this.close_panel,this),this.listenevents.push(i),s=e.bind(this.get("urlmodifier"),this,n.get("href"))(),u=this.get("textcache").retrieve(s),u?this._set_panel_contents(u.response):(o={method:"get",context:this,sync:!1,on:{complete:function(e,t){this._set_panel_contents(t.responseText,s)}}},e.io(s,o))},_set_panel_contents:function(t,n){var r;try{r=e.JSON.parse(t);if(r.error)return this.close_panel(),new M.core.ajaxException(r)}catch(i){return this.close_panel(),new M.core.exception(i)}e.bind(this.get("headerhandler"),this,r)(),e.bind(this.get("bodyhandler"),this,r)(),e.bind(this.get("footerhandler"),this,r)(),n&&this.get("textcache").add(n,t),this.get("buttons").header[0].focus()},set_header_content:function(e){this.set("headerContent",e.heading)},set_body_content:function(t){var n=e.Node.create("<div />").set("innerHTML",t.text).setAttribute("role","alert").addClass(i.PANELTEXT);this.set("bodyContent",n)},modify_url:function(e){return e.replace(/\.php\?/,"_ajax.php?")},close_panel:function(e){this.hide(),this.cancel_events(),e&&e.preventDefault()},cancel_events:function(){var e;while(this.listenevents.length)e=this.listenevents.shift(),e.detach()}}),M.core=M.core||{},M.core.tooltip=M.core.tooltip=n},"@VERSION@",{requires:["base","node","io-base","moodle-core-notification","json-parse","widget-position","widget-position-align","event-outside","cache"]});
36 lib/yui/build/moodle-core-tooltip/moodle-core-tooltip.js
View
@@ -191,6 +191,19 @@ ATTRS.footerhandler = {
};
/**
+ * The function which handles modifying the URL that was clicked on.
+ *
+ * The default function rewrites '.php' to '_ajax.php'.
+ *
+ * @attribute urlmodifier
+ * @type Function|String|null
+ * @default null
+ */
+ATTRS.urlmodifier = {
+ value: null
+};
+
+/**
* Set the Y.Cache object to use.
*
* By default a new Y.Cache object will be created for each instance of the tooltip.
@@ -247,6 +260,9 @@ Y.extend(TOOLTIP, M.core.dialogue, {
if (!this.get('footerhandler')) {
this.set('footerhandler', function() {});
}
+ if (!this.get('urlmodifier')) {
+ this.set('urlmodifier', this.modify_url);
+ }
// Set up the dialogue with initial content.
this.setAttrs({
@@ -290,7 +306,7 @@ Y.extend(TOOLTIP, M.core.dialogue, {
/**
* Display the tooltip for the clicked link.
*
- * The anchor for the clicked link is used, additionally appending ajax=1 to the parameters.
+ * The anchor for the clicked link is used.
*
* @method display_panel
* @param {EventFacade} e The event from the clicked link. This is used to determine the clicked URL.
@@ -332,7 +348,8 @@ Y.extend(TOOLTIP, M.core.dialogue, {
thisevent = this.bb.on('mousedownoutside', this.close_panel, this);
this.listenevents.push(thisevent);
- ajaxurl = clickedlink.get('href');
+ // Modify the URL as required.
+ ajaxurl = Y.bind(this.get('urlmodifier'), this, clickedlink.get('href'))();
cacheentry = this.get('textcache').retrieve(ajaxurl);
if (cacheentry) {
@@ -344,10 +361,6 @@ Y.extend(TOOLTIP, M.core.dialogue, {
method: 'get',
context: this,
sync: false,
- data: {
- // We use a slightly different AJAX URL to the one on the anchor to allow non-JS fallback.
- ajax: 1
- },
on: {
complete: function(tid, response) {
this._set_panel_contents(response.responseText, ajaxurl);
@@ -355,7 +368,7 @@ Y.extend(TOOLTIP, M.core.dialogue, {
}
};
- Y.io(clickedlink.get('href'), config);
+ Y.io(ajaxurl, config);
}
},
@@ -371,10 +384,7 @@ Y.extend(TOOLTIP, M.core.dialogue, {
}
} catch (error) {
this.close_panel();
- return new M.core.exception({
- name: error.name,
- message: "Unable to retrieve the requested content. The following error was returned: " + error.message
- });
+ return new M.core.exception(error);
}
// Set the contents using various handlers.
@@ -403,6 +413,10 @@ Y.extend(TOOLTIP, M.core.dialogue, {
this.set('bodyContent', bodycontent);
},
+ modify_url: function(url) {
+ return url.replace(/\.php\?/, '_ajax.php?');
+ },
+
close_panel: function(e) {
// Hide the panel first.
this.hide();
36 lib/yui/src/tooltip/js/tooltip.js
View
@@ -189,6 +189,19 @@ ATTRS.footerhandler = {
};
/**
+ * The function which handles modifying the URL that was clicked on.
+ *
+ * The default function rewrites '.php' to '_ajax.php'.
+ *
+ * @attribute urlmodifier
+ * @type Function|String|null
+ * @default null
+ */
+ATTRS.urlmodifier = {
+ value: null
+};
+
+/**
* Set the Y.Cache object to use.
*
* By default a new Y.Cache object will be created for each instance of the tooltip.
@@ -245,6 +258,9 @@ Y.extend(TOOLTIP, M.core.dialogue, {
if (!this.get('footerhandler')) {
this.set('footerhandler', function() {});
}
+ if (!this.get('urlmodifier')) {
+ this.set('urlmodifier', this.modify_url);
+ }
// Set up the dialogue with initial content.
this.setAttrs({
@@ -288,7 +304,7 @@ Y.extend(TOOLTIP, M.core.dialogue, {
/**
* Display the tooltip for the clicked link.
*
- * The anchor for the clicked link is used, additionally appending ajax=1 to the parameters.
+ * The anchor for the clicked link is used.
*
* @method display_panel
* @param {EventFacade} e The event from the clicked link. This is used to determine the clicked URL.
@@ -330,7 +346,8 @@ Y.extend(TOOLTIP, M.core.dialogue, {
thisevent = this.bb.on('mousedownoutside', this.close_panel, this);
this.listenevents.push(thisevent);
- ajaxurl = clickedlink.get('href');
+ // Modify the URL as required.
+ ajaxurl = Y.bind(this.get('urlmodifier'), this, clickedlink.get('href'))();
cacheentry = this.get('textcache').retrieve(ajaxurl);
if (cacheentry) {
@@ -342,10 +359,6 @@ Y.extend(TOOLTIP, M.core.dialogue, {
method: 'get',
context: this,
sync: false,
- data: {
- // We use a slightly different AJAX URL to the one on the anchor to allow non-JS fallback.
- ajax: 1
- },
on: {
complete: function(tid, response) {
this._set_panel_contents(response.responseText, ajaxurl);
@@ -353,7 +366,7 @@ Y.extend(TOOLTIP, M.core.dialogue, {
}
};
- Y.io(clickedlink.get('href'), config);
+ Y.io(ajaxurl, config);
}
},
@@ -369,10 +382,7 @@ Y.extend(TOOLTIP, M.core.dialogue, {
}
} catch (error) {
this.close_panel();
- return new M.core.exception({
- name: error.name,
- message: "Unable to retrieve the requested content. The following error was returned: " + error.message
- });
+ return new M.core.exception(error);
}
// Set the contents using various handlers.
@@ -401,6 +411,10 @@ Y.extend(TOOLTIP, M.core.dialogue, {
this.set('bodyContent', bodycontent);
},
+ modify_url: function(url) {
+ return url.replace(/\.php\?/, '_ajax.php?');
+ },
+
close_panel: function(e) {
// Hide the panel first.
this.hide();
Please sign in to comment.
Something went wrong with that request. Please try again.