Don't rely on body classes so much
authorJohn Firebaugh <john.firebaugh@gmail.com>
Fri, 4 Oct 2013 18:36:53 +0000 (11:36 -0700)
committerJohn Firebaugh <john.firebaugh@gmail.com>
Sun, 13 Oct 2013 21:46:08 +0000 (14:46 -0700)
Doesn't work well with pushState-based navigation.

app/assets/stylesheets/common.css.scss
app/controllers/site_controller.rb
app/helpers/application_helper.rb
app/views/layouts/map.html.erb

index 0c8ea4e..43d59cf 100644 (file)
@@ -947,7 +947,7 @@ a.donate {
 
 /* Rules for the data browser */
 
-body.browse #sidebar_content {
+#sidebar_content {
   .browse-section {
     padding: 20px;
     border-bottom: 1px solid #CCC;
index eb8749f..9979739 100644 (file)
@@ -45,8 +45,6 @@ class SiteController < ApplicationController
       return
     end
 
-    @extra_body_class = "site-edit-#{editor}"
-
     if params[:node]
       bbox = Node.find(params[:node]).bbox.to_unscaled
       @lat = bbox.centre_lat
index 23e3b34..5d61e8c 100644 (file)
@@ -94,24 +94,14 @@ module ApplicationHelper
   end
 
   def body_class
-    [
-        params[:controller],
-        "#{params[:controller]}-#{params[:action]}",
-        "#{current_layout}-layout",
-        @extra_body_class
-    ].compact.join(" ")
+    if content_for? :body_class
+      content_for :body_class
+    else
+      "#{params[:controller]} #{params[:controller]}-#{params[:action]}"
+    end
   end
 
   def current_page_class(path)
     :current if current_page?(path)
   end
-
-  def current_layout
-    layout = controller.send(:_layout)
-    if layout.instance_of? String
-      layout
-    else
-      File.basename(layout.identifier).split('.').first
-    end
-  end
 end
index d5666ed..6e6caf9 100644 (file)
@@ -2,6 +2,8 @@
   <%= javascript_include_tag "index" %>
 <% end %>
 
+<% content_for(:body_class) { "map-layout" } %>
+
 <% content_for :content do %>
   <div id="sidebar">
     <%= form_tag url_for(:controller => :geocoder, :action => :search), :id => "search_form" do %>