- ${result.description} -
- -diff --git a/static/js/cookie-consent-listener.js b/static/js/cookie-consent-listener.js index 25ccaca..afa446c 100644 --- a/static/js/cookie-consent-listener.js +++ b/static/js/cookie-consent-listener.js @@ -1,6 +1,5 @@ let gaInitialized = false; document.addEventListener('cookieconsent_allowed', () => { - console.log('allowed'); if (gaInitialized === true) return; const script = document.createElement('script'); script.src = 'https://www.googletagmanager.com/gtag/js?id=G-TW89K2P8L4'; diff --git a/static/js/cookie-consent.js b/static/js/cookie-consent.js index 866b2fe..65ddb59 100644 --- a/static/js/cookie-consent.js +++ b/static/js/cookie-consent.js @@ -31,10 +31,10 @@ const cookieConsent = (function () { View our cookie policy
@@ -49,6 +49,8 @@ const cookieConsent = (function () { const wrapper = document.createElement("div"); wrapper.innerHTML = modalHTML; document.body.appendChild(wrapper) + document.getElementById('cookie-decline').addEventListener('click', cookieConsent.deny); + document.getElementById('cookie-allow').addEventListener('click', cookieConsent.allow); } diff --git a/static/js/main.js b/static/js/main.js index e0012e4..12b17ba 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -1,5 +1,5 @@ document.querySelectorAll('[data-modal]').forEach(item => { - item.onclick = () => { + item.addEventListener('click', () => { const modal = document.getElementById(item.dataset.modal); modal.style.display = 'block'; modal.querySelector('.btn-primary').focus(); @@ -8,22 +8,23 @@ document.querySelectorAll('[data-modal]').forEach(item => { dc.classList.add('close'); setTimeout(() => dc.classList.remove('close'), 100); } - } + }) }) -window.onclick = e => { - if (e.target.classList.contains('modal')) { - e.target.style.display = "none"; +window.addEventListener('click', (e)=>{ + const {target} = e; + if (target.classList.contains('modal')) { + target.style.display = "none"; } - if (!e.target.closest('.dropdown-select') || e.target.parentElement.classList.contains('dropdown-select_options')) { + if (!target.closest('.dropdown-select') || target.parentElement.classList.contains('dropdown-select_options')) { document.querySelectorAll('.dropdown-select').forEach(item => item.classList.remove('opened')) } -} +}) -document.querySelectorAll('.dropdown-select span').forEach(item => item.onclick = () => { +document.querySelectorAll('.dropdown-select span').forEach(item => item.addEventListener('click', () => { item.closest('.dropdown-select').classList.toggle('opened') -}); +})); const versionsDropdown = document.querySelector('.dropdown-select.versions'); if (versionsDropdown) { @@ -39,7 +40,6 @@ document.onkeyup = e => { } } -const closeModal = (el) => el.closest('.modal').style.display = 'none'; const fakeLogin = (el) => { el.style.display = 'none'; @@ -47,32 +47,34 @@ const fakeLogin = (el) => { } document.querySelectorAll('.tabs div[data-tab]').forEach(item => { - item.onclick = function () { + item.addEventListener('click', () => { document.querySelector('div[data-tab].active').classList.remove('active'); item.classList.add('active'); document.querySelector('.tabs-content.opened').classList.remove('opened'); document.getElementById(`tab${item.dataset.tab}`).classList.add('opened'); - } + }) }) const collapse = document.querySelector('.collapse'); const dropDownHandler = function (element) { - const openedClass = "opened"; - document.querySelector('li.dropdown.opened').classList.remove('opened'); - const li = element.closest('li'); - if (li.className.indexOf(openedClass) == -1) { - li.className += ` ${openedClass}`; - } else { - li.className = li.className.replace(` ${openedClass}`, ""); + document.querySelectorAll('.dropdown-item-onclick.opened').forEach((el)=> el !== element && el.classList.toggle('opened') ); + + if(window.matchMedia("(pointer: coarse)").matches) { + element.classList.toggle('opened'); } } +document.querySelectorAll('.dropdown-item-onclick').forEach(element=>{ + element.addEventListener('click', (e)=>dropDownHandler(e.target)); +}) -const openMenuHandler = function (collapseMenu) { +const openMenuHandler = function () { + const collapseMenu = document.getElementById('openMenuToggle'); const menu = document.querySelector('.main-menu .links'); const openedClass = "opened"; + document.querySelectorAll('.dropdown-item-onclick.opened').forEach((element)=>element.classList.toggle('opened')); if (collapseMenu.className.indexOf(openedClass) == -1) { collapseMenu.className += ` ${openedClass}`; menu.className += ` d-b`; @@ -81,6 +83,7 @@ const openMenuHandler = function (collapseMenu) { menu.className = menu.className.replace(` d-b`, ""); } } +document.getElementById('openMenuToggle').addEventListener('click', () => openMenuHandler()); const allTags = el => { const tags = document.querySelector('.modules-right-tags_list'); @@ -92,6 +95,10 @@ const allTags = el => { tags.classList.add('opened'); } } +const allTagsElement = document.getElementById('all-tags'); +allTagsElement?.addEventListener('click',(e)=>{ + allTags(e.target); +}) let tm; const cl = document.querySelector('.copy-link.bi-link-45deg'); @@ -126,3 +133,15 @@ String.prototype.capitalize = function() { // remove all chars except alphanumeric, spaces and . , _ - const sanitizeString = str => str !== null ? str.replace(/[^a-z0-9\.\s,_-]/gim,"") : null; +const publishModalElement = document.querySelector('[data-modal="publishModal"]'); +publishModalElement.addEventListener('click', ()=>{ + const closeModal = (el) => el.closest('.modal').style.display = 'none'; + document.querySelectorAll('.close-modal-click').forEach(element => { + element.addEventListener('click', e=> closeModal(e.target)); + }) + document.querySelectorAll('.opened').forEach(element=>element.classList.toggle('opened')) + const menu = document.querySelector('.links.d-b'); + if (menu){ + menu.classList.toggle('d-b'); + } +}) \ No newline at end of file diff --git a/static/js/modules-list.js b/static/js/modules-list.js index 34ce8af..c171933 100644 --- a/static/js/modules-list.js +++ b/static/js/modules-list.js @@ -9,7 +9,25 @@ const sortOptions = { }; let sort = sortOptions.alphabetic; +const modulesList = function (query, tags = []) { + let ids = []; + modules = []; + if (query.length > 0) { + flexSearchIndex.search(query).forEach(item => ids.push(...item.result)); + [...new Set(ids)].map(key => { + modules.push(pagesIndex[key]) + }); + } else { + modules = Object.keys(pagesIndex).map(key => pagesIndex[key]); + } + if (tags.length > 0) { + // if we merge module tags and tags from the filter and unique array length will be the same as module tags length, + // then all filtered tags intersect with module tags + modules = modules.filter(item => [...new Set([...item.tags, ...tags])].length == (item.tags.length )) + } + return modules; +} // if sorting is selected from the dropdown then do not change it automatically const changeDefaultSorting = newSortOption => (getSearchParam('sort') == null) && (sort = newSortOption) @@ -76,18 +94,32 @@ const orderChanged = (e) => { document.querySelectorAll('.sort-by .dropdown-select_options div').forEach(item => item.addEventListener('click', orderChanged)) +const createTagElement = (tag, remove = false)=>{ + const li = document.createElement('li'); + const a = document.createElement('a'); + a.textContent = tag; + a.addEventListener('click',()=>remove ? removeTag(tag) : selectTag(tag)); + li.appendChild(a); + if (remove){ + const i = document.createElement('i'); + i.className = 'bi bi-x'; + li.appendChild(i); + } + return li; +} + document.addEventListener('TAGS_LOADED', function (e) { const selectedTags = getTags(); - let tagsHtml = ''; - tags.forEach(tag => tagsHtml += tag == 'Supported' ? '' : `- ${result.description} -
- -