let navToggle = true; document.onscroll = function() { try { document.querySelector('.background-decoration').style.opacity = `${1 - window.scrollY / 621}`; document.querySelector('.background-decoration').style.top = `-${window.scrollY / 5}px`; } catch (e) { console.log('No background decoration found'); } try { if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) { document.querySelector('.banner').classList = 'banner banner-scrolled'; } else { document.querySelector('.banner').classList = 'banner'; } } catch (e) { console.log('No banner found'); } if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) { document.querySelector('.jumpUp').classList = 'jumpUp jumpUp--show'; } else { document.querySelector('.jumpUp').classList = 'jumpUp'; } } document.querySelector('.jumpUp').onclick = function() { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; } function imgFade(obj) { $(obj).animate({opacity: 1}, 250); } var times = document.getElementsByClassName('time'); for (var i = 0; i < times.length; i++) { var time = times[i].innerHTML; var date = new Date(time); times[i].innerHTML = date.toLocaleString('en-GB'); } function addNotification(text='Sample notification', type=4) { var container = document.querySelector('.notifications'); // Create notification element var div = document.createElement('div'); div.classList.add('sniffle__notification'); div.onclick = function() { if (div.parentNode) { div.classList.add('sniffle__notification--hide'); setTimeout(function() { container.removeChild(div); }, 500); } }; // Create icon element and append to notification var icon = document.createElement('span'); icon.classList.add('sniffle__notification-icon'); switch (type) { case 1: div.classList.add('sniffle__notification--success'); icon.innerHTML = '\ \ '; break; case 2: div.classList.add('sniffle__notification--error'); icon.innerHTML = '\ \ '; break; case 3: div.classList.add('sniffle__notification--warning'); icon.innerHTML = '\ \ '; break; default: div.classList.add('sniffle__notification--info'); icon.innerHTML = '\ \ '; break; } div.appendChild(icon); // Create text element and append to notification var description = document.createElement('span'); description.classList.add('sniffle__notification-text'); description.innerHTML = text; div.appendChild(description); // Create span to show time remaining var timer = document.createElement('span'); timer.classList.add('sniffle__notification-time'); div.appendChild(timer); // Append notification to container container.appendChild(div); setTimeout(function() { div.classList.add('sniffle__notification-show'); }, 100); // Remove notification after 5 seconds setTimeout(function() { if (div.parentNode) { div.classList.add('sniffle__notification--hide'); setTimeout(function() { container.removeChild(div); }, 500); } }, 5000); } function popUpShow(title, body, actions, content) { var popup = document.querySelector('.pop-up'); var popupContent = document.querySelector('.pop-up-content'); var popupActions = document.querySelector('.pop-up-controlls'); // Set tile and description h3 = document.createElement('h3'); h3.innerHTML = title; p = document.createElement('p'); p.innerHTML = body; popupContent.innerHTML = ''; popupContent.appendChild(h3); popupContent.appendChild(p); // Set content if (content != '') { popupContent.innerHTML += content; } // Set buttons that will be displayed popupActions.innerHTML = ''; if (actions != '') { popupActions.innerHTML += actions; } popupActions.innerHTML += ''; // Show popup popup.classList.add('pop-up__active'); } function popupDissmiss() { var popup = document.querySelector('.pop-up'); popup.classList.add('pop-up__hide'); setTimeout(function() { popup.classList = 'pop-up'; }, 200); }