mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-35836 Rewrite doctonewwindow handling to use delegation instead of individual events
This commit is contained in:
parent
7e8ae12a7a
commit
afe3566cca
4 changed files with 44 additions and 34 deletions
|
@ -1911,7 +1911,7 @@ function get_module_metadata($course, $modnames, $sectionreturn = null) {
|
||||||
if ($sm->string_exists('modulename_link', $modname)) { // Link to further info in Moodle docs
|
if ($sm->string_exists('modulename_link', $modname)) { // Link to further info in Moodle docs
|
||||||
$link = get_string('modulename_link', $modname);
|
$link = get_string('modulename_link', $modname);
|
||||||
$linktext = get_string('morehelp');
|
$linktext = get_string('morehelp');
|
||||||
$module->help .= html_writer::tag('div', $OUTPUT->doc_link($link, $linktext), array('class' => 'helpdoclink'));
|
$module->help .= html_writer::tag('div', $OUTPUT->doc_link($link, $linktext, true), array('class' => 'helpdoclink'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$module->archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
|
$module->archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
|
||||||
|
|
30
course/yui/modchooser/modchooser.js
vendored
30
course/yui/modchooser/modchooser.js
vendored
|
@ -34,36 +34,6 @@ YUI.add('moodle-course-modchooser', function(Y) {
|
||||||
|
|
||||||
// Catch the page toggle
|
// Catch the page toggle
|
||||||
Y.all('.block_settings #settingsnav .type_course .modchoosertoggle a').on('click', this.toggle_mod_chooser, this);
|
Y.all('.block_settings #settingsnav .type_course .modchoosertoggle a').on('click', this.toggle_mod_chooser, this);
|
||||||
|
|
||||||
// Ensure that help links are opened in an appropriate popup
|
|
||||||
this.container.all('div.helpdoclink a').on('click', function(e) {
|
|
||||||
var anchor = e.target.ancestor('a', true);
|
|
||||||
|
|
||||||
var args = {
|
|
||||||
'name' : 'popup',
|
|
||||||
'url' : anchor.getAttribute('href'),
|
|
||||||
'option' : ''
|
|
||||||
};
|
|
||||||
var options = [
|
|
||||||
'height=600',
|
|
||||||
'width=800',
|
|
||||||
'top=0',
|
|
||||||
'left=0',
|
|
||||||
'menubar=0',
|
|
||||||
'location=0',
|
|
||||||
'scrollbars',
|
|
||||||
'resizable',
|
|
||||||
'toolbar',
|
|
||||||
'status',
|
|
||||||
'directories=0',
|
|
||||||
'fullscreen=0',
|
|
||||||
'dependent'
|
|
||||||
]
|
|
||||||
args.options = options.join(',');
|
|
||||||
|
|
||||||
// Note: openpopup is provided by lib/javascript-static.js
|
|
||||||
openpopup(e, args);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Update any section areas within the scope of the specified
|
* Update any section areas within the scope of the specified
|
||||||
|
|
|
@ -1403,6 +1403,42 @@ function hide_item(itemid) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
M.util.help_popups = {
|
||||||
|
setup : function(Y) {
|
||||||
|
Y.one('body').delegate('click', this.open_popup, 'a.helplinkpopup', this);
|
||||||
|
},
|
||||||
|
open_popup : function(e) {
|
||||||
|
// Prevent the default page action
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Grab the anchor that was clicked
|
||||||
|
var anchor = e.target.ancestor('a', true);
|
||||||
|
var args = {
|
||||||
|
'name' : 'popup',
|
||||||
|
'url' : anchor.getAttribute('href'),
|
||||||
|
'options' : ''
|
||||||
|
};
|
||||||
|
var options = [
|
||||||
|
'height=600',
|
||||||
|
'width=800',
|
||||||
|
'top=0',
|
||||||
|
'left=0',
|
||||||
|
'menubar=0',
|
||||||
|
'location=0',
|
||||||
|
'scrollbars',
|
||||||
|
'resizable',
|
||||||
|
'toolbar',
|
||||||
|
'status',
|
||||||
|
'directories=0',
|
||||||
|
'fullscreen=0',
|
||||||
|
'dependent'
|
||||||
|
]
|
||||||
|
args.options = options.join(',');
|
||||||
|
|
||||||
|
openpopup(e, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
M.util.help_icon = {
|
M.util.help_icon = {
|
||||||
Y : null,
|
Y : null,
|
||||||
instance : null,
|
instance : null,
|
||||||
|
|
|
@ -370,6 +370,9 @@ class core_renderer extends renderer_base {
|
||||||
// flow player embedding support
|
// flow player embedding support
|
||||||
$this->page->requires->js_function_call('M.util.load_flowplayer');
|
$this->page->requires->js_function_call('M.util.load_flowplayer');
|
||||||
|
|
||||||
|
// Set up help link popups for all links with the helplinkpopup class
|
||||||
|
$this->page->requires->js_init_call('M.util.help_popups.setup');
|
||||||
|
|
||||||
$this->page->requires->js_function_call('setTimeout', array('fix_column_widths()', 20));
|
$this->page->requires->js_function_call('setTimeout', array('fix_column_widths()', 20));
|
||||||
|
|
||||||
$focus = $this->page->focuscontrol;
|
$focus = $this->page->focuscontrol;
|
||||||
|
@ -1514,9 +1517,10 @@ class core_renderer extends renderer_base {
|
||||||
*
|
*
|
||||||
* @param string $path The page link after doc root and language, no leading slash.
|
* @param string $path The page link after doc root and language, no leading slash.
|
||||||
* @param string $text The text to be displayed for the link
|
* @param string $text The text to be displayed for the link
|
||||||
|
* @param boolean $forcepopup Whether to force a popup regardless of the value of $CFG->doctonewwindow
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function doc_link($path, $text = '') {
|
public function doc_link($path, $text = '', $forcepopup = false) {
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
$icon = $this->pix_icon('docs', $text, 'moodle', array('class'=>'iconhelp'));
|
$icon = $this->pix_icon('docs', $text, 'moodle', array('class'=>'iconhelp'));
|
||||||
|
@ -1524,8 +1528,8 @@ class core_renderer extends renderer_base {
|
||||||
$url = new moodle_url(get_docs_url($path));
|
$url = new moodle_url(get_docs_url($path));
|
||||||
|
|
||||||
$attributes = array('href'=>$url);
|
$attributes = array('href'=>$url);
|
||||||
if (!empty($CFG->doctonewwindow)) {
|
if (!empty($CFG->doctonewwindow) || $forcepopup) {
|
||||||
$attributes['id'] = $this->add_action_handler(new popup_action('click', $url));
|
$attributes['class'] = 'helplinkpopup';
|
||||||
}
|
}
|
||||||
|
|
||||||
return html_writer::tag('a', $icon.$text, $attributes);
|
return html_writer::tag('a', $icon.$text, $attributes);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue