Skip to content
Snippets Groups Projects
Commit 5750cc31 authored by Martin Leblanc's avatar Martin Leblanc
Browse files

Merge branch 'feature/ISTWCMS-5710-ebremner-fix-linting' into '1.0.x'

Feature/istwcms 5710 ebremner fix linting

See merge request !19
parents 0d4f9da4 41b60579
No related branches found
No related tags found
1 merge request!19Feature/istwcms 5710 ebremner fix linting
......@@ -9,6 +9,7 @@
// uw-horizontal-nav.
$(document).ready(
function () {
// Have to add the run this code only once, so that multiple
// loads of the menu are not shown when logged in.
$(document, context).once('menuhorizontal').each(
......@@ -19,14 +20,9 @@
var menus = document.querySelectorAll('.menu--horizontal');
var items = document.querySelectorAll('.menu__item');
/* Toggle mobile menu */
/**
* Javascript for Toggle mobile menu
* Allows for buttons to be used.
* @const {string}
* @const {string}
* @const {Object}
* @const {Object}
* Javascript for Toggle mobile menu,
* allows for buttons to be used.
* @returns {boolean} css for toggle.
*/
function toggleMenu() {
......@@ -50,12 +46,8 @@
}
/**
* Javascript for Toggle items
* Allows for buttons to be used.
* @const {string}
* @const {string}
* @const {Object}
* @const {Object}
* Javascript for Toggle items,
* allows for buttons to be used.
* @returns {boolean} css for toggle.
*/
function toggleItem() {
......@@ -72,6 +64,7 @@
this.setAttribute('aria-expanded', 'false');
}
// If hamburger.
if (screenWidth <= 767) {
// Look at parents and reset the menus.
......@@ -106,22 +99,14 @@
}
for (let menu of menus) {
/* Close Submenu From Anywhere */
/**
* Javascript
* Allows for close menu.
* @returns {boolean} close menu.
*/
function closeSubmenu(e) {
document.addEventListener('click', function (e) {
let isClickInside = menu.contains(e.target);
if (!isClickInside && menu.querySelector('.submenu-active')) {
menu.querySelector('.submenu-active').classList.remove('submenu-active');
}
}
document.addEventListener('click', closeSubmenu, false);
});
}
for (let item of items) {
......@@ -160,14 +145,10 @@
toggle.addEventListener('click', toggleMenu, false);
}
// Apply timeout to the to event firing
// so it fires at end of event.
/**
* Javascript for debounce
* @var {string}
* @var {Object}
* @const {Object}
* @returns {funcction} debounce.
* @param {func} func, the type of function.
* @returns {function} debounce.
*/
function debouncer(func) {
var timeoutID;
......@@ -188,10 +169,7 @@
// force the button click if wider that 767px.
/**
* Javascript for check width
* @var {string}
* @var {Object}
* @const {Object}
* @returns {funcction} how wide.
* @returns {function} how wide.
*/
function menuCheckWidth() {
// Check if menu is on page.
......
......@@ -16,11 +16,10 @@
$('.uw-header__masthead').toggleClass('open');
}
);
/**
* Javascript for debounce
* @var {string}
* @var {Object}
* @param {func}
* @param {func} func The function to perform
* @returns {function} debounce.
*/
function debouncer(func) {
......@@ -37,7 +36,11 @@
);
};
}
// Check the width of the screen and.
/**
* Function to check the width.
* @returns {null} Null return.
*/
function checkWidth() {
// Set screenWidth var.
var screenWidth = $(window).width();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment