<script type="text/javascript">
- function openMapKey() {
+$(document).ready(function () {
+ var updateMapKey = function () {
+ $("#sidebar_content").load("<%= url_for :action => :key %>", {
+ layer: map.baseLayer.keyid,
+ zoom: map.getZoom()
+ });
+ }
+
+ var closeMapKey = function () {
+ map.events.unregister("zoomend", map, updateMapKey);
+ map.events.unregister("changelayer", map, updateMapKey);
+ }
+
+ $("#open_map_key").click(function () {
updateMapKey();
openSidebar({
map.events.register("zoomend", map, updateMapKey);
map.events.register("changelayer", map, updateMapKey);
- }
-
- function closeMapKey() {
- map.events.unregister("zoomend", map, updateMapKey);
- map.events.unregister("changelayer", map, updateMapKey);
- }
-
- function updateMapKey() {
- var layer = map.baseLayer.keyid;
- var zoom = map.getZoom();
-
- <%= remote_function :update => "sidebar_content",
- :url => { :action => "key" },
- :with => "'layer=' + layer + '&zoom=' + zoom",
- :method => :get
- %>
- }
+ });
+});
</script>
<% content_for :left_menu do %>
- <%= link_to_function t('site.key.map_key'), "openMapKey()", :title => t('site.key.map_key_tooltip') %>
+ <li><%= link_to t("site.key.map_key"), "#", :id => "open_map_key", :title => t("site.key.map_key_tooltip") %></li>
<% end %>