From 058466e15d3ce800cad7e6b4034fb887c335c6f2 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 12 Mar 2015 15:07:42 +0000 Subject: Use the uos-live.js library for the bus stop popups This replaces the bus.southampton.ac.uk iframe, which improves performance, responsiveness, and the integration of the user interface. --- resources/leaflet-route/leaflet-route.js | 37 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'resources/leaflet-route/leaflet-route.js') diff --git a/resources/leaflet-route/leaflet-route.js b/resources/leaflet-route/leaflet-route.js index dbce204..4d78148 100644 --- a/resources/leaflet-route/leaflet-route.js +++ b/resources/leaflet-route/leaflet-route.js @@ -159,6 +159,8 @@ L.Control.Route.createRouteMasterList = function(routeMasters, routeSelected, so var li = L.DomUtil.create('li', '', ul); var a = L.DomUtil.create('a', null, li); + a.className = "ls-route-master-link"; + a.style.background = routeMaster.routes[0].properties.colour; a.textContent = "U"; @@ -176,6 +178,25 @@ L.Control.Route.createRouteMasterList = function(routeMasters, routeSelected, so return ul; }; +L.Control.Route.createRouteLink = function(route, routeSelected) { + var a = document.createElement("a"); + + a.className = "ls-route-link"; + + a.style.background = route.properties.colour; + + a.textContent = "U"; + var strong = document.createElement("strong"); + strong.textContent = route.properties.ref.slice(1); + a.appendChild(strong); + + a.onclick = function() { + routeSelected(); + }; + + return a; +}; + L.Control.Route.createRouteList = function(routeMaster, routeSelected) { var ul = L.DomUtil.create('ul', 'ls-route-list'); @@ -183,20 +204,10 @@ L.Control.Route.createRouteList = function(routeMaster, routeSelected) { var route = routeMaster.routes[i]; var li = L.DomUtil.create('li', '', ul); - var a = L.DomUtil.create('a', null, li); - a.style.background = route.properties.colour; - - a.textContent = "U"; - var strong = document.createElement("strong"); - strong.textContent = route.properties.ref.slice(1); - a.appendChild(strong); - - a.onclick = (function(routeName) { - return function() { - routeSelected(routeName); - }; - })(route.properties.name); + li.appendChild(L.Control.Route.createRouteLink(route, function() { + routeSelected(route.properties.name); + })); } return ul; -- cgit v1.2.3