From: John Firebaugh Date: Fri, 12 Oct 2012 00:27:35 +0000 (-0700) Subject: Use jQuery's toggle binding X-Git-Tag: live~5244^2~51 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/e316f0e425cc934295c8e64cdcf03f00899f287c Use jQuery's toggle binding The old code never unbound the existing binding, so they piled up. --- diff --git a/app/assets/javascripts/index/browse.js b/app/assets/javascripts/index/browse.js index 1792c8577..e75ae9dd2 100644 --- a/app/assets/javascripts/index/browse.js +++ b/app/assets/javascripts/index/browse.js @@ -52,8 +52,7 @@ $(document).ready(function () { $("#browse_select_box").click(startDrag); $("#browse_hide_areas_box").html(I18n.t('browse.start_rjs.hide_areas')); - $("#browse_hide_areas_box").show(); - $("#browse_hide_areas_box").click(hideAreas); + $("#browse_hide_areas_box").toggle(hideAreas, showAreas); function updateData() { if (browseMode == "auto") { @@ -128,8 +127,6 @@ $(document).ready(function () { function hideAreas() { $("#browse_hide_areas_box").html(I18n.t('browse.start_rjs.show_areas')); - $("#browse_hide_areas_box").show(); - $("#browse_hide_areas_box").click(showAreas); areasHidden = true; @@ -138,8 +135,6 @@ $(document).ready(function () { function showAreas() { $("#browse_hide_areas_box").html(I18n.t('browse.start_rjs.hide_areas')); - $("#browse_hide_areas_box").show(); - $("#browse_hide_areas_box").click(hideAreas); areasHidden = false;