From: Tom Hughes Date: Tue, 19 Jul 2011 21:22:04 +0000 (+0100) Subject: Add edit links to data browser pages X-Git-Tag: live~6234 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/f242c9de94fb197c79291c5c885bd9acfb74ab28?ds=sidebyside Add edit links to data browser pages --- diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 65029e4ef..21ef26bac 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -48,6 +48,18 @@ class SiteController < ApplicationController @lat = params['mlat'].to_f @zoom = params['zoom'].to_i + elsif params['bbox'] + bbox = params['bbox'].split(",") + + @lon = ( bbox[0].to_f + bbox[2].to_f ) / 2.0 + @lat = ( bbox[1].to_f + bbox[3].to_f ) / 2.0 + @zoom = 16 + + elsif params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat'] + @lon = ( params['maxlon'].to_f + params['minlon'].to_f ) / 2.0 + @lat = ( params['maxlat'].to_f + params['minlat'].to_f ) / 2.0 + @zoom = 16 + elsif params['gpx'] @lon = Trace.find(params['gpx']).longitude @lat = Trace.find(params['gpx']).latitude diff --git a/app/views/browse/_map.html.erb b/app/views/browse/_map.html.erb index 13a352820..e6409cc82 100644 --- a/app/views/browse/_map.html.erb +++ b/app/views/browse/_map.html.erb @@ -1,24 +1,67 @@ <%= javascript_include_tag '/openlayers/OpenLayers.js' %> <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %> <%= javascript_include_tag 'map.js' %> + + +
<% if map.instance_of? Changeset or (map.instance_of? Node and map.version > 1) or map.visible %>
<%= t 'browse.map.loading' %> - + <%= link_to(t("browse.map.larger.area"), { :controller => :site, :action => :index, :box => "yes" }, { :id => "area_larger_map", :class => "geolink bbox" }) %> +
+ <%= link_to(t("browse.map.edit.area"), { :controller => :site, :action => :edit }, { :id => "area_edit", :class => "geolink bbox" }) %> <% unless map.instance_of? Changeset %>
- + <%= link_to("", { :controller => :site, :action => :index }, { :id => "object_larger_map", :class => "geolink object" }) %> +
+ <%= link_to("", { :controller => :site, :action => :edit }, { :id => "object_edit", :class => "geolink object" }) %> <% end %> <% else %> <%= t 'browse.map.deleted' %> <% end %>
+ + + + + <% if map.instance_of? Changeset or (map.instance_of? Node and map.version > 1) or map.visible %>
diff --git a/app/views/site/index.html.erb b/app/views/site/index.html.erb index e417c2695..c4d990618 100644 --- a/app/views/site/index.html.erb +++ b/app/views/site/index.html.erb @@ -66,7 +66,13 @@ if params['node'] or params['way'] or params['relation'] end # Decide on a lat lon to initialise the map with. Various ways of doing this -if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat'] +if params['bbox'] + bbox = true + minlon, minlat, maxlon, maxlat = h(params['bbox']).split(",") + layers = h(params['layers']) + box = true if params['box']=="yes" + object_zoom = false +elsif params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat'] bbox = true minlon = h(params['minlon']) minlat = h(params['minlat']) diff --git a/config/locales/en.yml b/config/locales/en.yml index fbf650660..a907b9d2a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -157,6 +157,11 @@ en: node: "View node on larger map" way: "View way on larger map" relation: "View relation on larger map" + edit: + area: "Edit area" + node: "Edit node" + way: "Edit way" + relation: "Edit relation" node_details: coordinates: "Coordinates:" part_of: "Part of:" diff --git a/public/javascripts/menu.js b/public/javascripts/menu.js index 5b4c3050e..261517756 100644 --- a/public/javascripts/menu.js +++ b/public/javascripts/menu.js @@ -1,13 +1,21 @@ /* * Open a menu. */ -function openMenu(anchor, menu) { - menu.style.display = "block"; +function openMenu(anchor, menu, align) { + var offset; + + if (align == "left") { + offset = 0; + } else if (align == "right") { + offset = anchor.getWidth() - menu.getWidth(); + } menu.clonePosition(anchor, { setLeft: true, setTop: true, setWidth: false, setHeight: false, - offsetLeft: 0, offsetTop: anchor.getHeight() + offsetLeft: offset, offsetTop: anchor.getHeight() }); + + menu.style.display = "block"; } /* @@ -21,14 +29,14 @@ function closeMenu(menu) { /* * Callback called when the mouse enters a menu anchor. */ -function enterMenuAnchor(event, anchor, menu, delay) { +function enterMenuAnchor(event, anchor, menu, delay, align) { if (!anchor.hasClassName("disabled")) { clearTimeout(menu.timer); if (delay > 0) { - menu.timer = setTimeout(function () { openMenu(anchor, menu) }, delay); + menu.timer = setTimeout(function () { openMenu(anchor, menu, align) }, delay); } else { - openMenu(event, menu); + openMenu(event, menu, align); } } } @@ -62,12 +70,12 @@ function leaveMenu(event, anchor, menu) { /* * Setup a menu, triggered by hovering over an anchor for a given time. */ -function createMenu(anchorid, menuid, delay) { +function createMenu(anchorid, menuid, delay, align) { var anchor = $(anchorid); var menu = $(menuid); anchor.observe("mouseup", function (event) { closeMenu(menu) }); - anchor.observe("mouseover", function (event) { enterMenuAnchor(anchor, anchor, menu, delay) }); + anchor.observe("mouseover", function (event) { enterMenuAnchor(anchor, anchor, menu, delay, align) }); anchor.observe("mouseout", function (event) { leaveMenuAnchor(event, anchor, menu) }); menu.observe("mouseup", function (event) { closeMenu(menu) }); menu.observe("mouseout", function (event) { leaveMenu(event, anchor, menu) }); diff --git a/public/stylesheets/common.css b/public/stylesheets/common.css index c773a3218..fd4dfac6a 100644 --- a/public/stylesheets/common.css +++ b/public/stylesheets/common.css @@ -358,7 +358,7 @@ hr { /* Rules for edit menu */ -#editmenu { +.menu { display: none; z-index: 10000; position: absolute; @@ -366,15 +366,16 @@ hr { border: 1px solid black; } -#editmenu ul { +.menu ul { margin-top: 10px; margin-bottom: 10px; padding-left: 10px; padding-right: 10px; } -#editmenu li { +.menu li { list-style-type: none; + white-space: nowrap; } /* Rules for attribution text under the main map shown on printouts */ @@ -660,6 +661,10 @@ table.browse_details th { border: solid 1px black; } +#browse_map .geolink { + display: none; +} + /* Rules for the trace list shown by the traces tab etc */ #trace_list {