diff --git a/pagination/bootstrap_input.js b/pagination/bootstrap_input.js new file mode 100644 index 0000000..abbe683 --- /dev/null +++ b/pagination/bootstrap_input.js @@ -0,0 +1,42 @@ +/** + * Plug-in offers the same functionality as `default` pagination type + * (see `pagingType` option) but with input field for jumping pages, for use with bootstrap theme. + * + * @example + * $(document).ready(function() { + * $('#example').dataTable( { + * "pagingType": "bootstrap_input" + * } ); + * } ); + */ + +$.fn.DataTable.ext.pager.bootstrap_input = function (page, pages) { + return ['first', 'previous', 'input', 'next', 'last']; +}; + + +main_pageButtonFunc = $.fn.DataTable.ext.renderer.pageButton.bootstrap + +$.fn.DataTable.ext.renderer.pageButton = $.extend(true, $.fn.DataTable.ext.renderer.pageButton, + { + bootstrap: function (settings, host, idx, buttons, page, pages) { + main_pageButtonFunc(settings, host, idx, buttons, page, pages); + + input_html = '
' + + '' + + ' of ' + pages + '' + + '
' + + let input_section = $(host).find("[data-dt-idx='input']"); + input_section.closest("li").prop("onclick", null).off("click"); + input_section.closest("li").prop("onkeypress", null).off("keypress"); + input_section.replaceWith(input_html); + + const api = new DataTable.Api(settings); + + $(host).find("ul.pagination input").val(page + 1).on('change', function (e) { + api.page(Number($(e.target).val()) - 1).draw('page'); + }); + } + } +) diff --git a/sorting/natural.js b/sorting/natural.js index 50d47aa..57d003f 100644 --- a/sorting/natural.js +++ b/sorting/natural.js @@ -147,7 +147,7 @@ DataTable.ext.type.order['natural-desc'] = function (a, b) { DataTable.ext.type.order['natural-nohtml-asc'] = function (a, b) { return naturalSort(a, b, false); }; -DataTable.ext.type.order['natural-nohtml-asc'] = function (a, b) { +DataTable.ext.type.order['natural-nohtml-desc'] = function (a, b) { return naturalSort(a, b, false) * -1; }; DataTable.ext.type.order['natural-ci-asc'] = function (a, b) { @@ -155,7 +155,7 @@ DataTable.ext.type.order['natural-ci-asc'] = function (a, b) { b = b.toString().toLowerCase(); return naturalSort(a, b, true); }; -DataTable.ext.type.order['natural-ci-asc'] = function (a, b) { +DataTable.ext.type.order['natural-ci-desc'] = function (a, b) { a = a.toString().toLowerCase(); b = b.toString().toLowerCase(); return naturalSort(a, b, true) * -1; diff --git a/sorting/natural.min.js b/sorting/natural.min.js index a91a3fa..3801415 100644 --- a/sorting/natural.min.js +++ b/sorting/natural.min.js @@ -1,2 +1,2 @@ /*! © SpryMedia Ltd, Jim Palmer, Michael Buehler, Mike Grier, Clint Priest, Kyle Adams, guillermo - datatables.net/license */ -!function(r){var n,a;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return r(e,window,document)}):"object"==typeof exports?(n=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||n(e),a(e,t),r(t,0,e.document)}:(a(window,n),module.exports=r(n,window,window.document))):r(jQuery,window,document)}(function(e,t,r,n){"use strict";e=e.fn.dataTable;function a(e,t,r){var n=/(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?%?$|^0x[0-9a-f]+$|[0-9]+)/gi,a=/(^[ ]*|[ ]*$)/g,o=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,i=/^0x[0-9a-f]+$/i,u=/^0/,c=/(<([^>]+)>)/gi,e=e.toString().replace(a,"")||"",t=t.toString().replace(a,"")||"",d=(r||(e=e.replace(c,""),t=t.replace(c,"")),e.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0")),f=t.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),a=parseInt(e.match(i),10)||1!==d.length&&e.match(o)&&Date.parse(e),r=parseInt(t.match(i),10)||a&&t.match(o)&&Date.parse(t)||null;if(r){if(a]+)>)/gi,e=e.toString().replace(a,"")||"",t=t.toString().replace(a,"")||"",d=(r||(e=e.replace(c,""),t=t.replace(c,"")),e.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0")),f=t.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),a=parseInt(e.match(i),10)||1!==d.length&&e.match(o)&&Date.parse(e),r=parseInt(t.match(i),10)||a&&t.match(o)&&Date.parse(t)||null;if(r){if(a]+)>)/gi,t=t.toString().replace(n,"")||"",a=a.toString().replace(n,"")||"",i=(r||(t=t.replace(c,""),a=a.replace(c,"")),t.replace(e,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0")),p=a.replace(e,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),n=parseInt(t.match(l),10)||1!==i.length&&t.match(o)&&Date.parse(t),r=parseInt(a.match(l),10)||n&&a.match(o)&&Date.parse(a)||null;if(r){if(n]+)>)/gi,t=t.toString().replace(n,"")||"",a=a.toString().replace(n,"")||"",i=(r||(t=t.replace(c,""),a=a.replace(c,"")),t.replace(e,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0")),p=a.replace(e,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),n=parseInt(t.match(l),10)||1!==i.length&&t.match(o)&&Date.parse(t),r=parseInt(a.match(l),10)||n&&a.match(o)&&Date.parse(a)||null;if(r){if(n