Merge pull request #392 from fred104/master

Use template to generate pagination info
pull/397/head
Allan Jardine 6 years ago committed by GitHub
commit 47eb88cc28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -54,9 +54,9 @@
var lastClassName = 'last';
var paginateClassName = 'paginate';
var paginateOfClassName = 'paginate_of';
var paginatePageClassName = 'paginate_page';
var paginateInputClassName = 'paginate_input';
var paginateTotalClassName = 'paginate_total';
$.fn.dataTableExt.oPagination.input = {
'fnInit': function (oSettings, nPaging, fnCallbackDraw) {
@ -65,11 +65,12 @@
var nNext = document.createElement('span');
var nLast = document.createElement('span');
var nInput = document.createElement('input');
var nPage = document.createElement('span');
var nOf = document.createElement('span');
var nTotal = document.createElement('span');
var nInfo = document.createElement('span');
var language = oSettings.oLanguage.oPaginate;
var classes = oSettings.oClasses;
var info = language.info || 'Page _INPUT_ of _TOTAL_';
nFirst.innerHTML = language.sFirst;
nPrevious.innerHTML = language.sPrevious;
@ -81,9 +82,8 @@
nNext.className = nextClassName + ' ' + classes.sPageButton;
nLast.className = lastClassName + ' ' + classes.sPageButton;
nOf.className = paginateOfClassName;
nPage.className = paginatePageClassName;
nInput.className = paginateInputClassName;
nTotal.className = paginateTotalClassName;
if (oSettings.sTableId !== '') {
nPaging.setAttribute('id', oSettings.sTableId + '_' + paginateClassName);
@ -94,13 +94,16 @@
}
nInput.type = 'text';
nPage.innerHTML = 'Page ';
info = info.replace(/_INPUT_/g, '</span>' + nInput.outerHTML + '<span>');
info = info.replace(/_TOTAL_/g, '</span>' + nTotal.outerHTML + '<span>');
nInfo.innerHTML = '<span>' + info + '</span>';
nPaging.appendChild(nFirst);
nPaging.appendChild(nPrevious);
nPaging.appendChild(nPage);
nPaging.appendChild(nInput);
nPaging.appendChild(nOf);
$(nInfo).children().each(function (i, n) {
nPaging.appendChild(n);
});
nPaging.appendChild(nNext);
nPaging.appendChild(nLast);
@ -136,7 +139,7 @@
}
});
$(nInput).keyup(function (e) {
$(nPaging).find('.' + paginateInputClassName).keyup(function (e) {
// 38 = up arrow, 39 = right arrow
if (e.which === 38 || e.which === 39) {
this.value++;
@ -215,10 +218,10 @@
.addClass(disableClasses[lastClassName]);
// Paginate of N pages text
$(an).children('.' + paginateOfClassName).html(' of ' + iPages);
$(an).find('.' + paginateTotalClassName).html(iPages);
// Current page numer input value
$(an).children('.' + paginateInputClassName).val(iCurrentPage);
// Current page number input value
$(an).find('.' + paginateInputClassName).val(iCurrentPage);
}
};
})(jQuery);

Loading…
Cancel
Save