jquery-datatables 1.10.17 → 1.10.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +26 -9
  4. data/app/assets/javascripts/datatables/dataTables.bootstrap4.js +2 -2
  5. data/app/assets/javascripts/datatables/dataTables.dataTables.js +37 -0
  6. data/app/assets/javascripts/datatables/dataTables.semanticui.js +7 -3
  7. data/app/assets/javascripts/datatables/jquery.dataTables.js +3 -3
  8. data/app/assets/javascripts/datatables/plugins/api/average.js +0 -1
  9. data/app/assets/javascripts/datatables/plugins/api/sum.js +9 -10
  10. data/app/assets/javascripts/datatables/plugins/pagination/input.js +203 -203
  11. data/app/assets/javascripts/datatables/plugins/search/{alphabetSearch.js → dataTables.alphabetSearch.js} +81 -50
  12. data/app/assets/javascripts/datatables/plugins/sorting/currency.js +36 -0
  13. data/app/assets/javascripts/datatables/plugins/sorting/date-uk.js +42 -0
  14. data/app/assets/javascripts/datatables/plugins/sorting/file-size.js +2 -1
  15. data/app/assets/javascripts/datatables/plugins/sorting/formatted-numbers.js +40 -0
  16. data/app/assets/javascripts/datatables/plugins/sorting/ip-address.js +74 -73
  17. data/app/assets/javascripts/datatables/plugins/sorting/num-html.js +38 -0
  18. data/app/assets/javascripts/datatables/plugins/sorting/numeric-comma.js +37 -0
  19. data/app/assets/javascripts/datatables/plugins/type-detection/currency.js +40 -0
  20. data/app/assets/javascripts/datatables/plugins/type-detection/date-uk.js +19 -0
  21. data/app/assets/javascripts/datatables/plugins/type-detection/file-size.js +20 -0
  22. data/app/assets/javascripts/datatables/plugins/type-detection/formatted-num.js +28 -0
  23. data/app/assets/javascripts/datatables/plugins/type-detection/ip-address.js +18 -0
  24. data/app/assets/javascripts/datatables/plugins/type-detection/num-html.js +56 -0
  25. data/app/assets/javascripts/datatables/plugins/type-detection/numeric-comma.js +40 -0
  26. data/app/assets/stylesheets/datatables/dataTables.bootstrap4.scss +1 -1
  27. data/app/assets/stylesheets/datatables/dataTables.semanticui.scss +1 -1
  28. data/app/assets/stylesheets/datatables/plugins/search/dataTables.alphabetSearch.bootstrap.css +53 -0
  29. data/app/assets/stylesheets/datatables/plugins/search/dataTables.alphabetSearch.css +83 -0
  30. data/jquery-datatables.gemspec +3 -5
  31. data/lib/generators/jquery/datatables/templates/javascripts/initializer.js.tt +11 -0
  32. data/lib/generators/jquery/datatables/templates/views/index.html.erb +1 -1
  33. data/lib/generators/jquery/datatables/templates/views/index.html.haml +12 -0
  34. data/lib/jquery-datatables/version.rb +1 -1
  35. metadata +19 -18
  36. data/app/assets/stylesheets/datatables/plugins/search/alphabetSearch.css +0 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 681cbce4e90454b5a033b6082241a8cabcfe3872558a5c39ad35eee32944f32b
4
- data.tar.gz: c619f8924e5f9b43e1e237379a581fbe17b04cd2f4ff60888504aabafb011140
3
+ metadata.gz: b570f797c94b675a1ca66f34cb200644090bd0d97e550461acac0ca697da18c1
4
+ data.tar.gz: 732f86dcb5f363428d0f811d3b350595219b1c86a46641d8325ae0c68e46ecbd
5
5
  SHA512:
6
- metadata.gz: 783b181782fd948624f1a29d4f8fa9c72b1e83c8a75ddf385b851404adbb1cf5af85481c14251ecb95051841a4ab40d66a59eb2fe750e9535630192a845fb1d4
7
- data.tar.gz: e6f67600ae98753348aaa32cbb785a9ec142d5827f60a0978b0c02a0c10ec83c7cf955b808d423c4d1b66bc0d900ad58ab01a335023491e097feff173f148b43
6
+ metadata.gz: f98304dba880ead665a5c353c41e87bfb274f817eab977ad5f2c8e380348806e835f984dd7ae5efa26e43f7eecd0c6c761c6930849dedfffa2aee7dc41c068fb
7
+ data.tar.gz: da9cf41ebac6116d1971503c7365daded1a95df4314948f77e99f39ea9a39cd9892d0cb5d37fe278e6b3f59999746c8ad56b1886a09167d9e1c1d47201e32df6
data/.gitignore CHANGED
@@ -22,3 +22,4 @@ tmp
22
22
  mkmf.log
23
23
  DataTablesSrc/
24
24
  alphabetSearchSrc/
25
+ PluginsSrc
data/README.md CHANGED
@@ -31,18 +31,30 @@ rails g jquery:datatables:install
31
31
 
32
32
  ```
33
33
 
34
- or if you using bootstrap
34
+ or if you using css framework
35
35
 
36
36
  ```
37
- rails g jquery:datatables:install bootstrap
37
+ rails g jquery:datatables:install bootstrap4
38
38
 
39
39
  ```
40
40
 
41
41
  this generator will:
42
42
  - 1. append ```//= require datatables ``` add `app/assets/javascripts/application.js`
43
43
  - 2. append ```*= require datatables ``` add `app/assets/stylesheets/application.css`
44
- - 3. create datatable.js in ```app/assets/javascripts/```
44
+ - 3. create datatable.js in ```app/assets/javascripts/``` with default init script.
45
45
  - 4. create datatable.scss in ```app/assets/stylesheets/```
46
+ - 5. create scaffold index template in ```lib/template```
47
+
48
+
49
+ available [styling](https://datatables.net/examples/styling/)
50
+ - bootstrap
51
+ - bootstrap4
52
+ - foundation
53
+ - jqueryui
54
+ - sematicui
55
+ - material (Tech. preview)
56
+ - uikit (Tech. preview)
57
+
46
58
 
47
59
  ## Manual install
48
60
 
@@ -93,7 +105,7 @@ Create new file `app/assets/stylesheets/datatables.scss`
93
105
  @import 'datatables/extensions/Responsive/responsive.dataTables';
94
106
  @import 'datatables/extensions/Buttons/buttons.dataTables';
95
107
  ```
96
- ** if using boostrap theme
108
+ ** if using boostrap4 theme
97
109
  ```scss
98
110
  @import 'datatables/dataTables.bootstrap4';
99
111
  @import 'datatables/extensions/Responsive/responsive.bootstrap4';
@@ -103,7 +115,7 @@ Create new file `app/assets/stylesheets/datatables.scss`
103
115
  *** you may refer other extensions in this directory: [click me](https://github.com/mkhairi/jquery-datatables/tree/master/app/assets/stylesheets/datatables/extensions)
104
116
 
105
117
 
106
- ### Initialization
118
+ ### Basic Initialization
107
119
 
108
120
  Where needed in your JavaScripts, initialize your DataTables:
109
121
 
@@ -113,10 +125,15 @@ $(document).ready(function() {
113
125
  });
114
126
  ```
115
127
 
116
- ## Todo
117
- - update instructions
118
- - add scaffolds generators
119
- - add ajax helpers
128
+ ### Server Side processing
129
+
130
+ Recommended use this gem
131
+
132
+ ```ruby
133
+ gem 'ajax-datatables-rails'
134
+ ```
135
+ see [docs](https://github.com/jbox-web/ajax-datatables-rails) for details instruction
136
+
120
137
 
121
138
  ## Contributing
122
139
 
@@ -55,9 +55,9 @@ $.extend( true, DataTable.defaults, {
55
55
 
56
56
  /* Default class modification */
57
57
  $.extend( DataTable.ext.classes, {
58
- sWrapper: "dataTables_wrapper container-fluid dt-bootstrap4",
58
+ sWrapper: "dataTables_wrapper dt-bootstrap4",
59
59
  sFilterInput: "form-control form-control-sm",
60
- sLengthSelect: "form-control form-control-sm",
60
+ sLengthSelect: "custom-select custom-select-sm form-control form-control-sm",
61
61
  sProcessing: "dataTables_processing card",
62
62
  sPageButton: "paginate_button page-item"
63
63
  } );
@@ -0,0 +1,37 @@
1
+ /*! DataTables styling integration
2
+ * ©2018 SpryMedia Ltd - datatables.net/license
3
+ */
4
+
5
+ (function( factory ){
6
+ if ( typeof define === 'function' && define.amd ) {
7
+ // AMD
8
+ define( ['jquery', 'datatables.net'], function ( $ ) {
9
+ return factory( $, window, document );
10
+ } );
11
+ }
12
+ else if ( typeof exports === 'object' ) {
13
+ // CommonJS
14
+ module.exports = function (root, $) {
15
+ if ( ! root ) {
16
+ root = window;
17
+ }
18
+
19
+ if ( ! $ || ! $.fn.dataTable ) {
20
+ // Require DataTables, which attaches to jQuery, including
21
+ // jQuery if needed and have a $ property so we can access the
22
+ // jQuery object that is used
23
+ $ = require('datatables.net')(root, $).$;
24
+ }
25
+
26
+ return factory( $, root, root.document );
27
+ };
28
+ }
29
+ else {
30
+ // Browser
31
+ factory( jQuery, window, document );
32
+ }
33
+ }(function( $, window, document, undefined ) {
34
+
35
+ return $.fn.dataTable;
36
+
37
+ }));
@@ -195,14 +195,18 @@ $(document).on( 'init.dt', function (e, ctx) {
195
195
  return;
196
196
  }
197
197
 
198
+ var api = new $.fn.dataTable.Api( ctx );
199
+
198
200
  // Length menu drop down
199
201
  if ( $.fn.dropdown ) {
200
- var api = new $.fn.dataTable.Api( ctx );
201
-
202
202
  $( 'div.dataTables_length select', api.table().container() ).dropdown();
203
203
  }
204
+
205
+ // Filtering input
206
+ $( 'div.dataTables_filter.ui.input', api.table().container() ).removeClass('input').addClass('form');
207
+ $( 'div.dataTables_filter input', api.table().container() ).wrap( '<span class="ui input" />' );
204
208
  } );
205
209
 
206
210
 
207
211
  return DataTable;
208
- }));
212
+ }));
@@ -1,11 +1,11 @@
1
- /*! DataTables 1.10.17
1
+ /*! DataTables 1.10.18
2
2
  * ©2008-2018 SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
5
5
  /**
6
6
  * @summary DataTables
7
7
  * @description Paginate, search and order HTML tables
8
- * @version 1.10.17
8
+ * @version 1.10.18
9
9
  * @file jquery.dataTables.js
10
10
  * @author SpryMedia Ltd
11
11
  * @contact www.datatables.net
@@ -9464,7 +9464,7 @@
9464
9464
  * @type string
9465
9465
  * @default Version number
9466
9466
  */
9467
- DataTable.version = "1.10.17";
9467
+ DataTable.version = "1.10.18";
9468
9468
 
9469
9469
  /**
9470
9470
  * Private data store, containing all of the settings objects that are
@@ -29,4 +29,3 @@ jQuery.fn.dataTable.Api.register( 'average()', function () {
29
29
 
30
30
  return sum / data.length;
31
31
  } );
32
-
@@ -37,15 +37,14 @@
37
37
  */
38
38
 
39
39
  jQuery.fn.dataTable.Api.register( 'sum()', function ( ) {
40
- return this.flatten().reduce( function ( a, b ) {
41
- if ( typeof a === 'string' ) {
42
- a = a.replace(/[^\d.-]/g, '') * 1;
43
- }
44
- if ( typeof b === 'string' ) {
45
- b = b.replace(/[^\d.-]/g, '') * 1;
46
- }
40
+ return this.flatten().reduce( function ( a, b ) {
41
+ if ( typeof a === 'string' ) {
42
+ a = a.replace(/[^\d.-]/g, '') * 1;
43
+ }
44
+ if ( typeof b === 'string' ) {
45
+ b = b.replace(/[^\d.-]/g, '') * 1;
46
+ }
47
47
 
48
- return a + b;
49
- }, 0 );
48
+ return a + b;
49
+ }, 0 );
50
50
  } );
51
-
@@ -19,206 +19,206 @@
19
19
  */
20
20
 
21
21
  (function ($) {
22
- function calcDisableClasses(oSettings) {
23
- var start = oSettings._iDisplayStart;
24
- var length = oSettings._iDisplayLength;
25
- var visibleRecords = oSettings.fnRecordsDisplay();
26
- var all = length === -1;
27
-
28
- // Gordey Doronin: Re-used this code from main jQuery.dataTables source code. To be consistent.
29
- var page = all ? 0 : Math.ceil(start / length);
30
- var pages = all ? 1 : Math.ceil(visibleRecords / length);
31
-
32
- var disableFirstPrevClass = (page > 0 ? '' : oSettings.oClasses.sPageButtonDisabled);
33
- var disableNextLastClass = (page < pages - 1 ? '' : oSettings.oClasses.sPageButtonDisabled);
34
-
35
- return {
36
- 'first': disableFirstPrevClass,
37
- 'previous': disableFirstPrevClass,
38
- 'next': disableNextLastClass,
39
- 'last': disableNextLastClass
40
- };
41
- }
42
-
43
- function calcCurrentPage(oSettings) {
44
- return Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
45
- }
46
-
47
- function calcPages(oSettings) {
48
- return Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength);
49
- }
50
-
51
- var firstClassName = 'first';
52
- var previousClassName = 'previous';
53
- var nextClassName = 'next';
54
- var lastClassName = 'last';
55
-
56
- var paginateClassName = 'paginate';
57
- var paginateOfClassName = 'paginate_of';
58
- var paginatePageClassName = 'paginate_page';
59
- var paginateInputClassName = 'paginate_input';
60
-
61
- $.fn.dataTableExt.oPagination.input = {
62
- 'fnInit': function (oSettings, nPaging, fnCallbackDraw) {
63
- var nFirst = document.createElement('span');
64
- var nPrevious = document.createElement('span');
65
- var nNext = document.createElement('span');
66
- var nLast = document.createElement('span');
67
- var nInput = document.createElement('input');
68
- var nPage = document.createElement('span');
69
- var nOf = document.createElement('span');
70
-
71
- var language = oSettings.oLanguage.oPaginate;
72
- var classes = oSettings.oClasses;
73
-
74
- nFirst.innerHTML = language.sFirst;
75
- nPrevious.innerHTML = language.sPrevious;
76
- nNext.innerHTML = language.sNext;
77
- nLast.innerHTML = language.sLast;
78
-
79
- nFirst.className = firstClassName + ' ' + classes.sPageButton;
80
- nPrevious.className = previousClassName + ' ' + classes.sPageButton;
81
- nNext.className = nextClassName + ' ' + classes.sPageButton;
82
- nLast.className = lastClassName + ' ' + classes.sPageButton;
83
-
84
- nOf.className = paginateOfClassName;
85
- nPage.className = paginatePageClassName;
86
- nInput.className = paginateInputClassName;
87
-
88
- if (oSettings.sTableId !== '') {
89
- nPaging.setAttribute('id', oSettings.sTableId + '_' + paginateClassName);
90
- nFirst.setAttribute('id', oSettings.sTableId + '_' + firstClassName);
91
- nPrevious.setAttribute('id', oSettings.sTableId + '_' + previousClassName);
92
- nNext.setAttribute('id', oSettings.sTableId + '_' + nextClassName);
93
- nLast.setAttribute('id', oSettings.sTableId + '_' + lastClassName);
94
- }
95
-
96
- nInput.type = 'text';
97
- nPage.innerHTML = 'Page ';
98
-
99
- nPaging.appendChild(nFirst);
100
- nPaging.appendChild(nPrevious);
101
- nPaging.appendChild(nPage);
102
- nPaging.appendChild(nInput);
103
- nPaging.appendChild(nOf);
104
- nPaging.appendChild(nNext);
105
- nPaging.appendChild(nLast);
106
-
107
- $(nFirst).click(function() {
108
- var iCurrentPage = calcCurrentPage(oSettings);
109
- if (iCurrentPage !== 1) {
110
- oSettings.oApi._fnPageChange(oSettings, 'first');
111
- fnCallbackDraw(oSettings);
112
- }
113
- });
114
-
115
- $(nPrevious).click(function() {
116
- var iCurrentPage = calcCurrentPage(oSettings);
117
- if (iCurrentPage !== 1) {
118
- oSettings.oApi._fnPageChange(oSettings, 'previous');
119
- fnCallbackDraw(oSettings);
120
- }
121
- });
122
-
123
- $(nNext).click(function() {
124
- var iCurrentPage = calcCurrentPage(oSettings);
125
- if (iCurrentPage !== calcPages(oSettings)) {
126
- oSettings.oApi._fnPageChange(oSettings, 'next');
127
- fnCallbackDraw(oSettings);
128
- }
129
- });
130
-
131
- $(nLast).click(function() {
132
- var iCurrentPage = calcCurrentPage(oSettings);
133
- if (iCurrentPage !== calcPages(oSettings)) {
134
- oSettings.oApi._fnPageChange(oSettings, 'last');
135
- fnCallbackDraw(oSettings);
136
- }
137
- });
138
-
139
- $(nInput).keyup(function (e) {
140
- // 38 = up arrow, 39 = right arrow
141
- if (e.which === 38 || e.which === 39) {
142
- this.value++;
143
- }
144
- // 37 = left arrow, 40 = down arrow
145
- else if ((e.which === 37 || e.which === 40) && this.value > 1) {
146
- this.value--;
147
- }
148
-
149
- if (this.value === '' || this.value.match(/[^0-9]/)) {
150
- /* Nothing entered or non-numeric character */
151
- this.value = this.value.replace(/[^\d]/g, ''); // don't even allow anything but digits
152
- return;
153
- }
154
-
155
- var iNewStart = oSettings._iDisplayLength * (this.value - 1);
156
- if (iNewStart < 0) {
157
- iNewStart = 0;
158
- }
159
- if (iNewStart >= oSettings.fnRecordsDisplay()) {
160
- iNewStart = (Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength) - 1) * oSettings._iDisplayLength;
161
- }
162
-
163
- oSettings._iDisplayStart = iNewStart;
164
- fnCallbackDraw(oSettings);
165
- });
166
-
167
- // Take the brutal approach to cancelling text selection.
168
- $('span', nPaging).bind('mousedown', function () { return false; });
169
- $('span', nPaging).bind('selectstart', function() { return false; });
170
-
171
- // If we can't page anyway, might as well not show it.
172
- var iPages = calcPages(oSettings);
173
- if (iPages <= 1) {
174
- $(nPaging).hide();
175
- }
176
- },
177
-
178
- 'fnUpdate': function (oSettings) {
179
- if (!oSettings.aanFeatures.p) {
180
- return;
181
- }
182
-
183
- var iPages = calcPages(oSettings);
184
- var iCurrentPage = calcCurrentPage(oSettings);
185
-
186
- var an = oSettings.aanFeatures.p;
187
- if (iPages <= 1) // hide paging when we can't page
188
- {
189
- $(an).hide();
190
- return;
191
- }
192
-
193
- var disableClasses = calcDisableClasses(oSettings);
194
-
195
- $(an).show();
196
-
197
- // Enable/Disable `first` button.
198
- $(an).children('.' + firstClassName)
199
- .removeClass(oSettings.oClasses.sPageButtonDisabled)
200
- .addClass(disableClasses[firstClassName]);
201
-
202
- // Enable/Disable `prev` button.
203
- $(an).children('.' + previousClassName)
204
- .removeClass(oSettings.oClasses.sPageButtonDisabled)
205
- .addClass(disableClasses[previousClassName]);
206
-
207
- // Enable/Disable `next` button.
208
- $(an).children('.' + nextClassName)
209
- .removeClass(oSettings.oClasses.sPageButtonDisabled)
210
- .addClass(disableClasses[nextClassName]);
211
-
212
- // Enable/Disable `last` button.
213
- $(an).children('.' + lastClassName)
214
- .removeClass(oSettings.oClasses.sPageButtonDisabled)
215
- .addClass(disableClasses[lastClassName]);
216
-
217
- // Paginate of N pages text
218
- $(an).children('.' + paginateOfClassName).html(' of ' + iPages);
219
-
220
- // Current page numer input value
221
- $(an).children('.' + paginateInputClassName).val(iCurrentPage);
222
- }
223
- };
224
- })(jQuery);
22
+ function calcDisableClasses(oSettings) {
23
+ var start = oSettings._iDisplayStart;
24
+ var length = oSettings._iDisplayLength;
25
+ var visibleRecords = oSettings.fnRecordsDisplay();
26
+ var all = length === -1;
27
+
28
+ // Gordey Doronin: Re-used this code from main jQuery.dataTables source code. To be consistent.
29
+ var page = all ? 0 : Math.ceil(start / length);
30
+ var pages = all ? 1 : Math.ceil(visibleRecords / length);
31
+
32
+ var disableFirstPrevClass = (page > 0 ? '' : oSettings.oClasses.sPageButtonDisabled);
33
+ var disableNextLastClass = (page < pages - 1 ? '' : oSettings.oClasses.sPageButtonDisabled);
34
+
35
+ return {
36
+ 'first': disableFirstPrevClass,
37
+ 'previous': disableFirstPrevClass,
38
+ 'next': disableNextLastClass,
39
+ 'last': disableNextLastClass
40
+ };
41
+ }
42
+
43
+ function calcCurrentPage(oSettings) {
44
+ return Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
45
+ }
46
+
47
+ function calcPages(oSettings) {
48
+ return Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength);
49
+ }
50
+
51
+ var firstClassName = 'first';
52
+ var previousClassName = 'previous';
53
+ var nextClassName = 'next';
54
+ var lastClassName = 'last';
55
+
56
+ var paginateClassName = 'paginate';
57
+ var paginateOfClassName = 'paginate_of';
58
+ var paginatePageClassName = 'paginate_page';
59
+ var paginateInputClassName = 'paginate_input';
60
+
61
+ $.fn.dataTableExt.oPagination.input = {
62
+ 'fnInit': function (oSettings, nPaging, fnCallbackDraw) {
63
+ var nFirst = document.createElement('span');
64
+ var nPrevious = document.createElement('span');
65
+ var nNext = document.createElement('span');
66
+ var nLast = document.createElement('span');
67
+ var nInput = document.createElement('input');
68
+ var nPage = document.createElement('span');
69
+ var nOf = document.createElement('span');
70
+
71
+ var language = oSettings.oLanguage.oPaginate;
72
+ var classes = oSettings.oClasses;
73
+
74
+ nFirst.innerHTML = language.sFirst;
75
+ nPrevious.innerHTML = language.sPrevious;
76
+ nNext.innerHTML = language.sNext;
77
+ nLast.innerHTML = language.sLast;
78
+
79
+ nFirst.className = firstClassName + ' ' + classes.sPageButton;
80
+ nPrevious.className = previousClassName + ' ' + classes.sPageButton;
81
+ nNext.className = nextClassName + ' ' + classes.sPageButton;
82
+ nLast.className = lastClassName + ' ' + classes.sPageButton;
83
+
84
+ nOf.className = paginateOfClassName;
85
+ nPage.className = paginatePageClassName;
86
+ nInput.className = paginateInputClassName;
87
+
88
+ if (oSettings.sTableId !== '') {
89
+ nPaging.setAttribute('id', oSettings.sTableId + '_' + paginateClassName);
90
+ nFirst.setAttribute('id', oSettings.sTableId + '_' + firstClassName);
91
+ nPrevious.setAttribute('id', oSettings.sTableId + '_' + previousClassName);
92
+ nNext.setAttribute('id', oSettings.sTableId + '_' + nextClassName);
93
+ nLast.setAttribute('id', oSettings.sTableId + '_' + lastClassName);
94
+ }
95
+
96
+ nInput.type = 'text';
97
+ nPage.innerHTML = 'Page ';
98
+
99
+ nPaging.appendChild(nFirst);
100
+ nPaging.appendChild(nPrevious);
101
+ nPaging.appendChild(nPage);
102
+ nPaging.appendChild(nInput);
103
+ nPaging.appendChild(nOf);
104
+ nPaging.appendChild(nNext);
105
+ nPaging.appendChild(nLast);
106
+
107
+ $(nFirst).click(function() {
108
+ var iCurrentPage = calcCurrentPage(oSettings);
109
+ if (iCurrentPage !== 1) {
110
+ oSettings.oApi._fnPageChange(oSettings, 'first');
111
+ fnCallbackDraw(oSettings);
112
+ }
113
+ });
114
+
115
+ $(nPrevious).click(function() {
116
+ var iCurrentPage = calcCurrentPage(oSettings);
117
+ if (iCurrentPage !== 1) {
118
+ oSettings.oApi._fnPageChange(oSettings, 'previous');
119
+ fnCallbackDraw(oSettings);
120
+ }
121
+ });
122
+
123
+ $(nNext).click(function() {
124
+ var iCurrentPage = calcCurrentPage(oSettings);
125
+ if (iCurrentPage !== calcPages(oSettings)) {
126
+ oSettings.oApi._fnPageChange(oSettings, 'next');
127
+ fnCallbackDraw(oSettings);
128
+ }
129
+ });
130
+
131
+ $(nLast).click(function() {
132
+ var iCurrentPage = calcCurrentPage(oSettings);
133
+ if (iCurrentPage !== calcPages(oSettings)) {
134
+ oSettings.oApi._fnPageChange(oSettings, 'last');
135
+ fnCallbackDraw(oSettings);
136
+ }
137
+ });
138
+
139
+ $(nInput).keyup(function (e) {
140
+ // 38 = up arrow, 39 = right arrow
141
+ if (e.which === 38 || e.which === 39) {
142
+ this.value++;
143
+ }
144
+ // 37 = left arrow, 40 = down arrow
145
+ else if ((e.which === 37 || e.which === 40) && this.value > 1) {
146
+ this.value--;
147
+ }
148
+
149
+ if (this.value === '' || this.value.match(/[^0-9]/)) {
150
+ /* Nothing entered or non-numeric character */
151
+ this.value = this.value.replace(/[^\d]/g, ''); // don't even allow anything but digits
152
+ return;
153
+ }
154
+
155
+ var iNewStart = oSettings._iDisplayLength * (this.value - 1);
156
+ if (iNewStart < 0) {
157
+ iNewStart = 0;
158
+ }
159
+ if (iNewStart >= oSettings.fnRecordsDisplay()) {
160
+ iNewStart = (Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength) - 1) * oSettings._iDisplayLength;
161
+ }
162
+
163
+ oSettings._iDisplayStart = iNewStart;
164
+ fnCallbackDraw(oSettings);
165
+ });
166
+
167
+ // Take the brutal approach to cancelling text selection.
168
+ $('span', nPaging).bind('mousedown', function () { return false; });
169
+ $('span', nPaging).bind('selectstart', function() { return false; });
170
+
171
+ // If we can't page anyway, might as well not show it.
172
+ var iPages = calcPages(oSettings);
173
+ if (iPages <= 1) {
174
+ $(nPaging).hide();
175
+ }
176
+ },
177
+
178
+ 'fnUpdate': function (oSettings) {
179
+ if (!oSettings.aanFeatures.p) {
180
+ return;
181
+ }
182
+
183
+ var iPages = calcPages(oSettings);
184
+ var iCurrentPage = calcCurrentPage(oSettings);
185
+
186
+ var an = oSettings.aanFeatures.p;
187
+ if (iPages <= 1) // hide paging when we can't page
188
+ {
189
+ $(an).hide();
190
+ return;
191
+ }
192
+
193
+ var disableClasses = calcDisableClasses(oSettings);
194
+
195
+ $(an).show();
196
+
197
+ // Enable/Disable `first` button.
198
+ $(an).children('.' + firstClassName)
199
+ .removeClass(oSettings.oClasses.sPageButtonDisabled)
200
+ .addClass(disableClasses[firstClassName]);
201
+
202
+ // Enable/Disable `prev` button.
203
+ $(an).children('.' + previousClassName)
204
+ .removeClass(oSettings.oClasses.sPageButtonDisabled)
205
+ .addClass(disableClasses[previousClassName]);
206
+
207
+ // Enable/Disable `next` button.
208
+ $(an).children('.' + nextClassName)
209
+ .removeClass(oSettings.oClasses.sPageButtonDisabled)
210
+ .addClass(disableClasses[nextClassName]);
211
+
212
+ // Enable/Disable `last` button.
213
+ $(an).children('.' + lastClassName)
214
+ .removeClass(oSettings.oClasses.sPageButtonDisabled)
215
+ .addClass(disableClasses[lastClassName]);
216
+
217
+ // Paginate of N pages text
218
+ $(an).children('.' + paginateOfClassName).html(' of ' + iPages);
219
+
220
+ // Current page numer input value
221
+ $(an).children('.' + paginateInputClassName).val(iCurrentPage);
222
+ }
223
+ };
224
+ })(jQuery);