Skip to content

Commit

Permalink
Merge pull request #6496 from fecgov/feature/6493-add-a11y-modal-to-i…
Browse files Browse the repository at this point in the history
…nit-js

Add a11y modal dialog to global.js
  • Loading branch information
patphongs authored Oct 8, 2024
2 parents 06a7221 + 0ceb031 commit b80281c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
12 changes: 1 addition & 11 deletions fec/fec/static/js/data-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Implementing a polyfill for js native WeakMap
// in order to patch functionality in an included library
// require('es6-weak-map/implement');
import { default as A11yDialog } from 'a11y-dialog';

import { Accordion } from 'aria-accordion/src/accordion.js';
import { default as Sticky } from 'component-sticky/index.js';

Expand Down Expand Up @@ -69,16 +69,6 @@ $(function() {
new Search($(this));
});

$('.js-modal').each(function() {
new A11yDialog(this);
this.addEventListener('dialog:show', function() {
$('body').css('overflow', 'hidden');
});
this.addEventListener('dialog:hide', function() {
$('body').css('overflow', 'scroll');
});
});

// Initialize cycle selects
$('.js-cycle').each(function(idx, elm) {
CycleSelect.build($(elm));
Expand Down
11 changes: 11 additions & 0 deletions fec/fec/static/js/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import Glossary from 'glossary-panel/src/glossary.js';

import { default as A11yDialog } from 'a11y-dialog';
import { default as terms } from './data/terms.json' assert { type: 'json' };
import Feedback from './modules/feedback.js';
import SiteNav from './modules/site-nav.js';
Expand Down Expand Up @@ -56,4 +57,14 @@ $(function() {
window.submitFeedback = function(token) {
feedbackWidget.submit(token);
};

$('.js-modal').each(function() {
new A11yDialog(this);
this.addEventListener('dialog:show', function() {
$('body').css('overflow', 'hidden');
});
this.addEventListener('dialog:hide', function() {
$('body').css('overflow', 'scroll');
});
});
});
2 changes: 2 additions & 0 deletions fec/fec/static/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* If present, this file initializes…
* .js-accordion, .js-dropdown, .js-form-nav, .js-post-content, .js-scroll, .js-sticky-side
*/

import { Accordion } from 'aria-accordion/src/accordion.js';
import { default as Sticky } from 'component-sticky/index.js';

Expand Down Expand Up @@ -74,3 +75,4 @@ $(function() {
$p.nextAll().remove();
});
});

1 change: 0 additions & 1 deletion fec/home/templates/home/full_width_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,5 @@ <h4 class="sidebar__title">Legal citations</h4>

{% block extra_js %}
<script> window.BASE_PATH = '/data' </script>
{% tags_for_js_chunks 'data-init.js' '' %}
{% tags_for_js_chunks 'reporting-dates-tables.js' '' %}
{% endblock %}

0 comments on commit b80281c

Please sign in to comment.