1jQuery(document).ready(function() { 2 3 function createDataTables() { 4 //targeting table with class datatable 5 // add "aaSorting" to disable default sort 6 jQuery('table.datatable, div.field-name-field-data-table-csv table, div.datatable table.views-table').DataTable({ 7 aaSorting: [], 8 retrieve:true 9 }); 10 //508 compliance calls and set title attributes 11 jQuery('th').attr('scope', 'col'); 12 jQuery('td').removeAttr('tabindex'); 13 jQuery('tfoot').remove(); 14 jQuery('.sorting_asc').attr('title','This is a sortable column in a HTML data table that is sorted ascending.'); 15 jQuery('.sorting').attr('title','No sort applied to this column.'); 16 jQuery('.dataTables_filter').find('label').attr('for','datatables_search'); 17 jQuery('.dataTables_filter').find('input').attr('id','datatables_search'); 18 19 //this applies the default sort arrows to our datatable 20 jQuery('.datatable th:nth-child(n+1)').append("<img class='sort_arrow' src='/profiles/femad8_gov/themes/fema_uswds/images/icon_table_nosort.png' align='right' alt='No sort applied to this column.'>"); 21 22 //the binding event that fires when we sort on a column - 508 compliant version on img 23 jQuery('.sorting, .sorting_asc').bind('click keypress', function(e) { 24 var this_index = jQuery(this).index(); 25 jQuery('thead').each(function () { 26 jQuery('th', this).each(function () { 27 var td_index = jQuery(this).index(); 28 if (td_index != this_index) { 29 jQuery(this).find('.sort_arrow').remove(); 30 jQuery(this).append("<img class='sort_arrow' src='/profiles/femad8_gov/themes/fema_uswds/images/icon_table_nosort.png' align='right' alt='No sort applied to this column.'>"); 31 } 32 }) 33 }) 34 //we use aria-label to determine the state, ascending or descending 35 var aria_t = jQuery(this).attr('aria-label'); 36 aria_value = aria_t.split(':')[1]; 37 if (aria_value.toLowerCase().indexOf("ascending") >= 0) { 38 //we are switching state so provide the opposite 39 jQuery(this).attr('title', 'This is a sortable column in a HTML data table that is sorted descending.'); 40 jQuery(this).find('img').attr('src','/profiles/femad8_gov/themes/fema_uswds/images/icon_table_descending.png'); 41 jQuery(this).find('img').attr('alt','This column is sorted descending. Click to sort ascending.'); 42 } else { 43 jQuery(this).attr('title', 'This is a sortable column in a HTML data table that is sorted ascending.'); 44 jQuery(this).find('img').attr('src','/profiles/femad8_gov/themes/fema_uswds/images/icon_table_ascending.png'); 45 jQuery(this).find('img').attr('alt','This column is sorted ascending. Click to sort descending.'); 46 } 47 jQuery('td').removeAttr('tabindex'); 48 e.preventDefault(); 49 }) 50 51 } 52 53 // #1291 - Allow sort on Data Table CSV fields on custom site pages. 54 // Whenever there are Data Table CSV Fields in a table, make it sortable. 55 targetTable = jQuery('.field--name-field-data-table-csv .datatable').DataTable(); 56 if (targetTable) { 57 targetTable.order([0, 'desc']).draw(); 58 } 59});
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.