jquery-datatables-rails 1.12.2 → 2.1.10.0.0
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.
- checksums.yaml +4 -4
- data/app/assets/images/dataTables/extras/filler.png +0 -0
- data/app/assets/images/dataTables/extras/loading-background.png +0 -0
- data/app/assets/images/dataTables/sort_asc_disabled.png +0 -0
- data/app/assets/javascripts/dataTables/extras/dataTables.autoFill.js +851 -0
- data/app/assets/javascripts/dataTables/extras/{ColReorder.js → dataTables.colReorder.js} +558 -223
- data/app/assets/javascripts/dataTables/extras/dataTables.colVis.js +1096 -0
- data/app/assets/javascripts/dataTables/extras/{FixedColumns.js → dataTables.fixedColumns.js} +163 -113
- data/app/assets/javascripts/dataTables/extras/{FixedHeader.js → dataTables.fixedHeader.js} +306 -219
- data/app/assets/javascripts/dataTables/extras/{KeyTable.js → dataTables.keyTable.js} +155 -95
- data/app/assets/javascripts/dataTables/extras/{Scroller.js → dataTables.scroller.js} +469 -188
- data/app/assets/javascripts/dataTables/extras/{TableTools.js → dataTables.tableTools.js} +949 -341
- data/app/assets/javascripts/dataTables/jquery.dataTables.foundation.js +4 -4
- data/app/assets/javascripts/dataTables/jquery.dataTables.js +10711 -8427
- data/app/assets/media/dataTables/extras/swf/copy_csv_xls.swf +0 -0
- data/app/assets/media/dataTables/extras/swf/copy_csv_xls_pdf.swf +0 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.autoFill.css.scss +24 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.colReorder.css.scss +14 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.colVis.css.scss +184 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.colvis.jqueryui.css.scss +23 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.fixedColumns.css.scss +24 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.fixedHeader.css.scss +7 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.keyTable.css.scss +7 -0
- data/app/assets/stylesheets/dataTables/extras/dataTables.scroller.css.scss +44 -0
- data/app/assets/stylesheets/dataTables/extras/{TableTools.css.erb → dataTables.tableTools.css.scss} +30 -15
- data/app/assets/stylesheets/dataTables/jquery.dataTables.bootstrap.css.scss +6 -0
- data/app/assets/stylesheets/dataTables/jquery.dataTables.css.scss +363 -184
- data/app/assets/stylesheets/dataTables/src/jquery.dataTables_themeroller.css +307 -220
- data/lib/jquery/datatables/rails/version.rb +1 -1
- metadata +42 -22
- data/app/assets/javascripts/dataTables/extras/AutoFill.js +0 -820
- data/app/assets/javascripts/dataTables/extras/ColVis.js +0 -1005
- data/app/assets/javascripts/dataTables/extras/TableTools.min.js +0 -77
- data/app/assets/stylesheets/dataTables/extras/ColReorder.css.erb +0 -21
- data/app/assets/stylesheets/dataTables/extras/ColVis.css +0 -76
- data/app/assets/stylesheets/dataTables/extras/ColVisAlt.css.erb +0 -104
@@ -0,0 +1,1096 @@
|
|
1
|
+
/*! ColVis 1.1.0
|
2
|
+
* ©2010-2014 SpryMedia Ltd - datatables.net/license
|
3
|
+
*/
|
4
|
+
|
5
|
+
/**
|
6
|
+
* @summary ColVis
|
7
|
+
* @description Controls for column visibility in DataTables
|
8
|
+
* @version 1.1.0
|
9
|
+
* @file dataTables.colReorder.js
|
10
|
+
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
11
|
+
* @contact www.sprymedia.co.uk/contact
|
12
|
+
* @copyright Copyright 2010-2014 SpryMedia Ltd.
|
13
|
+
*
|
14
|
+
* This source file is free software, available under the following license:
|
15
|
+
* MIT license - http://datatables.net/license/mit
|
16
|
+
*
|
17
|
+
* This source file is distributed in the hope that it will be useful, but
|
18
|
+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
19
|
+
* or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
|
20
|
+
*
|
21
|
+
* For details please refer to: http://www.datatables.net
|
22
|
+
*/
|
23
|
+
|
24
|
+
(function(window, document, undefined) {
|
25
|
+
|
26
|
+
|
27
|
+
var factory = function( $, DataTable ) {
|
28
|
+
"use strict";
|
29
|
+
|
30
|
+
/**
|
31
|
+
* ColVis provides column visibility control for DataTables
|
32
|
+
*
|
33
|
+
* @class ColVis
|
34
|
+
* @constructor
|
35
|
+
* @param {object} DataTables settings object. With DataTables 1.10 this can
|
36
|
+
* also be and API instance, table node, jQuery collection or jQuery selector.
|
37
|
+
* @param {object} ColVis configuration options
|
38
|
+
*/
|
39
|
+
var ColVis = function( oDTSettings, oInit )
|
40
|
+
{
|
41
|
+
/* Santiy check that we are a new instance */
|
42
|
+
if ( !this.CLASS || this.CLASS != "ColVis" )
|
43
|
+
{
|
44
|
+
alert( "Warning: ColVis must be initialised with the keyword 'new'" );
|
45
|
+
}
|
46
|
+
|
47
|
+
if ( typeof oInit == 'undefined' )
|
48
|
+
{
|
49
|
+
oInit = {};
|
50
|
+
}
|
51
|
+
|
52
|
+
if ( $.fn.dataTable.camelToHungarian ) {
|
53
|
+
$.fn.dataTable.camelToHungarian( ColVis.defaults, oInit );
|
54
|
+
}
|
55
|
+
|
56
|
+
|
57
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
58
|
+
* Public class variables
|
59
|
+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @namespace Settings object which contains customisable information for
|
63
|
+
* ColVis instance. Augmented by ColVis.defaults
|
64
|
+
*/
|
65
|
+
this.s = {
|
66
|
+
/**
|
67
|
+
* DataTables settings object
|
68
|
+
* @property dt
|
69
|
+
* @type Object
|
70
|
+
* @default null
|
71
|
+
*/
|
72
|
+
"dt": null,
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Customisation object
|
76
|
+
* @property oInit
|
77
|
+
* @type Object
|
78
|
+
* @default passed in
|
79
|
+
*/
|
80
|
+
"oInit": oInit,
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Flag to say if the collection is hidden
|
84
|
+
* @property hidden
|
85
|
+
* @type boolean
|
86
|
+
* @default true
|
87
|
+
*/
|
88
|
+
"hidden": true,
|
89
|
+
|
90
|
+
/**
|
91
|
+
* Store the original visibility settings so they could be restored
|
92
|
+
* @property abOriginal
|
93
|
+
* @type Array
|
94
|
+
* @default []
|
95
|
+
*/
|
96
|
+
"abOriginal": []
|
97
|
+
};
|
98
|
+
|
99
|
+
|
100
|
+
/**
|
101
|
+
* @namespace Common and useful DOM elements for the class instance
|
102
|
+
*/
|
103
|
+
this.dom = {
|
104
|
+
/**
|
105
|
+
* Wrapper for the button - given back to DataTables as the node to insert
|
106
|
+
* @property wrapper
|
107
|
+
* @type Node
|
108
|
+
* @default null
|
109
|
+
*/
|
110
|
+
"wrapper": null,
|
111
|
+
|
112
|
+
/**
|
113
|
+
* Activation button
|
114
|
+
* @property button
|
115
|
+
* @type Node
|
116
|
+
* @default null
|
117
|
+
*/
|
118
|
+
"button": null,
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Collection list node
|
122
|
+
* @property collection
|
123
|
+
* @type Node
|
124
|
+
* @default null
|
125
|
+
*/
|
126
|
+
"collection": null,
|
127
|
+
|
128
|
+
/**
|
129
|
+
* Background node used for shading the display and event capturing
|
130
|
+
* @property background
|
131
|
+
* @type Node
|
132
|
+
* @default null
|
133
|
+
*/
|
134
|
+
"background": null,
|
135
|
+
|
136
|
+
/**
|
137
|
+
* Element to position over the activation button to catch mouse events when using mouseover
|
138
|
+
* @property catcher
|
139
|
+
* @type Node
|
140
|
+
* @default null
|
141
|
+
*/
|
142
|
+
"catcher": null,
|
143
|
+
|
144
|
+
/**
|
145
|
+
* List of button elements
|
146
|
+
* @property buttons
|
147
|
+
* @type Array
|
148
|
+
* @default []
|
149
|
+
*/
|
150
|
+
"buttons": [],
|
151
|
+
|
152
|
+
/**
|
153
|
+
* List of group button elements
|
154
|
+
* @property groupButtons
|
155
|
+
* @type Array
|
156
|
+
* @default []
|
157
|
+
*/
|
158
|
+
"groupButtons": [],
|
159
|
+
|
160
|
+
/**
|
161
|
+
* Restore button
|
162
|
+
* @property restore
|
163
|
+
* @type Node
|
164
|
+
* @default null
|
165
|
+
*/
|
166
|
+
"restore": null
|
167
|
+
};
|
168
|
+
|
169
|
+
/* Store global reference */
|
170
|
+
ColVis.aInstances.push( this );
|
171
|
+
|
172
|
+
/* Constructor logic */
|
173
|
+
this.s.dt = $.fn.dataTable.Api ?
|
174
|
+
new $.fn.dataTable.Api( oDTSettings ).settings()[0] :
|
175
|
+
oDTSettings;
|
176
|
+
|
177
|
+
this._fnConstruct( oInit );
|
178
|
+
return this;
|
179
|
+
};
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
ColVis.prototype = {
|
184
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
185
|
+
* Public methods
|
186
|
+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
187
|
+
|
188
|
+
/**
|
189
|
+
* Get the ColVis instance's control button so it can be injected into the
|
190
|
+
* DOM
|
191
|
+
* @method button
|
192
|
+
* @returns {node} ColVis button
|
193
|
+
*/
|
194
|
+
button: function ()
|
195
|
+
{
|
196
|
+
return this.dom.wrapper;
|
197
|
+
},
|
198
|
+
|
199
|
+
/**
|
200
|
+
* Alias of `rebuild` for backwards compatibility
|
201
|
+
* @method fnRebuild
|
202
|
+
*/
|
203
|
+
"fnRebuild": function ()
|
204
|
+
{
|
205
|
+
this.rebuild();
|
206
|
+
},
|
207
|
+
|
208
|
+
/**
|
209
|
+
* Rebuild the list of buttons for this instance (i.e. if there is a column
|
210
|
+
* header update)
|
211
|
+
* @method fnRebuild
|
212
|
+
*/
|
213
|
+
rebuild: function ()
|
214
|
+
{
|
215
|
+
/* Remove the old buttons */
|
216
|
+
for ( var i=this.dom.buttons.length-1 ; i>=0 ; i-- ) {
|
217
|
+
this.dom.collection.removeChild( this.dom.buttons[i] );
|
218
|
+
}
|
219
|
+
this.dom.buttons.splice( 0, this.dom.buttons.length );
|
220
|
+
|
221
|
+
if ( this.dom.restore ) {
|
222
|
+
this.dom.restore.parentNode( this.dom.restore );
|
223
|
+
}
|
224
|
+
|
225
|
+
/* Re-add them (this is not the optimal way of doing this, it is fast and effective) */
|
226
|
+
this._fnAddGroups();
|
227
|
+
this._fnAddButtons();
|
228
|
+
|
229
|
+
/* Update the checkboxes */
|
230
|
+
this._fnDrawCallback();
|
231
|
+
},
|
232
|
+
|
233
|
+
|
234
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
235
|
+
* Private methods (they are of course public in JS, but recommended as private)
|
236
|
+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
237
|
+
|
238
|
+
/**
|
239
|
+
* Constructor logic
|
240
|
+
* @method _fnConstruct
|
241
|
+
* @returns void
|
242
|
+
* @private
|
243
|
+
*/
|
244
|
+
"_fnConstruct": function ( init )
|
245
|
+
{
|
246
|
+
this._fnApplyCustomisation( init );
|
247
|
+
|
248
|
+
var that = this;
|
249
|
+
var i, iLen;
|
250
|
+
this.dom.wrapper = document.createElement('div');
|
251
|
+
this.dom.wrapper.className = "ColVis";
|
252
|
+
|
253
|
+
this.dom.button = $( '<button />', {
|
254
|
+
'class': !this.s.dt.bJUI ?
|
255
|
+
"ColVis_Button ColVis_MasterButton" :
|
256
|
+
"ColVis_Button ColVis_MasterButton ui-button ui-state-default"
|
257
|
+
} )
|
258
|
+
.append( '<span>'+this.s.buttonText+'</span>' )
|
259
|
+
.bind( this.s.activate=="mouseover" ? "mouseover" : "click", function (e) {
|
260
|
+
e.preventDefault();
|
261
|
+
that._fnCollectionShow();
|
262
|
+
} )
|
263
|
+
.appendTo( this.dom.wrapper )[0];
|
264
|
+
|
265
|
+
this.dom.catcher = this._fnDomCatcher();
|
266
|
+
this.dom.collection = this._fnDomCollection();
|
267
|
+
this.dom.background = this._fnDomBackground();
|
268
|
+
|
269
|
+
this._fnAddGroups();
|
270
|
+
this._fnAddButtons();
|
271
|
+
|
272
|
+
/* Store the original visibility information */
|
273
|
+
for ( i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
|
274
|
+
{
|
275
|
+
this.s.abOriginal.push( this.s.dt.aoColumns[i].bVisible );
|
276
|
+
}
|
277
|
+
|
278
|
+
/* Update on each draw */
|
279
|
+
this.s.dt.aoDrawCallback.push( {
|
280
|
+
"fn": function () {
|
281
|
+
that._fnDrawCallback.call( that );
|
282
|
+
},
|
283
|
+
"sName": "ColVis"
|
284
|
+
} );
|
285
|
+
|
286
|
+
/* If columns are reordered, then we need to update our exclude list and
|
287
|
+
* rebuild the displayed list
|
288
|
+
*/
|
289
|
+
$(this.s.dt.oInstance).bind( 'column-reorder', function ( e, oSettings, oReorder ) {
|
290
|
+
for ( i=0, iLen=that.s.aiExclude.length ; i<iLen ; i++ ) {
|
291
|
+
that.s.aiExclude[i] = oReorder.aiInvertMapping[ that.s.aiExclude[i] ];
|
292
|
+
}
|
293
|
+
|
294
|
+
var mStore = that.s.abOriginal.splice( oReorder.iFrom, 1 )[0];
|
295
|
+
that.s.abOriginal.splice( oReorder.iTo, 0, mStore );
|
296
|
+
|
297
|
+
that.fnRebuild();
|
298
|
+
} );
|
299
|
+
|
300
|
+
// Set the initial state
|
301
|
+
this._fnDrawCallback();
|
302
|
+
},
|
303
|
+
|
304
|
+
|
305
|
+
/**
|
306
|
+
* Apply any customisation to the settings from the DataTables initialisation
|
307
|
+
* @method _fnApplyCustomisation
|
308
|
+
* @returns void
|
309
|
+
* @private
|
310
|
+
*/
|
311
|
+
"_fnApplyCustomisation": function ( init )
|
312
|
+
{
|
313
|
+
$.extend( true, this.s, ColVis.defaults, init );
|
314
|
+
|
315
|
+
// Slightly messy overlap for the camelCase notation
|
316
|
+
if ( ! this.s.showAll && this.s.bShowAll ) {
|
317
|
+
this.s.showAll = this.s.sShowAll;
|
318
|
+
}
|
319
|
+
|
320
|
+
if ( ! this.s.restore && this.s.bRestore ) {
|
321
|
+
this.s.restore = this.s.sRestore;
|
322
|
+
}
|
323
|
+
|
324
|
+
// CamelCase to Hungarian for the column groups
|
325
|
+
var groups = this.s.groups;
|
326
|
+
var hungarianGroups = this.s.aoGroups;
|
327
|
+
if ( groups ) {
|
328
|
+
for ( var i=0, ien=groups.length ; i<ien ; i++ ) {
|
329
|
+
if ( groups[i].title ) {
|
330
|
+
hungarianGroups[i].sTitle = groups[i].title;
|
331
|
+
}
|
332
|
+
if ( groups[i].columns ) {
|
333
|
+
hungarianGroups[i].aiColumns = groups[i].columns;
|
334
|
+
}
|
335
|
+
}
|
336
|
+
}
|
337
|
+
},
|
338
|
+
|
339
|
+
|
340
|
+
/**
|
341
|
+
* On each table draw, check the visibility checkboxes as needed. This allows any process to
|
342
|
+
* update the table's column visibility and ColVis will still be accurate.
|
343
|
+
* @method _fnDrawCallback
|
344
|
+
* @returns void
|
345
|
+
* @private
|
346
|
+
*/
|
347
|
+
"_fnDrawCallback": function ()
|
348
|
+
{
|
349
|
+
var columns = this.s.dt.aoColumns;
|
350
|
+
var buttons = this.dom.buttons;
|
351
|
+
var groups = this.s.aoGroups;
|
352
|
+
var button;
|
353
|
+
|
354
|
+
for ( var i=0, ien=buttons.length ; i<ien ; i++ ) {
|
355
|
+
button = buttons[i];
|
356
|
+
|
357
|
+
if ( button.__columnIdx !== undefined ) {
|
358
|
+
$('input', button).prop( 'checked', columns[ button.__columnIdx ].bVisible );
|
359
|
+
}
|
360
|
+
}
|
361
|
+
|
362
|
+
var allVisible = function ( columnIndeces ) {
|
363
|
+
for ( var k=0, kLen=columnIndeces.length ; k<kLen ; k++ )
|
364
|
+
{
|
365
|
+
if ( columns[columnIndeces[k]].bVisible === false ) { return false; }
|
366
|
+
}
|
367
|
+
return true;
|
368
|
+
};
|
369
|
+
var allHidden = function ( columnIndeces ) {
|
370
|
+
for ( var m=0 , mLen=columnIndeces.length ; m<mLen ; m++ )
|
371
|
+
{
|
372
|
+
if ( columns[columnIndeces[m]].bVisible === true ) { return false; }
|
373
|
+
}
|
374
|
+
return true;
|
375
|
+
};
|
376
|
+
|
377
|
+
for ( var j=0, jLen=groups.length ; j<jLen ; j++ )
|
378
|
+
{
|
379
|
+
if ( allVisible(groups[j].aiColumns) )
|
380
|
+
{
|
381
|
+
$('input', this.dom.groupButtons[j]).prop('checked', true);
|
382
|
+
$('input', this.dom.groupButtons[j]).prop('indeterminate', false);
|
383
|
+
}
|
384
|
+
else if ( allHidden(groups[j].aiColumns) )
|
385
|
+
{
|
386
|
+
$('input', this.dom.groupButtons[j]).prop('checked', false);
|
387
|
+
$('input', this.dom.groupButtons[j]).prop('indeterminate', false);
|
388
|
+
}
|
389
|
+
else
|
390
|
+
{
|
391
|
+
$('input', this.dom.groupButtons[j]).prop('indeterminate', true);
|
392
|
+
}
|
393
|
+
}
|
394
|
+
},
|
395
|
+
|
396
|
+
|
397
|
+
/**
|
398
|
+
* Loop through the groups (provided in the settings) and create a button for each.
|
399
|
+
* @method _fnAddgroups
|
400
|
+
* @returns void
|
401
|
+
* @private
|
402
|
+
*/
|
403
|
+
"_fnAddGroups": function ()
|
404
|
+
{
|
405
|
+
var nButton;
|
406
|
+
|
407
|
+
if ( typeof this.s.aoGroups != 'undefined' )
|
408
|
+
{
|
409
|
+
for ( var i=0, iLen=this.s.aoGroups.length ; i<iLen ; i++ )
|
410
|
+
{
|
411
|
+
nButton = this._fnDomGroupButton( i );
|
412
|
+
this.dom.groupButtons.push( nButton );
|
413
|
+
this.dom.buttons.push( nButton );
|
414
|
+
this.dom.collection.appendChild( nButton );
|
415
|
+
}
|
416
|
+
}
|
417
|
+
},
|
418
|
+
|
419
|
+
|
420
|
+
/**
|
421
|
+
* Loop through the columns in the table and as a new button for each one.
|
422
|
+
* @method _fnAddButtons
|
423
|
+
* @returns void
|
424
|
+
* @private
|
425
|
+
*/
|
426
|
+
"_fnAddButtons": function ()
|
427
|
+
{
|
428
|
+
var
|
429
|
+
nButton,
|
430
|
+
columns = this.s.dt.aoColumns;
|
431
|
+
|
432
|
+
if ( $.inArray( 'all', this.s.aiExclude ) === -1 ) {
|
433
|
+
for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
|
434
|
+
{
|
435
|
+
if ( $.inArray( i, this.s.aiExclude ) === -1 )
|
436
|
+
{
|
437
|
+
nButton = this._fnDomColumnButton( i );
|
438
|
+
nButton.__columnIdx = i;
|
439
|
+
this.dom.buttons.push( nButton );
|
440
|
+
}
|
441
|
+
}
|
442
|
+
}
|
443
|
+
|
444
|
+
if ( this.s.order === 'alpha' ) {
|
445
|
+
this.dom.buttons.sort( function ( a, b ) {
|
446
|
+
var titleA = columns[ a.__columnIdx ].sTitle;
|
447
|
+
var titleB = columns[ b.__columnIdx ].sTitle;
|
448
|
+
|
449
|
+
return titleA === titleB ?
|
450
|
+
0 :
|
451
|
+
titleA < titleB ?
|
452
|
+
-1 :
|
453
|
+
1;
|
454
|
+
} );
|
455
|
+
}
|
456
|
+
|
457
|
+
if ( this.s.restore )
|
458
|
+
{
|
459
|
+
nButton = this._fnDomRestoreButton();
|
460
|
+
nButton.className += " ColVis_Restore";
|
461
|
+
this.dom.buttons.push( nButton );
|
462
|
+
}
|
463
|
+
|
464
|
+
if ( this.s.showAll )
|
465
|
+
{
|
466
|
+
nButton = this._fnDomShowAllButton();
|
467
|
+
nButton.className += " ColVis_ShowAll";
|
468
|
+
this.dom.buttons.push( nButton );
|
469
|
+
}
|
470
|
+
|
471
|
+
$(this.dom.collection).append( this.dom.buttons );
|
472
|
+
},
|
473
|
+
|
474
|
+
|
475
|
+
/**
|
476
|
+
* Create a button which allows a "restore" action
|
477
|
+
* @method _fnDomRestoreButton
|
478
|
+
* @returns {Node} Created button
|
479
|
+
* @private
|
480
|
+
*/
|
481
|
+
"_fnDomRestoreButton": function ()
|
482
|
+
{
|
483
|
+
var
|
484
|
+
that = this,
|
485
|
+
dt = this.s.dt;
|
486
|
+
|
487
|
+
return $(
|
488
|
+
'<li class="ColVis_Special '+(dt.bJUI ? 'ui-button ui-state-default' : '')+'">'+
|
489
|
+
this.s.restore+
|
490
|
+
'</li>'
|
491
|
+
)
|
492
|
+
.click( function (e) {
|
493
|
+
for ( var i=0, iLen=that.s.abOriginal.length ; i<iLen ; i++ )
|
494
|
+
{
|
495
|
+
that.s.dt.oInstance.fnSetColumnVis( i, that.s.abOriginal[i], false );
|
496
|
+
}
|
497
|
+
that._fnAdjustOpenRows();
|
498
|
+
that.s.dt.oInstance.fnAdjustColumnSizing( false );
|
499
|
+
that.s.dt.oInstance.fnDraw( false );
|
500
|
+
} )[0];
|
501
|
+
},
|
502
|
+
|
503
|
+
|
504
|
+
/**
|
505
|
+
* Create a button which allows a "show all" action
|
506
|
+
* @method _fnDomShowAllButton
|
507
|
+
* @returns {Node} Created button
|
508
|
+
* @private
|
509
|
+
*/
|
510
|
+
"_fnDomShowAllButton": function ()
|
511
|
+
{
|
512
|
+
var
|
513
|
+
that = this,
|
514
|
+
dt = this.s.dt;
|
515
|
+
|
516
|
+
return $(
|
517
|
+
'<li class="ColVis_Special '+(dt.bJUI ? 'ui-button ui-state-default' : '')+'">'+
|
518
|
+
this.s.showAll+
|
519
|
+
'</li>'
|
520
|
+
)
|
521
|
+
.click( function (e) {
|
522
|
+
for ( var i=0, iLen=that.s.abOriginal.length ; i<iLen ; i++ )
|
523
|
+
{
|
524
|
+
if (that.s.aiExclude.indexOf(i) === -1)
|
525
|
+
{
|
526
|
+
that.s.dt.oInstance.fnSetColumnVis( i, true, false );
|
527
|
+
}
|
528
|
+
}
|
529
|
+
that._fnAdjustOpenRows();
|
530
|
+
that.s.dt.oInstance.fnAdjustColumnSizing( false );
|
531
|
+
that.s.dt.oInstance.fnDraw( false );
|
532
|
+
} )[0];
|
533
|
+
},
|
534
|
+
|
535
|
+
|
536
|
+
/**
|
537
|
+
* Create the DOM for a show / hide group button
|
538
|
+
* @method _fnDomGroupButton
|
539
|
+
* @param {int} i Group in question, order based on that provided in settings
|
540
|
+
* @returns {Node} Created button
|
541
|
+
* @private
|
542
|
+
*/
|
543
|
+
"_fnDomGroupButton": function ( i )
|
544
|
+
{
|
545
|
+
var
|
546
|
+
that = this,
|
547
|
+
dt = this.s.dt,
|
548
|
+
oGroup = this.s.aoGroups[i];
|
549
|
+
|
550
|
+
return $(
|
551
|
+
'<li class="ColVis_Special '+(dt.bJUI ? 'ui-button ui-state-default' : '')+'">'+
|
552
|
+
'<label>'+
|
553
|
+
'<input type="checkbox" />'+
|
554
|
+
'<span>'+oGroup.sTitle+'</span>'+
|
555
|
+
'</label>'+
|
556
|
+
'</li>'
|
557
|
+
)
|
558
|
+
.click( function (e) {
|
559
|
+
var showHide = !$('input', this).is(":checked");
|
560
|
+
if ( e.target.nodeName.toLowerCase() !== "li" )
|
561
|
+
{
|
562
|
+
showHide = ! showHide;
|
563
|
+
}
|
564
|
+
|
565
|
+
for ( var j=0 ; j < oGroup.aiColumns.length ; j++ )
|
566
|
+
{
|
567
|
+
that.s.dt.oInstance.fnSetColumnVis( oGroup.aiColumns[j], showHide );
|
568
|
+
}
|
569
|
+
} )[0];
|
570
|
+
},
|
571
|
+
|
572
|
+
|
573
|
+
/**
|
574
|
+
* Create the DOM for a show / hide button
|
575
|
+
* @method _fnDomColumnButton
|
576
|
+
* @param {int} i Column in question
|
577
|
+
* @returns {Node} Created button
|
578
|
+
* @private
|
579
|
+
*/
|
580
|
+
"_fnDomColumnButton": function ( i )
|
581
|
+
{
|
582
|
+
var
|
583
|
+
that = this,
|
584
|
+
column = this.s.dt.aoColumns[i],
|
585
|
+
dt = this.s.dt;
|
586
|
+
|
587
|
+
var title = this.s.fnLabel===null ?
|
588
|
+
column.sTitle :
|
589
|
+
this.s.fnLabel( i, column.sTitle, column.nTh );
|
590
|
+
|
591
|
+
return $(
|
592
|
+
'<li '+(dt.bJUI ? 'class="ui-button ui-state-default"' : '')+'>'+
|
593
|
+
'<label>'+
|
594
|
+
'<input type="checkbox" />'+
|
595
|
+
'<span>'+title+'</span>'+
|
596
|
+
'</label>'+
|
597
|
+
'</li>'
|
598
|
+
)
|
599
|
+
.click( function (e) {
|
600
|
+
var showHide = !$('input', this).is(":checked");
|
601
|
+
if ( e.target.nodeName.toLowerCase() !== "li" )
|
602
|
+
{
|
603
|
+
showHide = ! showHide;
|
604
|
+
}
|
605
|
+
|
606
|
+
/* Need to consider the case where the initialiser created more than one table - change the
|
607
|
+
* API index that DataTables is using
|
608
|
+
*/
|
609
|
+
var oldIndex = $.fn.dataTableExt.iApiIndex;
|
610
|
+
$.fn.dataTableExt.iApiIndex = that._fnDataTablesApiIndex.call(that);
|
611
|
+
|
612
|
+
// Optimisation for server-side processing when scrolling - don't do a full redraw
|
613
|
+
if ( dt.oFeatures.bServerSide )
|
614
|
+
{
|
615
|
+
that.s.dt.oInstance.fnSetColumnVis( i, showHide, false );
|
616
|
+
that.s.dt.oInstance.fnAdjustColumnSizing( false );
|
617
|
+
if (dt.oScroll.sX !== "" || dt.oScroll.sY !== "" )
|
618
|
+
{
|
619
|
+
that.s.dt.oInstance.oApi._fnScrollDraw( that.s.dt );
|
620
|
+
}
|
621
|
+
that._fnDrawCallback();
|
622
|
+
}
|
623
|
+
else
|
624
|
+
{
|
625
|
+
that.s.dt.oInstance.fnSetColumnVis( i, showHide );
|
626
|
+
}
|
627
|
+
|
628
|
+
$.fn.dataTableExt.iApiIndex = oldIndex; /* Restore */
|
629
|
+
|
630
|
+
if ( that.s.fnStateChange !== null )
|
631
|
+
{
|
632
|
+
that.s.fnStateChange.call( that, i, showHide );
|
633
|
+
}
|
634
|
+
} )[0];
|
635
|
+
},
|
636
|
+
|
637
|
+
|
638
|
+
/**
|
639
|
+
* Get the position in the DataTables instance array of the table for this
|
640
|
+
* instance of ColVis
|
641
|
+
* @method _fnDataTablesApiIndex
|
642
|
+
* @returns {int} Index
|
643
|
+
* @private
|
644
|
+
*/
|
645
|
+
"_fnDataTablesApiIndex": function ()
|
646
|
+
{
|
647
|
+
for ( var i=0, iLen=this.s.dt.oInstance.length ; i<iLen ; i++ )
|
648
|
+
{
|
649
|
+
if ( this.s.dt.oInstance[i] == this.s.dt.nTable )
|
650
|
+
{
|
651
|
+
return i;
|
652
|
+
}
|
653
|
+
}
|
654
|
+
return 0;
|
655
|
+
},
|
656
|
+
|
657
|
+
|
658
|
+
/**
|
659
|
+
* Create the element used to contain list the columns (it is shown and
|
660
|
+
* hidden as needed)
|
661
|
+
* @method _fnDomCollection
|
662
|
+
* @returns {Node} div container for the collection
|
663
|
+
* @private
|
664
|
+
*/
|
665
|
+
"_fnDomCollection": function ()
|
666
|
+
{
|
667
|
+
return $('<ul />', {
|
668
|
+
'class': !this.s.dt.bJUI ?
|
669
|
+
"ColVis_collection" :
|
670
|
+
"ColVis_collection ui-buttonset ui-buttonset-multi"
|
671
|
+
} )
|
672
|
+
.css( {
|
673
|
+
'display': 'none',
|
674
|
+
'opacity': 0,
|
675
|
+
'position': ! this.s.bCssPosition ?
|
676
|
+
'absolute' :
|
677
|
+
''
|
678
|
+
} )[0];
|
679
|
+
},
|
680
|
+
|
681
|
+
|
682
|
+
/**
|
683
|
+
* An element to be placed on top of the activate button to catch events
|
684
|
+
* @method _fnDomCatcher
|
685
|
+
* @returns {Node} div container for the collection
|
686
|
+
* @private
|
687
|
+
*/
|
688
|
+
"_fnDomCatcher": function ()
|
689
|
+
{
|
690
|
+
var
|
691
|
+
that = this,
|
692
|
+
nCatcher = document.createElement('div');
|
693
|
+
nCatcher.className = "ColVis_catcher";
|
694
|
+
|
695
|
+
$(nCatcher).click( function () {
|
696
|
+
that._fnCollectionHide.call( that, null, null );
|
697
|
+
} );
|
698
|
+
|
699
|
+
return nCatcher;
|
700
|
+
},
|
701
|
+
|
702
|
+
|
703
|
+
/**
|
704
|
+
* Create the element used to shade the background, and capture hide events (it is shown and
|
705
|
+
* hidden as needed)
|
706
|
+
* @method _fnDomBackground
|
707
|
+
* @returns {Node} div container for the background
|
708
|
+
* @private
|
709
|
+
*/
|
710
|
+
"_fnDomBackground": function ()
|
711
|
+
{
|
712
|
+
var that = this;
|
713
|
+
|
714
|
+
var background = $('<div></div>')
|
715
|
+
.addClass( 'ColVis_collectionBackground' )
|
716
|
+
.css( 'opacity', 0 )
|
717
|
+
.click( function () {
|
718
|
+
that._fnCollectionHide.call( that, null, null );
|
719
|
+
} );
|
720
|
+
|
721
|
+
/* When considering a mouse over action for the activation, we also consider a mouse out
|
722
|
+
* which is the same as a mouse over the background - without all the messing around of
|
723
|
+
* bubbling events. Use the catcher element to avoid messing around with bubbling
|
724
|
+
*/
|
725
|
+
if ( this.s.activate == "mouseover" )
|
726
|
+
{
|
727
|
+
background.mouseover( function () {
|
728
|
+
that.s.overcollection = false;
|
729
|
+
that._fnCollectionHide.call( that, null, null );
|
730
|
+
} );
|
731
|
+
}
|
732
|
+
|
733
|
+
return background[0];
|
734
|
+
},
|
735
|
+
|
736
|
+
|
737
|
+
/**
|
738
|
+
* Show the show / hide list and the background
|
739
|
+
* @method _fnCollectionShow
|
740
|
+
* @returns void
|
741
|
+
* @private
|
742
|
+
*/
|
743
|
+
"_fnCollectionShow": function ()
|
744
|
+
{
|
745
|
+
var that = this, i, iLen, iLeft;
|
746
|
+
var oPos = $(this.dom.button).offset();
|
747
|
+
var nHidden = this.dom.collection;
|
748
|
+
var nBackground = this.dom.background;
|
749
|
+
var iDivX = parseInt(oPos.left, 10);
|
750
|
+
var iDivY = parseInt(oPos.top + $(this.dom.button).outerHeight(), 10);
|
751
|
+
|
752
|
+
if ( ! this.s.bCssPosition )
|
753
|
+
{
|
754
|
+
nHidden.style.top = iDivY+"px";
|
755
|
+
nHidden.style.left = iDivX+"px";
|
756
|
+
}
|
757
|
+
|
758
|
+
$(nHidden).css( {
|
759
|
+
'display': 'block',
|
760
|
+
'opacity': 0
|
761
|
+
} );
|
762
|
+
|
763
|
+
nBackground.style.bottom ='0px';
|
764
|
+
nBackground.style.right = '0px';
|
765
|
+
|
766
|
+
var oStyle = this.dom.catcher.style;
|
767
|
+
oStyle.height = $(this.dom.button).outerHeight()+"px";
|
768
|
+
oStyle.width = $(this.dom.button).outerWidth()+"px";
|
769
|
+
oStyle.top = oPos.top+"px";
|
770
|
+
oStyle.left = iDivX+"px";
|
771
|
+
|
772
|
+
document.body.appendChild( nBackground );
|
773
|
+
document.body.appendChild( nHidden );
|
774
|
+
document.body.appendChild( this.dom.catcher );
|
775
|
+
|
776
|
+
/* This results in a very small delay for the end user but it allows the animation to be
|
777
|
+
* much smoother. If you don't want the animation, then the setTimeout can be removed
|
778
|
+
*/
|
779
|
+
$(nHidden).animate({"opacity": 1}, that.s.iOverlayFade);
|
780
|
+
$(nBackground).animate({"opacity": 0.1}, that.s.iOverlayFade, 'linear', function () {
|
781
|
+
/* In IE6 if you set the checked attribute of a hidden checkbox, then this is not visually
|
782
|
+
* reflected. As such, we need to do it here, once it is visible. Unbelievable.
|
783
|
+
*/
|
784
|
+
if ( $.browser && $.browser.msie && $.browser.version == "6.0" )
|
785
|
+
{
|
786
|
+
that._fnDrawCallback();
|
787
|
+
}
|
788
|
+
});
|
789
|
+
|
790
|
+
/* Visual corrections to try and keep the collection visible */
|
791
|
+
if ( !this.s.bCssPosition )
|
792
|
+
{
|
793
|
+
iLeft = ( this.s.sAlign=="left" ) ?
|
794
|
+
iDivX :
|
795
|
+
iDivX - $(nHidden).outerWidth() + $(this.dom.button).outerWidth();
|
796
|
+
|
797
|
+
nHidden.style.left = iLeft+"px";
|
798
|
+
|
799
|
+
var iDivWidth = $(nHidden).outerWidth();
|
800
|
+
var iDivHeight = $(nHidden).outerHeight();
|
801
|
+
var iDocWidth = $(document).width();
|
802
|
+
|
803
|
+
if ( iLeft + iDivWidth > iDocWidth )
|
804
|
+
{
|
805
|
+
nHidden.style.left = (iDocWidth-iDivWidth)+"px";
|
806
|
+
}
|
807
|
+
}
|
808
|
+
|
809
|
+
this.s.hidden = false;
|
810
|
+
},
|
811
|
+
|
812
|
+
|
813
|
+
/**
|
814
|
+
* Hide the show / hide list and the background
|
815
|
+
* @method _fnCollectionHide
|
816
|
+
* @returns void
|
817
|
+
* @private
|
818
|
+
*/
|
819
|
+
"_fnCollectionHide": function ( )
|
820
|
+
{
|
821
|
+
var that = this;
|
822
|
+
|
823
|
+
if ( !this.s.hidden && this.dom.collection !== null )
|
824
|
+
{
|
825
|
+
this.s.hidden = true;
|
826
|
+
|
827
|
+
$(this.dom.collection).animate({"opacity": 0}, that.s.iOverlayFade, function (e) {
|
828
|
+
this.style.display = "none";
|
829
|
+
} );
|
830
|
+
|
831
|
+
$(this.dom.background).animate({"opacity": 0}, that.s.iOverlayFade, function (e) {
|
832
|
+
document.body.removeChild( that.dom.background );
|
833
|
+
document.body.removeChild( that.dom.catcher );
|
834
|
+
} );
|
835
|
+
}
|
836
|
+
},
|
837
|
+
|
838
|
+
|
839
|
+
/**
|
840
|
+
* Alter the colspan on any fnOpen rows
|
841
|
+
*/
|
842
|
+
"_fnAdjustOpenRows": function ()
|
843
|
+
{
|
844
|
+
var aoOpen = this.s.dt.aoOpenRows;
|
845
|
+
var iVisible = this.s.dt.oApi._fnVisbleColumns( this.s.dt );
|
846
|
+
|
847
|
+
for ( var i=0, iLen=aoOpen.length ; i<iLen ; i++ ) {
|
848
|
+
aoOpen[i].nTr.getElementsByTagName('td')[0].colSpan = iVisible;
|
849
|
+
}
|
850
|
+
}
|
851
|
+
};
|
852
|
+
|
853
|
+
|
854
|
+
|
855
|
+
|
856
|
+
|
857
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
858
|
+
* Static object methods
|
859
|
+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
860
|
+
|
861
|
+
/**
|
862
|
+
* Rebuild the collection for a given table, or all tables if no parameter given
|
863
|
+
* @method ColVis.fnRebuild
|
864
|
+
* @static
|
865
|
+
* @param object oTable DataTable instance to consider - optional
|
866
|
+
* @returns void
|
867
|
+
*/
|
868
|
+
ColVis.fnRebuild = function ( oTable )
|
869
|
+
{
|
870
|
+
var nTable = null;
|
871
|
+
if ( typeof oTable != 'undefined' )
|
872
|
+
{
|
873
|
+
nTable = oTable.fnSettings().nTable;
|
874
|
+
}
|
875
|
+
|
876
|
+
for ( var i=0, iLen=ColVis.aInstances.length ; i<iLen ; i++ )
|
877
|
+
{
|
878
|
+
if ( typeof oTable == 'undefined' || nTable == ColVis.aInstances[i].s.dt.nTable )
|
879
|
+
{
|
880
|
+
ColVis.aInstances[i].fnRebuild();
|
881
|
+
}
|
882
|
+
}
|
883
|
+
};
|
884
|
+
|
885
|
+
|
886
|
+
ColVis.defaults = {
|
887
|
+
/**
|
888
|
+
* Mode of activation. Can be 'click' or 'mouseover'
|
889
|
+
* @property activate
|
890
|
+
* @type string
|
891
|
+
* @default click
|
892
|
+
*/
|
893
|
+
active: 'click',
|
894
|
+
|
895
|
+
/**
|
896
|
+
* Text used for the button
|
897
|
+
* @property buttonText
|
898
|
+
* @type string
|
899
|
+
* @default Show / hide columns
|
900
|
+
*/
|
901
|
+
buttonText: 'Show / hide columns',
|
902
|
+
|
903
|
+
/**
|
904
|
+
* List of columns (integers) which should be excluded from the list
|
905
|
+
* @property aiExclude
|
906
|
+
* @type array
|
907
|
+
* @default []
|
908
|
+
*/
|
909
|
+
aiExclude: [],
|
910
|
+
|
911
|
+
/**
|
912
|
+
* Show restore button
|
913
|
+
* @property bRestore
|
914
|
+
* @type boolean
|
915
|
+
* @default false
|
916
|
+
*/
|
917
|
+
bRestore: false,
|
918
|
+
|
919
|
+
/**
|
920
|
+
* Restore button text
|
921
|
+
* @property sRestore
|
922
|
+
* @type string
|
923
|
+
* @default Restore original
|
924
|
+
*/
|
925
|
+
sRestore: 'Restore original',
|
926
|
+
|
927
|
+
/**
|
928
|
+
* Show Show-All button
|
929
|
+
* @property bShowAll
|
930
|
+
* @type boolean
|
931
|
+
* @default false
|
932
|
+
*/
|
933
|
+
bShowAll: false,
|
934
|
+
|
935
|
+
/**
|
936
|
+
* Show All button text
|
937
|
+
* @property sShowAll
|
938
|
+
* @type string
|
939
|
+
* @default Restore original
|
940
|
+
*/
|
941
|
+
sShowAll: 'Show All',
|
942
|
+
|
943
|
+
/**
|
944
|
+
* Position of the collection menu when shown - align "left" or "right"
|
945
|
+
* @property sAlign
|
946
|
+
* @type string
|
947
|
+
* @default left
|
948
|
+
*/
|
949
|
+
sAlign: 'left',
|
950
|
+
|
951
|
+
/**
|
952
|
+
* Callback function to tell the user when the state has changed
|
953
|
+
* @property fnStateChange
|
954
|
+
* @type function
|
955
|
+
* @default null
|
956
|
+
*/
|
957
|
+
fnStateChange: null,
|
958
|
+
|
959
|
+
/**
|
960
|
+
* Overlay animation duration in mS
|
961
|
+
* @property iOverlayFade
|
962
|
+
* @type integer|false
|
963
|
+
* @default 500
|
964
|
+
*/
|
965
|
+
iOverlayFade: 500,
|
966
|
+
|
967
|
+
/**
|
968
|
+
* Label callback for column names. Takes three parameters: 1. the
|
969
|
+
* column index, 2. the column title detected by DataTables and 3. the
|
970
|
+
* TH node for the column
|
971
|
+
* @property fnLabel
|
972
|
+
* @type function
|
973
|
+
* @default null
|
974
|
+
*/
|
975
|
+
fnLabel: null,
|
976
|
+
|
977
|
+
/**
|
978
|
+
* Indicate if the column list should be positioned by Javascript,
|
979
|
+
* visually below the button or allow CSS to do the positioning
|
980
|
+
* @property bCssPosition
|
981
|
+
* @type boolean
|
982
|
+
* @default false
|
983
|
+
*/
|
984
|
+
bCssPosition: false,
|
985
|
+
|
986
|
+
/**
|
987
|
+
* Group buttons
|
988
|
+
* @property aoGroups
|
989
|
+
* @type array
|
990
|
+
* @default []
|
991
|
+
*/
|
992
|
+
aoGroups: [],
|
993
|
+
|
994
|
+
/**
|
995
|
+
* Button ordering - 'alpha' (alphabetical) or 'column' (table column
|
996
|
+
* order)
|
997
|
+
* @property order
|
998
|
+
* @type string
|
999
|
+
* @default column
|
1000
|
+
*/
|
1001
|
+
order: 'column'
|
1002
|
+
};
|
1003
|
+
|
1004
|
+
|
1005
|
+
|
1006
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
1007
|
+
* Static object properties
|
1008
|
+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
1009
|
+
|
1010
|
+
/**
|
1011
|
+
* Collection of all ColVis instances
|
1012
|
+
* @property ColVis.aInstances
|
1013
|
+
* @static
|
1014
|
+
* @type Array
|
1015
|
+
* @default []
|
1016
|
+
*/
|
1017
|
+
ColVis.aInstances = [];
|
1018
|
+
|
1019
|
+
|
1020
|
+
|
1021
|
+
|
1022
|
+
|
1023
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
1024
|
+
* Constants
|
1025
|
+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
1026
|
+
|
1027
|
+
/**
|
1028
|
+
* Name of this class
|
1029
|
+
* @constant CLASS
|
1030
|
+
* @type String
|
1031
|
+
* @default ColVis
|
1032
|
+
*/
|
1033
|
+
ColVis.prototype.CLASS = "ColVis";
|
1034
|
+
|
1035
|
+
|
1036
|
+
/**
|
1037
|
+
* ColVis version
|
1038
|
+
* @constant VERSION
|
1039
|
+
* @type String
|
1040
|
+
* @default See code
|
1041
|
+
*/
|
1042
|
+
ColVis.VERSION = "1.1.0";
|
1043
|
+
ColVis.prototype.VERSION = ColVis.VERSION;
|
1044
|
+
|
1045
|
+
|
1046
|
+
|
1047
|
+
|
1048
|
+
|
1049
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
1050
|
+
* Initialisation
|
1051
|
+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
1052
|
+
|
1053
|
+
/*
|
1054
|
+
* Register a new feature with DataTables
|
1055
|
+
*/
|
1056
|
+
if ( typeof $.fn.dataTable == "function" &&
|
1057
|
+
typeof $.fn.dataTableExt.fnVersionCheck == "function" &&
|
1058
|
+
$.fn.dataTableExt.fnVersionCheck('1.7.0') )
|
1059
|
+
{
|
1060
|
+
$.fn.dataTableExt.aoFeatures.push( {
|
1061
|
+
"fnInit": function( oDTSettings ) {
|
1062
|
+
var init = oDTSettings.oInit;
|
1063
|
+
var colvis = new ColVis( oDTSettings, init.colVis || init.oColVis || {} );
|
1064
|
+
return colvis.button();
|
1065
|
+
},
|
1066
|
+
"cFeature": "C",
|
1067
|
+
"sFeature": "ColVis"
|
1068
|
+
} );
|
1069
|
+
}
|
1070
|
+
else
|
1071
|
+
{
|
1072
|
+
alert( "Warning: ColVis requires DataTables 1.7 or greater - www.datatables.net/download");
|
1073
|
+
}
|
1074
|
+
|
1075
|
+
|
1076
|
+
// Make ColVis accessible from the DataTables instance
|
1077
|
+
$.fn.dataTable.ColVis = ColVis;
|
1078
|
+
$.fn.DataTable.ColVis = ColVis;
|
1079
|
+
|
1080
|
+
|
1081
|
+
return ColVis;
|
1082
|
+
}; // /factory
|
1083
|
+
|
1084
|
+
|
1085
|
+
// Define as an AMD module if possible
|
1086
|
+
if ( typeof define === 'function' && define.amd ) {
|
1087
|
+
define( 'datatables-colvis', ['jquery', 'datatables'], factory );
|
1088
|
+
}
|
1089
|
+
else if ( jQuery && !jQuery.fn.dataTable.ColVis ) {
|
1090
|
+
// Otherwise simply initialise as normal, stopping multiple evaluation
|
1091
|
+
factory( jQuery, jQuery.fn.dataTable );
|
1092
|
+
}
|
1093
|
+
|
1094
|
+
|
1095
|
+
})(window, document);
|
1096
|
+
|