diff --git a/resources/assets/javascripts/bootstrap/studip_helper_attributes.js b/resources/assets/javascripts/bootstrap/studip_helper_attributes.js index a433bb267ce8021796235034bffec26282cf8f96..60a9e1c40e02a73e8a7206b2fae0b14b819c2ada 100644 --- a/resources/assets/javascripts/bootstrap/studip_helper_attributes.js +++ b/resources/assets/javascripts/bootstrap/studip_helper_attributes.js @@ -227,3 +227,12 @@ $(document).on('change', 'input[data-must-equal]', function() { this.setCustomValidity(''); } }); + +//Generalisation: The enter-accessible class allows an element to be accessible via keyboard +//by triggering the click event when the enter key is pressed. +$(document).on('keydown', '.enter-accessible', function(event) { + if (event.code == 'Enter') { + //The enter key has been pressed. + $(this).trigger('click'); + } +}); diff --git a/templates/contentbar/contentbar.php b/templates/contentbar/contentbar.php index 887f49525439dc5855b7900d54f62eb41428b956..4433aabdc5becaf64b99083232120ccf8a72c937 100644 --- a/templates/contentbar/contentbar.php +++ b/templates/contentbar/contentbar.php @@ -16,7 +16,7 @@ <div class="contentbar-icons"> <? if ($toc->hasChildren()) : ?> <input type="checkbox" id="cb-toc"> - <label for="cb-toc" class="check-box" title="<?= _('Inhaltsverzeichnis') ?>" > + <label for="cb-toc" class="check-box enter-accessible" title="<?= _('Inhaltsverzeichnis') ?>" tabindex="0"> <?= Icon::create('table-of-contents')->asImg(24) ?> </label> <?= $ttpl->render() ?> diff --git a/templates/toc/generic-toc-list.php b/templates/toc/generic-toc-list.php index ff81cb22f3f0b85fd6c8314d23a6d88ca4dba205..475ceaae4572c144e2bc115cf86d5445b43ed3c4 100644 --- a/templates/toc/generic-toc-list.php +++ b/templates/toc/generic-toc-list.php @@ -2,7 +2,7 @@ <article class="toc_overview toc_transform" id="toc"> <header id="toc_header"> <h1 id="toc_h1"><?= sprintf(_('Inhalt (%u Elemente)'), htmlReady($root->countAllChildren())) ?></h1> - <label for="cb-toc" class="check-box" title="<?= _('Schließen')?>"> + <label for="cb-toc" class="check-box enter-accessible" title="<?= _('Schließen')?>" tabindex="0"> <?= Icon::create('decline')->asImg(24) ?> </label> </header>