From a92c7ffdb431bdf126e080c009b3b9c324642755 Mon Sep 17 00:00:00 2001 From: Oliver Foster Date: Fri, 25 Oct 2019 13:23:29 +0100 Subject: [PATCH] issue/2553 Added a11y_alt_text helper (#2554) --- js/helpers.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/helpers.js b/js/helpers.js index 0c8ff546..b4c4d8a4 100644 --- a/js/helpers.js +++ b/js/helpers.js @@ -355,6 +355,18 @@ define([ a11y_attrs_tabbable: function() { Adapt.a11y.log.deprecated('a11y_attrs_tabbable should not be used. tabbable elements should be natively tabbable.'); return new Handlebars.SafeString(' role="region" tabindex="0" '); + }, + + /** + * Produce display text with alternative screen reader version. + * @param {string} visible Text that will be displayed on screen + * @param {string} alternatives Text that will be read by the screen reader (instead of what's displayed on screen) + * @example {{a11y_alt_text '$5bn' 'five billion dollars'}} or {{a11y_alt_text 'Here are some bits to read' 'There are' _items.length 'items to read'}} + */ + a11y_alt_text: function(visible, alternatives) { + var values = Array.prototype.slice.call(arguments, 1, -1); + values = values.filter(Boolean); + return new Handlebars.SafeString(''+values.join(' ')+''); } };