From 18729c6b9d0a6f25ff3e28cc39f65d1629169d5b Mon Sep 17 00:00:00 2001 From: Dorian Merz <merz@ub.uni-leipzig.de> Date: Thu, 10 Dec 2020 14:32:12 +0100 Subject: [PATCH] refs #18790 [finc] use div in Flashmessages again but add role="alert" * reverts some changes from #17950 * also adds role=alert to alerts (accessibility:vf5.1) co-authored by: "Claas Kazzer <kazzer@uni-leipzig.de>" --- .../finc/src/finc/View/Helper/Root/Flashmessages.php | 10 +++++----- .../templates/Recommend/AlphaBrowseLink.phtml | 2 +- .../templates/Recommend/Channels.phtml | 2 +- .../finc-accessibility/templates/Recommend/DOI.phtml | 2 +- .../templates/Recommend/RemoveFilters.phtml | 2 +- .../templates/Recommend/SwitchType.phtml | 2 +- .../templates/RecordDriver/EDS/result-list.phtml | 2 +- .../templates/Related/Channels.phtml | 2 +- .../templates/myresearch/delete.phtml | 2 +- .../templates/myresearch/login.phtml | 2 +- .../templates/record/comments-list.phtml | 2 +- themes/finc/js/lightbox.js | 4 ++-- .../RecordDriver/DefaultRecord/collection-info.phtml | 2 +- .../RecordDriver/DefaultRecord/result-list.phtml | 2 +- 14 files changed, 19 insertions(+), 19 deletions(-) diff --git a/module/finc/src/finc/View/Helper/Root/Flashmessages.php b/module/finc/src/finc/View/Helper/Root/Flashmessages.php index 1b099d258b2..c26fbb8288a 100644 --- a/module/finc/src/finc/View/Helper/Root/Flashmessages.php +++ b/module/finc/src/finc/View/Helper/Root/Flashmessages.php @@ -39,8 +39,8 @@ namespace finc\View\Helper\Root; class Flashmessages extends \VuFind\View\Helper\Bootstrap3\Flashmessages { /** - * Generate flash message <p>'s with appropriate classes based on message type. - * This is basically a copy of the parent method but uses p-Tags instead of divs + * Generate flash message <div>'s with appropriate classes based on message type. + * This is basically a copy of the parent method but adds role = alert to divs * * @return string $html */ @@ -53,14 +53,14 @@ class Flashmessages extends \VuFind\View\Helper\Bootstrap3\Flashmessages $this->fm->getMessages($ns), $this->fm->getCurrentMessages($ns) ); foreach (array_unique($messages, SORT_REGULAR) as $msg) { - $html .= '<p class="' . $this->getClassForNamespace($ns) . '"'; + $html .= '<div class="' . $this->getClassForNamespace($ns) . '"'; if (isset($msg['dataset'])) { foreach ($msg['dataset'] as $attr => $value) { $html .= ' data-' . $attr . '="' . htmlspecialchars($value) . '"'; } } - $html .= '>'; + $html .= ' role="alert">'; // Advanced form: if (is_array($msg)) { // Use a different translate helper depending on whether @@ -83,7 +83,7 @@ class Flashmessages extends \VuFind\View\Helper\Bootstrap3\Flashmessages $transEsc = $this->getView()->plugin('transEsc'); $html .= $transEsc($msg); } - $html .= '</p>'; + $html .= '</div>'; } $this->fm->clearMessages($ns); $this->fm->clearCurrentMessages($ns); diff --git a/themes/finc-accessibility/templates/Recommend/AlphaBrowseLink.phtml b/themes/finc-accessibility/templates/Recommend/AlphaBrowseLink.phtml index 6c3f63c4b61..8d7fc91cc4c 100644 --- a/themes/finc-accessibility/templates/Recommend/AlphaBrowseLink.phtml +++ b/themes/finc-accessibility/templates/Recommend/AlphaBrowseLink.phtml @@ -14,5 +14,5 @@ ] ); ?> -<p class="alert alert-info"><?=$link?></p> +<p class="alert alert-info" role="alert"><?=$link?></p> <!-- finc-accessibility: Recommend - AlphaBrowseLink - END --> diff --git a/themes/finc-accessibility/templates/Recommend/Channels.phtml b/themes/finc-accessibility/templates/Recommend/Channels.phtml index 10710cbd401..9ea450e3ed1 100644 --- a/themes/finc-accessibility/templates/Recommend/Channels.phtml +++ b/themes/finc-accessibility/templates/Recommend/Channels.phtml @@ -7,7 +7,7 @@ . $results->getUrlQuery()->getParams(false) . '&source=' . urlencode($results->getParams()->getSearchClassId()); ?> -<p class="channels-alert alert alert-info"> +<p class="channels-alert alert alert-info" role="alert"> <a href="<?=$this->escapeHtmlAttr($link)?>"><?=$this->transEsc('channel_expand')?></a> </p> <!-- finc-accessibility: Recommend - Channels - END --> diff --git a/themes/finc-accessibility/templates/Recommend/DOI.phtml b/themes/finc-accessibility/templates/Recommend/DOI.phtml index 0a20a62a35e..d39d99a2e6c 100644 --- a/themes/finc-accessibility/templates/Recommend/DOI.phtml +++ b/themes/finc-accessibility/templates/Recommend/DOI.phtml @@ -3,7 +3,7 @@ <?php $doi = $this->recommend->getDOI(); if (!empty($doi)): ?> <?php $url = $this->recommend->getURL(); ?> - <p class="alert alert-info"> + <p class="alert alert-info" role="alert"> <?=$this->translate('doi_detected_html', ['%%url%%' => $url, '%%doi%%' => $doi])?> </p> <?php if ($this->recommend->isFullMatch()): ?> diff --git a/themes/finc-accessibility/templates/Recommend/RemoveFilters.phtml b/themes/finc-accessibility/templates/Recommend/RemoveFilters.phtml index c79a65f63ca..07f915a551d 100644 --- a/themes/finc-accessibility/templates/Recommend/RemoveFilters.phtml +++ b/themes/finc-accessibility/templates/Recommend/RemoveFilters.phtml @@ -2,7 +2,7 @@ <?php /* #17950 - use <p> for alerts - HR */ ?> <?php if ($this->recommend->hasFilters()): ?> - <p class="alert alert-info"> + <p class="alert alert-info" role="alert"> <?=$this->transEsc('nohit_active_filters')?> <a href="<?=$this->recommend->getFilterlessUrl()?>"><?=$this->transEsc('nohit_query_without_filters')?></a> </p> diff --git a/themes/finc-accessibility/templates/Recommend/SwitchType.phtml b/themes/finc-accessibility/templates/Recommend/SwitchType.phtml index c44dc55b6b0..9276727ecdf 100644 --- a/themes/finc-accessibility/templates/Recommend/SwitchType.phtml +++ b/themes/finc-accessibility/templates/Recommend/SwitchType.phtml @@ -2,7 +2,7 @@ <?php /* #17950 - use <p> for alerts - HR */ ?> <?php if ($handler = $this->recommend->getNewHandler()): ?> - <p class="alert alert-info"> + <p class="alert alert-info" role="alert" role="alert"> <?=$this->transEsc('widen_prefix')?> <a href="<?=$this->recommend->getResults()->getUrlQuery()->setHandler($handler)?>"><?=$this->transEsc($this->recommend->getNewHandlerName())?></a>. </p> diff --git a/themes/finc-accessibility/templates/RecordDriver/EDS/result-list.phtml b/themes/finc-accessibility/templates/RecordDriver/EDS/result-list.phtml index d65ddb57d0e..85fe0b87f75 100644 --- a/themes/finc-accessibility/templates/RecordDriver/EDS/result-list.phtml +++ b/themes/finc-accessibility/templates/RecordDriver/EDS/result-list.phtml @@ -118,7 +118,7 @@ <i class="fa fa-fw fa-star" aria-hidden="true"></i> <a href="<?=$this->recordLink()->getActionUrl($this->driver, 'Save')?>" class="save-record" data-lightbox id="<?=$this->driver->getUniqueId() ?>" title="<?=$this->transEsc('Add to favorites')?>"><?=$this->transEsc('Add to favorites')?></a><br/> <?php /* Saved lists */ ?> - <p class="savedLists alert alert-info hidden"> + <p class="savedLists alert alert-info hidden" role="alert"> <strong><?=$this->transEsc("Saved in")?>:</strong> </p> <?php endif; ?> diff --git a/themes/finc-accessibility/templates/Related/Channels.phtml b/themes/finc-accessibility/templates/Related/Channels.phtml index 04f65247244..5b5abb04658 100644 --- a/themes/finc-accessibility/templates/Related/Channels.phtml +++ b/themes/finc-accessibility/templates/Related/Channels.phtml @@ -7,7 +7,7 @@ . '?id=' . urlencode($driver->getUniqueId()) . '&source=' . urlencode($driver->getSourceIdentifier()); ?> -<p class="channels-alert alert alert-info"> +<p class="channels-alert alert alert-info" role="alert"> <a href="<?=$this->escapeHtmlAttr($link)?>"><?=$this->transEsc('channel_expand')?></a> </p> <!-- finc-accessibility: Related - Channels - END --> diff --git a/themes/finc-accessibility/templates/myresearch/delete.phtml b/themes/finc-accessibility/templates/myresearch/delete.phtml index 19fc345724e..aeb2c39b4b6 100644 --- a/themes/finc-accessibility/templates/myresearch/delete.phtml +++ b/themes/finc-accessibility/templates/myresearch/delete.phtml @@ -7,7 +7,7 @@ <div id="popupMessages"><?=$this->flashmessages()?></div> <div id="popupDetails"> <?php if (!$this->list): ?> - <p class="alert alert-info"><?=$this->transEsc("fav_delete_warn") ?></p> + <p class="alert alert-info" role="alert"><?=$this->transEsc("fav_delete_warn") ?></p> <?php else: ?> <h2><?=$this->transEsc("List") ?>: <?=$this->escapeHtml($this->list->title) ?></h2> <?php endif; ?> diff --git a/themes/finc-accessibility/templates/myresearch/login.phtml b/themes/finc-accessibility/templates/myresearch/login.phtml index 5bf1facad28..f7d5f804794 100644 --- a/themes/finc-accessibility/templates/myresearch/login.phtml +++ b/themes/finc-accessibility/templates/myresearch/login.phtml @@ -22,7 +22,7 @@ <?=$this->flashmessages()?> <?php if ($hideLogin): ?> - <p class="alert alert-danger"><?=$this->transEsc('login_disabled')?></p> + <p class="alert alert-danger" role="alert"><?=$this->transEsc('login_disabled')?></p> <?php else: ?> <?=$this->auth()->getLogin()?> <?php endif; ?> diff --git a/themes/finc-accessibility/templates/record/comments-list.phtml b/themes/finc-accessibility/templates/record/comments-list.phtml index 66b90c54bb8..fa892bbad12 100644 --- a/themes/finc-accessibility/templates/record/comments-list.phtml +++ b/themes/finc-accessibility/templates/record/comments-list.phtml @@ -1,7 +1,7 @@ <!-- finc-accessibility: record - comments-list --> <?php $comments = $this->driver->getComments(); ?> <?php if (empty($comments) || count($comments) == 0): ?> - <p class="alert alert-info"><?=$this->transEsc('Be the first to leave a comment')?>!</p> + <p class="alert alert-info" role="alert"><?=$this->transEsc('Be the first to leave a comment')?>!</p> <?php else: ?> <?php foreach ($comments as $comment): ?> <div class="comment"> diff --git a/themes/finc/js/lightbox.js b/themes/finc/js/lightbox.js index 50e34faa90b..ecd9155acd7 100644 --- a/themes/finc/js/lightbox.js +++ b/themes/finc/js/lightbox.js @@ -42,7 +42,7 @@ VuFind.register('lightbox', function Lightbox() { // Public: Present an alert function showAlert(message, _type) { var type = _type || 'info'; - _html('<p class="flash-message alert alert-' + type + '">' + message + '</p>' + _html('<div class="flash-message alert alert-' + type + '" role="alert">' + message + '</div>' + '<button class="btn btn-default" data-dismiss="modal">' + VuFind.translate('close') + '</button>'); _modal.modal('show'); } @@ -50,7 +50,7 @@ VuFind.register('lightbox', function Lightbox() { var type = _type || 'info'; _modalBody.find('.flash-message,.fa.fa-spinner').remove(); _modalBody.find('h2:first-of-type') - .after('<p class="flash-message alert alert-' + type + '">' + message + '</p>'); + .after('<div class="flash-message alert alert-' + type + '" role="alert">' + message + '</div>'); } function close() { _modal.modal('hide'); diff --git a/themes/finc/templates/RecordDriver/DefaultRecord/collection-info.phtml b/themes/finc/templates/RecordDriver/DefaultRecord/collection-info.phtml index fcd4bba892f..9a632703f39 100644 --- a/themes/finc/templates/RecordDriver/DefaultRecord/collection-info.phtml +++ b/themes/finc/templates/RecordDriver/DefaultRecord/collection-info.phtml @@ -34,7 +34,7 @@ <?php endif; ?> <?php /* Display the lists that this record is saved to */ ?> - <p class="savedLists hidden alert alert-info" id="savedLists"> + <p class="savedLists hidden alert alert-info" id="savedLists" role="alert"> <strong><?=$this->transEsc("Saved in")?>:</strong> </p> diff --git a/themes/finc/templates/RecordDriver/DefaultRecord/result-list.phtml b/themes/finc/templates/RecordDriver/DefaultRecord/result-list.phtml index 36660cc5e39..f1f15d36742 100644 --- a/themes/finc/templates/RecordDriver/DefaultRecord/result-list.phtml +++ b/themes/finc/templates/RecordDriver/DefaultRecord/result-list.phtml @@ -216,7 +216,7 @@ $i = 0; <?=$block?> <?php endif; ?> <?php /* Saved lists */ ?> - <p class="savedLists alert alert-info hidden"> + <p class="savedLists alert alert-info hidden" role="alert"> <strong><?=$this->transEsc("Saved in")?>:</strong> </p> <?php endif; ?> -- GitLab