From 3161f1542e60be909369fa729790c2d90ffebab7 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Mon, 12 May 2014 16:10:29 +0000 Subject: [PATCH] Show event details when selecting a marker. Hide when popup closes. TODO: do this without a global variable. --- www/map.js | 22 +++++++++++++++++----- www/misc.js | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/www/map.js b/www/map.js index ff4eb26..d3371fd 100644 --- a/www/map.js +++ b/www/map.js @@ -136,12 +136,24 @@ $(document).ready(function() { map.on('popupopen', function() { // convert date/time to localtime $("div.leaflet-popup span.utctime").each(function(){$(this).addClass("localtime").removeClass("utctime");$.localtime.formatObject($(this), "dd.MM.yyyy - HH:mm")}); - var eventid = $("div.leaflet-popup h3").attr("eventid"); - if ( eventid ) { - // highlight event in table - highlightEvent(eventid); + openMarkerID = $("div.leaflet-popup h3").attr("eventid"); + if ( openMarkerID ) { // update city in popup - $("div.leaflet-popup h3").text(geolocationTable[eventid]); + $("div.leaflet-popup h3").text(geolocationTable[openMarkerID]); + // highlight event in table and show details + // highlightEvent(eventid); + $('#eventstable > tbody > tr > td > a.toggle').each(function() { + if ( $(this).attr('eventid') == openMarkerID ) { + $(this)[0].click(); + }; + }); }; }); + map.on('popupclose', function() { + $('#eventstable > tbody > tr > td > a.toggle').each(function() { + if ( $(this).attr('eventid') == openMarkerID ) { + $(this)[0].click(); + }; + }); + }); }); diff --git a/www/misc.js b/www/misc.js index 7da0a00..702a3d1 100644 --- a/www/misc.js +++ b/www/misc.js @@ -73,6 +73,7 @@ $( window ).resize(function() { /* create global vars */ var map; +var openMarkerID; var eventTable = {}; var eventDetails = {}; var stationTable = {};