Merge branch 'MDL-49811_master' of git://github.com/jinhofer/moodle

This commit is contained in:
David Monllao 2015-10-06 10:19:02 +08:00 committed by Dan Poltawski
commit 7da61f95ce
5 changed files with 41 additions and 22 deletions

View file

@ -1828,3 +1828,17 @@ M.util.load_flowplayer = function() {
document.getElementsByTagName('head')[0].appendChild(fileref);
}
};
/**
* Initiates the listeners for skiplink interaction
*
* @param {YUI} Y
*/
M.util.init_skiplink = function(Y) {
Y.one(Y.config.doc.body).delegate('click', function(e) {
e.preventDefault();
e.stopPropagation();
Y.one(this.getAttribute('data-target')).focus();
return true;
}, 'a.skip');
};

View file

@ -1394,8 +1394,11 @@ class core_renderer extends renderer_base {
$output = '';
$skipdest = '';
} else {
$output = html_writer::tag('a', get_string('skipa', 'access', $skiptitle), array('href' => '#sb-' . $bc->skipid, 'class' => 'skip-block'));
$skipdest = html_writer::tag('span', '', array('id' => 'sb-' . $bc->skipid, 'class' => 'skip-block-to'));
$output = html_writer::link('#', get_string('skipa', 'access', $skiptitle),
array('class' => 'skip skip-block', 'id'=>'fsb-' . $bc->skipid,
'data-target' => '#sb-'.$bc->skipid));
$skipdest = html_writer::span('', 'skip-block-to',
array('id' => 'sb-' . $bc->skipid, 'tabindex' => '-1'));
}
$output .= html_writer::start_tag('div', $bc->attributes);
@ -2960,7 +2963,7 @@ EOD;
* @return string the HTML to output.
*/
public function skip_link_target($id = null) {
return html_writer::tag('span', '', array('id' => $id));
return html_writer::span('', '', array('id' => $id, 'tabindex' => '-1'));
}
/**

View file

@ -1537,12 +1537,13 @@ class page_requirements_manager {
public function get_top_of_body_code() {
// First the skip links.
$links = '';
$attributes = array('class'=>'skip');
$attributes = array('class' => 'skip');
foreach ($this->skiplinks as $url => $text) {
$attributes['href'] = '#' . $url;
$links .= html_writer::tag('a', $text, $attributes);
$attributes['data-target'] = '#'.$url;
$links .= html_writer::link('#', $text, $attributes);
}
$output = html_writer::tag('div', $links, array('class'=>'skiplinks')) . "\n";
$this->js_init_call('M.util.init_skiplink');
// YUI3 JS needs to be loaded early in the body. It should be cached well by the browser.
$output .= $this->get_yui3lib_headcode();