Bugzilla – Attachment 183952 Details for
Bug 39706
Accessibility: Missing text alternative for the star rating.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39706: Add alternative text to the stars rating
Bug-39706-Add-alternative-text-to-the-stars-rating.patch (text/plain), 7.31 KB, created by
Owen Leonard
on 2025-07-10 16:54:05 UTC
(
hide
)
Description:
Bug 39706: Add alternative text to the stars rating
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2025-07-10 16:54:05 UTC
Size:
7.31 KB
patch
obsolete
>From 90a066de98dd35e3fdcbac69176089214155ecca Mon Sep 17 00:00:00 2001 >From: nina martinez <nina.martinez@biblibre.com> >Date: Wed, 16 Apr 2025 11:46:27 +0200 >Subject: [PATCH] Bug 39706: Add alternative text to the stars rating > >Test Plan: > >1- Enable the following system preference: OpacStarRatings (results, > details, and patron). >2- Apply the patch. >3- Go to the Opac. >4- Search a record. >5- Inspect the HTML code before the stars and notice that there is "Star > rating" in a span tag with the class "sr-only". Inspect the stars, > there should be a span tag for each star. After the stars, notice > that there is the average rating in a span with the "sr-only" class. >6- Click on a record and do the same as the 5: go to the star rating, > inspect the HTML code, and notice that there is a span tag for each > star. >7- Now, log into an account. >8- Search a record. >9- It should be the same information as in the step 5. >10- Click on a record to view the details. Now, you can change the > rating. Inspect the stars, each should have the number of stars in > the span tag with a "sr-only" class, which are in the link tags. >11- For this part, you need to have a record checked out (if you don't > have a record checked out, go to the staff interface and do it. > Choose your patron and enter the barcode of the record). >12- Go to your account. In the "Checked Out" section, you should see the > same as in the 10 step: the number of stars and be able to change > your rating or make a new one. > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss | 6 +++--- > .../bootstrap/en/includes/user-star-ratings.inc | 1 + > .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 9 +++++---- > koha-tmpl/opac-tmpl/bootstrap/js/ratings.js | 13 +++++++++++++ > 4 files changed, 22 insertions(+), 7 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss >index 05063f81603..b10559a3278 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss >+++ b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss >@@ -2629,7 +2629,7 @@ $star-selected: #EDB867; > height: 28px; > white-space: nowrap; > >- a { >+ span,a { > font: normal normal normal 20px/1 "Font Awesome 6 Free"; > -webkit-font-smoothing: antialiased; > margin-right: 2px; >@@ -2660,7 +2660,7 @@ $star-selected: #EDB867; > } > > .br-readonly { >- a { >+ span, a { > cursor: default; > } > } >@@ -2675,7 +2675,7 @@ $star-selected: #EDB867; > @media print { > .br-theme-fontawesome-stars { > .br-widget { >- a { >+ span,a { > &::after { > color: #000000; > content: "\f006"; >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/user-star-ratings.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/user-star-ratings.inc >index b5aaac3e4a2..7d3698f7ef7 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/user-star-ratings.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/user-star-ratings.inc >@@ -16,6 +16,7 @@ > </div> > </div> > >+ <label class="sr-only" for="star_rating-[% item.itemnumber | html %]">star rating</label> > <select class="star_rating" id="star_rating-[% item.itemnumber | html %]" name="rating" autocomplete="off" data-biblionumber="[% item.biblionumber | html %]" data-context="rating-[% item.itemnumber | html %]"> > [% IF ( rating_avg_int == 0 ) %] > <option value="" selected="selected"></option> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >index 2713c1bf2b1..c1ed108d615 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -386,6 +386,7 @@ > [% INCLUDE "openlibrary-readapi.inc" bib = SEARCH_RESULT %] > > [% IF ( OpacStarRatings == 'all' ) %] >+ <span class="sr-only"> star rating </span> > <div class="results_summary ratings"> > [% SET rating_avg = SEARCH_RESULT.ratings.get_avg_rating() %] > [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %] >@@ -393,16 +394,16 @@ > <div class="br-widget br-readonly"> > [% FOREACH i IN [ 1 2 3 4 5 ] %] > [% IF rating_avg_int == i %] >- <a href="#" class="br-selected br-current"></a> >+ <span href="#" class="br-selected br-current"></span> > [% ELSIF rating_avg_int > i %] >- <a href="#" class="br-selected"></a> >+ <span href="#" class="br-selected"></span> > [% ELSE %] >- <a href="#"></a> >+ <span href="#"></span> > [% END %] > [% END %] > </div> > </div> >- >+ <span class="sr-only"> Average : [% rating_avg | html %] out of 5 stars</span> > [% IF SEARCH_RESULT.ratings.count > 0 %] > <span id="rating_total_[% SEARCH_RESULT.biblionumber | html %]"> ([% SEARCH_RESULT.ratings.count | html %] votes)</span> > [% ELSE %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/ratings.js b/koha-tmpl/opac-tmpl/bootstrap/js/ratings.js >index 7c70068dbf1..13be3083c78 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/js/ratings.js >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/ratings.js >@@ -58,4 +58,17 @@ $(document).ready(function () { > var context = "#" + $(this).data("context"); > $(context).barrating("set", ""); > }); >+ >+ $(".br-widget a").each(function () { >+ if (!is_logged_in) { >+ var span = $("<span></span>"); >+ $.each(this.attributes, function () { >+ span.attr(this.name, this.value); >+ }); >+ $(this).replaceWith(span); >+ } else { >+ var data_rating = $(this).attr("data-rating-value"); >+ $(this).append('<span class="sr-only">' + data_rating + "</span>"); >+ } >+ }); > }); >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39706
:
182254
|
183923
|
183952
|
184070
|
184355