Skip to content
Snippets Groups Projects
Commit e3c988b9 authored by Moritz Strohm's avatar Moritz Strohm Committed by Jan-Hendrik Willms
Browse files

TIC #394

parent 9844e948
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,7 @@ class ContentGroupMenu
private $rows = 1;
private $columns = 1;
private $image = null;
private $image_link_attributes = [];
private $label;
private $aria_label;
......@@ -223,6 +224,7 @@ class ContentGroupMenu
if ($this->image) {
$template->image = $this->image;
$template->image_link_attributes = $this->image_link_attributes;
} else {
$template->image = "<div></div><div></div><div></div>";
}
......@@ -267,10 +269,13 @@ class ContentGroupMenu
* Sets the icon of the menu.
*
* @param String $menu_image image html for the menu
*
* @param array $image_link_attributes Additional HTML attributes for the link that surrounds the image.
*/
public function setIcon($menu_image)
public function setIcon($menu_image, array $image_link_attributes = [])
{
$this->image = $menu_image;
$this->image_link_attributes = $image_link_attributes;
}
/**
......
......@@ -34,24 +34,6 @@ class SearchWidget extends SidebarWidget
$this->template = 'sidebar/search-widget';
}
/**
* Sets the id for the form element.
*/
public function setId($id)
{
$this->id = $id;
}
/**
* Returns the id for the form element.
*
* @return mixed String containing the id or null if no id has been set.
*/
public function getId()
{
return $this->id;
}
/**
* Sets the request method used for the form.
*/
......@@ -143,7 +125,6 @@ class SearchWidget extends SidebarWidget
$this->template_variables['url_params'] = $query_params;
$this->template_variables['method'] = $this->method;
$this->template_variables['id'] = $this->id;
foreach ($this->needles as $index => $needle) {
if ($needle['quick_search']) {
......
......@@ -9,11 +9,37 @@
*/
class SidebarWidget extends Widget
{
protected $id = '';
public function __construct()
{
$this->layout = 'sidebar/widget-layout.php';
}
/**
* Sets the ID of the HTML element that represents the widget.
*
* @param $id The element-ID to be used for the widget.
*
*/
public function setId(string $id)
{
$this->id = $id;
}
/**
* Returns the ID of this widget, if it is set.
*
* @return string The ID of the widget or an empty string, if it is not set.
*/
public function getId() : string
{
return $this->id;
}
/**
* Sets the title of the widget.
*
......@@ -46,7 +72,7 @@ class SidebarWidget extends Widget
{
$this->extra = $extra;
}
public function getExtra()
{
return $this->extra;
......@@ -65,6 +91,9 @@ class SidebarWidget extends Widget
*/
public function render($variables = [])
{
if ($this->id) {
$this->template_variables['id'] = $this->id;
}
return parent::render($variables);
}
}
\ No newline at end of file
}
......@@ -23,6 +23,13 @@
#skiplink_list {
display: none;
button.skiplink {
border: 0;
background-color: #fff;
color: @base-color;
line-height: 1em;
margin-bottom: 0.1em;
}
}
body.enable-skiplinks {
......
<!-- Beginn Footer -->
<?= SkipLinks::addIndex(_('Fußzeile'), 'layout_footer',900) ?>
<div id="layout_footer">
<? if (is_object($GLOBALS['user']) && $GLOBALS['user']->id != 'nobody') : ?>
<div id="footer">
......
......@@ -56,6 +56,7 @@ if (isset($_COOKIE['navigation-length'])) {
<? if (PageLayout::hasCustomQuicksearch()): ?>
<?= PageLayout::getCustomQuicksearch() ?>
<? else: ?>
<? SkipLinks::addIndex(_('Suche'), 'globalsearch-input', 910) ?>
<li id="quicksearch_item">
<script>
var selectSem = function (seminar_id, name) {
......@@ -119,7 +120,10 @@ if (isset($_COOKIE['navigation-length'])) {
$action_menu->addAttribute('data-action-menu-reposition', 'false');
$action_menu->setLabel(User::findCurrent()->getFullName());
$action_menu->setAriaLabel(_("Profilmenü"));
$action_menu->setIcon(Avatar::getAvatar(User::findCurrent()->id)->getImageTag(Avatar::MEDIUM));
$action_menu->setIcon(
Avatar::getAvatar(User::findCurrent()->id)->getImageTag(Avatar::MEDIUM),
['id' => 'header_avatar_image_link']
);
foreach (Navigation::getItem('/avatar') as $subnav) {
$action_menu->addLink(
......@@ -128,7 +132,7 @@ if (isset($_COOKIE['navigation-length'])) {
$subnav->getImage()
);
}
SkipLinks::addIndex(_("Profilmenü"), "header_avatar_menu", 2);
SkipLinks::addIndex(_("Profilmenü"), "header_avatar_image_link", 1);
?>
<?= $action_menu->render(); ?>
</div>
......@@ -148,7 +152,7 @@ if (isset($_COOKIE['navigation-length'])) {
</div>
-->
<? SkipLinks::addIndex(_('Hauptnavigation'), 'barTopMenu', 1); ?>
<? SkipLinks::addIndex(_('Hauptnavigation'), 'barTopMenu', 2); ?>
<ul id="barTopMenu" role="navigation" <? if (count($header_nav['hidden']) > 0) echo 'class="overflown"'; ?>>
<? foreach ($header_nav['visible'] as $path => $nav): ?>
<?= $this->render_partial(
......
<div class="helpbar-container">
<a href="#" class="helpbar-toggler" data-toggles=".helpbar" title="<?= _('Hilfelasche anzeigen/verstecken') ?>">
<?= SkipLinks::addIndex(_('Tipps & Hilfe'), 'helpbar_icon', 920) ?>
<a id="helpbar_icon" href="#" class="helpbar-toggler" data-toggles=".helpbar" title="<?= _('Hilfelasche anzeigen/verstecken') ?>">
<?= Icon::create('question-circle')->asImg(24) ?>
</a>
<div class="helpbar" <? if (!$open) echo 'style="display: none"'; ?>>
......
<? // class "action-menu" will be set from API ?>
<nav <?= arrayToHtmlAttributes($attributes) ?>>
<a class="action-menu-icon" title="<?= htmlReady($label) ?>"
aria-expanded="false" aria-label="<?= htmlReady($aria_label) ?>" href="#">
aria-expanded="false" aria-label="<?= htmlReady($aria_label) ?>" href="#"
<?= $image_link_attributes ? arrayToHtmlAttributes($image_link_attributes) : '' ?>>
<?= $image ?>
</a>
<div class="action-menu-content">
......
......@@ -20,6 +20,15 @@
</div>
<? foreach ($widgets as $index => $widget): ?>
<?
if ($widget instanceof NavigationWidget) {
$widget->setId('nav_layer_3');
SkipLinks::addIndex(_('Dritte Navigationsebene'), 'nav_layer_3', 20, false);
} elseif ($widget instanceof ActionsWidget) {
$widget->setId('sidebar_actions');
SkipLinks::addIndex(_('Aktionen'), 'sidebar_actions', 21, false);
}
?>
<?= $widget->render(['base_class' => 'sidebar']) ?>
<? endforeach; ?>
</section>
......
......@@ -3,16 +3,15 @@
?>
<? if ($navigation instanceof Navigation && iterator_count($navigation) > 0) : ?>
<ul role="navigation" id="skiplink_list">
<? $i = 1 ?>
<? foreach ($navigation as $nav) : ?>
<li>
<? if (mb_substr($url = $nav->getURL(), 0, 1) == '#') : ?>
<a href="<?= $url ?>" onclick="STUDIP.SkipLinks.setActiveTarget('<?= $url ?>');" tabindex="<?= $i++ ?>"><?= htmlReady($nav->getTitle()) ?></a>
<button class="skiplink" onclick="STUDIP.SkipLinks.setActiveTarget('<?= $url ?>');"><?= htmlReady($nav->getTitle()) ?></button>
<? else : ?>
<? if (is_internal_url($url)) : ?>
<a href="<?= URLHelper::getLink($url) ?>" tabindex="<?= $i++ ?>"><?= htmlReady($nav->getTitle()) ?></a>
<a href="<?= URLHelper::getLink($url) ?>"><?= htmlReady($nav->getTitle()) ?></a>
<? else : ?>
<a href="<?= htmlReady($url) ?>" tabindex="<?= $i++ ?>"><?= htmlReady($nav->getTitle()) ?></a>
<a href="<?= htmlReady($url) ?>"><?= htmlReady($nav->getTitle()) ?></a>
<? endif ?>
<? endif ?>
</li>
......
......@@ -8,7 +8,7 @@ foreach (Navigation::getItem("/")->getSubNavigation() as $path => $nav) {
$ebene3 = [];
?>
<div class="tabs_wrapper">
<? SkipLinks::addIndex(_('Erste Reiternavigation'), 'tabs', 10); ?>
<? SkipLinks::addIndex(_('Zweite Navigationsebene'), 'tabs', 10); ?>
<ul id="tabs" role="navigation">
<? if (!empty($navigation)): ?>
<? foreach ($navigation as $path => $nav) : ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment