|
|
@ -5,12 +5,9 @@
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 'maxNormalPages' is used for the maximum pages in normal mode
|
|
|
|
* 'maxNormalPages' is used for the maximum pages in normal mode
|
|
|
|
* 'maxSelectPages' is used for the selectbox mode
|
|
|
|
* 'maxSelectPages' is used for the selectbox mode
|
|
|
|
* 'maxInputPages' is used for the input mode,
|
|
|
|
|
|
|
|
* 'bootstrapTooltip' is used to display max input value for the input mode with bootstrap tooltip plugin
|
|
|
|
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @name Dynamic input,select or basic navigation
|
|
|
|
* @name Dynamic input,select list
|
|
|
|
*
|
|
|
|
* @summary Show a `dt-tag select` `dt-tag input` list of pages the user can pick from.
|
|
|
|
* @summary Show a `dt-tag select`,`dt-tag input` or basic navigation the user can use to navigate through the tables.
|
|
|
|
|
|
|
|
* @author Frank van Os
|
|
|
|
* @author Frank van Os
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* @example
|
|
|
@ -23,7 +20,6 @@
|
|
|
|
$.fn.dataTableExt.oPagination.dynamic_pagination = {
|
|
|
|
$.fn.dataTableExt.oPagination.dynamic_pagination = {
|
|
|
|
'maxNormalPages': 10,
|
|
|
|
'maxNormalPages': 10,
|
|
|
|
'maxSelectPages': 20,
|
|
|
|
'maxSelectPages': 20,
|
|
|
|
'maxInputPages': 50,
|
|
|
|
|
|
|
|
'bootstrapTooltip': false,
|
|
|
|
'bootstrapTooltip': false,
|
|
|
|
'fnClickHandler': function(e) {
|
|
|
|
'fnClickHandler': function(e) {
|
|
|
|
var fnCallbackDraw = e.data.fnCallbackDraw,
|
|
|
|
var fnCallbackDraw = e.data.fnCallbackDraw,
|
|
|
@ -84,20 +80,16 @@ $.fn.dataTableExt.oPagination.dynamic_pagination = {
|
|
|
|
function updatePage(element){
|
|
|
|
function updatePage(element){
|
|
|
|
if (element.val() === '' || element.val().match(/[^0-9]/)) {
|
|
|
|
if (element.val() === '' || element.val().match(/[^0-9]/)) {
|
|
|
|
/* Nothing entered or non-numeric character */
|
|
|
|
/* Nothing entered or non-numeric character */
|
|
|
|
element.val() = element.val().replace(/[^\d]/g, ''); // don't even allow anything but digits
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var iNewStart = oSettings._iDisplayLength * (element.val() - 1);
|
|
|
|
|
|
|
|
if (iNewStart > oSettings.fnRecordsDisplay()) { /* Display overrun */
|
|
|
|
var iNewStart = oSettings._iDisplayLength * (element.val() - 1);
|
|
|
|
oSettings._iDisplayStart = (Math.ceil((oSettings.fnRecordsDisplay() - 1) / oSettings._iDisplayLength) - 1) * oSettings._iDisplayLength;
|
|
|
|
if (iNewStart < 0) {
|
|
|
|
fnCallbackDraw(oSettings);
|
|
|
|
iNewStart = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (iNewStart >= oSettings.fnRecordsDisplay()) {
|
|
|
|
oSettings._iDisplayStart = iNewStart;
|
|
|
|
iNewStart = (Math.ceil((oSettings.fnRecordsDisplay() - 1) / oSettings._iDisplayLength) - 1) * oSettings._iDisplayLength;
|
|
|
|
fnCallbackDraw(oSettings);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
oSettings._iDisplayStart = iNewStart;
|
|
|
|
|
|
|
|
fnCallbackDraw(oSettings);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$(nInputText).keypress(function (e) {
|
|
|
|
$(nInputText).keypress(function (e) {
|
|
|
@ -135,7 +127,7 @@ $.fn.dataTableExt.oPagination.dynamic_pagination = {
|
|
|
|
var info = oSettings.aanFeatures.i;
|
|
|
|
var info = oSettings.aanFeatures.i;
|
|
|
|
var that = this;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0, iLen = paging.length; i < iLen; i++) {
|
|
|
|
for (var i = 0, iLen = paging.length; i < iLen; i++) {
|
|
|
|
|
|
|
|
|
|
|
|
if ( oSettings._iDisplayStart === 0 ){
|
|
|
|
if ( oSettings._iDisplayStart === 0 ){
|
|
|
|
$(paging).find('.first').attr('class',"paginate_button disabled first");
|
|
|
|
$(paging).find('.first').attr('class',"paginate_button disabled first");
|
|
|
@ -159,7 +151,7 @@ $.fn.dataTableExt.oPagination.dynamic_pagination = {
|
|
|
|
$(paging).hide();
|
|
|
|
$(paging).hide();
|
|
|
|
$(info).hide();
|
|
|
|
$(info).hide();
|
|
|
|
|
|
|
|
|
|
|
|
if(iPages < that.maxNormalPages){
|
|
|
|
if(iPages <= that.maxNormalPages){
|
|
|
|
$(paging).find('select,input').css('display','none');
|
|
|
|
$(paging).find('select,input').css('display','none');
|
|
|
|
|
|
|
|
|
|
|
|
// Erase
|
|
|
|
// Erase
|
|
|
@ -180,45 +172,44 @@ $.fn.dataTableExt.oPagination.dynamic_pagination = {
|
|
|
|
$(oNumber).appendTo('#'+oSettings.sTableId+'_pagination_controls');
|
|
|
|
$(oNumber).appendTo('#'+oSettings.sTableId+'_pagination_controls');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(iPages > that.maxSelectPages) {
|
|
|
|
else if(iPages > that.maxNormalPages && iPages <= that.maxSelectPages) {
|
|
|
|
|
|
|
|
|
|
|
|
// Erase
|
|
|
|
// Erase
|
|
|
|
$('#'+oSettings.sTableId+'_pagination_controls').find('a.paginate_button').remove();
|
|
|
|
$('#'+oSettings.sTableId+'_pagination_controls').find('a.paginate_button').remove();
|
|
|
|
|
|
|
|
|
|
|
|
var inputType = (iPages>that.maxInputPages) ? 'input' : 'select';
|
|
|
|
var input = $(paging).find('select');
|
|
|
|
var input = $(paging).find(inputType);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(input).css('display','inline');
|
|
|
|
input.css('display','inline');
|
|
|
|
|
|
|
|
|
|
|
|
if(oSettings._iDisplayStart === 0 && oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay()){
|
|
|
|
if(oSettings._iDisplayStart === 0 && oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay()){
|
|
|
|
$(input).attr('disabled','disabled').attr('class','form-control disabled');
|
|
|
|
input.attr('disabled','disabled').attr('class','form-control disabled');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
$(input)
|
|
|
|
input
|
|
|
|
.removeAttr('disabled','disabled')
|
|
|
|
.removeAttr('disabled','disabled')
|
|
|
|
.attr('class','form-control');
|
|
|
|
.attr('class','form-control');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(inputType=='select'){
|
|
|
|
input.empty();
|
|
|
|
$(input).empty();
|
|
|
|
for (var j = 0; j < iPages; j++) { //add the pages
|
|
|
|
for (var j = 0; j < iPages; j++) { //add the pages
|
|
|
|
input.append($('<option>', {value:j+1,text:j+1}));
|
|
|
|
$(input).append($('<option>', {value:j+1,text:j+1}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
input.val(iCurrentPage);
|
|
|
|
$(input).val(iCurrentPage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(paging).find('input').css('display','none');
|
|
|
|
$(paging).find('input').css('display','none');
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(inputType=='input'){
|
|
|
|
|
|
|
|
if(that.bootstrapTooltip){
|
|
|
|
|
|
|
|
$('.pagination > li > input').attr('data-title','Max. page number: '+iPages).tooltip({
|
|
|
|
|
|
|
|
container: '.pagination',
|
|
|
|
|
|
|
|
placement: 'top'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$(input).val(iCurrentPage);
|
|
|
|
|
|
|
|
$(paging).find('select').css('display','none');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(iPages > that.maxNormalPages && iPages > that.maxSelectPages){
|
|
|
|
|
|
|
|
var input = $(paging).find('input');
|
|
|
|
|
|
|
|
input.css('display','inline');
|
|
|
|
|
|
|
|
if(that.bootstrapTooltip){
|
|
|
|
|
|
|
|
$('.pagination > li > input').attr('data-title','Max. page number: '+iPages).tooltip({
|
|
|
|
|
|
|
|
container: '.pagination',
|
|
|
|
|
|
|
|
placement: 'top'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
input.val(iCurrentPage);
|
|
|
|
|
|
|
|
$(paging).find('select').css('display','none');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// When there are pages show pagination block and info block
|
|
|
|
// When there are pages show pagination block and info block
|
|
|
|
$(paging).show();
|
|
|
|
$(paging).show();
|
|
|
|