From 37a4fc6dd14dfedc0c44a8d7bf6453df0db9e1b5 Mon Sep 17 00:00:00 2001 From: Holger Jeromin Date: Mon, 14 Sep 2015 16:52:39 +0200 Subject: [PATCH 1/1] Add srcset to img tags inside picture elements Some browsers (in particular Safari on iOS) don't support picture yet but do support srcset on the img tag. --- .rubocop_todo.yml | 2 +- app/helpers/user_roles_helper.rb | 2 +- app/views/layouts/_flash.html.erb | 6 +++--- app/views/layouts/_header.html.erb | 2 +- test/helpers/user_roles_helper_test.rb | 16 ++++++++-------- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 03c2e3d6f..287fcd9f9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -75,7 +75,7 @@ Metrics/CyclomaticComplexity: # Offense count: 2535 # Configuration parameters: AllowURI, URISchemes. Metrics/LineLength: - Max: 878 + Max: 962 # Offense count: 628 # Configuration parameters: CountComments. diff --git a/app/helpers/user_roles_helper.rb b/app/helpers/user_roles_helper.rb index 2d3d49d77..b6961cd8b 100644 --- a/app/helpers/user_roles_helper.rb +++ b/app/helpers/user_roles_helper.rb @@ -26,7 +26,7 @@ module UserRolesHelper if image svg_icon = tag("source", :srcset => image_path("#{image}.svg"), :type => "image/svg+xml") - png_icon = image_tag("#{image}.png", :size => "20x20", :border => 0, :alt => alt, :title => title) + png_icon = image_tag("#{image}.png", :srcset => image_path("#{image}.svg"), :size => "20x20", :border => 0, :alt => alt, :title => title) icon = content_tag("picture", svg_icon + png_icon) icon = link_to(icon, url, :method => :post, :confirm => confirm) if url end diff --git a/app/views/layouts/_flash.html.erb b/app/views/layouts/_flash.html.erb index 2ba8ee95d..dc458fdcf 100644 --- a/app/views/layouts/_flash.html.erb +++ b/app/views/layouts/_flash.html.erb @@ -2,7 +2,7 @@
" type="image/svg+xml"> - <%= image_tag("notice.png", :class => "small_icon", :border => 0) %> + <%= image_tag("notice.png", :srcset => image_path("notice.svg"), :class => "small_icon", :border => 0) %>
<%= flash[:error] %>
@@ -12,7 +12,7 @@
" type="image/svg+xml"> - <%= image_tag("notice.png", :class => "small_icon", :border => 0) %> + <%= image_tag("notice.png", :srcset => image_path("notice.svg"), :class => "small_icon", :border => 0) %>
<%= flash[:warning] %>
@@ -22,7 +22,7 @@
" type="image/svg+xml"> - <%= image_tag("notice.png", :class => "small_icon", :border => 0) %> + <%= image_tag("notice.png", :srcset => image_path("notice.svg"), :class => "small_icon", :border => 0) %>
<%= flash[:notice] %>
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 7e4dd96d3..f5cfd205b 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -3,7 +3,7 @@ " type="image/svg+xml"> - <%= image_tag "osm_logo.png", :alt => t('layouts.logo.alt_text'), :class => 'logo' %> + <%= image_tag "osm_logo.png", :srcset => image_path("osm_logo.svg"), :alt => t('layouts.logo.alt_text'), :class => 'logo' %> <%= t 'layouts.project_name.h1' %> diff --git a/test/helpers/user_roles_helper_test.rb b/test/helpers/user_roles_helper_test.rb index ad9a6ed63..53169b75a 100644 --- a/test/helpers/user_roles_helper_test.rb +++ b/test/helpers/user_roles_helper_test.rb @@ -10,17 +10,17 @@ class UserRolesHelperTest < ActionView::TestCase assert_dom_equal "", icon icon = role_icon(users(:moderator_user), "moderator") - assert_dom_equal 'This user is a moderator', icon + assert_dom_equal 'This user is a moderator', icon end def test_role_icon_administrator @user = users(:administrator_user) icon = role_icon(users(:normal_user), "moderator") - assert_dom_equal 'Grant moderator access', icon + assert_dom_equal 'Grant moderator access', icon icon = role_icon(users(:moderator_user), "moderator") - assert_dom_equal 'Revoke moderator access', icon + assert_dom_equal 'Revoke moderator access', icon end def test_role_icons_normal @@ -30,22 +30,22 @@ class UserRolesHelperTest < ActionView::TestCase assert_dom_equal " ", icons icons = role_icons(users(:moderator_user)) - assert_dom_equal ' This user is a moderator', icons + assert_dom_equal ' This user is a moderator', icons icons = role_icons(users(:super_user)) - assert_dom_equal ' This user is an administrator This user is a moderator', icons + assert_dom_equal ' This user is an administrator This user is a moderator', icons end def test_role_icons_administrator @user = users(:administrator_user) icons = role_icons(users(:normal_user)) - assert_dom_equal ' Grant administrator access Grant moderator access', icons + assert_dom_equal ' Grant administrator access Grant moderator access', icons icons = role_icons(users(:moderator_user)) - assert_dom_equal ' Grant administrator access Revoke moderator access', icons + assert_dom_equal ' Grant administrator access Revoke moderator access', icons icons = role_icons(users(:super_user)) - assert_dom_equal ' Revoke administrator access Revoke moderator access', icons + assert_dom_equal ' Revoke administrator access Revoke moderator access', icons end end -- 2.39.5