Module: Kitchen::Directions::BakeScreenreaderSpans
- Defined in:
- lib/kitchen/directions/bake_screenreader_spans.rb
Class Method Summary collapse
- .add_screenreader_text(element:, begin_message:, end_message:) ⇒ Object
-
.v1(book:) ⇒ Object
Add text for accessibility.
Class Method Details
.add_screenreader_text(element:, begin_message:, end_message:) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/kitchen/directions/bake_screenreader_spans.rb', line 46 def self.add_screenreader_text(element:, begin_message:, end_message:) element.prepend(child: "<span data-screenreader-only=\"true\">#{}</span>" ) element.append(child: "<span data-screenreader-only=\"true\">#{}</span>" ) end |
.v1(book:) ⇒ Object
Add text for accessibility. Additional screenreader spans can be added below.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/kitchen/directions/bake_screenreader_spans.rb', line 8 def self.v1(book:) book.search('u[data-effect="underline"]').each do |element| add_screenreader_text( element: element, begin_message: I18n.t(:'screenreader.underline'), end_message: "#{I18n.t(:'screenreader.end')} #{I18n.t(:'screenreader.underline')}" ) end book.search('u[data-effect="double-underline"]').each do |element| add_screenreader_text( element: element, begin_message: I18n.t(:'screenreader.double-underline'), end_message: "#{I18n.t(:'screenreader.end')} #{I18n.t(:'screenreader.double-underline')}" ) end book.search('p.public-domain').each do |element| add_screenreader_text( element: element, begin_message: I18n.t(:'screenreader.public-domain'), end_message: "#{I18n.t(:'screenreader.end')} #{I18n.t(:'screenreader.public-domain')}" ) end book.search('p.student-sample').each do |element| add_screenreader_text( element: element, begin_message: I18n.t(:'screenreader.student-sample'), end_message: "#{I18n.t(:'screenreader.end')} #{I18n.t(:'screenreader.student-sample')}" ) end book.search('p.annotation-text').each do |element| add_screenreader_text( element: element, begin_message: I18n.t(:'screenreader.annotation-text'), end_message: "#{I18n.t(:'screenreader.end')} #{I18n.t(:'screenreader.annotation-text')}" ) end end |