diff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erb
index 91a862f0a..c85594189 100644
--- a/app/views/layouts/_head.html.erb
+++ b/app/views/layouts/_head.html.erb
@@ -29,6 +29,8 @@
<% if session[:location] %>
OSM.location = <%= session[:location].to_json.html_safe %>;
<% end %>
+
+ OSM.preferred_editor = <%= preferred_editor.to_json.html_safe %>;
<%= t 'layouts.project_name.title' %><%= ' | '+ @title if @title %>
diff --git a/app/views/layouts/site.html.erb b/app/views/layouts/site.html.erb
index 064fbed0a..31f87eb85 100644
--- a/app/views/layouts/site.html.erb
+++ b/app/views/layouts/site.html.erb
@@ -32,7 +32,7 @@
<%= link_to h(t('layouts.edit')) + content_tag(:span, "▾", :class => "menuicon"), edit_path, {
:id => 'editanchor',
:title => t('javascripts.site.edit_tooltip'),
- :data => { :minzoom => 13 },
+ :data => { :minzoom => 13, :editor => preferred_editor },
:class => 'geolink llz object disabled'
} %>
<%= link_to t('layouts.history'), browse_changesets_path, {
@@ -44,6 +44,7 @@
<%= link_to t('layouts.export'), export_path, {
:id => 'exportanchor',
:title => t('layouts.export_tooltip'),
+ :data => { :url => url_for(:controller => :export, :action => :start) },
:class => 'geolink llz layers'
} %>
@@ -54,7 +55,7 @@
<%= link_to t('layouts.edit_with',
:editor => t("editor.#{editor}.description")),
edit_path(:editor => editor), {
- :id => editor + 'anchor',
+ :data => { :editor => editor },
:class => "geolink llz object"
} %>
<% end %>
diff --git a/app/views/site/index.html.erb b/app/views/site/index.html.erb
index 657db8474..98a3a1ce7 100644
--- a/app/views/site/index.html.erb
+++ b/app/views/site/index.html.erb
@@ -141,22 +141,18 @@
$("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + extent.left + "&top=" + extent.top + "&right=" + extent.right + "&bottom=" + extent.bottom);
setTimeout(function () {
- if (!loaded) alert("<%=j t('site.index.remote_failed') %>");
+ if (!loaded) alert(I18n.t('site.index.remote_failed'));
}, 1000);
return false;
}
function installEditHandler() {
- $("#remoteanchor").click(remoteEditHandler);
+ $("a[data-editor=remote]").click(remoteEditHandler);
- <% if preferred_editor == "remote" %>
- $("#editanchor").click(remoteEditHandler);
-
- <% if params[:action] == "edit" %>
- remoteEditHandler();
- <% end %>
- <% end %>
+ if (OSM.preferred_editor == "remote" && $('body').hasClass("site-edit")) {
+ remoteEditHandler();
+ }
}
$(document).ready(mapInit);
@@ -174,19 +170,20 @@
$(document).ready(function () {
$("#exportanchor").click(function (e) {
- $.ajax({ url: "<%= url_for :controller => :export, :action => :start %>", success: function (sidebarHtml) {
+ $.ajax({ url: $(this).data('url'), success: function (sidebarHtml) {
startExport(sidebarHtml);
}});
e.preventDefault();
});
- <% if params[:export] -%>
- $("#exportanchor").click();
- <% end -%>
+ if (window.location.pathname == "/export") {
+ $("#exportanchor").click();
+ }
- <% if params[:query] -%>
- doSearch("<%= params[:query] %>");
- <% end %>
+ var query;
+ if (query = getArgs(window.location.toString()).query) {
+ doSearch(query);
+ }
});
// -->
diff --git a/config/i18n-js.yml b/config/i18n-js.yml
index 261fb6c0f..f80b142c5 100644
--- a/config/i18n-js.yml
+++ b/config/i18n-js.yml
@@ -26,3 +26,4 @@ translations:
- "*.browse.start_rjs.*"
- "*.export.start_rjs.*"
- "*.javascripts.*"
+ - "*.site.index.remote_failed"