From: Tom Hughes Date: Mon, 6 May 2013 10:09:17 +0000 (+0100) Subject: Replace some inline javascript with a UJS solution X-Git-Tag: live~5011 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/e84b2bd22f7c92fb7a128a91c999f86e350bf04d Replace some inline javascript with a UJS solution --- diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 284ec77e6..4c2b79403 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -18,6 +18,7 @@ //= require sidebar //= require richtext //= require resize +//= require geocoder function zoomPrecision(zoom) { var decimals = Math.pow(10, Math.floor(zoom/3)); diff --git a/app/assets/javascripts/geocoder.js b/app/assets/javascripts/geocoder.js new file mode 100644 index 000000000..0809bef78 --- /dev/null +++ b/app/assets/javascripts/geocoder.js @@ -0,0 +1,14 @@ +$(document).ready(function () { + $("body").on("click", ".search_more a", function (e) { + e.preventDefault(); + + var div = $(this).parents(".search_more"); + + div.find(".search_results_entry").hide(); + div.find(".search_searching").show(); + + $.get($(this).attr("href"), function(data) { + div.replaceWith(data); + }); + }); +}); diff --git a/app/views/geocoder/results.html.erb b/app/views/geocoder/results.html.erb index 7fd21775e..f98f2abc9 100644 --- a/app/views/geocoder/results.html.erb +++ b/app/views/geocoder/results.html.erb @@ -7,20 +7,11 @@ <% end %> <% if @more_params %> -
+
- <%= link_to t('geocoder.results.more_results'), "#", :class => "button" %> + <%= link_to t('geocoder.results.more_results'), url_for(@more_params), :class => "button" %>
- <%= image_tag "searching.gif", :class => "search_searching" %> + <%= image_tag "searching.gif", :class => ["search_searching", "hidden"] %>
- <% end %> <% end %>