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