jquery-datatables 1.10.19.1 → 1.10.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +1 -0
  3. data/README.md +28 -1
  4. data/app/assets/javascripts/datatables/dataTables.uikit.js +2 -2
  5. data/app/assets/javascripts/datatables/extensions/AutoFill/dataTables.autoFill.js +42 -29
  6. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.bootstrap.js +1 -1
  7. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.bootstrap4.js +8 -2
  8. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.colVis.js +6 -3
  9. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.foundation.js +5 -4
  10. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.html5.js +58 -6
  11. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.print.js +16 -5
  12. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.semanticui.js +1 -1
  13. data/app/assets/javascripts/datatables/extensions/Buttons/dataTables.buttons.js +267 -152
  14. data/app/assets/javascripts/datatables/extensions/ColReorder/colReorder.foundation.js +1 -1
  15. data/app/assets/javascripts/datatables/extensions/ColReorder/dataTables.colReorder.js +121 -52
  16. data/app/assets/javascripts/datatables/extensions/FixedColumns/dataTables.fixedColumns.js +32 -5
  17. data/app/assets/javascripts/datatables/extensions/KeyTable/dataTables.keyTable.js +166 -63
  18. data/app/assets/javascripts/datatables/extensions/KeyTable/keyTable.foundation.js +1 -1
  19. data/app/assets/javascripts/datatables/extensions/RowGroup/dataTables.rowGroup.js +105 -53
  20. data/app/assets/javascripts/datatables/extensions/RowGroup/rowGroup.foundation.js +1 -1
  21. data/app/assets/javascripts/datatables/extensions/RowGroup/{rowGroup.semanicui.js → rowGroup.semanticui.js} +0 -0
  22. data/app/assets/javascripts/datatables/extensions/RowReorder/dataTables.rowReorder.js +10 -9
  23. data/app/assets/javascripts/datatables/extensions/RowReorder/rowReorder.foundation.js +1 -1
  24. data/app/assets/javascripts/datatables/extensions/Scroller/dataTables.scroller.js +519 -636
  25. data/app/assets/javascripts/datatables/extensions/Scroller/scroller.foundation.js +1 -1
  26. data/app/assets/javascripts/datatables/extensions/Select/dataTables.select.js +49 -18
  27. data/app/assets/javascripts/datatables/extensions/Select/select.foundation.js +1 -1
  28. data/app/assets/javascripts/datatables/jquery.dataTables.js +97 -60
  29. data/app/assets/javascripts/datatables/plugins/api/average.js +7 -6
  30. data/app/assets/javascripts/datatables/plugins/api/sum.js +7 -6
  31. data/app/assets/javascripts/datatables/plugins/pagination/ellipses.js +160 -0
  32. data/app/assets/javascripts/datatables/plugins/pagination/extjs.js +137 -0
  33. data/app/assets/javascripts/datatables/plugins/pagination/four_button.js +110 -0
  34. data/app/assets/javascripts/datatables/plugins/pagination/full_numbers_no_ellipses.js +59 -0
  35. data/app/assets/javascripts/datatables/plugins/pagination/input.js +22 -19
  36. data/app/assets/javascripts/datatables/plugins/pagination/scrolling.js +130 -0
  37. data/app/assets/javascripts/datatables/plugins/pagination/select.js +97 -0
  38. data/app/assets/javascripts/datatables/plugins/pagination/simple_incremental_bootstrap.js +154 -0
  39. data/app/assets/javascripts/datatables/plugins/pagination/simple_numbers_no_ellipses.js +59 -0
  40. data/app/assets/javascripts/datatables/plugins/search/dataTables.alphabetSearch.js +440 -399
  41. data/app/assets/javascripts/datatables/plugins/sorting/enum.js +51 -0
  42. data/app/assets/javascripts/datatables/plugins/type-detection/date-dd-MMM-yyyy.js +63 -0
  43. data/app/assets/javascripts/datatables/plugins/type-detection/date-de.js +125 -0
  44. data/app/assets/javascripts/datatables/plugins/type-detection/date-eu.js +64 -0
  45. data/app/assets/javascripts/datatables/plugins/type-detection/date-euro.js +48 -0
  46. data/app/assets/javascripts/datatables/plugins/type-detection/date-uk.js +35 -12
  47. data/app/assets/javascripts/datatables/plugins/type-detection/datetime-moment.js +74 -0
  48. data/app/assets/javascripts/datatables/plugins/type-detection/datetime-us.js +86 -0
  49. data/app/assets/javascripts/datatables/plugins/type-detection/file-size.js +37 -13
  50. data/app/assets/javascripts/datatables/plugins/type-detection/ip-address.js +113 -11
  51. data/app/assets/javascripts/datatables/plugins/type-detection/numString.js +63 -0
  52. data/app/assets/javascripts/datatables/plugins/type-detection/percent.js +34 -0
  53. data/app/assets/javascripts/datatables/plugins/type-detection/time-elapsed-dhms.js +42 -0
  54. data/app/assets/javascripts/datatables/plugins/type-detection/time.js +56 -0
  55. data/app/assets/javascripts/datatables/plugins/type-detection/title-numeric.js +40 -0
  56. data/app/assets/javascripts/datatables/plugins/type-detection/title-string.js +36 -0
  57. data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.dataTables.scss +10 -3
  58. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap.scss +12 -3
  59. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap4.scss +13 -6
  60. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.dataTables.scss +2 -0
  61. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.foundation.scss +5 -1
  62. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.jqueryui.scss +1 -0
  63. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.semanticui.scss +2 -1
  64. data/app/assets/stylesheets/datatables/extensions/Buttons/common.scss +10 -0
  65. data/app/assets/stylesheets/datatables/extensions/Buttons/mixins.scss +42 -30
  66. data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.bootstrap.scss +11 -7
  67. data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.foundation.scss +1 -0
  68. data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.dataTables.scss +13 -5
  69. data/app/assets/stylesheets/datatables/extensions/RowGroup/rowGroup.dataTables.scss +20 -2
  70. data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.dataTables.scss +15 -2
  71. data/lib/jquery-datatables/version.rb +1 -1
  72. metadata +26 -12
  73. data/app/assets/javascripts/datatables/dataTables.bootstrap2.js +0 -162
  74. data/app/assets/javascripts/datatables/extensions/ColReorder/colReorder.semanicui.js +0 -38
  75. data/app/assets/javascripts/datatables/extensions/FixedColumns/fixedColumns.semanicui.js +0 -38
  76. data/app/assets/javascripts/datatables/extensions/FixedHeader/fixedHeader.semanicui.js +0 -38
  77. data/app/assets/javascripts/datatables/extensions/KeyTable/keyTable.semanicui.js +0 -38
  78. data/app/assets/javascripts/datatables/extensions/RowReorder/rowReorder.semanicui.js +0 -38
  79. data/app/assets/stylesheets/datatables/dataTables.bootstrap2.scss +0 -178
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Plug-in offers the same functionality as `full_numbers` pagination type
3
+ * (see `pagingType` option) but without ellipses.
4
+ *
5
+ * See [example](http://www.gyrocode.com/articles/jquery-datatables-pagination-without-ellipses) for demonstration.
6
+ *
7
+ * @name Full Numbers - No Ellipses
8
+ * @summary Same pagination as 'full_numbers' but without ellipses
9
+ * @author [Michael Ryvkin](http://www.gyrocode.com)
10
+ *
11
+ * @example
12
+ * $(document).ready(function() {
13
+ * $('#example').dataTable( {
14
+ * "pagingType": "full_numbers_no_ellipses"
15
+ * } );
16
+ * } );
17
+ */
18
+
19
+ $.fn.DataTable.ext.pager.full_numbers_no_ellipses = function(page, pages){
20
+ var numbers = [];
21
+ var buttons = $.fn.DataTable.ext.pager.numbers_length;
22
+ var half = Math.floor( buttons / 2 );
23
+
24
+ var _range = function ( len, start ){
25
+ var end;
26
+
27
+ if ( typeof start === "undefined" ){
28
+ start = 0;
29
+ end = len;
30
+
31
+ } else {
32
+ end = start;
33
+ start = len;
34
+ }
35
+
36
+ var out = [];
37
+ for ( var i = start ; i < end; i++ ){ out.push(i); }
38
+
39
+ return out;
40
+ };
41
+
42
+
43
+ if ( pages <= buttons ) {
44
+ numbers = _range( 0, pages );
45
+
46
+ } else if ( page <= half ) {
47
+ numbers = _range( 0, buttons);
48
+
49
+ } else if ( page >= pages - 1 - half ) {
50
+ numbers = _range( pages - buttons, pages );
51
+
52
+ } else {
53
+ numbers = _range( page - half, page + half + 1);
54
+ }
55
+
56
+ numbers.DT_el = 'span';
57
+
58
+ return [ 'first', 'previous', numbers, 'next', 'last' ];
59
+ };
@@ -54,9 +54,9 @@
54
54
  var lastClassName = 'last';
55
55
 
56
56
  var paginateClassName = 'paginate';
57
- var paginateOfClassName = 'paginate_of';
58
57
  var paginatePageClassName = 'paginate_page';
59
58
  var paginateInputClassName = 'paginate_input';
59
+ var paginateTotalClassName = 'paginate_total';
60
60
 
61
61
  $.fn.dataTableExt.oPagination.input = {
62
62
  'fnInit': function (oSettings, nPaging, fnCallbackDraw) {
@@ -65,11 +65,12 @@
65
65
  var nNext = document.createElement('span');
66
66
  var nLast = document.createElement('span');
67
67
  var nInput = document.createElement('input');
68
- var nPage = document.createElement('span');
69
- var nOf = document.createElement('span');
68
+ var nTotal = document.createElement('span');
69
+ var nInfo = document.createElement('span');
70
70
 
71
71
  var language = oSettings.oLanguage.oPaginate;
72
72
  var classes = oSettings.oClasses;
73
+ var info = language.info || 'Page _INPUT_ of _TOTAL_';
73
74
 
74
75
  nFirst.innerHTML = language.sFirst;
75
76
  nPrevious.innerHTML = language.sPrevious;
@@ -81,9 +82,8 @@
81
82
  nNext.className = nextClassName + ' ' + classes.sPageButton;
82
83
  nLast.className = lastClassName + ' ' + classes.sPageButton;
83
84
 
84
- nOf.className = paginateOfClassName;
85
- nPage.className = paginatePageClassName;
86
85
  nInput.className = paginateInputClassName;
86
+ nTotal.className = paginateTotalClassName;
87
87
 
88
88
  if (oSettings.sTableId !== '') {
89
89
  nPaging.setAttribute('id', oSettings.sTableId + '_' + paginateClassName);
@@ -94,17 +94,20 @@
94
94
  }
95
95
 
96
96
  nInput.type = 'text';
97
- nPage.innerHTML = 'Page ';
97
+
98
+ info = info.replace(/_INPUT_/g, '</span>' + nInput.outerHTML + '<span>');
99
+ info = info.replace(/_TOTAL_/g, '</span>' + nTotal.outerHTML + '<span>');
100
+ nInfo.innerHTML = '<span>' + info + '</span>';
98
101
 
99
102
  nPaging.appendChild(nFirst);
100
103
  nPaging.appendChild(nPrevious);
101
- nPaging.appendChild(nPage);
102
- nPaging.appendChild(nInput);
103
- nPaging.appendChild(nOf);
104
+ $(nInfo).children().each(function (i, n) {
105
+ nPaging.appendChild(n);
106
+ });
104
107
  nPaging.appendChild(nNext);
105
108
  nPaging.appendChild(nLast);
106
109
 
107
- $(nFirst).click(function() {
110
+ $(nFirst).click(function () {
108
111
  var iCurrentPage = calcCurrentPage(oSettings);
109
112
  if (iCurrentPage !== 1) {
110
113
  oSettings.oApi._fnPageChange(oSettings, 'first');
@@ -112,7 +115,7 @@
112
115
  }
113
116
  });
114
117
 
115
- $(nPrevious).click(function() {
118
+ $(nPrevious).click(function () {
116
119
  var iCurrentPage = calcCurrentPage(oSettings);
117
120
  if (iCurrentPage !== 1) {
118
121
  oSettings.oApi._fnPageChange(oSettings, 'previous');
@@ -120,7 +123,7 @@
120
123
  }
121
124
  });
122
125
 
123
- $(nNext).click(function() {
126
+ $(nNext).click(function () {
124
127
  var iCurrentPage = calcCurrentPage(oSettings);
125
128
  if (iCurrentPage !== calcPages(oSettings)) {
126
129
  oSettings.oApi._fnPageChange(oSettings, 'next');
@@ -128,7 +131,7 @@
128
131
  }
129
132
  });
130
133
 
131
- $(nLast).click(function() {
134
+ $(nLast).click(function () {
132
135
  var iCurrentPage = calcCurrentPage(oSettings);
133
136
  if (iCurrentPage !== calcPages(oSettings)) {
134
137
  oSettings.oApi._fnPageChange(oSettings, 'last');
@@ -136,7 +139,7 @@
136
139
  }
137
140
  });
138
141
 
139
- $(nInput).keyup(function (e) {
142
+ $(nPaging).find('.' + paginateInputClassName).keyup(function (e) {
140
143
  // 38 = up arrow, 39 = right arrow
141
144
  if (e.which === 38 || e.which === 39) {
142
145
  this.value++;
@@ -166,7 +169,7 @@
166
169
 
167
170
  // Take the brutal approach to cancelling text selection.
168
171
  $('span', nPaging).bind('mousedown', function () { return false; });
169
- $('span', nPaging).bind('selectstart', function() { return false; });
172
+ $('span', nPaging).bind('selectstart', function () { return false; });
170
173
 
171
174
  // If we can't page anyway, might as well not show it.
172
175
  var iPages = calcPages(oSettings);
@@ -215,10 +218,10 @@
215
218
  .addClass(disableClasses[lastClassName]);
216
219
 
217
220
  // Paginate of N pages text
218
- $(an).children('.' + paginateOfClassName).html(' of ' + iPages);
221
+ $(an).find('.' + paginateTotalClassName).html(iPages);
219
222
 
220
- // Current page numer input value
221
- $(an).children('.' + paginateInputClassName).val(iCurrentPage);
223
+ // Current page number input value
224
+ $(an).find('.' + paginateInputClassName).val(iCurrentPage);
222
225
  }
223
226
  };
224
- })(jQuery);
227
+ })(jQuery);
@@ -0,0 +1,130 @@
1
+ /**
2
+ * This modification of DataTables' standard two button pagination controls
3
+ * adds a little animation effect to the paging action by redrawing the table
4
+ * multiple times for each event, each draw progressing by one row until the
5
+ * required point in the table is reached.
6
+ *
7
+ * @name Scrolling navigation
8
+ * @summary Show page changes as a redraw of the table, scrolling records.
9
+ * @author [Allan Jardine](http://sprymedia.co.uk)
10
+ *
11
+ * @example
12
+ * $(document).ready(function() {
13
+ * $('#example').dataTable( {
14
+ * "sPaginationType": "scrolling"
15
+ * } );
16
+ * } );
17
+ */
18
+
19
+
20
+ /* Time between each scrolling frame */
21
+ $.fn.dataTableExt.oPagination.iTweenTime = 100;
22
+
23
+ $.fn.dataTableExt.oPagination.scrolling = {
24
+ "fnInit": function ( oSettings, nPaging, fnCallbackDraw )
25
+ {
26
+ var oLang = oSettings.oLanguage.oPaginate;
27
+ var oClasses = oSettings.oClasses;
28
+ var fnClickHandler = function ( e ) {
29
+ if ( oSettings.oApi._fnPageChange( oSettings, e.data.action ) )
30
+ {
31
+ fnCallbackDraw( oSettings );
32
+ }
33
+ };
34
+
35
+ var sAppend = (!oSettings.bJUI) ?
36
+ '<a class="'+oSettings.oClasses.sPagePrevDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button">'+oLang.sPrevious+'</a>'+
37
+ '<a class="'+oSettings.oClasses.sPageNextDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button">'+oLang.sNext+'</a>'
38
+ :
39
+ '<a class="'+oSettings.oClasses.sPagePrevDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button"><span class="'+oSettings.oClasses.sPageJUIPrev+'"></span></a>'+
40
+ '<a class="'+oSettings.oClasses.sPageNextDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button"><span class="'+oSettings.oClasses.sPageJUINext+'"></span></a>';
41
+ $(nPaging).append( sAppend );
42
+
43
+ var els = $('a', nPaging);
44
+ var nPrevious = els[0],
45
+ nNext = els[1];
46
+
47
+ oSettings.oApi._fnBindAction( nPrevious, {action: "previous"}, function() {
48
+ /* Disallow paging event during a current paging event */
49
+ if ( typeof oSettings.iPagingLoopStart != 'undefined' && oSettings.iPagingLoopStart != -1 )
50
+ {
51
+ return;
52
+ }
53
+
54
+ oSettings.iPagingLoopStart = oSettings._iDisplayStart;
55
+ oSettings.iPagingEnd = oSettings._iDisplayStart - oSettings._iDisplayLength;
56
+
57
+ /* Correct for underrun */
58
+ if ( oSettings.iPagingEnd < 0 )
59
+ {
60
+ oSettings.iPagingEnd = 0;
61
+ }
62
+
63
+ var iTween = $.fn.dataTableExt.oPagination.iTweenTime;
64
+ var innerLoop = function () {
65
+ if ( oSettings.iPagingLoopStart > oSettings.iPagingEnd ) {
66
+ oSettings.iPagingLoopStart--;
67
+ oSettings._iDisplayStart = oSettings.iPagingLoopStart;
68
+ fnCallbackDraw( oSettings );
69
+ setTimeout( function() { innerLoop(); }, iTween );
70
+ } else {
71
+ oSettings.iPagingLoopStart = -1;
72
+ }
73
+ };
74
+ innerLoop();
75
+ } );
76
+
77
+ oSettings.oApi._fnBindAction( nNext, {action: "next"}, function() {
78
+ /* Disallow paging event during a current paging event */
79
+ if ( typeof oSettings.iPagingLoopStart != 'undefined' && oSettings.iPagingLoopStart != -1 )
80
+ {
81
+ return;
82
+ }
83
+
84
+ oSettings.iPagingLoopStart = oSettings._iDisplayStart;
85
+
86
+ /* Make sure we are not over running the display array */
87
+ if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() )
88
+ {
89
+ oSettings.iPagingEnd = oSettings._iDisplayStart + oSettings._iDisplayLength;
90
+ }
91
+
92
+ var iTween = $.fn.dataTableExt.oPagination.iTweenTime;
93
+ var innerLoop = function () {
94
+ if ( oSettings.iPagingLoopStart < oSettings.iPagingEnd ) {
95
+ oSettings.iPagingLoopStart++;
96
+ oSettings._iDisplayStart = oSettings.iPagingLoopStart;
97
+ fnCallbackDraw( oSettings );
98
+ setTimeout( function() { innerLoop(); }, iTween );
99
+ } else {
100
+ oSettings.iPagingLoopStart = -1;
101
+ }
102
+ };
103
+ innerLoop();
104
+ } );
105
+ },
106
+
107
+ "fnUpdate": function ( oSettings, fnCallbackDraw )
108
+ {
109
+ if ( !oSettings.aanFeatures.p )
110
+ {
111
+ return;
112
+ }
113
+
114
+ /* Loop over each instance of the pager */
115
+ var an = oSettings.aanFeatures.p;
116
+ for ( var i=0, iLen=an.length ; i<iLen ; i++ )
117
+ {
118
+ if ( an[i].childNodes.length !== 0 )
119
+ {
120
+ an[i].childNodes[0].className =
121
+ ( oSettings._iDisplayStart === 0 ) ?
122
+ oSettings.oClasses.sPagePrevDisabled : oSettings.oClasses.sPagePrevEnabled;
123
+
124
+ an[i].childNodes[1].className =
125
+ ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) ?
126
+ oSettings.oClasses.sPageNextDisabled : oSettings.oClasses.sPageNextEnabled;
127
+ }
128
+ }
129
+ }
130
+ };
@@ -0,0 +1,97 @@
1
+ /**
2
+ * This pagination plug-in provides a `dt-tag select` menu with the list of the page
3
+ * numbers that are available for viewing.
4
+ *
5
+ * @name Select list
6
+ * @summary Show a `dt-tag select` list of pages the user can pick from.
7
+ * @author _jneilliii_
8
+ *
9
+ * @example
10
+ * $(document).ready(function() {
11
+ * $('#example').dataTable( {
12
+ * "sPaginationType": "listbox"
13
+ * } );
14
+ * } );
15
+ */
16
+
17
+ $.fn.dataTableExt.oPagination.listbox = {
18
+ /*
19
+ * Function: oPagination.listbox.fnInit
20
+ * Purpose: Initalise dom elements required for pagination with listbox input
21
+ * Returns: -
22
+ * Inputs: object:oSettings - dataTables settings object
23
+ * node:nPaging - the DIV which contains this pagination control
24
+ * function:fnCallbackDraw - draw function which must be called on update
25
+ */
26
+ "fnInit": function (oSettings, nPaging, fnCallbackDraw) {
27
+ var nInput = document.createElement('select');
28
+ var nPage = document.createElement('span');
29
+ var nOf = document.createElement('span');
30
+ nOf.className = "paginate_of";
31
+ nPage.className = "paginate_page";
32
+ if (oSettings.sTableId !== '') {
33
+ nPaging.setAttribute('id', oSettings.sTableId + '_paginate');
34
+ }
35
+ nInput.style.display = "inline";
36
+ nPage.innerHTML = "Page ";
37
+ nPaging.appendChild(nPage);
38
+ nPaging.appendChild(nInput);
39
+ nPaging.appendChild(nOf);
40
+ $(nInput).change(function (e) { // Set DataTables page property and redraw the grid on listbox change event.
41
+ window.scroll(0,0); //scroll to top of page
42
+ if (this.value === "" || this.value.match(/[^0-9]/)) { /* Nothing entered or non-numeric character */
43
+ return;
44
+ }
45
+ var iNewStart = oSettings._iDisplayLength * (this.value - 1);
46
+ if (iNewStart > oSettings.fnRecordsDisplay()) { /* Display overrun */
47
+ oSettings._iDisplayStart = (Math.ceil((oSettings.fnRecordsDisplay() - 1) / oSettings._iDisplayLength) - 1) * oSettings._iDisplayLength;
48
+ fnCallbackDraw(oSettings);
49
+ return;
50
+ }
51
+ oSettings._iDisplayStart = iNewStart;
52
+ fnCallbackDraw(oSettings);
53
+ }); /* Take the brutal approach to cancelling text selection */
54
+ $('span', nPaging).bind('mousedown', function () {
55
+ return false;
56
+ });
57
+ $('span', nPaging).bind('selectstart', function () {
58
+ return false;
59
+ });
60
+ },
61
+
62
+ /*
63
+ * Function: oPagination.listbox.fnUpdate
64
+ * Purpose: Update the listbox element
65
+ * Returns: -
66
+ * Inputs: object:oSettings - dataTables settings object
67
+ * function:fnCallbackDraw - draw function which must be called on update
68
+ */
69
+ "fnUpdate": function (oSettings, fnCallbackDraw) {
70
+ if (!oSettings.aanFeatures.p) {
71
+ return;
72
+ }
73
+ var iPages = Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength);
74
+ var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1; /* Loop over each instance of the pager */
75
+ var an = oSettings.aanFeatures.p;
76
+ for (var i = 0, iLen = an.length; i < iLen; i++) {
77
+ var spans = an[i].getElementsByTagName('span');
78
+ var inputs = an[i].getElementsByTagName('select');
79
+ var elSel = inputs[0];
80
+ if(elSel.options.length != iPages) {
81
+ elSel.options.length = 0; //clear the listbox contents
82
+ for (var j = 0; j < iPages; j++) { //add the pages
83
+ var oOption = document.createElement('option');
84
+ oOption.text = j + 1;
85
+ oOption.value = j + 1;
86
+ try {
87
+ elSel.add(oOption, null); // standards compliant; doesn't work in IE
88
+ } catch (ex) {
89
+ elSel.add(oOption); // IE only
90
+ }
91
+ }
92
+ spans[1].innerHTML = "&nbsp;of&nbsp;" + iPages;
93
+ }
94
+ elSel.value = iCurrentPage;
95
+ }
96
+ }
97
+ };
@@ -0,0 +1,154 @@
1
+ /**
2
+ * This pagination style shows Previous/Next buttons, and page numbers only
3
+ * for "known" pages that are visited at least once time using [Next>] button.
4
+ * Initially only Prev/Next buttons are shown (Prev is initially disabled).
5
+ *
6
+ * [<Previous] [Next>]
7
+ *
8
+ * When user navigates through the pages using [Next>] button, navigation shows
9
+ * the numbers for the previous pages. As an example, when user reaches page 2,
10
+ * page numbers 1 and 2 are shown:
11
+ *
12
+ * [<Previous] 1 2 [Next>]
13
+ *
14
+ * When user reaches page 4, page numbers 1, 2, 3, and 4 are shown:
15
+ *
16
+ * [<Previous] 1 2 3 4 [Next>]
17
+ *
18
+ * When user navigates back, pagination will remember the last page number
19
+ * he reached and the numbesr up to the last known page are shown. As an example,
20
+ * when user returns to the page 2, page numbers 1, 2, 3, and 4 are still shown:
21
+ *
22
+ * [<Previous] 1 2 3 4 [Next>]
23
+ *
24
+ * This pagination style is designed for users who will not directly jump to
25
+ * the random page that they have not opened before. Assumption is that users
26
+ * will discover new pages using [Next>] button. This pagination enables users
27
+ * to easily go back and forth to any page that they discovered.
28
+ *
29
+ * Key benefit: This pagination supports usual pagination pattern and does not
30
+ * require server to return total count of items just to calculate last page and
31
+ * all numbers. This migh be huge performance benefit because server does not
32
+ * need to execute two queries in server-side processing mode:
33
+ * - One to get the records that will be shown on the current page,
34
+ * - Second to get the total count just to calculate full pagination.
35
+ *
36
+ * Without second query, page load time might be 2x faster, especially in cases
37
+ * when server can quickly get top 100 records, but it would need to scan entire
38
+ * database table just to calculate the total count and position of the last
39
+ * page. This pagination style is reasonable trade-off between simple and fullnumbers
40
+ * pagination.
41
+ *
42
+ * @name Simple Incremental navigation (Bootstrap)
43
+ * @summary Shows forward/back buttons and all known page numbers.
44
+ * @author [Jovan Popovic](http://github.com/JocaPC)
45
+ *
46
+ * @example
47
+ * $(document).ready(function() {
48
+ * $('#example').dataTable( {
49
+ * "pagingType": "simple_incremental_bootstrap"
50
+ * } );
51
+ * } );
52
+ */
53
+
54
+ $.fn.dataTableExt.oPagination.simple_incremental_bootstrap = {
55
+
56
+ "fnInit": function (oSettings, nPaging, fnCallbackDraw) {
57
+ $(nPaging).prepend($("<ul class=\"pagination\"></ul>"));
58
+ var ul = $("ul", $(nPaging));
59
+ nFirst = document.createElement('li');
60
+ nPrevious = document.createElement('li');
61
+ nNext = document.createElement('li');
62
+
63
+ $(nPrevious).append($('<span>' + (oSettings.oLanguage.oPaginate.sPrevious) + '</span>'));
64
+ $(nFirst).append($('<span>1</span>'));
65
+ $(nNext).append($('<span>' + (oSettings.oLanguage.oPaginate.sNext) + '</span>'));
66
+
67
+ nFirst.className = "paginate_button first active";
68
+ nPrevious.className = "paginate_button previous";
69
+ nNext.className = "paginate_button next";
70
+
71
+ ul.append(nPrevious);
72
+ ul.append(nFirst);
73
+ ul.append(nNext);
74
+
75
+ $(nFirst).click(function () {
76
+ oSettings.oApi._fnPageChange(oSettings, "first");
77
+ fnCallbackDraw(oSettings);
78
+ });
79
+
80
+ $(nPrevious).click(function () {
81
+ if (!(oSettings._iDisplayStart === 0)) {
82
+ oSettings.oApi._fnPageChange(oSettings, "previous");
83
+ fnCallbackDraw(oSettings);
84
+ }
85
+ });
86
+
87
+ $(nNext).click(function () {
88
+ if (!(oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay()
89
+ ||
90
+ oSettings.aiDisplay.length < oSettings._iDisplayLength)) {
91
+ oSettings.oApi._fnPageChange(oSettings, "next");
92
+ fnCallbackDraw(oSettings);
93
+ }
94
+ });
95
+
96
+ /* Disallow text selection */
97
+ $(nFirst).bind('selectstart', function () { return false; });
98
+ $(nPrevious).bind('selectstart', function () { return false; });
99
+ $(nNext).bind('selectstart', function () { return false; });
100
+
101
+ // Reset dynamically generated pages on length/filter change.
102
+ $(oSettings.nTable).DataTable().on('length.dt', function (e, settings, len) {
103
+ $("li.dynamic_page_item", nPaging).remove();
104
+ });
105
+
106
+ $(oSettings.nTable).DataTable().on('search.dt', function (e, settings, len) {
107
+ $("li.dynamic_page_item", nPaging).remove();
108
+ });
109
+ },
110
+
111
+ /*
112
+ * Function: oPagination.simple_incremental_bootstrap.fnUpdate
113
+ * Purpose: Update the list of page buttons shows
114
+ * Inputs: object:oSettings - dataTables settings object
115
+ * function:fnCallbackDraw - draw function which must be called on update
116
+ */
117
+ "fnUpdate": function (oSettings, fnCallbackDraw) {
118
+ if (!oSettings.aanFeatures.p) {
119
+ return;
120
+ }
121
+
122
+ /* Loop over each instance of the pager */
123
+ var an = oSettings.aanFeatures.p;
124
+ for (var i = 0, iLen = an.length ; i < iLen ; i++) {
125
+ var buttons = an[i].getElementsByTagName('li');
126
+ $(buttons).removeClass("active");
127
+
128
+ if (oSettings._iDisplayStart === 0) {
129
+ buttons[0].className = "paginate_buttons disabled previous";
130
+ buttons[buttons.length - 1].className = "paginate_button enabled next";
131
+ } else {
132
+ buttons[0].className = "paginate_buttons enabled previous";
133
+ }
134
+
135
+ var page = Math.round(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
136
+ if (page == buttons.length-1 && oSettings.aiDisplay.length > 0) {
137
+ $new = $('<li class="dynamic_page_item active"><span>' + page + "</span></li>");
138
+ $(buttons[buttons.length - 1]).before($new);
139
+ $new.click(function () {
140
+ $(oSettings.nTable).DataTable().page(page-1);
141
+
142
+ fnCallbackDraw(oSettings);
143
+ });
144
+ } else
145
+ $(buttons[page]).addClass("active");
146
+
147
+ if (oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay()
148
+ ||
149
+ oSettings.aiDisplay.length < oSettings._iDisplayLength) {
150
+ buttons[buttons.length - 1].className = "paginate_button disabled next";
151
+ }
152
+ }
153
+ }
154
+ };