|
1 | 1 | /*jslint browser: true */
|
2 |
| -/*global $,ga */ |
| 2 | +/*global L,jQuery,ga */ |
3 | 3 |
|
4 |
| -function trackOutboundLinkClicks(link) { |
| 4 | +function trackOutboundLinkClicks(link, event) { |
5 | 5 | 'use strict';
|
6 |
| - |
| 6 | + |
7 | 7 | var href = link.attr('href'),
|
8 | 8 | noProtocol = href.replace(/http[s]?:\/\//, '');
|
9 |
| - |
| 9 | + |
10 | 10 | ga('send', 'event', {
|
11 | 11 | eventCategory: 'Outbound Link',
|
12 | 12 | eventAction: 'click',
|
13 | 13 | eventLabel: noProtocol
|
14 | 14 | });
|
15 | 15 | }
|
16 | 16 |
|
17 |
| -jQuery(document).ready(function () { |
| 17 | +function displayMap() { |
18 | 18 | 'use strict';
|
19 | 19 |
|
20 |
| - var query = 'a:not([href*="' + document.domain + '"])'; |
21 |
| - |
22 |
| - jQuery(query).mousedown(function (event) { |
23 |
| - trackOutboundLinkClicks(jQuery(this)); |
24 |
| - }); |
25 |
| - |
26 |
| - var venue_map = L.map('js-venue-map', { |
| 20 | + var venueMap = L.map('js-venue-map', { |
27 | 21 | center: [43.65534, -79.38287],
|
28 | 22 | zoom: 14,
|
29 | 23 | scrollWheelZoom: false
|
30 | 24 | });
|
31 |
| - L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', { |
32 |
| - attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>', |
| 25 | + |
| 26 | + L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', { |
| 27 | + attribution: 'Map data © <a href="http://openstreetmap.org"> OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>', |
33 | 28 | maxZoom: 18,
|
34 | 29 | id: 'myles.163k2c22',
|
35 | 30 | accessToken: 'pk.eyJ1IjoibXlsZXMiLCJhIjoiY2lzM2p0YzN2MDVjdzJzbzBsc2c1NHZ1OSJ9.k7R24jfN4E8iNh7mlJoK7w'
|
36 |
| - }).addTo(venue_map); |
| 31 | + }).addTo(venueMap); |
37 | 32 |
|
38 | 33 | L.Icon.Default.imagePath = "/static/images/leaflet";
|
39 | 34 |
|
40 |
| - var marker = L.marker([43.65534, -79.38287]).addTo(venue_map); |
| 35 | + var marker = L.marker([43.65534, -79.38287]).addTo(venueMap); |
| 36 | +} |
| 37 | + |
| 38 | +jQuery(window).resize(function() { |
| 39 | + var nav = document.getElementById("js-navigation-menu"); |
| 40 | + |
| 41 | + if (jQuery(nav).length > 0) { |
| 42 | + var windowWidth = jQuery(window).width(); |
| 43 | + var moreLeftSideToPageLeftSide = jQuery(nav).offset().left; |
| 44 | + var moreLeftSideToPageRightSide = windowWidth - moreLeftSideToPageLeftSide; |
| 45 | + |
| 46 | + if (moreLeftSideToPageRightSide < 330) { |
| 47 | + jQuery("#js-navigation-menu").removeClass("navigation__list--fly-out-right"); |
| 48 | + jQuery("#js-navigation-menu").addClass("navigation__list--fly-out-left"); |
| 49 | + } |
| 50 | + |
| 51 | + if (moreLeftSideToPageRightSide > 330) { |
| 52 | + jQuery("#js-navigation-menu").removeClass("navigation__list--fly-out-left"); |
| 53 | + jQuery("#js-navigation-menu").addClass("navigation__list--fly-out-right"); |
| 54 | + } |
| 55 | + } |
| 56 | +}); |
| 57 | + |
| 58 | +jQuery(document).ready(function () { |
| 59 | + 'use strict'; |
| 60 | + |
| 61 | + var navToggle = jQuery("#js-navigation-button").unbind() |
| 62 | + jQuery("#js-navigation-menu").removeClass("show"); |
| 63 | + |
| 64 | + navToggle.on("click", function (e) { |
| 65 | + e.preventDefault(); |
| 66 | + |
| 67 | + jQuery("#js-navigation-menu").slideToggle(function () { |
| 68 | + if (jQuery("#js-navigation-menu").is(":hidden")) { |
| 69 | + jQuery("#js-navigation-menu").removeAttr("style"); |
| 70 | + } |
| 71 | + }); |
| 72 | + }); |
| 73 | + |
| 74 | + var query = 'a:not([href*="' + document.domain + '"])'; |
| 75 | + |
| 76 | + jQuery(query).mousedown(function (event) { |
| 77 | + trackOutboundLinkClicks(jQuery(this), event); |
| 78 | + }); |
| 79 | + |
| 80 | + if (jQuery('.js-venue-map')) { |
| 81 | + displayMap(); |
| 82 | + } |
41 | 83 | });
|
0 commit comments