From e8ac6bd5d918bb71647c05da4b2b294a1423948b Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 27 Sep 2013 18:05:47 -0700 Subject: [PATCH 1/1] Convert history page to sidebar layout --- app/assets/javascripts/changeset.js | 22 +---------- app/assets/javascripts/index.js | 2 + app/assets/stylesheets/common.css.scss | 52 ++----------------------- app/controllers/changeset_controller.rb | 21 ++-------- app/views/changeset/_map.html.erb | 2 - app/views/changeset/list.html.erb | 44 +++++++-------------- config/locales/en.yml | 14 ------- 7 files changed, 26 insertions(+), 131 deletions(-) delete mode 100644 app/views/changeset/_map.html.erb diff --git a/app/assets/javascripts/changeset.js b/app/assets/javascripts/changeset.js index d9c09bab4..0aecced85 100644 --- a/app/assets/javascripts/changeset.js +++ b/app/assets/javascripts/changeset.js @@ -1,14 +1,6 @@ -$(document).ready(function () { +function initializeChangesets(map) { var changesets = [], rects = {}; - var map = L.map("changeset_list_map", { - attributionControl: false, - zoomControl: false - }).addLayer(new L.OSM.Mapnik()); - - L.OSM.zoom() - .addTo(map); - var group = L.featureGroup().addTo(map); $("[data-changeset]").each(function () { @@ -60,14 +52,4 @@ $(document).ready(function () { unHighlightChangeset($(this).data("changeset").id); } }); - - $(window).scroll(function() { - if ($(window).scrollTop() > $('.content-heading').outerHeight() + $('#top-bar').outerHeight() ) { - $('#changeset_list_map_wrapper').addClass('scrolled'); - } else { - $('#changeset_list_map_wrapper').removeClass('scrolled'); - } - }); - - map.fitBounds(OSM.mapParams().bounds || group.getBounds()); -}); +} diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index d09213c5d..dff433a8a 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -211,6 +211,8 @@ $(document).ready(function () { initializeExport(map); initializeBrowse(map, params); initializeNotes(map, params); + + if ('undefined' !== typeof initializeChangesets) initializeChangesets(map); }); function updateLocation() { diff --git a/app/assets/stylesheets/common.css.scss b/app/assets/stylesheets/common.css.scss index f9065266b..fe8e4f238 100644 --- a/app/assets/stylesheets/common.css.scss +++ b/app/assets/stylesheets/common.css.scss @@ -594,9 +594,7 @@ nav.secondary { /* Rules for the home page */ -.site-export #map, -.site-index #map, -.site-edit #map { +#map { height: 100%; overflow: hidden; } @@ -927,7 +925,8 @@ ul.results-list li { border-bottom: 1px solid #ccc; } .site-index, .site-export, -.site-edit { +.site-edit, +.changeset-list { #content { position: absolute; top: $headerHeight; @@ -1081,51 +1080,6 @@ ul.results-list li { border-bottom: 1px solid #ccc; } /* Rules for the changeset list shown by the history tab etc */ -#changeset_list { - width: 100%; - ul { - padding: $lineheight/2 0; - margin-bottom: 0px; - border-top: 1px solid #ccc; - &:last-child { - border-bottom: 1px solid #ccc; - } - } - .selected { - background: #FFFFC0; - } - .date, - .user { - border-left: 1px solid #ccc; - padding-left: $lineheight/4; - margin-right: $lineheight/4; - } -} - -#changeset_list_map_wrapper { - position: absolute; - width: 50%; - height: 490px; - top: 0; - right: 0; -} - -#changeset_list_map_wrapper.scrolled { - position: fixed; -} - -#changeset_list_map { - position: absolute; - bottom: $lineheight; - top: $lineheight; - right: $lineheight; - left: $lineheight; - border: 1px solid #ccc; -} - -#changeset_list_map_wrapper.scrolled #changeset_list_map { - margin-left: 93px; -} /* Rules for the data browser */ diff --git a/app/controllers/changeset_controller.rb b/app/controllers/changeset_controller.rb index 36b3b5124..b07ca36ca 100644 --- a/app/controllers/changeset_controller.rb +++ b/app/controllers/changeset_controller.rb @@ -296,7 +296,6 @@ class ChangesetController < ApplicationController if bbox changesets = conditions_bbox(changesets, bbox) - bbox_link = render_to_string :partial => "bbox", :object => bbox end if user @@ -305,28 +304,16 @@ class ChangesetController < ApplicationController if params[:friends] and @user @title = t 'changeset.list.title_friend' - @heading = t 'changeset.list.heading_friend' - @description = t 'changeset.list.description_friend' + @heading = t 'changeset.list.title_friend' elsif params[:nearby] and @user @title = t 'changeset.list.title_nearby' - @heading = t 'changeset.list.heading_nearby' - @description = t 'changeset.list.description_nearby' - elsif user and bbox - @title = t 'changeset.list.title_user_bbox', :user => user.display_name, :bbox => bbox.to_s - @heading = t 'changeset.list.heading_user_bbox', :user => user.display_name, :bbox => bbox.to_s - @description = t 'changeset.list.description_user_bbox', :user => user_link, :bbox => bbox_link + @heading = t 'changeset.list.title_nearby' elsif user @title = t 'changeset.list.title_user', :user => user.display_name - @heading = t 'changeset.list.heading_user', :user => user.display_name - @description = t 'changeset.list.description_user', :user => user_link - elsif bbox - @title = t 'changeset.list.title_bbox', :bbox => bbox.to_s - @heading = t 'changeset.list.heading_bbox', :bbox => bbox.to_s - @description = t 'changeset.list.description_bbox', :bbox => bbox_link + @heading = t('changeset.list.title_user', :user => user_link).html_safe else @title = t 'changeset.list.title' - @heading = t 'changeset.list.heading' - @description = t 'changeset.list.description' + @heading = t 'changeset.list.title' end @page = (params[:page] || 1).to_i diff --git a/app/views/changeset/_map.html.erb b/app/views/changeset/_map.html.erb deleted file mode 100644 index 9730059ee..000000000 --- a/app/views/changeset/_map.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -
-
diff --git a/app/views/changeset/list.html.erb b/app/views/changeset/list.html.erb index ee8610574..262cae15f 100644 --- a/app/views/changeset/list.html.erb +++ b/app/views/changeset/list.html.erb @@ -1,37 +1,23 @@ <% content_for :head do -%> + <%= javascript_include_tag "index" %> <%= javascript_include_tag "changeset" %> -<% end -%> - -<% content_for :heading do %> - -

<%= @heading %>

- -<% end %> + <% unless params[:friends] or params[:nearby] -%> + <%= auto_discovery_link_tag :atom, params.merge({ :page => nil, :action => :feed }) %> + <% end -%> +<% end -%> -<%= render :partial => 'changeset_paging_nav' %> +<% content_for :sidebar do %> +

<%= @heading %>

-<% if @edits.size > 0 %> -
- <%= render :partial => 'map' %> -
-
+ <% if @edits.size > 0 %> <%= render :partial => 'changesets', :locals => { :showusername => !params.has_key?(:display_name) } %> -
- <%= render :partial => 'changeset_paging_nav' %> -<% elsif @user and @user.display_name == params[:display_name] %> -

<%= t('changeset.list.empty_user_html') %>

-<% else %> -

<%= t('changeset.list.empty_anon_html') %>

+ <%= render :partial => 'changeset_paging_nav' %> + <% elsif @user and @user.display_name == params[:display_name] %> +

<%= t('changeset.list.empty_user_html') %>

+ <% else %> +

<%= t('changeset.list.empty_anon_html') %>

+ <% end %> <% end %> -<% unless params[:friends] or params[:nearby] -%> - <% content_for :head do -%> - <%= auto_discovery_link_tag :atom, params.merge({ :page => nil, :action => :feed }) %> - <% end -%> -<% end -%> \ No newline at end of file +<%= render :template => 'layouts/map' %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 3afa70365..3268e7733 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -321,22 +321,8 @@ en: list: title: "Changesets" title_user: "Changesets by %{user}" - title_bbox: "Changesets within %{bbox}" - title_user_bbox: "Changesets by %{user} within %{bbox}" title_friend: "Changesets by your friends" title_nearby: "Changesets by nearby users" - heading: "Changesets" - heading_user: "Changesets" - heading_bbox: "Changesets" - heading_user_bbox: "Changesets" - heading_friend: "Changesets" - heading_nearby: "Changesets" - description: "Browse recent contributions to the map" - description_user: "Changesets by %{user}" - description_bbox: "Changesets within %{bbox}" - description_user_bbox: "Changesets by %{user} within %{bbox}" - description_friend: "Changesets by your friends" - description_nearby: "Changesets by nearby users" empty_user_html: "It looks you haven't made any edits yet. To get started, check out the Beginners Guide." empty_anon_html: "No edits made yet." timeout: -- 2.43.2