14
if ( typeof define === 'function' && define.amd ) {
16
define( ['jquery', 'datatables.net'], function ( $ ) {
17
return factory( $, window, document );
20
else if ( typeof exports === 'object' ) {
22
module.exports = function (root, $) {
27
if ( ! $ || ! $.fn.dataTable ) {
31
$ = require('datatables.net')(root, $).$;
34
return factory( $, root, root.document );
39
factory( jQuery, window, document );
41
}(function( $, window, document, undefined ) {
43
var DataTable = $.fn.dataTable;
47
$.extend( true, DataTable.defaults, {
49
"<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" +
50
"<'row'<'col-sm-12'tr>>" +
51
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
57
$.extend( DataTable.ext.classes, {
58
sWrapper: "dataTables_wrapper dt-bootstrap4",
59
sFilterInput: "form-control form-control-sm",
60
sLengthSelect: "custom-select custom-select-sm form-control form-control-sm",
61
sProcessing: "dataTables_processing card",
62
sPageButton: "paginate_button page-item"
67
DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) {
68
var api = new DataTable.Api( settings );
69
var classes = settings.oClasses;
70
var lang = settings.oLanguage.oPaginate;
71
var aria = settings.oLanguage.oAria.paginate || {};
72
var btnDisplay, btnClass, counter=0;
74
var attach = function( container, buttons ) {
75
var i, ien, node, button;
76
var clickHandler = function ( e ) {
78
if ( !$(e.currentTarget).hasClass('disabled') && api.page() != e.data.action ) {
79
api.page( e.data.action ).draw( 'page' );
83
for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
86
if ( Array.isArray( button ) ) {
87
attach( container, button );
95
btnDisplay = '…';
96
btnClass = 'disabled';
100
btnDisplay = lang.sFirst;
101
btnClass = button + (page > 0 ?
106
btnDisplay = lang.sPrevious;
107
btnClass = button + (page > 0 ?
112
btnDisplay = lang.sNext;
113
btnClass = button + (page < pages-1 ?
118
btnDisplay = lang.sLast;
119
btnClass = button + (page < pages-1 ?
124
btnDisplay = button + 1;
125
btnClass = page === button ?
132
'class': classes.sPageButton+' '+btnClass,
133
'id': idx === 0 && typeof button === 'string' ?
134
settings.sTableId +'_'+ button :
139
'aria-controls': settings.sTableId,
140
'aria-label': aria[ button ],
141
'data-dt-idx': counter,
142
'tabindex': settings.iTabIndex,
147
.appendTo( container );
149
settings.oApi._fnBindAction(
150
node, {action: button}, clickHandler
168
activeEl = $(host).find(document.activeElement).data('dt-idx');
173
$(host).empty().html('<ul class="pagination"/>').children('ul'),
177
if ( activeEl !== undefined ) {
178
$(host).find( '[data-dt-idx='+activeEl+']' ).trigger('focus');