PageSourceSearch

https://cafemom.com/wp-content/plugins/facetwp/assets/js/src/accessibility.js?ver=4.3.3

js cafemom.com collected 2026-10-01 10:12:02 UTC 3,941 bytes, 105 lines download raw bytes

1(function($) {
2    var last_checked = null;
3
4    if ('undefined' !== typeof FWP.hooks) {
5        FWP.hooks.addAction('facetwp/loaded', function() {
6
7            // checkbox, radio, fselect
8            $('.facetwp-checkbox, .facetwp-radio, .fs-option').each(function() {
9                let $el = $(this);
10                if (! $el.hasClass('disabled')) {
11                    $el.attr('role', 'checkbox');
12                    $el.attr('aria-checked', $el.hasClass('checked') ? 'true' : 'false');
13                    $el.attr('aria-label', $el.text());
14                    $el.attr('tabindex', 0);
15                }
16            });
17
18            // pager, show more, user selections, hierarchy
19            $('.facetwp-page, .facetwp-toggle, .facetwp-selection-value, .facetwp-link').each(function() {
20                let $el = $(this);
21                let label = $el.text();
22
23                if ($el.hasClass('facetwp-page')) {
24                    label = FWP_JSON.a11y.label_page + ' ' + label;
25
26                    if ($el.hasClass('next')) {
27                        label = FWP_JSON.a11y.label_page_next;
28                    }
29                    else if ($el.hasClass('prev')) {
30                        label = FWP_JSON.a11y.label_page_prev;
31                    }
32                }
33
34                $el.attr('role', 'link');
35                $el.attr('aria-label', label);
36                $el.attr('tabindex', 0);
37            });
38
39            // dropdown, sort facet, old sort feature
40            $('.facetwp-type-dropdown select, .facetwp-type-sort select, .facetwp-sort-select select').each(function() {
41                $(this).attr('aria-label', $(this).find('option:selected').text());
42            });
43
44            // search, date, number range
45            $('.facetwp-search, .facetwp-date, .facetwp-number').each(function() {
46                $(this).attr('aria-label', $(this).attr('placeholder'));
47            });
48
49            // checkbox group
50            $('.facetwp-type-checkboxes').each(function() {
51                let facet_name = $(this).attr('data-name');
52                $(this).attr('aria-label', FWP.settings.labels[facet_name]);
53                $(this).attr('role', 'group');
54            });
55
56            // fselect
57            $('.fs-wrap').each(function() {
58                $(this).attr('role', 'button');
59                $(this).attr('aria-haspopup', 'true');
60                $(this).attr('aria-expanded', $(this).hasClass('fs-open') ? 'true' : 'false');
61                $(this).attr('aria-label', $(this).find('.fs-label').html());
62            });
63
64            $('.facetwp-type-fselect .facetwp-dropdown').attr('aria-hidden', 'true');
65
66            // pager
67            $('.facetwp-pager').attr('role', 'navigation');
68            $('.facetwp-page.active').attr('aria-current', 'true');
69
70            // focus on selection
71            if (null != last_checked) {
72                var $el = $('.facetwp-facet [data-value="' + last_checked + '"]');
73                if ($el.len()) {
74                    $el.nodes[0].focus();
75                }
76                last_checked = null;
77            }
78        }, 999);
79    }
80
81    // keyboard support
82    $().on('keydown', '.facetwp-checkbox, .facetwp-radio, .facetwp-link', function(e) {
83        if (32 == e.keyCode || 13 == e.keyCode) {
84            last_checked = $(this).attr('data-value');
85            e.preventDefault();
86            this.click();
87        }
88    });
89
90    $().on('keydown', '.facetwp-page, .facetwp-toggle, .facetwp-selection-value', function(e) {
91        if (32 == e.keyCode || 13 == e.keyCode) {
92            e.preventDefault();
93            this.click();
94        }
95    });
96
97    // fselect - determine "aria-expanded"
98    function toggleExpanded(e) {
99        var $fs = $(e.detail[0]);
100        $fs.attr('aria-expanded', $fs.hasClass('fs-open') ? 'true' : 'false');
101    }
102
103    $().on('fs:opened', toggleExpanded);
104    $().on('fs:closed', toggleExpanded);
105})(fUtil);

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.