Skip to content

Commit

Permalink
Added a potentiall js solution for modal issue
Browse files Browse the repository at this point in the history
  • Loading branch information
natashapl committed Oct 21, 2024
1 parent c543950 commit ed06e32
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 3 deletions.
38 changes: 36 additions & 2 deletions _data/assetPaths.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,44 @@
"sourcesanspro-regular-webfont.woff2": "/assets/assets/sourcesanspro-regular-webfont-TJXUUIWO.woff2",
"unfold_more.svg": "/assets/assets/unfold_more-WL443JWS.svg",
"warning.svg": "/assets/assets/warning-5OR6W6GJ.svg",
"merriweathe": "/assets/fonts/merriweather",
"public": "/assets/fonts/public-sans",
"roboto": "/assets/fonts/roboto-mono",
"source-sans": "/assets/fonts/source-sans-pro",
"bm.svg": "/assets/images/bm-logo.svg",
"bm-small.svg": "/assets/images/bm-small-logo.svg",
"build.webp": "/assets/images/build-icon.webp",
"code.png": "/assets/images/codes.png",
"code.svg": "/assets/images/codes.svg",
"consistency.webp": "/assets/images/consistency-icon.webp",
"cost-effective.webp": "/assets/images/cost-effective-icon.webp",
"disaster.png": "/assets/images/disaster-info.png",
"experts.webp": "/assets/images/experts-lg.webp",
"expert.png": "/assets/images/experts.png",
"expert.svg": "/assets/images/experts.svg",
"help.svg": "/assets/images/help-icon.svg",
"help.webp": "/assets/images/help-icon.webp",
"her.jpg": "/assets/images/hero.jpg",
"her.png": "/assets/images/hero.png",
"her.webp": "/assets/images/hero.webp",
"hire.jpg": "/assets/images/hire-us.jpg",
"inspection.png": "/assets/images/inspections.png",
"inspection.svg": "/assets/images/inspections.svg",
"locatio.png": "/assets/images/location.png",
"logo.png": "/assets/images/logo-img.png",
"rapid-response.webp": "/assets/images/rapid-response-icon.webp",
"recover.png": "/assets/images/recovery.png",
"recover.svg": "/assets/images/recovery.svg",
"reduce-strain.webp": "/assets/images/reduce-strain-icon.webp",
"state": "/assets/images/states",
"upload": "/assets/images/uploads",
"admin.js": "/assets/js/admin-TRAB3TNM.js",
"admin.map": "/assets/js/admin-TRAB3TNM.js.map",
"app.js": "/assets/js/app-PHNK6WN2.js",
"app.map": "/assets/js/app-PHNK6WN2.js.map",
"index.css": "/assets/styles/index-TYS4KVMU.css",
"index.map": "/assets/styles/index-TYS4KVMU.css.map"
"uswds.js": "/assets/js/uswds-init.js",
"fema_mabd-region-8-fact.pdf": "/assets/pdf/fema_mabd-region-8-fact-sheet_2023.pdf",
"index.css": "/assets/styles/index-FVARWSJX.css",
"index.map": "/assets/styles/index-FVARWSJX.css.map",
"im": "/assets/uswds/img"
}
10 changes: 9 additions & 1 deletion _includes/disclaimer.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,12 @@ <h2 class="usa-modal__heading font-family-sans" id="modal-1-heading">
</svg>
</button>
</div>
</div>
</div>
{% capture modalFixJs %}
{% include "_includes/theme/js/modalFix.js" %}
{% endcapture %}

<script>
// Modal Fix
{{ modalFixJs | jsmin }}
</script>
44 changes: 44 additions & 0 deletions _includes/theme/js/modalFix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
(function() {
const modal=document.querySelector('#disclaimer-modal-1');
let overlay=document.getElementsByClassName("usa-modal-overlay");
const bodyContent = document.querySelector('.usa-app');
const nonModals = document.querySelectorAll('body > *:not(.usa-modal-wrapper)');
const openButton=document.querySelector('[data-open-modal]');

// Function to add inert attribute when modal is open
const addInert=() => {
nonModals.forEach(el => {
el.setAttribute('inert','true');
});
};

// Function to remove inert attribute when modal is closed
const removeInert=() => {
document.querySelectorAll('[inert]').forEach(el => {
el.removeAttribute('inert');
});
};

//openButton.addEventListener('click',addInert);

openButton.addEventListener('click',function(event) {
addInert();
});

// Listen for the closing event
modal.addEventListener('click',function(event) {
if(!modal.classList.contains('is-visible')) {
removeInert();
}
});

window.addEventListener('load',(event) => {
overlay[0].addEventListener('click',function(event) {
removeInert();
});

openButton.addEventListener('click',function(event) {
bodyContent.removeAttribute('aria-hidden');
});
});
})();

0 comments on commit ed06e32

Please sign in to comment.