jquery-datatables 1.10.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +27 -0
  5. data/README.md +118 -0
  6. data/Rakefile +166 -0
  7. data/app/assets/images/datatables/sort_asc.png +0 -0
  8. data/app/assets/images/datatables/sort_asc_disabled.png +0 -0
  9. data/app/assets/images/datatables/sort_both.png +0 -0
  10. data/app/assets/images/datatables/sort_desc.png +0 -0
  11. data/app/assets/images/datatables/sort_desc_disabled.png +0 -0
  12. data/app/assets/javascripts/datatables/dataTables.bootstrap.js +182 -0
  13. data/app/assets/javascripts/datatables/dataTables.bootstrap4.js +184 -0
  14. data/app/assets/javascripts/datatables/dataTables.foundation.js +174 -0
  15. data/app/assets/javascripts/datatables/dataTables.jqueryui.js +164 -0
  16. data/app/assets/javascripts/datatables/dataTables.material.js +191 -0
  17. data/app/assets/javascripts/datatables/dataTables.semanticui.js +208 -0
  18. data/app/assets/javascripts/datatables/dataTables.uikit.js +176 -0
  19. data/app/assets/javascripts/datatables/extensions/AutoFill/autoFill.bootstrap.js +43 -0
  20. data/app/assets/javascripts/datatables/extensions/AutoFill/autoFill.bootstrap4.js +43 -0
  21. data/app/assets/javascripts/datatables/extensions/AutoFill/autoFill.foundation.js +43 -0
  22. data/app/assets/javascripts/datatables/extensions/AutoFill/autoFill.jqueryui.js +43 -0
  23. data/app/assets/javascripts/datatables/extensions/AutoFill/autoFill.semanticui.js +43 -0
  24. data/app/assets/javascripts/datatables/extensions/AutoFill/dataTables.autoFill.js +1036 -0
  25. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.bootstrap.js +68 -0
  26. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.bootstrap4.js +60 -0
  27. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.colVis.js +199 -0
  28. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.flash.js +1325 -0
  29. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.foundation.js +85 -0
  30. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.html5.js +1322 -0
  31. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.jqueryui.js +62 -0
  32. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.print.js +172 -0
  33. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.semanticui.js +57 -0
  34. data/app/assets/javascripts/datatables/extensions/Buttons/dataTables.buttons.js +1634 -0
  35. data/app/assets/javascripts/datatables/extensions/ColReorder/dataTables.colReorder.js +1335 -0
  36. data/app/assets/javascripts/datatables/extensions/FixedColumns/dataTables.fixedColumns.js +1623 -0
  37. data/app/assets/javascripts/datatables/extensions/FixedHeader/dataTables.fixedHeader.js +672 -0
  38. data/app/assets/javascripts/datatables/extensions/KeyTable/dataTables.keyTable.js +883 -0
  39. data/app/assets/javascripts/datatables/extensions/Responsive/dataTables.responsive.js +1232 -0
  40. data/app/assets/javascripts/datatables/extensions/Responsive/responsive.bootstrap.js +81 -0
  41. data/app/assets/javascripts/datatables/extensions/Responsive/responsive.bootstrap4.js +81 -0
  42. data/app/assets/javascripts/datatables/extensions/Responsive/responsive.foundation.js +62 -0
  43. data/app/assets/javascripts/datatables/extensions/Responsive/responsive.jqueryui.js +63 -0
  44. data/app/assets/javascripts/datatables/extensions/Responsive/responsive.semanticui.js +77 -0
  45. data/app/assets/javascripts/datatables/extensions/RowReorder/dataTables.rowReorder.js +709 -0
  46. data/app/assets/javascripts/datatables/extensions/Scroller/dataTables.scroller.js +1349 -0
  47. data/app/assets/javascripts/datatables/extensions/Select/dataTables.select.js +1109 -0
  48. data/app/assets/javascripts/datatables/jquery.dataTables.js +15278 -0
  49. data/app/assets/media/swf/flashExport.swf +0 -0
  50. data/app/assets/stylesheets/datatables/dataTables.bootstrap.css +185 -0
  51. data/app/assets/stylesheets/datatables/dataTables.bootstrap4.css +193 -0
  52. data/app/assets/stylesheets/datatables/dataTables.foundation.css +116 -0
  53. data/app/assets/stylesheets/datatables/dataTables.jqueryui.css +481 -0
  54. data/app/assets/stylesheets/datatables/dataTables.material.css +87 -0
  55. data/app/assets/stylesheets/datatables/dataTables.semanticui.css +103 -0
  56. data/app/assets/stylesheets/datatables/dataTables.uikit.css +146 -0
  57. data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.bootstrap.css +81 -0
  58. data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.bootstrap4.css +81 -0
  59. data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.dataTables.css +92 -0
  60. data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.foundation.css +85 -0
  61. data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.jqueryui.css +85 -0
  62. data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.semanticui.css +81 -0
  63. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap.css +102 -0
  64. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap4.css +163 -0
  65. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.dataTables.css +298 -0
  66. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.foundation.css +129 -0
  67. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.jqueryui.css +162 -0
  68. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.semanticui.css +114 -0
  69. data/app/assets/stylesheets/datatables/extensions/Buttons/common.scss +27 -0
  70. data/app/assets/stylesheets/datatables/extensions/Buttons/mixins.scss +89 -0
  71. data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.bootstrap.css +11 -0
  72. data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.bootstrap4.css +11 -0
  73. data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.dataTables.css +11 -0
  74. data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.foundation.css +11 -0
  75. data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.jqueryui.css +11 -0
  76. data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.semanticui.css +11 -0
  77. data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.bootstrap.css +44 -0
  78. data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.bootstrap4.css +44 -0
  79. data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.dataTables.css +18 -0
  80. data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.foundation.css +27 -0
  81. data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.jqueryui.css +8 -0
  82. data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.semanticui.css +16 -0
  83. data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.bootstrap.css +20 -0
  84. data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.bootstrap4.css +20 -0
  85. data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.dataTables.css +19 -0
  86. data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.foundation.css +20 -0
  87. data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.jqueryui.css +15 -0
  88. data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.semanticui.css +14 -0
  89. data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.bootstrap.css +5 -0
  90. data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.bootstrap4.css +5 -0
  91. data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.dataTables.css +5 -0
  92. data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.foundation.css +5 -0
  93. data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.jqueryui.css +5 -0
  94. data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.semanticui.css +5 -0
  95. data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.bootstrap.css +181 -0
  96. data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.bootstrap4.css +181 -0
  97. data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.dataTables.css +178 -0
  98. data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.foundation.css +181 -0
  99. data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.jqueryui.css +178 -0
  100. data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.semanticui.css +181 -0
  101. data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.bootstrap.css +22 -0
  102. data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.bootstrap4.css +22 -0
  103. data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.dataTables.css +22 -0
  104. data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.foundation.css +22 -0
  105. data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.jqueryui.css +22 -0
  106. data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.semanticui.css +22 -0
  107. data/app/assets/stylesheets/datatables/extensions/RowReorder/semanticui.scss +5 -0
  108. data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.bootstrap.css +24 -0
  109. data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.bootstrap4.css +24 -0
  110. data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.dataTables.css +20 -0
  111. data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.foundation.css +17 -0
  112. data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.jqueryui.css +20 -0
  113. data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.semanticui.css +20 -0
  114. data/app/assets/stylesheets/datatables/extensions/Select/select.bootstrap.css +110 -0
  115. data/app/assets/stylesheets/datatables/extensions/Select/select.bootstrap4.css +110 -0
  116. data/app/assets/stylesheets/datatables/extensions/Select/select.dataTables.css +100 -0
  117. data/app/assets/stylesheets/datatables/extensions/Select/select.foundation.css +112 -0
  118. data/app/assets/stylesheets/datatables/extensions/Select/select.jqueryui.css +100 -0
  119. data/app/assets/stylesheets/datatables/extensions/Select/select.semanticui.css +105 -0
  120. data/app/assets/stylesheets/datatables/jquery.dataTables.css +452 -0
  121. data/app/assets/stylesheets/datatables/jquery.dataTables_themeroller.css +416 -0
  122. data/jquery-datatables.gemspec +27 -0
  123. data/lib/generators/jquery/datatables/install_generator.rb +63 -0
  124. data/lib/generators/jquery/datatables/templates/bootstrap.css.tt +15 -0
  125. data/lib/generators/jquery/datatables/templates/bootstrap.js.tt +22 -0
  126. data/lib/generators/jquery/datatables/templates/bootstrap4.css.tt +15 -0
  127. data/lib/generators/jquery/datatables/templates/bootstrap4.js.tt +22 -0
  128. data/lib/generators/jquery/datatables/templates/foundation.css.tt +15 -0
  129. data/lib/generators/jquery/datatables/templates/foundation.js.tt +24 -0
  130. data/lib/generators/jquery/datatables/templates/jqueryui.css.tt +15 -0
  131. data/lib/generators/jquery/datatables/templates/jqueryui.js.tt +18 -0
  132. data/lib/generators/jquery/datatables/templates/material.css.tt +15 -0
  133. data/lib/generators/jquery/datatables/templates/material.js.tt +19 -0
  134. data/lib/generators/jquery/datatables/templates/regular.css.tt +15 -0
  135. data/lib/generators/jquery/datatables/templates/regular.js.tt +18 -0
  136. data/lib/generators/jquery/datatables/templates/semanticui.css.tt +16 -0
  137. data/lib/generators/jquery/datatables/templates/semanticui.js.tt +22 -0
  138. data/lib/generators/jquery/datatables/templates/uikit.css.tt +15 -0
  139. data/lib/generators/jquery/datatables/templates/uikit.js.tt +19 -0
  140. data/lib/jquery-datatables.rb +26 -0
  141. data/lib/jquery-datatables/engine.rb +11 -0
  142. data/lib/jquery-datatables/version.rb +6 -0
  143. metadata +269 -0
@@ -0,0 +1,672 @@
1
+ /*! FixedHeader 3.1.2
2
+ * ©2009-2016 SpryMedia Ltd - datatables.net/license
3
+ */
4
+
5
+ /**
6
+ * @summary FixedHeader
7
+ * @description Fix a table's header or footer, so it is always visible while
8
+ * scrolling
9
+ * @version 3.1.2
10
+ * @file dataTables.fixedHeader.js
11
+ * @author SpryMedia Ltd (www.sprymedia.co.uk)
12
+ * @contact www.sprymedia.co.uk/contact
13
+ * @copyright Copyright 2009-2016 SpryMedia Ltd.
14
+ *
15
+ * This source file is free software, available under the following license:
16
+ * MIT license - http://datatables.net/license/mit
17
+ *
18
+ * This source file is distributed in the hope that it will be useful, but
19
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
21
+ *
22
+ * For details please refer to: http://www.datatables.net
23
+ */
24
+
25
+ (function( factory ){
26
+ if ( typeof define === 'function' && define.amd ) {
27
+ // AMD
28
+ define( ['jquery', 'datatables.net'], function ( $ ) {
29
+ return factory( $, window, document );
30
+ } );
31
+ }
32
+ else if ( typeof exports === 'object' ) {
33
+ // CommonJS
34
+ module.exports = function (root, $) {
35
+ if ( ! root ) {
36
+ root = window;
37
+ }
38
+
39
+ if ( ! $ || ! $.fn.dataTable ) {
40
+ $ = require('datatables.net')(root, $).$;
41
+ }
42
+
43
+ return factory( $, root, root.document );
44
+ };
45
+ }
46
+ else {
47
+ // Browser
48
+ factory( jQuery, window, document );
49
+ }
50
+ }(function( $, window, document, undefined ) {
51
+ 'use strict';
52
+ var DataTable = $.fn.dataTable;
53
+
54
+
55
+ var _instCounter = 0;
56
+
57
+ var FixedHeader = function ( dt, config ) {
58
+ // Sanity check - you just know it will happen
59
+ if ( ! (this instanceof FixedHeader) ) {
60
+ throw "FixedHeader must be initialised with the 'new' keyword.";
61
+ }
62
+
63
+ // Allow a boolean true for defaults
64
+ if ( config === true ) {
65
+ config = {};
66
+ }
67
+
68
+ dt = new DataTable.Api( dt );
69
+
70
+ this.c = $.extend( true, {}, FixedHeader.defaults, config );
71
+
72
+ this.s = {
73
+ dt: dt,
74
+ position: {
75
+ theadTop: 0,
76
+ tbodyTop: 0,
77
+ tfootTop: 0,
78
+ tfootBottom: 0,
79
+ width: 0,
80
+ left: 0,
81
+ tfootHeight: 0,
82
+ theadHeight: 0,
83
+ windowHeight: $(window).height(),
84
+ visible: true
85
+ },
86
+ headerMode: null,
87
+ footerMode: null,
88
+ autoWidth: dt.settings()[0].oFeatures.bAutoWidth,
89
+ namespace: '.dtfc'+(_instCounter++),
90
+ scrollLeft: {
91
+ header: -1,
92
+ footer: -1
93
+ },
94
+ enable: true
95
+ };
96
+
97
+ this.dom = {
98
+ floatingHeader: null,
99
+ thead: $(dt.table().header()),
100
+ tbody: $(dt.table().body()),
101
+ tfoot: $(dt.table().footer()),
102
+ header: {
103
+ host: null,
104
+ floating: null,
105
+ placeholder: null
106
+ },
107
+ footer: {
108
+ host: null,
109
+ floating: null,
110
+ placeholder: null
111
+ }
112
+ };
113
+
114
+ this.dom.header.host = this.dom.thead.parent();
115
+ this.dom.footer.host = this.dom.tfoot.parent();
116
+
117
+ var dtSettings = dt.settings()[0];
118
+ if ( dtSettings._fixedHeader ) {
119
+ throw "FixedHeader already initialised on table "+dtSettings.nTable.id;
120
+ }
121
+
122
+ dtSettings._fixedHeader = this;
123
+
124
+ this._constructor();
125
+ };
126
+
127
+
128
+ /*
129
+ * Variable: FixedHeader
130
+ * Purpose: Prototype for FixedHeader
131
+ * Scope: global
132
+ */
133
+ $.extend( FixedHeader.prototype, {
134
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
135
+ * API methods
136
+ */
137
+
138
+ /**
139
+ * Enable / disable the fixed elements
140
+ *
141
+ * @param {boolean} enable `true` to enable, `false` to disable
142
+ */
143
+ enable: function ( enable )
144
+ {
145
+ this.s.enable = enable;
146
+
147
+ if ( this.c.header ) {
148
+ this._modeChange( 'in-place', 'header', true );
149
+ }
150
+
151
+ if ( this.c.footer && this.dom.tfoot.length ) {
152
+ this._modeChange( 'in-place', 'footer', true );
153
+ }
154
+
155
+ this.update();
156
+ },
157
+
158
+ /**
159
+ * Set header offset
160
+ *
161
+ * @param {int} new value for headerOffset
162
+ */
163
+ headerOffset: function ( offset )
164
+ {
165
+ if ( offset !== undefined ) {
166
+ this.c.headerOffset = offset;
167
+ this.update();
168
+ }
169
+
170
+ return this.c.headerOffset;
171
+ },
172
+
173
+ /**
174
+ * Set footer offset
175
+ *
176
+ * @param {int} new value for footerOffset
177
+ */
178
+ footerOffset: function ( offset )
179
+ {
180
+ if ( offset !== undefined ) {
181
+ this.c.footerOffset = offset;
182
+ this.update();
183
+ }
184
+
185
+ return this.c.footerOffset;
186
+ },
187
+
188
+
189
+ /**
190
+ * Recalculate the position of the fixed elements and force them into place
191
+ */
192
+ update: function ()
193
+ {
194
+ this._positions();
195
+ this._scroll( true );
196
+ },
197
+
198
+
199
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
200
+ * Constructor
201
+ */
202
+
203
+ /**
204
+ * FixedHeader constructor - adding the required event listeners and
205
+ * simple initialisation
206
+ *
207
+ * @private
208
+ */
209
+ _constructor: function ()
210
+ {
211
+ var that = this;
212
+ var dt = this.s.dt;
213
+
214
+ $(window)
215
+ .on( 'scroll'+this.s.namespace, function () {
216
+ that._scroll();
217
+ } )
218
+ .on( 'resize'+this.s.namespace, function () {
219
+ that.s.position.windowHeight = $(window).height();
220
+ that.update();
221
+ } );
222
+
223
+ var autoHeader = $('.fh-fixedHeader');
224
+ if ( ! this.c.headerOffset && autoHeader.length ) {
225
+ this.c.headerOffset = autoHeader.outerHeight();
226
+ }
227
+
228
+ var autoFooter = $('.fh-fixedFooter');
229
+ if ( ! this.c.footerOffset && autoFooter.length ) {
230
+ this.c.footerOffset = autoFooter.outerHeight();
231
+ }
232
+
233
+ dt.on( 'column-reorder.dt.dtfc column-visibility.dt.dtfc draw.dt.dtfc column-sizing.dt.dtfc', function () {
234
+ that.update();
235
+ } );
236
+
237
+ dt.on( 'destroy.dtfc', function () {
238
+ dt.off( '.dtfc' );
239
+ $(window).off( that.s.namespace );
240
+ } );
241
+
242
+ this._positions();
243
+ this._scroll();
244
+ },
245
+
246
+
247
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
248
+ * Private methods
249
+ */
250
+
251
+ /**
252
+ * Clone a fixed item to act as a place holder for the original element
253
+ * which is moved into a clone of the table element, and moved around the
254
+ * document to give the fixed effect.
255
+ *
256
+ * @param {string} item 'header' or 'footer'
257
+ * @param {boolean} force Force the clone to happen, or allow automatic
258
+ * decision (reuse existing if available)
259
+ * @private
260
+ */
261
+ _clone: function ( item, force )
262
+ {
263
+ var dt = this.s.dt;
264
+ var itemDom = this.dom[ item ];
265
+ var itemElement = item === 'header' ?
266
+ this.dom.thead :
267
+ this.dom.tfoot;
268
+
269
+ if ( ! force && itemDom.floating ) {
270
+ // existing floating element - reuse it
271
+ itemDom.floating.removeClass( 'fixedHeader-floating fixedHeader-locked' );
272
+ }
273
+ else {
274
+ if ( itemDom.floating ) {
275
+ itemDom.placeholder.remove();
276
+ this._unsize( item );
277
+ itemDom.floating.children().detach();
278
+ itemDom.floating.remove();
279
+ }
280
+
281
+ itemDom.floating = $( dt.table().node().cloneNode( false ) )
282
+ .css( 'table-layout', 'fixed' )
283
+ .removeAttr( 'id' )
284
+ .append( itemElement )
285
+ .appendTo( 'body' );
286
+
287
+ // Insert a fake thead/tfoot into the DataTable to stop it jumping around
288
+ itemDom.placeholder = itemElement.clone( false );
289
+ itemDom.host.prepend( itemDom.placeholder );
290
+
291
+ // Clone widths
292
+ this._matchWidths( itemDom.placeholder, itemDom.floating );
293
+ }
294
+ },
295
+
296
+ /**
297
+ * Copy widths from the cells in one element to another. This is required
298
+ * for the footer as the footer in the main table takes its sizes from the
299
+ * header columns. That isn't present in the footer so to have it still
300
+ * align correctly, the sizes need to be copied over. It is also required
301
+ * for the header when auto width is not enabled
302
+ *
303
+ * @param {jQuery} from Copy widths from
304
+ * @param {jQuery} to Copy widths to
305
+ * @private
306
+ */
307
+ _matchWidths: function ( from, to ) {
308
+ var get = function ( name ) {
309
+ return $(name, from)
310
+ .map( function () {
311
+ return $(this).width();
312
+ } ).toArray();
313
+ };
314
+
315
+ var set = function ( name, toWidths ) {
316
+ $(name, to).each( function ( i ) {
317
+ $(this).css( {
318
+ width: toWidths[i],
319
+ minWidth: toWidths[i]
320
+ } );
321
+ } );
322
+ };
323
+
324
+ var thWidths = get( 'th' );
325
+ var tdWidths = get( 'td' );
326
+
327
+ set( 'th', thWidths );
328
+ set( 'td', tdWidths );
329
+ },
330
+
331
+ /**
332
+ * Remove assigned widths from the cells in an element. This is required
333
+ * when inserting the footer back into the main table so the size is defined
334
+ * by the header columns and also when auto width is disabled in the
335
+ * DataTable.
336
+ *
337
+ * @param {string} item The `header` or `footer`
338
+ * @private
339
+ */
340
+ _unsize: function ( item ) {
341
+ var el = this.dom[ item ].floating;
342
+
343
+ if ( el && (item === 'footer' || (item === 'header' && ! this.s.autoWidth)) ) {
344
+ $('th, td', el).css( {
345
+ width: '',
346
+ minWidth: ''
347
+ } );
348
+ }
349
+ else if ( el && item === 'header' ) {
350
+ $('th, td', el).css( 'min-width', '' );
351
+ }
352
+ },
353
+
354
+ /**
355
+ * Reposition the floating elements to take account of horizontal page
356
+ * scroll
357
+ *
358
+ * @param {string} item The `header` or `footer`
359
+ * @param {int} scrollLeft Document scrollLeft
360
+ * @private
361
+ */
362
+ _horizontal: function ( item, scrollLeft )
363
+ {
364
+ var itemDom = this.dom[ item ];
365
+ var position = this.s.position;
366
+ var lastScrollLeft = this.s.scrollLeft;
367
+
368
+ if ( itemDom.floating && lastScrollLeft[ item ] !== scrollLeft ) {
369
+ itemDom.floating.css( 'left', position.left - scrollLeft );
370
+
371
+ lastScrollLeft[ item ] = scrollLeft;
372
+ }
373
+ },
374
+
375
+ /**
376
+ * Change from one display mode to another. Each fixed item can be in one
377
+ * of:
378
+ *
379
+ * * `in-place` - In the main DataTable
380
+ * * `in` - Floating over the DataTable
381
+ * * `below` - (Header only) Fixed to the bottom of the table body
382
+ * * `above` - (Footer only) Fixed to the top of the table body
383
+ *
384
+ * @param {string} mode Mode that the item should be shown in
385
+ * @param {string} item 'header' or 'footer'
386
+ * @param {boolean} forceChange Force a redraw of the mode, even if already
387
+ * in that mode.
388
+ * @private
389
+ */
390
+ _modeChange: function ( mode, item, forceChange )
391
+ {
392
+ var dt = this.s.dt;
393
+ var itemDom = this.dom[ item ];
394
+ var position = this.s.position;
395
+
396
+ // Record focus. Browser's will cause input elements to loose focus if
397
+ // they are inserted else where in the doc
398
+ var tablePart = this.dom[ item==='footer' ? 'tfoot' : 'thead' ];
399
+ var focus = $.contains( tablePart[0], document.activeElement ) ?
400
+ document.activeElement :
401
+ null;
402
+
403
+ if ( mode === 'in-place' ) {
404
+ // Insert the header back into the table's real header
405
+ if ( itemDom.placeholder ) {
406
+ itemDom.placeholder.remove();
407
+ itemDom.placeholder = null;
408
+ }
409
+
410
+ this._unsize( item );
411
+
412
+ if ( item === 'header' ) {
413
+ itemDom.host.prepend( this.dom.thead );
414
+ }
415
+ else {
416
+ itemDom.host.append( this.dom.tfoot );
417
+ }
418
+
419
+ if ( itemDom.floating ) {
420
+ itemDom.floating.remove();
421
+ itemDom.floating = null;
422
+ }
423
+ }
424
+ else if ( mode === 'in' ) {
425
+ // Remove the header from the read header and insert into a fixed
426
+ // positioned floating table clone
427
+ this._clone( item, forceChange );
428
+
429
+ itemDom.floating
430
+ .addClass( 'fixedHeader-floating' )
431
+ .css( item === 'header' ? 'top' : 'bottom', this.c[item+'Offset'] )
432
+ .css( 'left', position.left+'px' )
433
+ .css( 'width', position.width+'px' );
434
+
435
+ if ( item === 'footer' ) {
436
+ itemDom.floating.css( 'top', '' );
437
+ }
438
+ }
439
+ else if ( mode === 'below' ) { // only used for the header
440
+ // Fix the position of the floating header at base of the table body
441
+ this._clone( item, forceChange );
442
+
443
+ itemDom.floating
444
+ .addClass( 'fixedHeader-locked' )
445
+ .css( 'top', position.tfootTop - position.theadHeight )
446
+ .css( 'left', position.left+'px' )
447
+ .css( 'width', position.width+'px' );
448
+ }
449
+ else if ( mode === 'above' ) { // only used for the footer
450
+ // Fix the position of the floating footer at top of the table body
451
+ this._clone( item, forceChange );
452
+
453
+ itemDom.floating
454
+ .addClass( 'fixedHeader-locked' )
455
+ .css( 'top', position.tbodyTop )
456
+ .css( 'left', position.left+'px' )
457
+ .css( 'width', position.width+'px' );
458
+ }
459
+
460
+ // Restore focus if it was lost
461
+ if ( focus && focus !== document.activeElement ) {
462
+ focus.focus();
463
+ }
464
+
465
+ this.s.scrollLeft.header = -1;
466
+ this.s.scrollLeft.footer = -1;
467
+ this.s[item+'Mode'] = mode;
468
+ },
469
+
470
+ /**
471
+ * Cache the positional information that is required for the mode
472
+ * calculations that FixedHeader performs.
473
+ *
474
+ * @private
475
+ */
476
+ _positions: function ()
477
+ {
478
+ var dt = this.s.dt;
479
+ var table = dt.table();
480
+ var position = this.s.position;
481
+ var dom = this.dom;
482
+ var tableNode = $(table.node());
483
+
484
+ // Need to use the header and footer that are in the main table,
485
+ // regardless of if they are clones, since they hold the positions we
486
+ // want to measure from
487
+ var thead = tableNode.children('thead');
488
+ var tfoot = tableNode.children('tfoot');
489
+ var tbody = dom.tbody;
490
+
491
+ position.visible = tableNode.is(':visible');
492
+ position.width = tableNode.outerWidth();
493
+ position.left = tableNode.offset().left;
494
+ position.theadTop = thead.offset().top;
495
+ position.tbodyTop = tbody.offset().top;
496
+ position.theadHeight = position.tbodyTop - position.theadTop;
497
+
498
+ if ( tfoot.length ) {
499
+ position.tfootTop = tfoot.offset().top;
500
+ position.tfootBottom = position.tfootTop + tfoot.outerHeight();
501
+ position.tfootHeight = position.tfootBottom - position.tfootTop;
502
+ }
503
+ else {
504
+ position.tfootTop = position.tbodyTop + tbody.outerHeight();
505
+ position.tfootBottom = position.tfootTop;
506
+ position.tfootHeight = position.tfootTop;
507
+ }
508
+ },
509
+
510
+
511
+ /**
512
+ * Mode calculation - determine what mode the fixed items should be placed
513
+ * into.
514
+ *
515
+ * @param {boolean} forceChange Force a redraw of the mode, even if already
516
+ * in that mode.
517
+ * @private
518
+ */
519
+ _scroll: function ( forceChange )
520
+ {
521
+ var windowTop = $(document).scrollTop();
522
+ var windowLeft = $(document).scrollLeft();
523
+ var position = this.s.position;
524
+ var headerMode, footerMode;
525
+
526
+ if ( ! this.s.enable ) {
527
+ return;
528
+ }
529
+
530
+ if ( this.c.header ) {
531
+ if ( ! position.visible || windowTop <= position.theadTop - this.c.headerOffset ) {
532
+ headerMode = 'in-place';
533
+ }
534
+ else if ( windowTop <= position.tfootTop - position.theadHeight - this.c.headerOffset ) {
535
+ headerMode = 'in';
536
+ }
537
+ else {
538
+ headerMode = 'below';
539
+ }
540
+
541
+ if ( forceChange || headerMode !== this.s.headerMode ) {
542
+ this._modeChange( headerMode, 'header', forceChange );
543
+ }
544
+
545
+ this._horizontal( 'header', windowLeft );
546
+ }
547
+
548
+ if ( this.c.footer && this.dom.tfoot.length ) {
549
+ if ( ! position.visible || windowTop + position.windowHeight >= position.tfootBottom + this.c.footerOffset ) {
550
+ footerMode = 'in-place';
551
+ }
552
+ else if ( position.windowHeight + windowTop > position.tbodyTop + position.tfootHeight + this.c.footerOffset ) {
553
+ footerMode = 'in';
554
+ }
555
+ else {
556
+ footerMode = 'above';
557
+ }
558
+
559
+ if ( forceChange || footerMode !== this.s.footerMode ) {
560
+ this._modeChange( footerMode, 'footer', forceChange );
561
+ }
562
+
563
+ this._horizontal( 'footer', windowLeft );
564
+ }
565
+ }
566
+ } );
567
+
568
+
569
+ /**
570
+ * Version
571
+ * @type {String}
572
+ * @static
573
+ */
574
+ FixedHeader.version = "3.1.2";
575
+
576
+ /**
577
+ * Defaults
578
+ * @type {Object}
579
+ * @static
580
+ */
581
+ FixedHeader.defaults = {
582
+ header: true,
583
+ footer: false,
584
+ headerOffset: 0,
585
+ footerOffset: 0
586
+ };
587
+
588
+
589
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
590
+ * DataTables interfaces
591
+ */
592
+
593
+ // Attach for constructor access
594
+ $.fn.dataTable.FixedHeader = FixedHeader;
595
+ $.fn.DataTable.FixedHeader = FixedHeader;
596
+
597
+
598
+ // DataTables creation - check if the FixedHeader option has been defined on the
599
+ // table and if so, initialise
600
+ $(document).on( 'init.dt.dtfh', function (e, settings, json) {
601
+ if ( e.namespace !== 'dt' ) {
602
+ return;
603
+ }
604
+
605
+ var init = settings.oInit.fixedHeader;
606
+ var defaults = DataTable.defaults.fixedHeader;
607
+
608
+ if ( (init || defaults) && ! settings._fixedHeader ) {
609
+ var opts = $.extend( {}, defaults, init );
610
+
611
+ if ( init !== false ) {
612
+ new FixedHeader( settings, opts );
613
+ }
614
+ }
615
+ } );
616
+
617
+ // DataTables API methods
618
+ DataTable.Api.register( 'fixedHeader()', function () {} );
619
+
620
+ DataTable.Api.register( 'fixedHeader.adjust()', function () {
621
+ return this.iterator( 'table', function ( ctx ) {
622
+ var fh = ctx._fixedHeader;
623
+
624
+ if ( fh ) {
625
+ fh.update();
626
+ }
627
+ } );
628
+ } );
629
+
630
+ DataTable.Api.register( 'fixedHeader.enable()', function ( flag ) {
631
+ return this.iterator( 'table', function ( ctx ) {
632
+ var fh = ctx._fixedHeader;
633
+
634
+ if ( fh ) {
635
+ fh.enable( flag !== undefined ? flag : true );
636
+ }
637
+ } );
638
+ } );
639
+
640
+ DataTable.Api.register( 'fixedHeader.disable()', function ( ) {
641
+ return this.iterator( 'table', function ( ctx ) {
642
+ var fh = ctx._fixedHeader;
643
+
644
+ if ( fh ) {
645
+ fh.enable( false );
646
+ }
647
+ } );
648
+ } );
649
+
650
+ $.each( ['header', 'footer'], function ( i, el ) {
651
+ DataTable.Api.register( 'fixedHeader.'+el+'Offset()', function ( offset ) {
652
+ var ctx = this.context;
653
+
654
+ if ( offset === undefined ) {
655
+ return ctx.length && ctx[0]._fixedHeader ?
656
+ ctx[0]._fixedHeader[el +'Offset']() :
657
+ undefined;
658
+ }
659
+
660
+ return this.iterator( 'table', function ( ctx ) {
661
+ var fh = ctx._fixedHeader;
662
+
663
+ if ( fh ) {
664
+ fh[ el +'Offset' ]( offset );
665
+ }
666
+ } );
667
+ } );
668
+ } );
669
+
670
+
671
+ return FixedHeader;
672
+ }));