From 8be0ac497debd2a971471c3f01d571c31a2c2d61 Mon Sep 17 00:00:00 2001 From: Frank van Os Date: Mon, 25 Jan 2016 14:43:02 +0100 Subject: [PATCH] ADDED page based pagination --- pagination/dynamic_pagination.js | 227 +++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100644 pagination/dynamic_pagination.js diff --git a/pagination/dynamic_pagination.js b/pagination/dynamic_pagination.js new file mode 100644 index 0000000..62c5684 --- /dev/null +++ b/pagination/dynamic_pagination.js @@ -0,0 +1,227 @@ +/** + * This pagination plug-in provides multiple navigation types ( Select box, input, or basic navigation ) + * + * To set the limits: + * + * 'maxNormalPages' is used for the maximum pages in normal 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 + * + * @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 + * + * @example + * $(document).ready(function() { + * $('#example').dataTable( { + * "sPaginationType": "dynamic_pagination" + * } ); + * } ); + */ +$.fn.dataTableExt.oPagination.dynamic_pagination = { + 'maxNormalPages': 10, + 'maxSelectPages': 20, + 'maxInputPages': 50, + 'bootstrapTooltip': false, + 'fnClickHandler': function(e) { + var fnCallbackDraw = e.data.fnCallbackDraw, + oSettings = e.data.oSettings, + sPage = e.data.sPage; + + if ($(this).is(':disabled')) { + return false; + } + + oSettings.oApi._fnPageChange(oSettings, sPage); + fnCallbackDraw(oSettings); + + return true; + }, + /* + * Function: oPagination.dynamic_pagination.fnInit + * Purpose: Initalise dom elements required for pagination with listbox input + * Returns: - + * Inputs: object:oSettings - dataTables settings object + * node:nPaging - the DIV which contains this pagination control + * function:fnCallbackDraw - draw function which must be called on update + */ + "fnInit": function (oSettings, nPaging, fnCallbackDraw) { + + if (oSettings.sTableId !== '') { + $(nPaging).attr('id', oSettings.sTableId + '_paginate'); + } + + var oClasses = oSettings.oClasses, + oLang = oSettings.oLanguage.oPaginate; + + var PagingHolder = $('