lib/hatemile/implementation/accessible_display_implementation.rb
##
# Force the screen reader display an information of element.
#
# @param element [Hatemile::Util::Html::HTMLDOMElement] The reference
#   element.
# @param text_before [String] The text content to show before the element.
# @param text_after [String] The text content to show after the element.
# @param data_of [String] The name of attribute that links the content
#   with element.
# @return [void]
Force the screen reader display an information of element.
Force the screen reader display an information of element .
def force_read_simple(element, text_before, text_after, data_of)
        @id_generator.generate_id(element)
        identifier = element.get_attribute('id')
        selector = "[#{data_of}=\"#{identifier}\"]"
        reference_before = @parser.find(
          ".#{CLASS_FORCE_READ_BEFORE}#{selector}"
        ).first_result
        reference_after = @parser.find(
          ".#{CLASS_FORCE_READ_AFTER}#{selector}"
        ).first_result
        references = @parser.find(selector).list_results
        if references.include?(reference_before)
          references.delete(reference_before)
        end
        if references.include?(reference_after)
          references.delete(reference_after)
        end
        return unless references.empty?
        unless text_before.empty?
          reference_before.remove_node unless reference_before.nil?
          span = @parser.create_element('span')
          span.set_attribute('class', CLASS_FORCE_READ_BEFORE)
          span.set_attribute(data_of, identifier)
          span.append_text(text_before)
          insert(element, span, true)
        end
        return if text_after.empty?
        reference_after.remove_node unless reference_after.nil?
        span = @parser.create_element('span')
        span.set_attribute('class', CLASS_FORCE_READ_AFTER)
        span.set_attribute(data_of, identifier)
        span.append_text(text_after)
        insert(element, span, false)
      end
def force_read_simple ( element , text_before , text_after , data_of ) @id_generator . generate_id ( element ) identifier = element . get_attribute ( 'id' ) selector = "[#{data_of}=\"#{identifier}\"]" reference_before = @parser . find ( ".#{CLASS_FORCE_READ_BEFORE}#{selector}" ) . first_result reference_after = @parser . find ( ".#{CLASS_FORCE_READ_AFTER}#{selector}" ) . first_result references = @parser . find ( selector ) . list_results if references . include? ( reference_before ) references . delete ( reference_before ) end if references . include? ( reference_after ) references . delete ( reference_after ) end return unless references . empty? unless text_before . empty? reference_before . remove_node unless reference_before . nil? span = @parser . create_element ( 'span' ) span . set_attribute ( 'class' , CLASS_FORCE_READ_BEFORE ) span . set_attribute ( data_of , identifier ) span . append_text ( text_before ) insert ( element , span , true ) end return if text_after . empty? reference_after . remove_node unless reference_after . nil? span = @parser . create_element ( 'span' ) span . set_attribute ( 'class' , CLASS_FORCE_READ_AFTER ) span . set_attribute ( data_of , identifier ) span . append_text ( text_after ) insert ( element , span , false ) end
Force the screen reader display an information of element.
Force the screen reader display an information of element .
None
void
element
The reference element.
The reference element .
text_before
The text content to show before the element.
The text content to show before the element .
text_after
The text content to show after the element.
The text content to show after the element .
data_of
The name of attribute that links the content with element.
The name of attribute that links the content with element .