Module: DsfrAccessibleSkipLinks::SkipLinks
- Defined in:
- lib/dsfr_accessible_skip_links/skip_links.rb
Constant Summary collapse
- TAB_PREFIX =
"tab-"
Instance Method Summary collapse
- #content_skip_link_text ⇒ Object
- #default_skip_links ⇒ Object
- #skip_link(text, anchor) ⇒ Object
- #skip_links_content ⇒ Object
Instance Method Details
#content_skip_link_text ⇒ Object
35 36 37 38 39 |
# File 'lib/dsfr_accessible_skip_links/skip_links.rb', line 35 def content_skip_link_text return content_for(:content_skip_link_text) if content_for?(:content_skip_link_text) "Aller au contenu" end |
#default_skip_links ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/dsfr_accessible_skip_links/skip_links.rb', line 18 def default_skip_links result = [ skip_link(content_skip_link_text, "content"), skip_link("Menu", "header"), skip_link("Pied de page", "footer") ].join result.respond_to?(:html_safe) ? result.html_safe : result end |
#skip_link(text, anchor) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/dsfr_accessible_skip_links/skip_links.rb', line 7 def skip_link(text, anchor) anchor_str = anchor.to_s content_tag(:li) do if anchor_str.start_with?(TAB_PREFIX) link_to(text, "##{anchor_str}", class: "fr-link", data: { anchor: anchor_str }) else link_to(text, "##{anchor_str}", class: "fr-link") end end end |
#skip_links_content ⇒ Object
28 29 30 31 32 33 |
# File 'lib/dsfr_accessible_skip_links/skip_links.rb', line 28 def skip_links_content return content_for(:skip_links) if content_for?(:skip_links) validate_skip_links_in_test! if defined?(Rails) && Rails.env.test? default_skip_links end |