diff --git a/static/js/embed.js b/static/js/embed.js index 69a80a851d3f1c757840c998ceeb0fd992ac19f3..0096c7988c8d428e5b57d2fdab193ca92eea7dd3 100644 --- a/static/js/embed.js +++ b/static/js/embed.js @@ -28,6 +28,11 @@ BusMap.Embed = function(opts) { var opt = $('<option value="' + s.id + '">' + s.title + '</option>'); opt.appendTo("#embed-stop"); } + if ($("#embed-stop option").length > 1 && !$("#embed-stop").val()) { + // We have stops. Select the first one. + $("#embed-stop option:nth-child(2)").prop('selected', true); + $("#embed-stop").change(); // fire event to handle the change + } } var updateEmbedUrl = function() { @@ -66,6 +71,11 @@ BusMap.Embed = function(opts) { $("#embed-mode").change(function() { embedVars['mode'] = $(this).val(); updateEmbedUrl(); + if ($(this).val() == "m") { + $("label[for=embed-popup]").show(); + } else { + $("label[for=embed-popup]").hide(); + } }); $("#embed-stop").change(function() { if ($(this).val()) { diff --git a/static/js/map.js b/static/js/map.js index 0f682ad94c1e86a0e8272b82d6cca91cd79bc81d..ed54ce9f5be804289890e395c092e2e9acc9730a 100644 --- a/static/js/map.js +++ b/static/js/map.js @@ -34,6 +34,11 @@ BusMap.Map = function(opts) { else {that.leaflet.fitBounds(that.opts.bounds)} if (that.opts.zoom) that.leaflet.setZoom(that.opts.zoom); + // Listen for hash change + window.onhashchange = function() { + setViewFromUrl(); + }; + // Go to view requested by URL hash (if set) var viewOk = setViewFromUrl(); @@ -48,10 +53,6 @@ BusMap.Map = function(opts) { setUrlFromView(); }); - // Listen for hash change - window.onhashchange = function() { - setViewFromUrl(); - }; // Show/hide markers based on zoom. that.leaflet.on('zoomend', zoomShowHide); @@ -352,7 +353,7 @@ BusMap.Map = function(opts) { window.location.replace("#" + view); return _avsLatLonZoom(view); function _avsStop(view) { - if (!that.stopMarkers) { + if (!that.stopMarkers || !that.stopMarkers[view.substring(1)]) { return setTimeout(function() { _avsStop(view) }, 500); } var marker = that.stopMarkers[view.substring(1)]; diff --git a/static/js/predictions.js b/static/js/predictions.js index 483086009166c38657880d1792d4a010fb950bfa..962ead9b9002975f4b64156fc71b6164295bac2d 100644 --- a/static/js/predictions.js +++ b/static/js/predictions.js @@ -19,10 +19,10 @@ BusMap.Predictions = function(opts) { } // Listen for hash change - window.onhashchange = function() { - console.log('foo'); - setViewFromUrl(); - }; + window.onhashchange = setViewFromUrl; + + // Grab initial URL + setViewFromUrl(); }; @@ -95,7 +95,10 @@ BusMap.Predictions = function(opts) { function setViewFromUrl() { var hash = window.location.hash.substring(1); - applyViewString(hash); + console.log(hash); + if (hash == "") { + $(that.opts.predictionsElement).html("No stop selected"); + } else applyViewString(hash); } /* Refresh (and/or create) UI elements for Stops */ diff --git a/templates/modal-embed.html b/templates/modal-embed.html index 5165b13d75398ff39438bf275338969a471e0593..fe051a1ae9634a1079878cfa80fc82b8313008ea 100644 --- a/templates/modal-embed.html +++ b/templates/modal-embed.html @@ -3,7 +3,7 @@ {% elif agency.title %}{{ agency.title }}{% endif %} Bus Map </h2> <p> - Use maps and/or stop predictions in your website or digital signage. + Use maps and stop predictions in your website or digital signage. </p> <h3>Embed Code</h3> <textarea id="embed-code" cols=100 rows=3 readonly=true></textarea> @@ -57,7 +57,7 @@ <label for="embed-responsive"> <span>Responsive:</span> <input id="embed-responsive" type="checkbox" checked> - <small>Map will resize automatically to fit a smaller window or device.</small> + <small>Resize automatically to fit a smaller window or device.</small> </label> </p> </form>