-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
74 changed files
with
1,097 additions
and
536 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,8 @@ | |
} | ||
.video-js .vjs-remaining-time { | ||
display: none; | ||
} | ||
} | ||
.filter-event-img { | ||
max-height:32px; | ||
max-width:32px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.event-card-container { | ||
min-width: 12rem; | ||
min-height: 11rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
let loader = document.querySelector(".lds-ring"); | ||
let checkedInputs = []; | ||
|
||
/** | ||
* Enable /disable all checkboxes. | ||
* | ||
* @param {boolean} value | ||
*/ | ||
function disableCheckboxes(value) { | ||
document.querySelectorAll("input[type=checkbox]").forEach((checkbox) => { | ||
checkbox.disabled = value; | ||
}); | ||
} | ||
|
||
/** | ||
* Return url with filters params. | ||
* | ||
* @returns {string} | ||
*/ | ||
function getUrlForRefresh() { | ||
let newUrl = window.location.pathname + "?"; | ||
|
||
checkedInputs.forEach((input) => { | ||
newUrl += input.name + "=" + input.value + "&"; | ||
}); | ||
|
||
// Add page parameter | ||
newUrl += "page=1"; | ||
return newUrl; | ||
} | ||
|
||
/** | ||
* Remove loader height. | ||
* | ||
* @param height | ||
* @returns {number} | ||
*/ | ||
function getHeightMinusLoader(height) { | ||
let loader_style = getComputedStyle(loader); | ||
let loader_height = loader_style.height; | ||
loader_height = loader_height.replace("px", ""); | ||
return height - loader_height; | ||
} | ||
|
||
/** | ||
* Async request to refresh view with filtered events list. | ||
*/ | ||
function refreshEvents() { | ||
// Erase list and enable loader | ||
const events_content = document.getElementById("events_content"); | ||
let width = events_content.offsetWidth; | ||
let height = getHeightMinusLoader(events_content.offsetHeight); | ||
|
||
events_content.innerHTML = | ||
"<div style='height: " + height + "px; width:" + width + "px'></div>"; | ||
loader.classList.add("show"); | ||
|
||
let url = getUrlForRefresh(); | ||
|
||
// Async GET request wth parameters by fetch method | ||
fetch(url, { | ||
method: "GET", | ||
headers: { | ||
"X-CSRFToken": "{{ csrf_token }}", | ||
"X-Requested-With": "XMLHttpRequest", | ||
}, | ||
cache: "no-store", | ||
}) | ||
.then((response) => response.text()) | ||
.then((data) => { | ||
// parse data into html and replace videos list | ||
let parser = new DOMParser(); | ||
let html = parser.parseFromString(data, "text/html").body; | ||
events_content.outerHTML = html.innerHTML; | ||
|
||
// change url with params sent | ||
window.history.pushState({}, "", url); | ||
}) | ||
.catch(() => { | ||
events_content.innerHTML = gettext("An Error occurred while processing."); | ||
}) | ||
.finally(() => { | ||
// Re-enable inputs and dismiss loader | ||
disableCheckboxes(false); | ||
loader.classList.remove("show"); | ||
}); | ||
} | ||
|
||
/** | ||
* Check or uncheck checkbox regarding url params. | ||
* | ||
* @param el | ||
*/ | ||
function setCheckboxStatus(el) { | ||
let currentUrl = window.location.href; | ||
el.checked = currentUrl.includes("type=" + el.value + "&"); | ||
} | ||
|
||
/** | ||
* Add listener to refresh events list on checkbox status change. | ||
* | ||
* @param el | ||
*/ | ||
function addCheckboxListener(el) { | ||
el.addEventListener("change", () => { | ||
checkedInputs = []; | ||
disableCheckboxes(true); | ||
document | ||
.querySelectorAll("#collapseFilterType input[type=checkbox]:checked") | ||
.forEach((e) => { | ||
checkedInputs.push(e); | ||
}); | ||
refreshEvents(); | ||
}); | ||
} | ||
|
||
// On page load | ||
document | ||
.querySelectorAll("#collapseFilterType input[type=checkbox]") | ||
.forEach((el) => { | ||
setCheckboxStatus(el); | ||
addCheckboxListener(el); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.