85 lines
2.4 KiB
JavaScript
85 lines
2.4 KiB
JavaScript
if (window.location.pathname == "/app") {
|
|
document
|
|
.querySelector(".np-sub-navigation")
|
|
.classList
|
|
.add("homepage-nav")
|
|
document
|
|
.querySelector(".np-header")
|
|
.classList
|
|
.add("homepage-nav")
|
|
}
|
|
|
|
document.querySelector(".np-hidden-desktop .dropdown-arrow").addEventListener("click", function(e) {
|
|
if (e
|
|
.target
|
|
.parentElement
|
|
.classList
|
|
.contains("open")) {
|
|
e
|
|
.target
|
|
.parentElement
|
|
.classList
|
|
.remove("open")
|
|
} else {
|
|
e
|
|
.target
|
|
.parentElement
|
|
.classList
|
|
.add("open")
|
|
}
|
|
})
|
|
|
|
window.onload = function() {
|
|
var stickySubNav = document.querySelector('.np-sub-navigation');
|
|
var headerOffset = findOffset(stickySubNav);
|
|
|
|
window.onscroll = function() {
|
|
var bodyScrollTop = document.documentElement.scrollTop || document.body.scrollTop;
|
|
if (bodyScrollTop > (headerOffset.top - 24)) {
|
|
stickySubNav.classList.add('fixed');
|
|
} else {
|
|
stickySubNav.classList.remove('fixed');
|
|
}
|
|
};
|
|
|
|
const firstPopupSeen = {{current_person.properties.first_time_user_popup_seen}}
|
|
|
|
function findOffset(element) {
|
|
var top = 0,
|
|
left = 0;
|
|
|
|
do {
|
|
top += element.offsetTop || 0;
|
|
left += element.offsetLeft || 0;
|
|
element = element.offsetParent;
|
|
} while (element);
|
|
|
|
return {top: top, left: left};
|
|
}
|
|
|
|
window.addEventListener("load", function() {
|
|
|
|
var progressCards = document.querySelectorAll(".np-card-learning-path-progress");
|
|
|
|
for (var i = 0; i < progressCards.length; i++) {
|
|
var lpProgressCard = progressCards[i]
|
|
var progressRing = lpProgressCard.querySelector(".progress-ring")
|
|
let circle = progressRing.querySelector(".circle-progress")
|
|
let total = progressRing.getAttribute("data-total")
|
|
let numCompleted = lpProgressCard.querySelector(".lp-completed-items span > div").getAttribute("data-completed")
|
|
var radius = circle.r.baseVal.value;
|
|
var circumference = radius * 2 * Math.PI;
|
|
|
|
circle.style.strokeDasharray = `${circumference} ${circumference}`;
|
|
circle.style.strokeDashoffset = `${circumference}`;
|
|
|
|
const percent = numCompleted / total
|
|
setProgress(percent, circle)
|
|
}
|
|
|
|
function setProgress(percent, circle) {
|
|
const offset = circumference - percent * circumference;
|
|
circle.style.strokeDashoffset = offset;
|
|
}
|
|
}
|