From 02de53eb45f31242bed45537aab2598d8f7dffae Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Wed, 5 Sep 2012 18:34:34 -0400 Subject: [PATCH] Refactor view and css code around homepage links This adds a new class to the body which we can use to do more styling in CSS rather than erb-embedded Ruby. The only visual change is that there's now a subtle transition for homepage links becoming active. --- app/assets/javascripts/application.js | 10 +- app/assets/stylesheets/common.css.scss | 15 ++- app/views/layouts/site.html.erb | 155 +++++++++++++++---------- 3 files changed, 107 insertions(+), 73 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index f337415c6..0f0b2fa10 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -58,11 +58,8 @@ function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,obj args[objtype] = objid; } - var classes = $(link).attr("class").split(" "); - - $(classes).each(function (index, classname) { - if (match = classname.match(/^minzoom([0-9]+)$/)) { - var minzoom = match[1]; + var minzoom = $(link).data("minzoom"); + if (minzoom) { var name = link.id.replace(/anchor$/, ""); $(link).off("click.minzoom"); @@ -75,8 +72,7 @@ function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,obj $(link).attr("title", I18n.t("javascripts.site." + name + "_disabled_tooltip")); $(link).addClass("disabled"); } - } - }); + } link.href = setArgs(link.href, args); }); diff --git a/app/assets/stylesheets/common.css.scss b/app/assets/stylesheets/common.css.scss index 43eea9ee0..5cef074e5 100644 --- a/app/assets/stylesheets/common.css.scss +++ b/app/assets/stylesheets/common.css.scss @@ -322,9 +322,18 @@ h2 { padding: 5px 10px; text-decoration: none; color: #333; -} - -#tabnav a:link.active, #tabnav a:visited.active { + -webkit-transition: color 200ms ease-in; + -moz-transition: color 200ms ease-in; + -o-transition: color 200ms ease-in; + transition: color 200ms ease-in; +} + +body.site-index #tabnav a#viewanchor, +body.site-edit #tabnav a#editanchor, +body.changeset-list #tabnav a#historyanchor, +body.site-export #tabnav a#exportanchor, +#tabnav a:link.active, +#tabnav a:visited.active { border-bottom: 1px solid #aaa; background: #9ed485; color: #000; diff --git a/app/views/layouts/site.html.erb b/app/views/layouts/site.html.erb index b51191189..7f55fb38b 100644 --- a/app/views/layouts/site.html.erb +++ b/app/views/layouts/site.html.erb @@ -1,17 +1,15 @@ <%= render :partial => "layouts/head" %> - +
<%= link_to(image_tag("osm_logo.png", :size => "16x16", :border => 0, :alt => t('layouts.logo.alt_text')), :controller => 'site', :action => 'index') %>

<%= t 'layouts.project_name.h1' %>

<%= render :partial => "layouts/flash", :locals => { :flash => flash } %> - <%= yield %>
-
<% if @user and @user.id %> @@ -26,63 +24,87 @@ <% end %>
- - -
- <%= yield :optionals %> - <% unless @user %> <% end %> - <% if STATUS == :database_offline or STATUS == :api_offline %> <% end %> - <% if false %> <% end %> -
  • <%= t'layouts.help' %> -
      -
    • <%= link_to(t('layouts.help_centre'), t('layouts.help_url'), :title => t('layouts.help_title')) %>
    • -
    • <%= link_to(t('layouts.documentation'), t('layouts.wiki_url'), :title => t('layouts.documentation_title')) %>
    • -
    • <%= link_to t('layouts.copyright'), {:controller => 'site', :action => 'copyright'} %>
    • -
    +
      +
    • <%= link_to(t('layouts.help_centre'), t('layouts.help_url'), :title => t('layouts.help_title')) %>
    • +
    • <%= link_to(t('layouts.documentation'), t('layouts.wiki_url'), :title => t('layouts.documentation_title')) %>
    • +
    • <%= link_to t('layouts.copyright'), {:controller => 'site', :action => 'copyright'} %>
    • +
  • <%= t'layouts.community' %> - +
  • -
  • <%= link_to t('layouts.gps_traces'), {:controller => 'trace', :action => 'list', :display_name => nil, :tag => nil, :page => nil}, {:id => 'traceanchor', :title => t('layouts.gps_traces_tooltip') } %>
  • +
  • <%= link_to t('layouts.gps_traces'), { + :controller => 'trace', + :action => 'list', + :display_name => nil, + :tag => nil, + :page => nil + }, { + :id => 'traceanchor', + :title => t('layouts.gps_traces_tooltip') + } %>
  • <%= yield :left_menu %>
-
- <%= link_to image_tag("sotm.png", :alt => t('layouts.sotm2012'), :title => t('layouts.sotm2012'), :border => "0"), "http://stateofthemap.org/register-now/" %> + <%= link_to image_tag("sotm.png", + :alt => t('layouts.sotm2012'), + :title => t('layouts.sotm2012'), + :border => "0"), "http://stateofthemap.org/register-now/" %>
-
- <% if defined?(PIWIK_LOCATION) and defined?(PIWIK_SITE) -%> <% end -%> -- 2.43.2