Merge branch 'feature/warning-links-open-in-new-window-7937'

resolves #7937
This commit is contained in:
Matthias Jentsch 2015-03-19 11:06:21 +01:00
commit 004301a2ba
4 changed files with 41 additions and 5 deletions

View File

@ -84,6 +84,13 @@ class Tab extends AbstractWidget
*/
private $tagParams;
/**
* Whether to open the link target on a new page
*
* @var boolean
*/
private $targetBlank = false;
/**
* Sets an icon image for this tab
*
@ -198,6 +205,11 @@ class Tab extends AbstractWidget
$this->tagParams = $tagParams;
}
public function setTargetBlank($value = true)
{
$this->targetBlank = $value;
}
/**
* Create a new Tab with the given properties
*
@ -244,6 +256,11 @@ class Tab extends AbstractWidget
$caption = $view->escape($this->getLabel());
$tagParams = $this->tagParams;
if ($this->targetBlank) {
// add warning to links that open in new tabs to improve accessibility, as recommended by WCAG20 G201
$caption .= '<span class="info-box display-on-hover"> opens in new window </span>';
$tagParams['target'] ='_blank';
}
if ($this->title) {
if ($tagParams !== null) {

View File

@ -48,10 +48,9 @@ class OutputFormat implements Tabextension
foreach ($this->getSupportedTypes() as $type => $tabConfig) {
if (!in_array($type, $disabled)) {
$tabConfig['url'] = Url::fromRequest();
$tabConfig['tagParams'] = array(
'target' => '_blank'
);
$this->tabs[] = new Tab($tabConfig);
$tab = new Tab($tabConfig);
$tab->setTargetBlank();
$this->tabs[] = $tab;
}
}
}

View File

@ -1,7 +1,11 @@
<?php
$links = array();
$linkText = '<a href="%s" target="_blank">%s</a>';
// add warning to links that open in new tabs to improve accessibility, as recommended by WCAG20 G201
$newTabInfo = sprintf('<span class="info-box display-on-hover"> %s </span>', $this->translate('opens in new window'));
$linkText = '<a href="%s" target="_blank">%s ' . $newTabInfo . '</a>';
$localLinkText = '<a href="%s">%s</a>';
if ($object->notes_url) {

View File

@ -148,3 +148,19 @@ a.close-tab {
content: '\e874';
}
}
span.display-on-hover {
font-size: 0.8em;
left: -9000px;
position: relative;
display: inline;
width: 0;
overflow: hidden;
color: #000000;
text-decoration: none;
}
:hover > span.display-on-hover, :focus > span.display-on-hover {
left:1em; width:12em;
text-align: center
}