<div>
<ul id="tabnav">
<%
- viewclass = ''
- editclass = 'disabled'
- historyclass = ''
- exportclass = ''
+ viewclass = 'geolink llz layers'
+ editclass = 'geolink llz object minzoom13 disabled'
+ historyclass = 'geolink bbox minzoom11'
+ exportclass = 'geolink llz layers'
traceclass = ''
- viewclass = 'active' if params['controller'] == 'site' and params['action'] == 'index'
- editclass = 'active' if params['controller'] == 'site' and params['action'] == 'edit'
- historyclass = 'active' if params['controller'] == 'changeset' and params['action'] == 'list'
- exportclass = 'active' if params['controller'] == 'site' and params['action'] == 'export'
- traceclass = 'active' if params['controller'] == 'trace'
- diaryclass = 'active' if params['controller'] == 'diary_entry'
+ viewclass += ' active' if params['controller'] == 'site' and params['action'] == 'index'
+ editclass += ' active' if params['controller'] == 'site' and params['action'] == 'edit'
+ historyclass += ' active' if params['controller'] == 'changeset' and params['action'] == 'list'
+ exportclass += ' active' if params['controller'] == 'site' and params['action'] == 'export'
+ traceclass += ' active' if params['controller'] == 'trace'
+ diaryclass += ' active' if params['controller'] == 'diary_entry'
%>
<li><%= link_to t('layouts.view'), {:controller => 'site', :action => 'index'}, {:id => 'viewanchor', :title => t('layouts.view_tooltip'), :class => viewclass} %></li>
<li><%= link_to t('layouts.edit') + ' ▾', {:controller => 'site', :action => 'edit'}, {:id => 'editanchor', :title => t('javascripts.site.edit_tooltip'), :class => editclass} %></li>
<div id="editmenu">
<ul>
<% Editors::ALL_EDITORS.each do |editor| %>
- <li><%= link_to t('layouts.edit_with', :editor => t("editor.#{editor}.description")), {:controller => 'site', :action => 'edit', :editor => editor}, {:id => editor + 'anchor'} %></li>
+ <li><%= link_to t('layouts.edit_with', :editor => t("editor.#{editor}.description")), {:controller => 'site', :action => 'edit', :editor => editor}, {:id => editor + 'anchor', :class => "geolink llz object"} %></li>
<% end %>
</ul>
</div>
lat = Math.round(lat * decimals) / decimals;
lon = Math.round(lon * decimals) / decimals;
- node = $("permalinkanchor");
- if (node) {
- var args = getArgs(node.href);
- args["lat"] = lat;
- args["lon"] = lon;
- args["zoom"] = zoom;
- if (layers) {
- args["layers"] = layers;
- }
- if (objtype && objid) {
- args[objtype] = objid;
- }
- node.href = setArgs(node.href, args);
- }
-
- node = $("viewanchor");
- if (node) {
- var args = getArgs(node.href);
- args["lat"] = lat;
- args["lon"] = lon;
- args["zoom"] = zoom;
- if (layers) {
- args["layers"] = layers;
- }
- node.href = setArgs(node.href, args);
+ if (minlon) {
+ minlon = Math.round(minlon * decimals) / decimals;
+ minlat = Math.round(minlat * decimals) / decimals;
+ maxlon = Math.round(maxlon * decimals) / decimals;
+ maxlat = Math.round(maxlat * decimals) / decimals;
}
- node = $("exportanchor");
- if (node) {
- var args = getArgs(node.href);
- args["lat"] = lat;
- args["lon"] = lon;
- args["zoom"] = zoom;
- if (layers) {
- args["layers"] = layers;
- }
- node.href = setArgs(node.href, args);
- }
+ $$(".geolink").each(function (link) {
+ var args = getArgs(link.href);
- node = $("editanchor");
- if (node) {
- if (zoom >= 13) {
- var args = new Object();
+ if (link.hasClassName("llz")) {
args.lat = lat;
args.lon = lon;
args.zoom = zoom;
- if (objtype && objid) {
- args[objtype] = objid;
- }
- node.href = setArgs("/edit", args);
- node.title = i18n("javascripts.site.edit_tooltip");
- node.removeClassName("disabled");
- } else {
- node.href = 'javascript:alert(i18n("javascripts.site.edit_zoom_alert"));';
- node.title = i18n("javascripts.site.edit_disabled_tooltip");
- node.addClassName("disabled");
+ } else if (minlon && link.hasClassName("bbox")) {
+ args.bbox = minlon + "," + minlat + "," + maxlon + "," + maxlat;
}
- }
- node = $("potlatchanchor");
- if (node) {
- var args = new Object();
- args.editor = "potlatch";
- args.lat = lat;
- args.lon = lon;
- args.zoom = zoom;
- if (objtype && objid) {
- args[objtype] = objid;
+ if (layers && link.hasClassName("layers")) {
+ args.layers = layers;
}
- node.href = setArgs("/edit", args);
- }
- node = $("potlatch2anchor");
- if (node) {
- var args = new Object();
- args.editor = "potlatch2";
- args.lat = lat;
- args.lon = lon;
- args.zoom = zoom;
- if (objtype && objid) {
+ if (objtype && link.hasClassName("object")) {
args[objtype] = objid;
}
- node.href = setArgs("/edit", args);
- }
- node = $("josmanchor");
- if (node) {
- var args = new Object();
- args.editor = "josm";
- args.lat = lat;
- args.lon = lon;
- args.zoom = zoom;
- if (objtype && objid) {
- args[objtype] = objid;
+ if (link.hasClassName("minzoom[0-9]+")) {
+ $w(link.className).each(function (classname) {
+ if (match = classname.match(/^minzoom([0-9]+)$/)) {
+ var minzoom = match[1];
+ var name = link.id.replace(/anchor$/, "");
+
+ if (zoom >= minzoom) {
+ link.onclick = null;
+ link.title = i18n("javascripts.site." + name + "_tooltip");
+ link.removeClassName("disabled");
+ } else {
+ link.onclick = function () { alert(i18n("javascripts.site." + name + "_zoom_alert")); return false; };
+ link.title = i18n("javascripts.site." + name + "_disabled_tooltip");
+ link.addClassName("disabled");
+ }
+ }
+ });
}
- node.href = setArgs("/edit", args);
- }
-
- node = $("historyanchor");
- if (node) {
- if (zoom >= 11) {
- var args = new Object();
- //set bbox param from 'extents' object
- if (typeof minlon == "number" &&
- typeof minlat == "number" &&
- typeof maxlon == "number" &&
- typeof maxlat == "number") {
-
- minlon = Math.round(minlon * decimals) / decimals;
- minlat = Math.round(minlat * decimals) / decimals;
- maxlon = Math.round(maxlon * decimals) / decimals;
- maxlat = Math.round(maxlat * decimals) / decimals;
- args.bbox = minlon + "," + minlat + "," + maxlon + "," + maxlat;
- }
- node.href = setArgs("/history", args);
- node.title = i18n("javascripts.site.history_tooltip");
- node.removeClassName("disabled");
- } else {
- node.href = 'javascript:alert(i18n("javascripts.site.history_zoom_alert"));';
- node.title = i18n("javascripts.site.history_disabled_tooltip");
- node.addClassName("disabled");
- }
- }
+ link.href = setArgs(link.href, args);
+ });
node = $("shortlinkanchor");
if (node) {