From 5e9119e91c2f9e898f2be06e157877c921ad872d Mon Sep 17 00:00:00 2001 From: Daniel Ritz Date: Sun, 31 Jan 2016 20:26:28 +0100 Subject: [PATCH] Improve accessibility for icon-only links by adding hidden text --- app/helpers/application_helper.rb | 10 +++---- app/helpers/email_addresses_helper.rb | 8 +++--- app/helpers/issues_helper.rb | 5 ++-- app/helpers/journals_helper.rb | 6 ++--- app/helpers/watchers_helper.rb | 2 +- app/views/attachments/_links.html.erb | 8 +++--- app/views/issues/_attributes.html.erb | 4 +-- app/views/issues/_relations.html.erb | 2 +- app/views/my/blocks/_timelog.html.erb | 4 +-- app/views/news/show.html.erb | 2 +- app/views/reports/issue_report.html.erb | 35 ++++++++++++++++++++----- app/views/repositories/_related_issues.html.erb | 2 +- app/views/settings/_repositories.html.erb | 10 ++++--- app/views/timelog/_list.html.erb | 6 ++--- public/stylesheets/application.css | 11 ++++++++ test/unit/helpers/application_helper_test.rb | 4 +-- 16 files changed, 77 insertions(+), 42 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ff20064..d643e1f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -454,16 +454,16 @@ module ApplicationHelper end def reorder_links(name, url, method = :post) - link_to('', + link_to(l(:label_sort_highest), url.merge({"#{name}[move_to]" => 'highest'}), :method => method, :title => l(:label_sort_highest), :class => 'icon-only icon-move-top') + - link_to('', + link_to(l(:label_sort_higher), url.merge({"#{name}[move_to]" => 'higher'}), :method => method, :title => l(:label_sort_higher), :class => 'icon-only icon-move-up') + - link_to('', + link_to(l(:label_sort_lower), url.merge({"#{name}[move_to]" => 'lower'}), :method => method, :title => l(:label_sort_lower), :class => 'icon-only icon-move-down') + - link_to('', + link_to(l(:label_sort_lowest), url.merge({"#{name}[move_to]" => 'lowest'}), :method => method, :title => l(:label_sort_lowest), :class => 'icon-only icon-move-bottom') end @@ -887,7 +887,7 @@ module ApplicationHelper @current_section += 1 if @current_section > 1 content_tag('div', - link_to('', options[:edit_section_links].merge(:section => @current_section), + link_to(l(:button_edit_section), options[:edit_section_links].merge(:section => @current_section), :class => 'icon-only icon-edit'), :class => "contextual heading-#{level}", :title => l(:button_edit_section), diff --git a/app/helpers/email_addresses_helper.rb b/app/helpers/email_addresses_helper.rb index c30aaa6..4131b61 100644 --- a/app/helpers/email_addresses_helper.rb +++ b/app/helpers/email_addresses_helper.rb @@ -22,17 +22,17 @@ module EmailAddressesHelper # Returns a link to enable or disable notifications for the address def toggle_email_address_notify_link(address) if address.notify? - link_to '', + link_to l(:label_disable_notifications), user_email_address_path(address.user, address, :notify => '0'), :method => :put, :remote => true, :title => l(:label_disable_notifications), - :class => 'icon icon-email' + :class => 'icon-only icon-email' else - link_to '', + link_to l(:label_enable_notifications), user_email_address_path(address.user, address, :notify => '1'), :method => :put, :remote => true, :title => l(:label_enable_notifications), - :class => 'icon icon-email-disabled' + :class => 'icon-only icon-email-disabled' end end end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 4a36800..199cf36 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -442,10 +442,11 @@ module IssuesHelper # Link to the attachment if it has not been removed value = link_to_attachment(atta, :download => true, :only_path => options[:only_path]) if options[:only_path] != false && atta.is_text? - value += link_to('', + value += link_to(l(:button_view), { :controller => 'attachments', :action => 'show', :id => atta, :filename => atta.filename }, - :class => 'icon icon-magnifier') + :class => 'icon-only icon-magnifier', + :title => l(:button_view)) end else value = content_tag("i", h(value)) if value diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb index 2a0a7d3..880b051 100644 --- a/app/helpers/journals_helper.rb +++ b/app/helpers/journals_helper.rb @@ -30,21 +30,21 @@ module JournalsHelper editable = User.current.logged? && (User.current.allowed_to?(:edit_issue_notes, issue.project) || (journal.user == User.current && User.current.allowed_to?(:edit_own_issue_notes, issue.project))) links = [] if !journal.notes.blank? - links << link_to('', + links << link_to(l(:button_quote), quoted_issue_path(issue, :journal_id => journal), :remote => true, :method => 'post', :title => l(:button_quote), :class => 'icon-only icon-comment' ) if options[:reply_links] - links << link_to('', + links << link_to(l(:button_edit), edit_journal_path(journal), :remote => true, :method => 'get', :title => l(:button_edit), :class => 'icon-only icon-edit' ) if editable - links << link_to('', + links << link_to(l(:button_delete), journal_path(journal, :notes => ""), :remote => true, :method => 'put', :data => {:confirm => l(:text_are_you_sure)}, diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 9a5de74..6cdef6c 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -58,7 +58,7 @@ module WatchersHelper :object_id => object.id, :user_id => user} s << ' ' - s << link_to('', url, + s << link_to(l(:button_delete), url, :remote => true, :method => 'delete', :class => "delete icon-only icon-del", :title => l(:button_delete)) diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index 53324c2..a71a722 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -1,6 +1,6 @@
- <%= link_to('', + <%= link_to(l(:label_edit_attachments), container_attachments_edit_path(container), :title => l(:label_edit_attachments), :class => 'icon-only icon-edit' @@ -9,16 +9,16 @@ <% for attachment in attachments %>

<%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> <% if attachment.is_text? %> - <%= link_to '', + <%= link_to l(:button_view), { :controller => 'attachments', :action => 'show', :id => attachment, :filename => attachment.filename }, - :class => 'icon icon-magnifier', + :class => 'icon-only icon-magnifier', :title => l(:button_view) %> <% end %> <%= " - #{attachment.description}" unless attachment.description.blank? %> (<%= number_to_human_size attachment.filesize %>) <% if options[:deletable] %> - <%= link_to '', attachment_path(attachment), + <%= link_to l(:button_delete), attachment_path(attachment), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :class => 'delete icon-only icon-del', diff --git a/app/views/issues/_attributes.html.erb b/app/views/issues/_attributes.html.erb index f0a9890..63782d2 100644 --- a/app/views/issues/_attributes.html.erb +++ b/app/views/issues/_attributes.html.erb @@ -20,7 +20,7 @@ <% if @issue.safe_attribute?('category_id') && @issue.project.issue_categories.any? %>

<%= f.select :category_id, (@issue.project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true, :required => @issue.required_attribute?('category_id') %> -<%= link_to('', +<%= link_to(l(:label_issue_category_new), new_project_issue_category_path(@issue.project), :remote => true, :method => 'get', @@ -32,7 +32,7 @@ <% if @issue.safe_attribute?('fixed_version_id') && @issue.assignable_versions.any? %>

<%= f.select :fixed_version_id, version_options_for_select(@issue.assignable_versions, @issue.fixed_version), :include_blank => true, :required => @issue.required_attribute?('fixed_version_id') %> -<%= link_to('', +<%= link_to(l(:label_version_new), new_project_version_path(@issue.project), :remote => true, :method => 'get', diff --git a/app/views/issues/_relations.html.erb b/app/views/issues/_relations.html.erb index b79e744..dcf0795 100644 --- a/app/views/issues/_relations.html.erb +++ b/app/views/issues/_relations.html.erb @@ -19,7 +19,7 @@ <%= other_issue.status.name %> <%= format_date(other_issue.start_date) %> <%= format_date(other_issue.due_date) %> - <%= link_to('', + <%= link_to(l(:label_relation_delete), relation_path(relation), :remote => true, :method => :delete, diff --git a/app/views/my/blocks/_timelog.html.erb b/app/views/my/blocks/_timelog.html.erb index 76b974e..7fcac4a 100644 --- a/app/views/my/blocks/_timelog.html.erb +++ b/app/views/my/blocks/_timelog.html.erb @@ -42,10 +42,10 @@ entries_by_day = entries.group_by(&:spent_on) <%= html_hours("%.2f" % entry.hours) %> <% if entry.editable_by?(@user) -%> - <%= link_to '', {:controller => 'timelog', :action => 'edit', :id => entry}, + <%= link_to l(:button_edit), {:controller => 'timelog', :action => 'edit', :id => entry}, :title => l(:button_edit), :class => 'icon-only icon-edit' %> - <%= link_to '', {:controller => 'timelog', :action => 'destroy', :id => entry}, + <%= link_to l(:button_delete), {:controller => 'timelog', :action => 'destroy', :id => entry}, :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete), :class => 'icon-only icon-del' %> diff --git a/app/views/news/show.html.erb b/app/views/news/show.html.erb index 0390964..2178e1c 100644 --- a/app/views/news/show.html.erb +++ b/app/views/news/show.html.erb @@ -36,7 +36,7 @@ <% @comments.each do |comment| %> <% next if comment.new_record? %>

- <%= link_to_if_authorized '', {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment}, + <%= link_to_if_authorized l(:button_delete), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment}, :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete), :class => 'icon-only icon-del' %> diff --git a/app/views/reports/issue_report.html.erb b/app/views/reports/issue_report.html.erb index 1cb3ccd..95c40ad 100644 --- a/app/views/reports/issue_report.html.erb +++ b/app/views/reports/issue_report.html.erb @@ -3,25 +3,37 @@

<%=l(:field_tracker)%>  - <%= link_to '', project_issues_report_details_path(@project, :detail => 'tracker'), :class => 'icon-only icon-zoom-in' %> + <%= link_to l(:label_details), + project_issues_report_details_path(@project, :detail => 'tracker'), + :class => 'icon-only icon-zoom-in', + :title => l(:label_details) %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_tracker, :field_name => "tracker_id", :rows => @trackers } %>

<%=l(:field_priority)%>  - <%= link_to '', project_issues_report_details_path(@project, :detail => 'priority'), :class => 'icon-only icon-zoom-in' %> + <%= link_to l(:label_details), + project_issues_report_details_path(@project, :detail => 'priority'), + :class => 'icon-only icon-zoom-in', + :title => l(:label_details) %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_priority, :field_name => "priority_id", :rows => @priorities } %>

<%=l(:field_assigned_to)%>  - <%= link_to '', project_issues_report_details_path(@project, :detail => 'assigned_to'), :class => 'icon-only icon-zoom-in' %> + <%= link_to l(:label_details), + project_issues_report_details_path(@project, :detail => 'assigned_to'), + :class => 'icon-only icon-zoom-in', + :title => l(:label_details) %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_assigned_to, :field_name => "assigned_to_id", :rows => @assignees } %>

<%=l(:field_author)%>  - <%= link_to '', project_issues_report_details_path(@project, :detail => 'author'), :class => 'icon-only icon-zoom-in' %> + <%= link_to l(:label_details), + project_issues_report_details_path(@project, :detail => 'author'), + :class => 'icon-only icon-zoom-in', + :title => l(:label_details) %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_author, :field_name => "author_id", :rows => @authors } %>
@@ -31,21 +43,30 @@

<%=l(:field_version)%>  - <%= link_to '', project_issues_report_details_path(@project, :detail => 'version'), :class => 'icon-only icon-zoom-in' %> + <%= link_to l(:label_details), + project_issues_report_details_path(@project, :detail => 'version'), + :class => 'icon-only icon-zoom-in', + :title => l(:label_details) %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_version, :field_name => "fixed_version_id", :rows => @versions } %>
<% if @project.children.any? %>

<%=l(:field_subproject)%>  - <%= link_to '', project_issues_report_details_path(@project, :detail => 'subproject'), :class => 'icon-only icon-zoom-in' %> + <%= link_to l(:label_details), + project_issues_report_details_path(@project, :detail => 'subproject'), + :class => 'icon-only icon-zoom-in', + :title => l(:label_details) %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_subproject, :field_name => "project_id", :rows => @subprojects } %>
<% end %>

<%=l(:field_category)%>  - <%= link_to '', project_issues_report_details_path(@project, :detail => 'category'), :class => 'icon-only icon-zoom-in' %> + <%= link_to l(:label_details), + project_issues_report_details_path(@project, :detail => 'category'), + :class => 'icon-only icon-zoom-in', + :title => l(:label_details) %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_category, :field_name => "category_id", :rows => @categories } %>
diff --git a/app/views/repositories/_related_issues.html.erb b/app/views/repositories/_related_issues.html.erb index ea45391..a90fbc3 100644 --- a/app/views/repositories/_related_issues.html.erb +++ b/app/views/repositories/_related_issues.html.erb @@ -11,7 +11,7 @@
    <% @changeset.issues.visible.each do |issue| %>
  • "><%= link_to_issue issue %> - <%= link_to('', + <%= link_to(l(:label_relation_delete), {:controller => 'repositories', :action => 'remove_related_issue', :id => @project, :repository_id => @repository.identifier_param, :rev => @changeset.identifier, :issue_id => issue}, diff --git a/app/views/settings/_repositories.html.erb b/app/views/settings/_repositories.html.erb index bb7a237..3dec98c 100644 --- a/app/views/settings/_repositories.html.erb +++ b/app/views/settings/_repositories.html.erb @@ -119,8 +119,9 @@ ) %> - <%= link_to('', '#', - :class => 'delete-commit-keywords icon-only icon-del') %> + <%= link_to(l(:button_delete), '#', + :class => 'delete-commit-keywords icon-only icon-del', + :title => l(:button_delete)) %> <% end %> @@ -130,8 +131,9 @@ - <%= link_to('', '#', - :class => 'add-commit-keywords icon-only icon-add') %> + <%= link_to(l(:button_add), '#', + :class => 'add-commit-keywords icon-only icon-add', + :title => l(:button_add)) %> diff --git a/app/views/timelog/_list.html.erb b/app/views/timelog/_list.html.erb index df497d4..89e1bc8 100644 --- a/app/views/timelog/_list.html.erb +++ b/app/views/timelog/_list.html.erb @@ -21,10 +21,10 @@ <%= raw @query.inline_columns.map {|column| "#{column_content(column, entry)}"}.join %> <% if entry.editable_by?(User.current) -%> - <%= link_to '', edit_time_entry_path(entry), + <%= link_to l(:button_edit), edit_time_entry_path(entry), :title => l(:button_edit), - :class => 'icon icon-edit' %> - <%= link_to '', time_entry_path(entry), + :class => 'icon-only icon-edit' %> + <%= link_to l(:button_delete), time_entry_path(entry), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete), diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index f7963dd..fd45ad6 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1101,6 +1101,17 @@ a.close-icon:hover {background-image:url('../images/close_hl.png');} background-repeat: no-repeat; padding-left: 16px; } +a.icon-only { + display: inline-block; + width: 0; + overflow: hidden; + padding-top: 0; + padding-bottom: 0; + font-size: 8px; +} +a.icon-only::after { + content: " "; +} .icon-add { background-image: url(../images/add.png); } .icon-edit { background-image: url(../images/edit.png); } diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 4ae9d4b..77474d6 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -1243,14 +1243,14 @@ RAW # heading that contains inline code assert_match Regexp.new('
    ' + - '
    ' + + 'Edit this section
' + '' + '

Subtitle with inline code

'), result # last heading assert_match Regexp.new('
' + - '
' + + 'Edit this section
' + '' + '

Subtitle after pre tag

'), result -- 2.6.3