title = $(this).text();
function updateMapKey() {
- $("#sidebar_content").load(url, {
- layer: map.baseLayer.keyid,
- zoom: map.getZoom()
+ var mapLayer = map.baseLayer.keyid,
+ mapZoom = map.getZoom();
+
+ $(".mapkey-table-entry").each(function () {
+ var entryLayer = $(this).attr("data-layer"),
+ entryZoomMin = parseInt($(this).attr("data-zoom-min")),
+ entryZoomMax = parseInt($(this).attr("data-zoom-max"));
+
+ if (mapLayer == entryLayer &&
+ mapZoom >= entryZoomMin && mapZoom <= entryZoomMax) {
+ $(this).show();
+ } else {
+ $(this).hide();
+ }
});
}
- updateMapKey();
+ $("#sidebar_content").load(url, updateMapKey);
+
openSidebar({ title: title });
$("#sidebar").one("closed", function () {
<div id="mapkey">
<table class="mapkey-table">
<% YAML.load_file("#{Rails.root}/config/key.yml").each do |name,data| %>
- <% if params[:layer] == name %>
- <% data.each do |entry| %>
- <% if params[:zoom].to_i >= entry['min_zoom'] && params[:zoom].to_i <= entry['max_zoom'] %>
- <tr>
- <td class="mapkey-table-key">
- <%= image_tag "key/#{name}/#{entry['image']}" %>
- </td>
- <td class="mapkey-table-value">
- <%= [*t("site.key.table.entry.#{entry['name']}")].to_sentence %>
- </td>
- </tr>
- <% end %>
- <% end %>
+ <% data.each do |entry| %>
+ <tr class="mapkey-table-entry" data-layer="<%= name %>" data-zoom-min="<%= entry['min_zoom'] %>" data-zoom-max="<%= entry['max_zoom'] %>">
+ <td class="mapkey-table-key">
+ <%= image_tag "key/#{name}/#{entry['image']}" %>
+ </td>
+ <td class="mapkey-table-value">
+ <%= [*t("site.key.table.entry.#{entry['name']}")].to_sentence %>
+ </td>
+ </tr>
<% end %>
<% end %>
</table>
match '/login' => 'user#login', :via => [:get, :post]
match '/logout' => 'user#logout', :via => [:get, :post]
match '/offline' => 'site#offline', :via => :get
- match '/key' => 'site#key', :via => :post
+ match '/key' => 'site#key', :via => :get
match '/user/new' => 'user#new', :via => :get
match '/user/terms' => 'user#terms', :via => [:get, :post]
match '/user/save' => 'user#save', :via => :post
{ :controller => "site", :action => "offline" }
)
assert_routing(
- { :path => "/key", :method => :post },
+ { :path => "/key", :method => :get },
{ :controller => "site", :action => "key" }
)
assert_routing(