Update dataTables to version 1.10.4
This commit is contained in:
@@ -41,85 +41,6 @@ function viewport() {
|
||||
};
|
||||
}
|
||||
|
||||
/* Style pagination control */
|
||||
$.extend( $.fn.dataTableExt.oPagination, {
|
||||
"sportspress": {
|
||||
"fnInit": function( oSettings, nPaging, fnDraw ) {
|
||||
var oLang = oSettings.oLanguage.oPaginate;
|
||||
var fnClickHandler = function ( e ) {
|
||||
e.preventDefault();
|
||||
if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) {
|
||||
fnDraw( oSettings );
|
||||
}
|
||||
};
|
||||
|
||||
$(nPaging).addClass('pagination').append(
|
||||
'<table class="sp-data-table sp-pagination" role="navigation">'+
|
||||
'<tfoot><tr>' +
|
||||
'<td class="prev disabled"><a>« '+oLang.sPrevious+'</a></td>'+
|
||||
'<td class="next disabled"><a>'+oLang.sNext+' » </a></td>'+
|
||||
'</tr></tfoot>' +
|
||||
'</table>'
|
||||
);
|
||||
var els = $('td', nPaging);
|
||||
$(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler );
|
||||
$(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler );
|
||||
},
|
||||
|
||||
"fnUpdate": function ( oSettings, fnDraw ) {
|
||||
var iListLength = 5;
|
||||
var oPaging = oSettings.oInstance.fnPagingInfo();
|
||||
var an = oSettings.aanFeatures.p;
|
||||
var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);
|
||||
|
||||
if ( oPaging.iTotalPages < iListLength) {
|
||||
iStart = 1;
|
||||
iEnd = oPaging.iTotalPages;
|
||||
}
|
||||
else if ( oPaging.iPage <= iHalf ) {
|
||||
iStart = 1;
|
||||
iEnd = iListLength;
|
||||
} else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) {
|
||||
iStart = oPaging.iTotalPages - iListLength + 1;
|
||||
iEnd = oPaging.iTotalPages;
|
||||
} else {
|
||||
iStart = oPaging.iPage - iHalf + 1;
|
||||
iEnd = iStart + iListLength - 1;
|
||||
}
|
||||
|
||||
for ( i=0, iLen=an.length ; i<iLen ; i++ ) {
|
||||
// Remove the middle elements
|
||||
$('td:gt(0)', an[i]).filter(':not(:last)').remove();
|
||||
|
||||
// Add the new cells and their event handlers
|
||||
for ( j=iStart ; j<=iEnd ; j++ ) {
|
||||
sClass = (j==oPaging.iPage+1) ? 'class="active"' : '';
|
||||
$('<td '+sClass+'><a>'+j+'</a></td>')
|
||||
.insertBefore( $('td:last', an[i])[0] )
|
||||
.bind('click', function (e) {
|
||||
e.preventDefault();
|
||||
oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;
|
||||
fnDraw( oSettings );
|
||||
});
|
||||
}
|
||||
|
||||
// Add / remove disabled classes from the static elements
|
||||
if ( oPaging.iPage === 0 ) {
|
||||
$('td:first', an[i]).addClass("disabled");
|
||||
} else {
|
||||
$('td:first', an[i]).removeClass("disabled");
|
||||
}
|
||||
|
||||
if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) {
|
||||
$('td:last', an[i]).addClass("disabled");
|
||||
} else {
|
||||
$('td:last', an[i]).removeClass("disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
/* Data Tables */
|
||||
$(".sp-data-table").each(function() {
|
||||
sortable = viewport().width > 640 && $(this).hasClass("sp-sortable-table");
|
||||
@@ -129,32 +50,34 @@ function viewport() {
|
||||
if ( $(this).find("tbody tr").length <= display_length ) paginated = false;
|
||||
if ( sortable || paginated ) {
|
||||
$(this).dataTable({
|
||||
"aaSorting": [],
|
||||
"bAutoWidth": false,
|
||||
"bFilter": false,
|
||||
"bInfo": false,
|
||||
"bPaginate": paginated,
|
||||
"bLengthChange": false,
|
||||
"sPaginationType": "sportspress",
|
||||
"iDisplayLength": display_length,
|
||||
"bSort": sortable,
|
||||
"oLanguage": {
|
||||
"oAria": {
|
||||
"sSortAscending": "",
|
||||
"sSortDescending": ""
|
||||
"order": [],
|
||||
"autoWidth": false,
|
||||
"searching": false,
|
||||
"info": false,
|
||||
"paging": paginated,
|
||||
"lengthChange": false,
|
||||
"pagingType": "simple_numbers",
|
||||
"pageLength": display_length,
|
||||
"ordering": sortable,
|
||||
"language": {
|
||||
"aria": {
|
||||
"sortAscending": "",
|
||||
"sortDescending": ""
|
||||
},
|
||||
"oPaginate": {
|
||||
"sPrevious": localized_strings.previous,
|
||||
"sNext": localized_strings.next,
|
||||
"paginate": {
|
||||
"previous": localized_strings.previous,
|
||||
"next": localized_strings.next,
|
||||
}
|
||||
},
|
||||
"aoColumnDefs": [
|
||||
{ "sType": "numeric", "aTargets": [ ".data-number", ".data-rank" ] },
|
||||
"columnDefs": [
|
||||
{ "type": "num-fmt", "targets": [ ".data-number", ".data-rank" ] },
|
||||
]
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/* Scrollable Tables */
|
||||
$(".sp-scrollable-table").wrap("<div class=\"sp-scrollable-table-wrapper\"></div>");
|
||||
|
||||
/*
|
||||
* Responsive Tables
|
||||
|
||||
Reference in New Issue
Block a user