Skip to content

Commit ad4957e

Browse files
committed
Started working on the mobile menu view.
1 parent f5d362f commit ad4957e

File tree

3 files changed

+61
-19
lines changed

3 files changed

+61
-19
lines changed

web/static/javascript/app.js

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,83 @@
11
/*jslint browser: true */
2-
/*global $,ga */
2+
/*global L,jQuery,ga */
33

4-
function trackOutboundLinkClicks(link) {
4+
function trackOutboundLinkClicks(link, event) {
55
'use strict';
6-
6+
77
var href = link.attr('href'),
88
noProtocol = href.replace(/http[s]?:\/\//, '');
9-
9+
1010
ga('send', 'event', {
1111
eventCategory: 'Outbound Link',
1212
eventAction: 'click',
1313
eventLabel: noProtocol
1414
});
1515
}
1616

17-
jQuery(document).ready(function () {
17+
function displayMap() {
1818
'use strict';
1919

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', {
2721
center: [43.65534, -79.38287],
2822
zoom: 14,
2923
scrollWheelZoom: false
3024
});
31-
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
32-
attribution: 'Map data &copy; <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 &copy; <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>',
3328
maxZoom: 18,
3429
id: 'myles.163k2c22',
3530
accessToken: 'pk.eyJ1IjoibXlsZXMiLCJhIjoiY2lzM2p0YzN2MDVjdzJzbzBsc2c1NHZ1OSJ9.k7R24jfN4E8iNh7mlJoK7w'
36-
}).addTo(venue_map);
31+
}).addTo(venueMap);
3732

3833
L.Icon.Default.imagePath = "/static/images/leaflet";
3934

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+
}
4183
});

web/static/scss/components/_navigation.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
display: block;
44

55
@include media(min-width $breakpoint-mobile) {
6-
display: hidden;
6+
display: none;
77
}
88
}
99

web/templates/includes/header.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
</a>
55

66
<nav class="navigation header__navigation">
7-
<a href="#" class="navigation__menu header__navigation-menu">MENU</a>
7+
<a href="#" class="navigation__menu header__navigation-menu" id="js-navigation-button">MENU</a>
88

9-
<ul class="navigation__list header__navigation-list">
9+
<ul class="navigation__list header__navigation-list" id="js-navigation-menu">
1010
<li class="navigation__item"><a class="navigation__link" href="{{ url_for('pages.index') }}">{{ _('Home') }}</a></li>
1111

1212
<li class="navigation__item"><a class="navigation__link {% if request.url_rule.endpoint == 'pages.about' %}navigation__link--active{% endif %}" href="{{ url_for('pages.about') }}">{{ _('About') }}</a></li>

0 commit comments

Comments
 (0)