2023-03-30 15:51:06 +00:00
|
|
|
function popUpShow(titleText, subtitleText, bodyContent=null, userActions=null) {
|
2023-03-10 15:55:34 +00:00
|
|
|
// Get popup elements
|
2023-04-12 15:30:54 +00:00
|
|
|
const popupSelector = document.querySelector('.pop-up');
|
|
|
|
const headerSelector = document.querySelector('.pop-up-header');
|
|
|
|
const actionsSelector = document.querySelector('.pop-up-controlls');
|
2023-03-05 18:16:28 +00:00
|
|
|
|
2023-03-30 15:51:06 +00:00
|
|
|
// Clear popup elements
|
|
|
|
headerSelector.innerHTML = '';
|
|
|
|
actionsSelector.innerHTML = '';
|
2023-03-05 18:16:28 +00:00
|
|
|
|
2023-03-30 15:51:06 +00:00
|
|
|
// Set popup header and subtitle
|
2023-04-12 15:30:54 +00:00
|
|
|
const titleElement = document.createElement('h2');
|
2023-03-30 15:51:06 +00:00
|
|
|
titleElement.innerHTML = titleText;
|
|
|
|
headerSelector.appendChild(titleElement);
|
2023-03-05 18:16:28 +00:00
|
|
|
|
2023-04-12 15:30:54 +00:00
|
|
|
const subtitleElement = document.createElement('p');
|
2023-03-30 15:51:06 +00:00
|
|
|
subtitleElement.innerHTML = subtitleText;
|
|
|
|
headerSelector.appendChild(subtitleElement);
|
2023-03-09 12:22:25 +00:00
|
|
|
|
2023-03-30 15:51:06 +00:00
|
|
|
if (bodyContent) {
|
|
|
|
headerSelector.appendChild(bodyContent);
|
|
|
|
}
|
2023-03-05 18:16:28 +00:00
|
|
|
|
2023-03-30 15:51:06 +00:00
|
|
|
// Set buttons that will be displayed
|
|
|
|
if (userActions) {
|
|
|
|
// for each user action, add the element
|
|
|
|
for (let i = 0; i < userActions.length; i++) {
|
2023-04-12 15:33:48 +00:00
|
|
|
actionsSelector.appendChild(userActions[i]);
|
2023-03-30 15:51:06 +00:00
|
|
|
}
|
|
|
|
} else {
|
2023-04-19 15:05:54 +00:00
|
|
|
actionsSelector.innerHTML = '<button class="btn-block transparent" onclick="popupDissmiss()">Close</button>';
|
2023-03-30 15:51:06 +00:00
|
|
|
}
|
2023-03-05 18:16:28 +00:00
|
|
|
|
2023-03-30 15:51:06 +00:00
|
|
|
// Stop scrolling and show popup
|
|
|
|
document.querySelector("html").style.overflow = "hidden";
|
|
|
|
popupSelector.style.display = 'block';
|
2023-04-19 18:11:19 +00:00
|
|
|
setTimeout(() => { popupSelector.classList.add('active') }, 5); // 2ms delay to allow for css transition >:C
|
2023-03-05 18:16:28 +00:00
|
|
|
}
|
|
|
|
|
2023-03-30 15:51:06 +00:00
|
|
|
function popupDissmiss() {
|
2023-04-12 15:30:54 +00:00
|
|
|
const popupSelector = document.querySelector('.pop-up');
|
2023-03-30 15:51:06 +00:00
|
|
|
|
|
|
|
document.querySelector("html").style.overflow = "auto";
|
|
|
|
popupSelector.classList.remove('active');
|
2023-04-19 18:11:19 +00:00
|
|
|
setTimeout(() => { popupSelector.style.display = 'none'; }, 200);
|
2023-03-30 15:51:06 +00:00
|
|
|
}
|