datatables.net-bs5
Advanced tools
Comparing version 1.13.10 to 2.0.0
@@ -46,3 +46,3 @@ /*! DataTables Bootstrap 5 integration | ||
} | ||
}(function( $, window, document, undefined ) { | ||
}(function( $, window, document ) { | ||
'use strict'; | ||
@@ -55,3 +55,3 @@ var DataTable = $.fn.dataTable; | ||
* DataTables integration for Bootstrap 5. This requires Bootstrap 5 and | ||
* DataTables 1.10 or newer. | ||
* DataTables 2 or newer. | ||
* | ||
@@ -65,6 +65,2 @@ * This file sets the defaults and adds options to DataTables to style its | ||
$.extend( true, DataTable.defaults, { | ||
dom: | ||
"<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" + | ||
"<'row dt-row'<'col-sm-12'tr>>" + | ||
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>", | ||
renderer: 'bootstrap' | ||
@@ -75,8 +71,13 @@ } ); | ||
/* Default class modification */ | ||
$.extend( DataTable.ext.classes, { | ||
sWrapper: "dataTables_wrapper dt-bootstrap5", | ||
sFilterInput: "form-control form-control-sm", | ||
sLengthSelect: "form-select form-select-sm", | ||
sProcessing: "dataTables_processing card", | ||
sPageButton: "paginate_button page-item" | ||
$.extend( true, DataTable.ext.classes, { | ||
container: "dt-container dt-bootstrap5", | ||
search: { | ||
input: "form-control form-control-sm" | ||
}, | ||
length: { | ||
select: "form-select form-select-sm" | ||
}, | ||
processing: { | ||
container: "dt-processing card" | ||
} | ||
} ); | ||
@@ -86,128 +87,63 @@ | ||
/* Bootstrap paging button renderer */ | ||
DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) { | ||
var api = new DataTable.Api( settings ); | ||
var classes = settings.oClasses; | ||
var lang = settings.oLanguage.oPaginate; | ||
var aria = settings.oLanguage.oAria.paginate || {}; | ||
var btnDisplay, btnClass; | ||
DataTable.ext.renderer.pagingButton.bootstrap = function (settings, buttonType, content, active, disabled) { | ||
var btnClasses = ['dt-paging-button', 'page-item']; | ||
var attach = function( container, buttons ) { | ||
var i, ien, node, button; | ||
var clickHandler = function ( e ) { | ||
e.preventDefault(); | ||
if ( !$(e.currentTarget).hasClass('disabled') && api.page() != e.data.action ) { | ||
api.page( e.data.action ).draw( 'page' ); | ||
} | ||
}; | ||
if (active) { | ||
btnClasses.push('active'); | ||
} | ||
for ( i=0, ien=buttons.length ; i<ien ; i++ ) { | ||
button = buttons[i]; | ||
if (disabled) { | ||
btnClasses.push('disabled') | ||
} | ||
if ( Array.isArray( button ) ) { | ||
attach( container, button ); | ||
} | ||
else { | ||
btnDisplay = ''; | ||
btnClass = ''; | ||
var li = $('<li>').addClass(btnClasses.join(' ')); | ||
var a = $('<a>', { | ||
'href': disabled ? null : '#', | ||
'class': 'page-link' | ||
}) | ||
.html(content) | ||
.appendTo(li); | ||
switch ( button ) { | ||
case 'ellipsis': | ||
btnDisplay = '…'; | ||
btnClass = 'disabled'; | ||
break; | ||
return { | ||
display: li, | ||
clicker: a | ||
}; | ||
}; | ||
case 'first': | ||
btnDisplay = lang.sFirst; | ||
btnClass = button + (page > 0 ? | ||
'' : ' disabled'); | ||
break; | ||
DataTable.ext.renderer.pagingContainer.bootstrap = function (settings, buttonEls) { | ||
return $('<ul/>').addClass('pagination').append(buttonEls); | ||
}; | ||
case 'previous': | ||
btnDisplay = lang.sPrevious; | ||
btnClass = button + (page > 0 ? | ||
'' : ' disabled'); | ||
break; | ||
DataTable.ext.renderer.layout.bootstrap = function ( settings, container, items ) { | ||
var row = $( '<div/>', { | ||
"class": items.full ? | ||
'row mt-2 justify-content-md-center' : | ||
'row mt-2 justify-content-between' | ||
} ) | ||
.appendTo( container ); | ||
case 'next': | ||
btnDisplay = lang.sNext; | ||
btnClass = button + (page < pages-1 ? | ||
'' : ' disabled'); | ||
break; | ||
$.each( items, function (key, val) { | ||
var klass; | ||
case 'last': | ||
btnDisplay = lang.sLast; | ||
btnClass = button + (page < pages-1 ? | ||
'' : ' disabled'); | ||
break; | ||
default: | ||
btnDisplay = button + 1; | ||
btnClass = page === button ? | ||
'active' : ''; | ||
break; | ||
} | ||
if ( btnDisplay ) { | ||
var disabled = btnClass.indexOf('disabled') !== -1; | ||
node = $('<li>', { | ||
'class': classes.sPageButton+' '+btnClass, | ||
'id': idx === 0 && typeof button === 'string' ? | ||
settings.sTableId +'_'+ button : | ||
null | ||
} ) | ||
.append( $('<a>', { | ||
'href': disabled ? null : '#', | ||
'aria-controls': settings.sTableId, | ||
'aria-disabled': disabled ? 'true' : null, | ||
'aria-label': aria[ button ], | ||
'role': 'link', | ||
'aria-current': btnClass === 'active' ? 'page' : null, | ||
'data-dt-idx': button, | ||
'tabindex': disabled ? -1 : settings.iTabIndex, | ||
'class': 'page-link' | ||
} ) | ||
.html( btnDisplay ) | ||
) | ||
.appendTo( container ); | ||
settings.oApi._fnBindAction( | ||
node, {action: button}, clickHandler | ||
); | ||
} | ||
} | ||
// Apply start / end (left / right when ltr) margins | ||
if (val.table) { | ||
klass = 'col-12'; | ||
} | ||
}; | ||
else if (key === 'start') { | ||
klass = 'col-md-auto me-auto'; | ||
} | ||
else if (key === 'end') { | ||
klass = 'col-md-auto ms-auto'; | ||
} | ||
else { | ||
klass = 'col-md'; | ||
} | ||
var hostEl = $(host); | ||
// IE9 throws an 'unknown error' if document.activeElement is used | ||
// inside an iframe or frame. | ||
var activeEl; | ||
try { | ||
// Because this approach is destroying and recreating the paging | ||
// elements, focus is lost on the select button which is bad for | ||
// accessibility. So we want to restore focus once the draw has | ||
// completed | ||
activeEl = hostEl.find(document.activeElement).data('dt-idx'); | ||
} | ||
catch (e) {} | ||
var paginationEl = hostEl.children('ul.pagination'); | ||
if (paginationEl.length) { | ||
paginationEl.empty(); | ||
} | ||
else { | ||
paginationEl = hostEl.html('<ul/>').children('ul').addClass('pagination'); | ||
} | ||
attach( | ||
paginationEl, | ||
buttons | ||
); | ||
if ( activeEl !== undefined ) { | ||
hostEl.find('[data-dt-idx='+activeEl+']').trigger('focus'); | ||
} | ||
$( '<div/>', { | ||
id: val.id || null, | ||
"class": klass + ' ' + (val.className || '') | ||
} ) | ||
.append( val.contents ) | ||
.appendTo( row ); | ||
} ); | ||
}; | ||
@@ -214,0 +150,0 @@ |
/*! DataTables Bootstrap 5 integration | ||
* 2020 SpryMedia Ltd - datatables.net/license | ||
*/ | ||
!function(t){var n,r;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return t(e,window,document)}):"object"==typeof exports?(n=require("jquery"),r=function(e,a){a.fn.dataTable||require("datatables.net")(e,a)},"undefined"==typeof window?module.exports=function(e,a){return e=e||window,a=a||n(e),r(e,a),t(a,0,e.document)}:(r(window,n),module.exports=t(n,window,window.document))):t(jQuery,window,document)}(function(x,e,r,o){"use strict";var i=x.fn.dataTable;return x.extend(!0,i.defaults,{dom:"<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>><'row dt-row'<'col-sm-12'tr>><'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",renderer:"bootstrap"}),x.extend(i.ext.classes,{sWrapper:"dataTables_wrapper dt-bootstrap5",sFilterInput:"form-control form-control-sm",sLengthSelect:"form-select form-select-sm",sProcessing:"dataTables_processing card",sPageButton:"paginate_button page-item"}),i.ext.renderer.pageButton.bootstrap=function(d,e,s,a,l,c){function u(e,a){for(var t,n,r=function(e){e.preventDefault(),x(e.currentTarget).hasClass("disabled")||b.page()==e.data.action||b.page(e.data.action).draw("page")},o=0,i=a.length;o<i;o++)if(t=a[o],Array.isArray(t))u(e,t);else{switch(f=p="",t){case"ellipsis":p="…",f="disabled";break;case"first":p=g.sFirst,f=t+(0<l?"":" disabled");break;case"previous":p=g.sPrevious,f=t+(0<l?"":" disabled");break;case"next":p=g.sNext,f=t+(l<c-1?"":" disabled");break;case"last":p=g.sLast,f=t+(l<c-1?"":" disabled");break;default:p=t+1,f=l===t?"active":""}p&&(n=-1!==f.indexOf("disabled"),n=x("<li>",{class:m.sPageButton+" "+f,id:0===s&&"string"==typeof t?d.sTableId+"_"+t:null}).append(x("<a>",{href:n?null:"#","aria-controls":d.sTableId,"aria-disabled":n?"true":null,"aria-label":w[t],role:"link","aria-current":"active"===f?"page":null,"data-dt-idx":t,tabindex:n?-1:d.iTabIndex,class:"page-link"}).html(p)).appendTo(e),d.oApi._fnBindAction(n,{action:t},r))}}var p,f,t,b=new i.Api(d),m=d.oClasses,g=d.oLanguage.oPaginate,w=d.oLanguage.oAria.paginate||{},e=x(e);try{t=e.find(r.activeElement).data("dt-idx")}catch(e){}var n=e.children("ul.pagination");n.length?n.empty():n=e.html("<ul/>").children("ul").addClass("pagination"),u(n,a),t!==o&&e.find("[data-dt-idx="+t+"]").trigger("focus")},i}); | ||
!function(n){var o,a;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return n(e,window,document)}):"object"==typeof exports?(o=require("jquery"),a=function(e,t){t.fn.dataTable||require("datatables.net")(e,t)},"undefined"==typeof window?module.exports=function(e,t){return e=e||window,t=t||o(e),a(e,t),n(t,0,e.document)}:(a(window,o),module.exports=n(o,window,window.document))):n(jQuery,window,document)}(function(d,e,t){"use strict";var n=d.fn.dataTable;return d.extend(!0,n.defaults,{renderer:"bootstrap"}),d.extend(!0,n.ext.classes,{container:"dt-container dt-bootstrap5",search:{input:"form-control form-control-sm"},length:{select:"form-select form-select-sm"},processing:{container:"dt-processing card"}}),n.ext.renderer.pagingButton.bootstrap=function(e,t,n,o,a){var r=["dt-paging-button","page-item"],o=(o&&r.push("active"),a&&r.push("disabled"),d("<li>").addClass(r.join(" ")));return{display:o,clicker:d("<a>",{href:a?null:"#",class:"page-link"}).html(n).appendTo(o)}},n.ext.renderer.pagingContainer.bootstrap=function(e,t){return d("<ul/>").addClass("pagination").append(t)},n.ext.renderer.layout.bootstrap=function(e,t,n){var o=d("<div/>",{class:n.full?"row mt-2 justify-content-md-center":"row mt-2 justify-content-between"}).appendTo(t);d.each(n,function(e,t){e=t.table?"col-12":"start"===e?"col-md-auto me-auto":"end"===e?"col-md-auto ms-auto":"col-md";d("<div/>",{id:t.id||null,class:e+" "+(t.className||"")}).append(t.contents).appendTo(o)})},n}); |
@@ -8,3 +8,3 @@ { | ||
"types": "./types/dataTables.bootstrap5.d.ts", | ||
"version": "1.13.10", | ||
"version": "2.0.0", | ||
"files": [ | ||
@@ -14,4 +14,3 @@ "css/**/*.css", | ||
"js/**/*.mjs", | ||
"types/**/*.d.ts", | ||
"images/*" | ||
"types/**/*.d.ts" | ||
], | ||
@@ -28,3 +27,3 @@ "keywords": [ | ||
"dependencies": { | ||
"datatables.net": "1.13.8", | ||
"datatables.net": "2.0.0", | ||
"jquery": ">=1.7" | ||
@@ -31,0 +30,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
42095
10
740
+ Addeddatatables.net@2.0.0(transitive)
- Removeddatatables.net@1.13.8(transitive)
Updateddatatables.net@2.0.0