diff --git a/library/Icinga/Web/Widget/Tab.php b/library/Icinga/Web/Widget/Tab.php index a210a206e..28e3fd3bd 100644 --- a/library/Icinga/Web/Widget/Tab.php +++ b/library/Icinga/Web/Widget/Tab.php @@ -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 .= ' opens in new window '; + $tagParams['target'] ='_blank'; + } if ($this->title) { if ($tagParams !== null) { diff --git a/library/Icinga/Web/Widget/Tabextension/OutputFormat.php b/library/Icinga/Web/Widget/Tabextension/OutputFormat.php index 0ef7eea69..f2da29f22 100644 --- a/library/Icinga/Web/Widget/Tabextension/OutputFormat.php +++ b/library/Icinga/Web/Widget/Tabextension/OutputFormat.php @@ -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; } } } diff --git a/modules/monitoring/application/views/scripts/show/components/actions.phtml b/modules/monitoring/application/views/scripts/show/components/actions.phtml index 1d926b33a..2defd616d 100644 --- a/modules/monitoring/application/views/scripts/show/components/actions.phtml +++ b/modules/monitoring/application/views/scripts/show/components/actions.phtml @@ -1,7 +1,11 @@ %s'; + +// add warning to links that open in new tabs to improve accessibility, as recommended by WCAG20 G201 +$newTabInfo = sprintf(' %s ', $this->translate('opens in new window')); + +$linkText = '%s ' . $newTabInfo . ''; $localLinkText = '%s'; if ($object->notes_url) { diff --git a/public/css/icinga/tabs.less b/public/css/icinga/tabs.less index d9161f672..8d391b038 100644 --- a/public/css/icinga/tabs.less +++ b/public/css/icinga/tabs.less @@ -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 +}