From aa20398cea1c212f27d9004170bdc0aee4d8f854 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 7 Oct 2013 17:15:04 -0700 Subject: [PATCH] Consolidate search-related JavaScript --- app/assets/javascripts/application.js | 1 - app/assets/javascripts/geocoder.js | 14 -------------- app/assets/javascripts/index/search.js | 18 +++++++++++++++++- 3 files changed, 17 insertions(+), 16 deletions(-) delete mode 100644 app/assets/javascripts/geocoder.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index c23976641..e244d8b30 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -18,7 +18,6 @@ //= require piwik //= require map //= require richtext -//= require geocoder //= require querystring var querystring = require('querystring-component'); diff --git a/app/assets/javascripts/geocoder.js b/app/assets/javascripts/geocoder.js deleted file mode 100644 index 0809bef78..000000000 --- a/app/assets/javascripts/geocoder.js +++ /dev/null @@ -1,14 +0,0 @@ -$(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/assets/javascripts/index/search.js b/app/assets/javascripts/index/search.js index 132447ec5..89418e006 100644 --- a/app/assets/javascripts/index/search.js +++ b/app/assets/javascripts/index/search.js @@ -7,7 +7,23 @@ OSM.Search = function(map) { $("#describe_location").fadeIn(100); }); - $("#sidebar_content").on("click", ".search_results_entry a.set_position", clickSearchResult); + $("#sidebar_content") + .on("click", ".search_more a", clickSearchMore) + .on("click", ".search_results_entry a.set_position", clickSearchResult); + + function clickSearchMore(e) { + e.preventDefault(); + e.stopPropagation(); + + 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); + }); + } function clickSearchResult(e) { e.preventDefault(); -- 2.39.5