From 1a8be897c053299a1981d2e7defa5fe616b2a6d0 Mon Sep 17 00:00:00 2001
From: Anton Sarukhanov <code@ant.sr>
Date: Wed, 4 May 2016 09:35:08 -0400
Subject: [PATCH] js cleanup

---
 bower.json         |  2 +-
 static/js/embed.js | 14 +++++++-------
 static/js/map.js   |  9 ++++++++-
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/bower.json b/bower.json
index 362ee25..8aa20b7 100644
--- a/bower.json
+++ b/bower.json
@@ -15,7 +15,7 @@
   ],
   "dependencies": {
     "leaflet": "~0.7.7",
-    "jquery": "~2.1.4",
+    "jquery": "~2.2.3",
     "leaflet.markercluster": "~0.4.0",
     "leaflet-marker-rotate": "https://git.xhost.io/anton/leaflet-marker-rotate.git",
     "Leaflet.label": "~0.2.1"
diff --git a/static/js/embed.js b/static/js/embed.js
index 0096c79..4fa38ab 100644
--- a/static/js/embed.js
+++ b/static/js/embed.js
@@ -47,28 +47,28 @@ BusMap.Embed = function(opts) {
 
     var bindEventHandlers = function() {
         // OnChange event handlers for Embed Options form
-        $("#embed-height").change(function() {
+        $("#embed-height").on('change', function() {
             if ($(this).val() != "") {
                 $("#embed-preview iframe").attr('height', $(this).val() + "px");
             } else {
                 $("#embed-preview iframe").removeAttr('height');
             }
         });
-        $("#embed-width").change(function() {
+        $("#embed-width").on('change', function() {
             if ($(this).val() != "") {
                 $("#embed-preview iframe").attr('width', $(this).val() + "px");
             } else {
                 $("#embed-preview iframe").removeAttr('width');
             }
         });
-        $("#embed-responsive").change(function() {
+        $("#embed-responsive").on('change', function() {
             if ($(this).prop("checked")) {
                 $("#embed-preview iframe").css('max-width', '100%');
             } else {
                 $("#embed-preview iframe").css('max-width', '');
             }
         });
-        $("#embed-mode").change(function() {
+        $("#embed-mode").on('change', function() {
             embedVars['mode'] = $(this).val();
             updateEmbedUrl();
             if ($(this).val() == "m") {
@@ -77,7 +77,7 @@ BusMap.Embed = function(opts) {
                 $("label[for=embed-popup]").hide();
             }
         });
-        $("#embed-stop").change(function() {
+        $("#embed-stop").on('change', function() {
             if ($(this).val()) {
                 embedVars['stop'] = $(this).val();
             } else {
@@ -85,7 +85,7 @@ BusMap.Embed = function(opts) {
             }
             updateEmbedUrl();
         });
-        $("#embed-popup").change(function() {
+        $("#embed-popup").on('change', function() {
             if ($(this).prop("checked")) {
                 embedVars['popup'] = true;
             } else {
@@ -94,7 +94,7 @@ BusMap.Embed = function(opts) {
             updateEmbedUrl();
         });
         // After ANY field is updated...
-        $("#embed-form :input").change(function() {
+        $("#embed-form :input").on('change', function() {
             updateEmbedCode();
         });
         // Hilight code for easy copying on click, key, focus.
diff --git a/static/js/map.js b/static/js/map.js
index ed54ce9..fdedad7 100644
--- a/static/js/map.js
+++ b/static/js/map.js
@@ -454,8 +454,15 @@ BusMap.Map = function(opts) {
             var modalName = $(".modal").attr('id').split('-')[1];
             view += ";" + modalName;
         }
+        if (window.location.hash == "#" + view) {
+            // Bail out if old hash == new hash.
+            // Otherwise, we'll set hashChangedProgrammatically, but
+            // the change handler will never fire, and it won't be unset.
+            // TODO: unfuck this bad design before it breaks something else
+            return;
+        }
         that.hashChangedProgrammatically = true; // avoid infinite loop!
-        window.location.replace("#" + view);
+        window.location.href.replace(window.location.hash, "#" + view);
     }
 
     init();
-- 
GitLab