From: John Firebaugh Date: Thu, 30 Aug 2012 16:55:39 +0000 (-0700) Subject: Move key JS to application bundle X-Git-Tag: live~5937 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/519c7dc2ddbaa946e5523a2968dae5c9ebd7339c?ds=sidebyside Move key JS to application bundle --- diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index df8dcda15..747c6d9af 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -9,6 +9,7 @@ //= require browse //= require export //= require map +//= require key //= require menu //= require sidebar diff --git a/app/assets/javascripts/key.js b/app/assets/javascripts/key.js new file mode 100644 index 000000000..d22738aaa --- /dev/null +++ b/app/assets/javascripts/key.js @@ -0,0 +1,26 @@ +$(document).ready(function () { + $("#open_map_key").click(function (e) { + var url = $(this).attr('href'), + title = $(this).text(); + + function updateMapKey() { + $("#sidebar_content").load(url, { + layer: map.baseLayer.keyid, + zoom: map.getZoom() + }); + } + + updateMapKey(); + openSidebar({ title: title }); + + $("#sidebar").one("closed", function () { + map.events.unregister("zoomend", map, updateMapKey); + map.events.unregister("changelayer", map, updateMapKey); + }); + + map.events.register("zoomend", map, updateMapKey); + map.events.register("changelayer", map, updateMapKey); + + e.preventDefault(); + }); +}); diff --git a/app/views/site/_key.html.erb b/app/views/site/_key.html.erb index 1129f69d2..19b08de4a 100644 --- a/app/views/site/_key.html.erb +++ b/app/views/site/_key.html.erb @@ -1,32 +1,3 @@ - - <% content_for :left_menu do %>
  • <%= link_to t("site.key.map_key"), {:action => :key}, :id => "open_map_key", :title => t("site.key.map_key_tooltip") %>
  • <% end %>