1/** 2 * openModal 3 * Opens a modal window. 4 * 5 * @param {*} modal 6 * @returns {void} 7 */ 8function openModal(modal) { 9 if (modal.dataset.modal.length > 0) { 10 document.querySelectorAll('.modal[data-modal="' + modal.dataset.modal + '"]').forEach((modal) => { 11 modal.classList.add("is-active"); 12 document.querySelector(".modal-container").classList.add("is-active"); 13 document.querySelector(".modal-container").appendChild(modal); 14 document.getElementById("tx-indexedsearch-searchbox-sword-bar").focus(); 15 }); 16 return; 17 } 18} 19 20/** 21 * closeModal 22 * Closes a modal window. 23 * 24 * @param {*} modal 25 * @returns {void} 26 */ 27function closeModal(modal) { 28 document.querySelectorAll('.modal[data-modal="' + modal + '"]').forEach((modal) => { 29 modal.classList.remove("is-active"); 30 document.querySelector(".modal-container").classList.remove("is-active"); 31 document.getElementById("search__toggle").focus(); 32 }); 33} 34 35document.addEventListener("keydown", function (event) { 36 if (document.getElementById("search-modal").classList.contains("is-active")) { 37 if (event.key === "Escape") { 38 closeModal("search-modal"); 39 } 40 } 41}); 42 43/** 44 * addModalContainer 45 * create a div element with class modal-container 46 * 47 */ 48function addModalContainer() { 49 const modalContainer = document.createElement("div"); 50 modalContainer.classList.add("modal-container"); 51 document.body.insertBefore(modalContainer, document.body.lastChild); 52} 53 54addModalContainer();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.