]> git.openstreetmap.org Git - rails.git/commitdiff
Make it easier to test RTL layout
authorJohn Firebaugh <john.firebaugh@gmail.com>
Fri, 26 Oct 2012 18:05:26 +0000 (11:05 -0700)
committerTom Hughes <tom@compton.nu>
Fri, 26 Oct 2012 20:36:59 +0000 (21:36 +0100)
Instead of fiddling with settings so the site appears in Arabic
or Hebrew, you can add a dir=rtl param to the URL.

app/helpers/application_helper.rb
app/views/layouts/_head.html.erb
app/views/layouts/site.html.erb
app/views/layouts/slim.html.erb

index e0c299ca54ce0e4b2a6c329b5f7be0b6d7eb75ac..000677646f58c0ab587b2a6c1b9647fc03fb80c8 100644 (file)
@@ -87,4 +87,12 @@ module ApplicationHelper
       end
     end
   end
+
+  def dir
+    if dir = params[:dir]
+      dir == "rtl" ? "rtl" : "ltr"
+    else
+      I18n.t("html.dir")
+    end
+  end
 end
index c85594189a96257d4a5f4e48aa84073c9fd58270..88ad3eb392735684341bd5418656f1f7c76a54ce 100644 (file)
@@ -2,10 +2,10 @@
   <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"/>
   <%= javascript_include_tag "application" %>
   <!--[if lt IE 7]><%= javascript_include_tag "pngfix" %><![endif]--> <!-- thanks, microsoft! -->
-  <%= stylesheet_link_tag "small-#{t 'html.dir'}", :media => "only screen and (max-width:641px)" %>
-  <%= stylesheet_link_tag "large-#{t 'html.dir'}", :media => "screen and (min-width: 642px)" %>
-  <%= stylesheet_link_tag "print-#{t 'html.dir'}", :media => "print" %>
-  <!--[if IE]><%= stylesheet_link_tag "large-#{t 'html.dir'}", :media => "screen" %><![endif]--> <!-- IE is totally broken with CSS media queries -->
+  <%= stylesheet_link_tag "small-#{dir}", :media => "only screen and (max-width:641px)" %>
+  <%= stylesheet_link_tag "large-#{dir}", :media => "screen and (min-width: 642px)" %>
+  <%= stylesheet_link_tag "print-#{dir}", :media => "print" %>
+  <!--[if IE]><%= stylesheet_link_tag "large-#{dir}", :media => "screen" %><![endif]--> <!-- IE is totally broken with CSS media queries -->
   <%= favicon_link_tag "favicon.ico" %>
   <%= favicon_link_tag "osm_logo.png", :rel => "apple-touch-icon", :type => "image/png" %>
   <%= tag("link", { :rel => "publisher", :href => "https://plus.google.com/111953119785824514010" }) %>
index cee35efb6b045da73aa44197469a20948ef3c456..f1ae440e7cad05dfc086c0f5fde8833a07569555 100644 (file)
@@ -1,5 +1,5 @@
 <!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= I18n.locale %>" lang="<%= I18n.locale %>" dir="<%= t'html.dir' %>">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= I18n.locale %>" lang="<%= I18n.locale %>" dir="<%= dir %>">
   <%= render :partial => "layouts/head" %>
   <body class="<%= params[:controller] %> <%= params[:controller] %>-<%= params[:action] %>">
     <div id="small-title">
index 862f55d874f0424af47049f1fe202ac47c7b9cfa..ba02104f4056fc113e53850942f842df9f6068aa 100644 (file)
@@ -1,5 +1,5 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= I18n.locale %>" lang="<%= I18n.locale %>" dir="<%= t'html.dir' %>">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= I18n.locale %>" lang="<%= I18n.locale %>" dir="<%= dir %>">
   <%= render :partial => "layouts/head" %>
   <body class="slim">
     <div id="slim_container">