Merge branch 'feature/warning-links-open-in-new-window-7937'
resolves #7937
This commit is contained in:
commit
004301a2ba
|
@ -84,6 +84,13 @@ class Tab extends AbstractWidget
|
||||||
*/
|
*/
|
||||||
private $tagParams;
|
private $tagParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to open the link target on a new page
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $targetBlank = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an icon image for this tab
|
* Sets an icon image for this tab
|
||||||
*
|
*
|
||||||
|
@ -198,6 +205,11 @@ class Tab extends AbstractWidget
|
||||||
$this->tagParams = $tagParams;
|
$this->tagParams = $tagParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setTargetBlank($value = true)
|
||||||
|
{
|
||||||
|
$this->targetBlank = $value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Tab with the given properties
|
* Create a new Tab with the given properties
|
||||||
*
|
*
|
||||||
|
@ -244,6 +256,11 @@ class Tab extends AbstractWidget
|
||||||
|
|
||||||
$caption = $view->escape($this->getLabel());
|
$caption = $view->escape($this->getLabel());
|
||||||
$tagParams = $this->tagParams;
|
$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 ($this->title) {
|
||||||
if ($tagParams !== null) {
|
if ($tagParams !== null) {
|
||||||
|
|
|
@ -48,10 +48,9 @@ class OutputFormat implements Tabextension
|
||||||
foreach ($this->getSupportedTypes() as $type => $tabConfig) {
|
foreach ($this->getSupportedTypes() as $type => $tabConfig) {
|
||||||
if (!in_array($type, $disabled)) {
|
if (!in_array($type, $disabled)) {
|
||||||
$tabConfig['url'] = Url::fromRequest();
|
$tabConfig['url'] = Url::fromRequest();
|
||||||
$tabConfig['tagParams'] = array(
|
$tab = new Tab($tabConfig);
|
||||||
'target' => '_blank'
|
$tab->setTargetBlank();
|
||||||
);
|
$this->tabs[] = $tab;
|
||||||
$this->tabs[] = new Tab($tabConfig);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$links = array();
|
$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>';
|
$localLinkText = '<a href="%s">%s</a>';
|
||||||
|
|
||||||
if ($object->notes_url) {
|
if ($object->notes_url) {
|
||||||
|
|
|
@ -148,3 +148,19 @@ a.close-tab {
|
||||||
content: '\e874';
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue