|
|
@@ -1,16 +1,32 @@
|
|
|
$(function() {
|
|
|
|
|
|
+ const $testsList = $("#tests-list");
|
|
|
+
|
|
|
+ $(document).on("click", "[data-jump-button]", event => {
|
|
|
+
|
|
|
+ $("#tests-list > .list-group-item").removeClass("list-group-item-primary");
|
|
|
+
|
|
|
+ event.preventDefault();
|
|
|
+ const $button = $(event.currentTarget);
|
|
|
+ const id = $button.data("id");
|
|
|
+ const target = `#test-${id}`;
|
|
|
+ const $listGroupItem = $(target);
|
|
|
+ $listGroupItem.addClass("list-group-item-primary");
|
|
|
+ const top = $listGroupItem.offset().top - 56 - 45;
|
|
|
+ $("html, body").animate({
|
|
|
+ scrollTop: top
|
|
|
+ }, "fast")
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
var infoWindow = false;
|
|
|
|
|
|
function initialiseMarkers() {
|
|
|
|
|
|
- if(infoWindow == false) {
|
|
|
+ if(infoWindow === false) {
|
|
|
infoWindow = new google.maps.InfoWindow();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
$.get(window.location, {
|
|
|
action: "get-tests"
|
|
|
}, function(response) {
|
|
|
@@ -22,6 +38,7 @@ function initialiseMarkers() {
|
|
|
let bounds = new google.maps.LatLngBounds();
|
|
|
|
|
|
for(let i in tests) {
|
|
|
+ if(!tests.hasOwnProperty(i)) continue;
|
|
|
let test = tests[i];
|
|
|
let latLng = {
|
|
|
lat: test.geolocation[0],
|
|
|
@@ -37,14 +54,15 @@ function initialiseMarkers() {
|
|
|
};
|
|
|
|
|
|
if(test.icon) {
|
|
|
- markerOptions.icon = "/img/markers/" + test.icon + ".png";
|
|
|
+ markerOptions.icon = `/img/markers/${test.icon}.png`;
|
|
|
}
|
|
|
|
|
|
let marker = new google.maps.Marker(markerOptions);
|
|
|
|
|
|
marker.addListener("click", function() {
|
|
|
- infoWindow.setContent("<strong>" + test.name + "</strong> " + "<span class=\"badge badge-" + test.statusClass + "\">" + test.status + "</span>" + "<br />" +
|
|
|
- "<small>" + test.address + "</small>"
|
|
|
+ infoWindow.setContent(`<strong>${test.name}</strong> <span class="badge badge-${test.statusClass}">${test.status}</span><br />
|
|
|
+<small>${test.address}</small><br />
|
|
|
+<a data-jump-button data-id="${test.id}" href="#">Find in List</a>`
|
|
|
);
|
|
|
infoWindow.open(map, marker);
|
|
|
});
|
|
|
@@ -53,7 +71,5 @@ function initialiseMarkers() {
|
|
|
|
|
|
map.fitBounds(bounds);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
});
|
|
|
-}
|
|
|
+}
|