From 0b9f9edb3de33ffd8f75821a31bc6cee13289f55 Mon Sep 17 00:00:00 2001 From: Anton Sarukhanov <code@ant.sr> Date: Wed, 4 May 2016 16:27:48 -0400 Subject: [PATCH] Make sure a stop is pre-selected on embed modal open --- static/js/embed.js | 2 +- static/js/map.js | 12 ++++++++---- templates/modal-embed.html | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/static/js/embed.js b/static/js/embed.js index 28d23a0..ab9f736 100644 --- a/static/js/embed.js +++ b/static/js/embed.js @@ -5,8 +5,8 @@ BusMap.Embed = function(opts) { /* Constructor - initialize the embed form */ function init() { - populateOptions(); bindEventHandlers(); + populateOptions(); } var updateEmbedCode = function() { diff --git a/static/js/map.js b/static/js/map.js index b780ebb..197b920 100644 --- a/static/js/map.js +++ b/static/js/map.js @@ -26,6 +26,7 @@ BusMap.Map = function(opts) { animate: false, reset: true, }; + that.map = that.opts.mapElement; that.leaflet = L.map(that.map, mapOptions) .fitBounds(that.opts.bounds) @@ -52,7 +53,7 @@ BusMap.Map = function(opts) { } // Hide any opened modals when map is clicked. - $(that.map).on('click', hideModal); + $(that.map).on('mousedown', hideModal); // Show/hide markers based on zoom. that.leaflet.on('zoomend', zoomShowHide); @@ -439,13 +440,15 @@ BusMap.Map = function(opts) { if (that.hashChangedProgrammatically ) { // Ignore hash changes caused programmatically (would inf-loop). delete that['hashChangedProgrammatically']; - return; + return false; } if (that.opts.hashListen == false) { - return; + return false; } var hash = window.location.hash.substring(1); - if (hash == "") return; + if (hash == "") { + return false; + } var parts = hash.split(";"); // First part: view string (lat,lon,zoom; vehicle; or stop) applyViewString(parts[0]); @@ -453,6 +456,7 @@ BusMap.Map = function(opts) { if (parts.length > 1) { showModal(parts[1]); } + return true; } function setUrlFromView() { diff --git a/templates/modal-embed.html b/templates/modal-embed.html index fe051a1..122708c 100644 --- a/templates/modal-embed.html +++ b/templates/modal-embed.html @@ -10,7 +10,7 @@ <h3>Preview</h3> <div id="embed-preview"> <iframe - src="{{ url_for('map_embed', mode='m', _external=True, _scheme='') }}" + src="" frameborder=0></iframe> </div> <h3>Options</h3> -- GitLab