Commit eb4e7e31 authored by Robert Lyon's avatar Robert Lyon

Bug 1568611: Adding accessibility to rating stars

behatnotneeded

Change-Id: Ife78860e6ba4a88fb57c6de0517caa955eb1a52e
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 75316569
......@@ -122,3 +122,5 @@ $string['heart'] = 'Heart';
$string['thumbsup'] = 'Thumbs up';
$string['ok'] = 'Tick';
$string['ratingexample'] = 'Generated example';
$string['removerating'] = 'Clear ratings';
$string['ratingoption'] = "Set rating %s out of %s";
......@@ -36,11 +36,11 @@
});
// Add 'no rating' glyph
this.append('<span data-value="0" class="ratingicon icon ' + settings.offglyph + '" style="' + style + '" aria-hidden="true"></span>');
this.append('<span title="' + get_string('removerating', 'artefact.comment') + '" tabindex="0" data-value="0" class="ratingicon icon ' + settings.offglyph + '" style="' + style + '" aria-hidden="true"></span>');
// Loop through the glyphs
for (var i = 0; i < settings.limit; i++) {
this.append('<span data-value="' + (i+1) + '" class="ratingicon icon ' + settings.glyph + '" style="' + style + '" aria-hidden="true"></span>');
this.append('<span title="' + get_string('ratingoption', 'artefact.comment', i+1, settings.limit) + '" tabindex="0" data-value="' + (i+1) + '" class="ratingicon icon ' + settings.glyph + '" style="' + style + '" aria-hidden="true"></span>');
}
// Paint the glyphs
......
......@@ -84,9 +84,18 @@ function pieform_element_ratings(Pieform $form, $element) {
* @return array An array of HTML elements to go in the <head>
*/
function pieform_element_ratings_get_headdata($element) {
$headdata = array();
$strings = array('artefact.comment' => array('removerating', 'ratingoption'));
$jsstrings = '';
foreach ($strings as $section => $sectionstrings) {
foreach ($sectionstrings as $s) {
$jsstrings .= "strings.$s=" . json_encode(get_raw_string($s, $section)) . ';';
}
}
$headdata[] = '<script type="application/javascript">' . $jsstrings . '</script>';
$libfile = get_config('wwwroot') . 'js/bootstrap-ratings.js';
$result = array(
'<script type="application/javascript" src="' . $libfile . '"></script>'
);
return $result;
}
\ No newline at end of file
$headdata[] = '<script type="application/javascript" src="' . $libfile . '"></script>';
return $headdata;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment