1/*! DataTables Bootstrap 5 integration 2 * 2020 SpryMedia Ltd - datatables.net/license 3 */ 4 5(function( factory ){ 6 if ( typeof define === 'function' && define.amd ) { 7 // AMD 8 define( ['jquery', 'datatables.net'], function ( $ ) { 9 return factory( $, window, document ); 10 } ); 11 } 12 else if ( typeof exports === 'object' ) { 13 // CommonJS 14 module.exports = function (root, $) { 15 if ( ! root ) { 16 // CommonJS environments without a window global must pass a 17 // root. This will give an error otherwise 18 root = window; 19 } 20 21 if ( ! $ ) { 22 $ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window 23 require('jquery') : 24 require('jquery')( root ); 25 } 26 27 if ( ! $.fn.dataTable ) { 28 require('datatables.net')(root, $); 29 } 30 31 return factory( $, root, root.document ); 32 }; 33 } 34 else { 35 // Browser 36 factory( jQuery, window, document ); 37 } 38}(function( $, window, document, undefined ) { 39'use strict'; 40var DataTable = $.fn.dataTable; 41 42 43 44/** 45 * DataTables integration for Bootstrap 5. This requires Bootstrap 5 and 46 * DataTables 1.10 or newer. 47 * 48 * This file sets the defaults and adds options to DataTables to style its 49 * controls using Bootstrap. See http://datatables.net/manual/styling/bootstrap 50 * for further information. 51 */ 52 53/* Set the defaults for DataTables initialisation */ 54$.extend( true, DataTable.defaults, { 55 dom: 56 "<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" + 57 "<'row dt-row'<'col-sm-12'tr>>" + 58 "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>", 59 renderer: 'bootstrap' 60} ); 61 62 63/* Default class modification */ 64$.extend( DataTable.ext.classes, { 65 sWrapper: "dataTables_wrapper dt-bootstrap5", 66 sFilterInput: "form-control form-control-sm", 67 sLengthSelect: "form-select form-select-sm", 68 sProcessing: "dataTables_processing card", 69 sPageButton: "paginate_button page-item" 70} ); 71 72 73/* Bootstrap paging button renderer */ 74DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) { 75 var api = new DataTable.Api( settings ); 76 var classes = settings.oClasses; 77 var lang = settings.oLanguage.oPaginate; 78 var aria = settings.oLanguage.oAria.paginate || {}; 79 var btnDisplay, btnClass; 80 81 var attach = function( container, buttons ) { 82 var i, ien, node, button; 83 var clickHandler = function ( e ) { 84 e.preventDefault(); 85 if ( !$(e.currentTarget).hasClass('disabled') && api.page() != e.data.action ) { 86 api.page( e.data.action ).draw( 'page' ); 87 } 88 }; 89 90 for ( i=0, ien=buttons.length ; i<ien ; i++ ) { 91 button = buttons[i]; 92 93 if ( Array.isArray( button ) ) { 94 attach( container, button ); 95 } 96 else { 97 btnDisplay = ''; 98 btnClass = ''; 99 100 switch ( button ) { 101 case 'ellipsis': 102 btnDisplay = '…'; 103 btnClass = 'disabled'; 104 break; 105 106 case 'first': 107 btnDisplay = lang.sFirst; 108 btnClass = button + (page > 0 ? 109 '' : ' disabled'); 110 break; 111 112 case 'previous': 113 btnDisplay = lang.sPrevious; 114 btnClass = button + (page > 0 ? 115 '' : ' disabled'); 116 break; 117 118 case 'next': 119 btnDisplay = lang.sNext; 120 btnClass = button + (page < pages-1 ? 121 '' : ' disabled'); 122 break; 123 124 case 'last': 125 btnDisplay = lang.sLast; 126 btnClass = button + (page < pages-1 ? 127 '' : ' disabled'); 128 break; 129 130 default: 131 btnDisplay = button + 1; 132 btnClass = page === button ? 133 'active' : ''; 134 break; 135 } 136 137 if ( btnDisplay ) { 138 var disabled = btnClass.indexOf('disabled') !== -1; 139 140 node = $('<li>', { 141 'class': classes.sPageButton+' '+btnClass, 142 'id': idx === 0 && typeof button === 'string' ? 143 settings.sTableId +'_'+ button : 144 null 145 } ) 146 .append( $('<a>', { 147 'href': disabled ? null : '#', 148 'aria-controls': settings.sTableId, 149 'aria-disabled': disabled ? 'true' : null, 150 'aria-label': aria[ button ], 151 'aria-role': 'link', 152 'aria-current': btnClass === 'active' ? 'page' : null, 153 'data-dt-idx': button, 154 'tabindex': settings.iTabIndex, 155 'class': 'page-link' 156 } ) 157 .html( btnDisplay ) 158 ) 159 .appendTo( container ); 160 161 settings.oApi._fnBindAction( 162 node, {action: button}, clickHandler 163 ); 164 } 165 } 166 } 167 }; 168 169 var hostEl = $(host); 170 // IE9 throws an 'unknown error' if document.activeElement is used 171 // inside an iframe or frame. 172 var activeEl; 173 174 try { 175 // Because this approach is destroying and recreating the paging 176 // elements, focus is lost on the select button which is bad for 177 // accessibility. So we want to restore focus once the draw has 178 // completed 179 activeEl = hostEl.find(document.activeElement).data('dt-idx'); 180 } 181 catch (e) {} 182 183 var paginationEl = hostEl.children('ul.pagination'); 184 185 if (paginationEl.length) { 186 paginationEl.empty(); 187 } 188 else { 189 paginationEl = hostEl.html('<ul/>').children('ul').addClass('pagination'); 190 } 191 192 attach( 193 paginationEl, 194 buttons 195 ); 196 197 if ( activeEl !== undefined ) { 198 hostEl.find('[data-dt-idx='+activeEl+']').trigger('focus'); 199 } 200}; 201 202 203return DataTable; 204}));
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.