-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdataTables.js
5019 lines (4493 loc) · 149 KB
/
dataTables.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* File: jquery.dataTables.js
* Version: 1.6.0.beta.1
* CVS: $Id$
* Description: Paginate, search and sort HTML tables
* Author: Allan Jardine (www.sprymedia.co.uk)
* Created: 28/3/2008
* Modified: $Date$ by $Author$
* Language: Javascript
* License: GPL v2 or BSD 3 point style
* Project: Mtaala
* Contact: allan.jardine@sprymedia.co.uk
*
* Copyright 2008-2010 Allan Jardine, all rights reserved.
*
* This source file is free software, under either the GPL v2 license or a
* BSD style license, as supplied with this software.
*
* This source file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
*
* For details pleease refer to: http://www.datatables.net
*/
/*
* When considering jsLint, we need to allow eval() as it it is used for reading cookies and
* building the dynamic multi-column sort functions.
*/
/*jslint evil: true, undef: true, browser: true */
/*globals $, jQuery,_fnReadCookie,_fnProcessingDisplay,_fnDraw,_fnSort,_fnReDraw,_fnDetectType,_fnSortingClasses,_fnSettingsFromNode,_fnBuildSearchArray,_fnCalculateEnd,_fnFeatureHtmlProcessing,_fnFeatureHtmlPaginate,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlFilter,_fnFilter,_fnSaveState,_fnFilterColumn,_fnEscapeRegex,_fnFilterComplete,_fnFeatureHtmlLength,_fnGetDataMaster,_fnVisibleToColumnIndex,_fnDrawHead,_fnAddData,_fnGetTrNodes,_fnColumnIndexToVisible,_fnCreateCookie,_fnAddOptionsHtml,_fnMap,_fnClearTable,_fnDataToSearch,_fnReOrderIndex,_fnFilterCustom,_fnNodeToDataIndex,_fnVisbleColumns,_fnAjaxUpdate,_fnAjaxUpdateDraw,_fnColumnOrdering,fnGetMaxLenString,_fnSortAttachListener,_fnPageChange*/
(function($) {
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Section - DataTables variables
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Variable: dataTableSettings
* Purpose: Store the settings for each dataTables instance
* Scope: jQuery.fn
*/
$.fn.dataTableSettings = [];
var _aoSettings = $.fn.dataTableSettings; /* Short reference for fast internal lookup */
/*
* Variable: dataTableExt
* Purpose: Container for customisable parts of DataTables
* Scope: jQuery.fn
*/
$.fn.dataTableExt = {};
var _oExt = $.fn.dataTableExt;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Section - DataTables extensible objects
*
* The _oExt object is used to provide an area where user dfined plugins can be
* added to DataTables. The following properties of the object are used:
* oApi - Plug-in API functions
* aTypes - Auto-detection of types
* oSort - Sorting functions used by DataTables (based on the type)
* oPagination - Pagination functions for different input styles
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Variable: sVersion
* Purpose: Version string for plug-ins to check compatibility
* Scope: jQuery.fn.dataTableExt
* Notes: Allowed format is a.b.c.d.e where:
* a:int, b:int, c:int, d:string(dev|beta), e:int. d and e are optional
*/
_oExt.sVersion = "1.6.0.beta.1";
/*
* Variable: iApiIndex
* Purpose: Index for what 'this' index API functions should use
* Scope: jQuery.fn.dataTableExt
*/
_oExt.iApiIndex = 0;
/*
* Variable: oApi
* Purpose: Container for plugin API functions
* Scope: jQuery.fn.dataTableExt
*/
_oExt.oApi = { };
/*
* Variable: aFiltering
* Purpose: Container for plugin filtering functions
* Scope: jQuery.fn.dataTableExt
*/
_oExt.afnFiltering = [ ];
/*
* Variable: aoFeatures
* Purpose: Container for plugin function functions
* Scope: jQuery.fn.dataTableExt
* Notes: Array of objects with the following parameters:
* fnInit: Function for initialisation of Feature. Takes oSettings and returns node
* cFeature: Character that will be matched in sDom - case sensitive
* sFeature: Feature name - just for completeness :-)
*/
_oExt.aoFeatures = [ ];
/*
* Variable: ofnSearch
* Purpose: Container for custom filtering functions
* Scope: jQuery.fn.dataTableExt
* Notes: This is an object (the name should match the type) for custom filtering function,
* which can be used for live DOM checking or formatted text filtering
*/
_oExt.ofnSearch = { };
/*
* Variable: afnSortData
* Purpose: Container for custom sorting data source functions
* Scope: jQuery.fn.dataTableExt
* Notes: Array (associative) of functions which is run prior to a column of this
* 'SortDataType' being sorted upon.
* Function input parameters:
* object:oSettings- DataTables settings object
* int:iColumn - Target column number
* Return value: Array of data which exactly matched the full data set size for the column to
* be sorted upon
*/
_oExt.afnSortData = [ ];
/*
* Variable: oStdClasses
* Purpose: Storage for the various classes that DataTables uses
* Scope: jQuery.fn.dataTableExt
*/
_oExt.oStdClasses = {
/* Two buttons buttons */
"sPagePrevEnabled": "paginate_enabled_previous",
"sPagePrevDisabled": "paginate_disabled_previous",
"sPageNextEnabled": "paginate_enabled_next",
"sPageNextDisabled": "paginate_disabled_next",
"sPageJUINext": "",
"sPageJUIPrev": "",
/* Full numbers paging buttons */
"sPageButton": "paginate_button",
"sPageButtonActive": "paginate_active",
"sPageButtonStaticDisabled": "paginate_button",
"sPageFirst": "first",
"sPagePrevious": "previous",
"sPageNext": "next",
"sPageLast": "last",
/* Stripping classes */
"sStripOdd": "odd",
"sStripEven": "even",
/* Empty row */
"sRowEmpty": "dataTables_empty",
/* Features */
"sWrapper": "dataTables_wrapper",
"sFilter": "dataTables_filter",
"sInfo": "dataTables_info",
"sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
"sLength": "dataTables_length",
"sProcessing": "dataTables_processing",
/* Sorting */
"sSortAsc": "sorting_asc",
"sSortDesc": "sorting_desc",
"sSortable": "sorting", /* Sortable in both directions */
"sSortableAsc": "sorting_asc_disabled",
"sSortableDesc": "sorting_desc_disabled",
"sSortableNone": "",
"sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
"sSortJUIAsc": "",
"sSortJUIDesc": "",
"sSortJUI": "",
"sSortJUIAscAllowed": "",
"sSortJUIDescAllowed": ""
};
/*
* Variable: oJUIClasses
* Purpose: Storage for the various classes that DataTables uses - jQuery UI suitable
* Scope: jQuery.fn.dataTableExt
*/
_oExt.oJUIClasses = {
/* Two buttons buttons */
"sPagePrevEnabled": "fg-button ui-state-default ui-corner-left",
"sPagePrevDisabled": "fg-button ui-state-default ui-corner-left ui-state-disabled",
"sPageNextEnabled": "fg-button ui-state-default ui-corner-right",
"sPageNextDisabled": "fg-button ui-state-default ui-corner-right ui-state-disabled",
"sPageJUINext": "ui-icon ui-icon-circle-arrow-e",
"sPageJUIPrev": "ui-icon ui-icon-circle-arrow-w",
/* Full numbers paging buttons */
"sPageButton": "fg-button ui-state-default",
"sPageButtonActive": "fg-button ui-state-default ui-state-disabled",
"sPageButtonStaticDisabled": "fg-button ui-state-default ui-state-disabled",
"sPageFirst": "first ui-corner-tl ui-corner-bl",
"sPagePrevious": "previous",
"sPageNext": "next",
"sPageLast": "last ui-corner-tr ui-corner-br",
/* Stripping classes */
"sStripOdd": "odd",
"sStripEven": "even",
/* Empty row */
"sRowEmpty": "dataTables_empty",
/* Features */
"sWrapper": "dataTables_wrapper",
"sFilter": "dataTables_filter",
"sInfo": "dataTables_info",
"sPaging": "dataTables_paginate fg-buttonset fg-buttonset-multi paging_", /* Note that the type is postfixed */
"sLength": "dataTables_length",
"sProcessing": "dataTables_processing",
/* Sorting */
"sSortAsc": "ui-state-default",
"sSortDesc": "ui-state-default",
"sSortable": "ui-state-default",
"sSortableAsc": "ui-state-default",
"sSortableDesc": "ui-state-default",
"sSortableNone": "ui-state-default",
"sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
"sSortJUIAsc": "css_right ui-icon ui-icon-triangle-1-n",
"sSortJUIDesc": "css_right ui-icon ui-icon-triangle-1-s",
"sSortJUI": "css_right ui-icon ui-icon-carat-2-n-s",
"sSortJUIAscAllowed": "css_right ui-icon ui-icon-carat-1-n",
"sSortJUIDescAllowed": "css_right ui-icon ui-icon-carat-1-s"
};
/*
* Variable: oPagination
* Purpose: Container for the various type of pagination that dataTables supports
* Scope: jQuery.fn.dataTableExt
*/
_oExt.oPagination = {
/*
* Variable: two_button
* Purpose: Standard two button (forward/back) pagination
* Scope: jQuery.fn.dataTableExt.oPagination
*/
"two_button": {
/*
* Function: oPagination.two_button.fnInit
* Purpose: Initalise dom elements required for pagination with forward/back buttons only
* Returns: -
* Inputs: object:oSettings - dataTables settings object
* node:nPaging - the DIV which contains this pagination control
* function:fnCallbackDraw - draw function which must be called on update
*/
"fnInit": function ( oSettings, nPaging, fnCallbackDraw )
{
var nPrevious, nNext, nPreviousInner, nNextInner;
/* Store the next and previous elements in the oSettings object as they can be very
* usful for automation - particularly testing
*/
if ( !oSettings.bJUI )
{
nPrevious = document.createElement( 'div' );
nNext = document.createElement( 'div' );
}
else
{
nPrevious = document.createElement( 'a' );
nNext = document.createElement( 'a' );
nNextInner = document.createElement('span');
nNextInner.className = oSettings.oClasses.sPageJUINext;
nNext.appendChild( nNextInner );
nPreviousInner = document.createElement('span');
nPreviousInner.className = oSettings.oClasses.sPageJUIPrev;
nPrevious.appendChild( nPreviousInner );
}
nPrevious.className = oSettings.oClasses.sPagePrevDisabled;
nNext.className = oSettings.oClasses.sPageNextDisabled;
nPrevious.title = oSettings.oLanguage.oPaginate.sPrevious;
nNext.title = oSettings.oLanguage.oPaginate.sNext;
nPaging.appendChild( nPrevious );
nPaging.appendChild( nNext );
$(nPrevious).click( function() {
oSettings.oApi._fnPageChange( oSettings, "previous" );
fnCallbackDraw( oSettings );
} );
$(nNext).click( function() {
oSettings.oApi._fnPageChange( oSettings, "next" );
fnCallbackDraw( oSettings );
} );
/* Take the brutal approach to cancelling text selection */
$(nPrevious).bind( 'selectstart', function () { return false; } );
$(nNext).bind( 'selectstart', function () { return false; } );
/* ID the first elements only */
if ( oSettings.sTableId !== '' && typeof oSettings.aanFeatures.p == "undefined" )
{
nPaging.setAttribute( 'id', oSettings.sTableId+'_paginate' );
nPrevious.setAttribute( 'id', oSettings.sTableId+'_previous' );
nNext.setAttribute( 'id', oSettings.sTableId+'_next' );
}
},
/*
* Function: oPagination.two_button.fnUpdate
* Purpose: Update the two button pagination at the end of the draw
* Returns: -
* Inputs: object:oSettings - dataTables settings object
* function:fnCallbackDraw - draw function to call on page change
*/
"fnUpdate": function ( oSettings, fnCallbackDraw )
{
if ( !oSettings.aanFeatures.p )
{
return;
}
/* Loop over each instance of the pager */
var an = oSettings.aanFeatures.p;
for ( var i=0, iLen=an.length ; i<iLen ; i++ )
{
if ( an[i].childNodes.length !== 0 )
{
an[i].childNodes[0].className =
( oSettings._iDisplayStart === 0 ) ?
oSettings.oClasses.sPagePrevDisabled : oSettings.oClasses.sPagePrevEnabled;
an[i].childNodes[1].className =
( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) ?
oSettings.oClasses.sPageNextDisabled : oSettings.oClasses.sPageNextEnabled;
}
}
}
},
/*
* Variable: iFullNumbersShowPages
* Purpose: Change the number of pages which can be seen
* Scope: jQuery.fn.dataTableExt.oPagination
*/
"iFullNumbersShowPages": 5,
/*
* Variable: full_numbers
* Purpose: Full numbers pagination
* Scope: jQuery.fn.dataTableExt.oPagination
*/
"full_numbers": {
/*
* Function: oPagination.full_numbers.fnInit
* Purpose: Initalise dom elements required for pagination with a list of the pages
* Returns: -
* Inputs: object:oSettings - dataTables settings object
* node:nPaging - the DIV which contains this pagination control
* function:fnCallbackDraw - draw function which must be called on update
*/
"fnInit": function ( oSettings, nPaging, fnCallbackDraw )
{
var nFirst = document.createElement( 'span' );
var nPrevious = document.createElement( 'span' );
var nList = document.createElement( 'span' );
var nNext = document.createElement( 'span' );
var nLast = document.createElement( 'span' );
nFirst.innerHTML = oSettings.oLanguage.oPaginate.sFirst;
nPrevious.innerHTML = oSettings.oLanguage.oPaginate.sPrevious;
nNext.innerHTML = oSettings.oLanguage.oPaginate.sNext;
nLast.innerHTML = oSettings.oLanguage.oPaginate.sLast;
var oClasses = oSettings.oClasses;
nFirst.className = oClasses.sPageButton+" "+oClasses.sPageFirst;
nPrevious.className = oClasses.sPageButton+" "+oClasses.sPagePrevious;
nNext.className= oClasses.sPageButton+" "+oClasses.sPageNext;
nLast.className = oClasses.sPageButton+" "+oClasses.sPageLast;
nPaging.appendChild( nFirst );
nPaging.appendChild( nPrevious );
nPaging.appendChild( nList );
nPaging.appendChild( nNext );
nPaging.appendChild( nLast );
$(nFirst).click( function () {
oSettings.oApi._fnPageChange( oSettings, "first" );
fnCallbackDraw( oSettings );
} );
$(nPrevious).click( function() {
oSettings.oApi._fnPageChange( oSettings, "previous" );
fnCallbackDraw( oSettings );
} );
$(nNext).click( function() {
oSettings.oApi._fnPageChange( oSettings, "next" );
fnCallbackDraw( oSettings );
} );
$(nLast).click( function() {
oSettings.oApi._fnPageChange( oSettings, "last" );
fnCallbackDraw( oSettings );
} );
/* Take the brutal approach to cancelling text selection */
$('span', nPaging)
.bind( 'mousedown', function () { return false; } )
.bind( 'selectstart', function () { return false; } );
/* ID the first elements only */
if ( oSettings.sTableId !== '' && typeof oSettings.aanFeatures.p == "undefined" )
{
nPaging.setAttribute( 'id', oSettings.sTableId+'_paginate' );
nFirst.setAttribute( 'id', oSettings.sTableId+'_first' );
nPrevious.setAttribute( 'id', oSettings.sTableId+'_previous' );
nNext.setAttribute( 'id', oSettings.sTableId+'_next' );
nLast.setAttribute( 'id', oSettings.sTableId+'_last' );
}
},
/*
* Function: oPagination.full_numbers.fnUpdate
* Purpose: Update the list of page buttons shows
* Returns: -
* Inputs: object:oSettings - dataTables settings object
* function:fnCallbackDraw - draw function to call on page change
*/
"fnUpdate": function ( oSettings, fnCallbackDraw )
{
if ( !oSettings.aanFeatures.p )
{
return;
}
var iPageCount = _oExt.oPagination.iFullNumbersShowPages;
var iPageCountHalf = Math.floor(iPageCount / 2);
var iPages = Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength);
var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
var sList = "";
var iStartButton, iEndButton, i, iLen;
var oClasses = oSettings.oClasses;
/* Pages calculation */
if (iPages < iPageCount)
{
iStartButton = 1;
iEndButton = iPages;
}
else
{
if (iCurrentPage <= iPageCountHalf)
{
iStartButton = 1;
iEndButton = iPageCount;
}
else
{
if (iCurrentPage >= (iPages - iPageCountHalf))
{
iStartButton = iPages - iPageCount + 1;
iEndButton = iPages;
}
else
{
iStartButton = iCurrentPage - Math.ceil(iPageCount / 2) + 1;
iEndButton = iStartButton + iPageCount - 1;
}
}
}
/* Build the dynamic list */
for ( i=iStartButton ; i<=iEndButton ; i++ )
{
if ( iCurrentPage != i )
{
sList += '<span class="'+oClasses.sPageButton+'">'+i+'</span>';
}
else
{
sList += '<span class="'+oClasses.sPageButtonActive+'">'+i+'</span>';
}
}
/* Loop over each instance of the pager */
var an = oSettings.aanFeatures.p;
var anButtons, anStatic, nPaginateList;
var fnClick = function() {
/* Use the information in the element to jump to the required page */
var iTarget = (this.innerHTML * 1) - 1;
oSettings._iDisplayStart = iTarget * oSettings._iDisplayLength;
fnCallbackDraw( oSettings );
return false;
};
var fnFalse = function () { return false; };
for ( i=0, iLen=an.length ; i<iLen ; i++ )
{
if ( an[i].childNodes.length === 0 )
{
continue;
}
/* Build up the dynamic list forst - html and listeners */
nPaginateList = an[i].childNodes[2];
nPaginateList.innerHTML = sList;
$('span', nPaginateList).click( fnClick ).bind( 'mousedown', fnFalse )
.bind( 'selectstart', fnFalse );
/* Update the 'premanent botton's classes */
anButtons = an[i].getElementsByTagName('span');
anStatic = [
anButtons[0], anButtons[1],
anButtons[anButtons.length-2], anButtons[anButtons.length-1]
];
$(anStatic).removeClass( oClasses.sPageButton+" "+oClasses.sPageButtonActive+" "+oClasses.sPageButtonStaticDisabled );
if ( iCurrentPage == 1 )
{
anStatic[0].className += " "+oClasses.sPageButtonStaticDisabled;
anStatic[1].className += " "+oClasses.sPageButtonStaticDisabled;
}
else
{
anStatic[0].className += " "+oClasses.sPageButton;
anStatic[1].className += " "+oClasses.sPageButton;
}
if ( iCurrentPage == iPages || oSettings._iDisplayLength == -1 )
{
anStatic[2].className += " "+oClasses.sPageButtonStaticDisabled;
anStatic[3].className += " "+oClasses.sPageButtonStaticDisabled;
}
else
{
anStatic[2].className += " "+oClasses.sPageButton;
anStatic[3].className += " "+oClasses.sPageButton;
}
}
}
}
};
/*
* Variable: oSort
* Purpose: Wrapper for the sorting functions that can be used in DataTables
* Scope: jQuery.fn.dataTableExt
* Notes: The functions provided in this object are basically standard javascript sort
* functions - they expect two inputs which they then compare and then return a priority
* result. For each sort method added, two functions need to be defined, an ascending sort and
* a descending sort.
*/
_oExt.oSort = {
/*
* text sorting
*/
"string-asc": function ( a, b )
{
var x = a.toLowerCase();
var y = b.toLowerCase();
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
},
"string-desc": function ( a, b )
{
var x = a.toLowerCase();
var y = b.toLowerCase();
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
},
/*
* html sorting (ignore html tags)
*/
"html-asc": function ( a, b )
{
var x = a.replace( /<.*?>/g, "" ).toLowerCase();
var y = b.replace( /<.*?>/g, "" ).toLowerCase();
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
},
"html-desc": function ( a, b )
{
var x = a.replace( /<.*?>/g, "" ).toLowerCase();
var y = b.replace( /<.*?>/g, "" ).toLowerCase();
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
},
/*
* date sorting
*/
"date-asc": function ( a, b )
{
var x = Date.parse( a );
var y = Date.parse( b );
if ( isNaN( x ) )
{
x = Date.parse( "01/01/1970 00:00:00" );
}
if ( isNaN( y ) )
{
y = Date.parse( "01/01/1970 00:00:00" );
}
return x - y;
},
"date-desc": function ( a, b )
{
var x = Date.parse( a );
var y = Date.parse( b );
if ( isNaN( x ) )
{
x = Date.parse( "01/01/1970 00:00:00" );
}
if ( isNaN( y ) )
{
y = Date.parse( "01/01/1970 00:00:00" );
}
return y - x;
},
/*
* numerical sorting
*/
"numeric-asc": function ( a, b )
{
var x = a == "-" ? 0 : a;
var y = b == "-" ? 0 : b;
return x - y;
},
"numeric-desc": function ( a, b )
{
var x = a == "-" ? 0 : a;
var y = b == "-" ? 0 : b;
return y - x;
}
};
/*
* Variable: aTypes
* Purpose: Container for the various type of type detection that dataTables supports
* Scope: jQuery.fn.dataTableExt
* Notes: The functions in this array are expected to parse a string to see if it is a data
* type that it recognises. If so then the function should return the name of the type (a
* corresponding sort function should be defined!), if the type is not recognised then the
* function should return null such that the parser and move on to check the next type.
* Note that ordering is important in this array - the functions are processed linearly,
* starting at index 0.
*/
_oExt.aTypes = [
/*
* Function: -
* Purpose: Check to see if a string is numeric
* Returns: string:'numeric' or null
* Inputs: string:sText - string to check
*/
function ( sData )
{
/* Snaity check that we are dealing with a string or quick return for a number */
if ( typeof sData == 'number' )
{
return 'numeric';
}
else if ( typeof sData.charAt != 'function' )
{
return null;
}
var sValidFirstChars = "0123456789-";
var sValidChars = "0123456789.";
var Char;
var bDecimal = false;
/* Check for a valid first char (no period and allow negatives) */
Char = sData.charAt(0);
if (sValidFirstChars.indexOf(Char) == -1)
{
return null;
}
/* Check all the other characters are valid */
for ( var i=1 ; i<sData.length ; i++ )
{
Char = sData.charAt(i);
if (sValidChars.indexOf(Char) == -1)
{
return null;
}
/* Only allowed one decimal place... */
if ( Char == "." )
{
if ( bDecimal )
{
return null;
}
bDecimal = true;
}
}
return 'numeric';
},
/*
* Function: -
* Purpose: Check to see if a string is actually a formatted date
* Returns: string:'date' or null
* Inputs: string:sText - string to check
*/
function ( sData )
{
var iParse = Date.parse(sData);
if ( iParse !== null && !isNaN(iParse) )
{
return 'date';
}
return null;
}
];
/*
* Variable: _oExternConfig
* Purpose: Store information for DataTables to access globally about other instances
* Scope: jQuery.fn.dataTableExt
*/
_oExt._oExternConfig = {
/* int:iNextUnique - next unique number for an instance */
"iNextUnique": 0
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Section - DataTables prototype
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Function: dataTable
* Purpose: DataTables information
* Returns: -
* Inputs: object:oInit - initalisation options for the table
*/
$.fn.dataTable = function( oInit )
{
/*
* Function: classSettings
* Purpose: Settings container function for all 'class' properties which are required
* by dataTables
* Returns: -
* Inputs: -
*/
function classSettings ()
{
this.fnRecordsTotal = function ()
{
if ( this.oFeatures.bServerSide ) {
return this._iRecordsTotal;
} else {
return this.aiDisplayMaster.length;
}
};
this.fnRecordsDisplay = function ()
{
if ( this.oFeatures.bServerSide ) {
return this._iRecordsDisplay;
} else {
return this.aiDisplay.length;
}
};
this.fnDisplayEnd = function ()
{
if ( this.oFeatures.bServerSide ) {
return this._iDisplayStart + this.aiDisplay.length;
} else {
return this._iDisplayEnd;
}
};
/*
* Variable: sInstance
* Purpose: Unique idendifier for each instance of the DataTables object
* Scope: jQuery.dataTable.classSettings
*/
this.sInstance = null;
/*
* Variable: oFeatures
* Purpose: Indicate the enablement of key dataTable features
* Scope: jQuery.dataTable.classSettings
*/
this.oFeatures = {
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bInfo": true,
"bAutoWidth": true,
"bProcessing": false,
"bSortClasses": true,
"bStateSave": false,
"bServerSide": false
};
/*
* Variable: aanFeatures
* Purpose: Array referencing the nodes which are used for the features
* Scope: jQuery.dataTable.classSettings
* Notes: The parameters of this object match what is allowed by sDom - i.e.
* 'l' - Length changing
* 'f' - Filtering input
* 't' - The table!
* 'i' - Information
* 'p' - Pagination
* 'r' - pRocessing
*/
this.aanFeatures = [];
/*
* Variable: oLanguage
* Purpose: Store the language strings used by dataTables
* Scope: jQuery.dataTable.classSettings
* Notes: The words in the format _VAR_ are variables which are dynamically replaced
* by javascript
*/
this.oLanguage = {
"sProcessing": "Processing...",
"sLengthMenu": "Show _MENU_ entries",
"sZeroRecords": "No matching records found",
"sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
"sInfoEmpty": "Showing 0 to 0 of 0 entries",
"sInfoFiltered": "(filtered from _MAX_ total entries)",
"sInfoPostFix": "",
"sSearch": "Search:",
"sUrl": "",
"oPaginate": {
"sFirst": "First",
"sPrevious": "Previous",
"sNext": "Next",
"sLast": "Last"
}
};
/*
* Variable: aoData
* Purpose: Store data information
* Scope: jQuery.dataTable.classSettings
* Notes: This is an array of objects with the following parameters:
* int: _iId - internal id for tracking
* array: _aData - internal data - used for sorting / filtering etc
* node: nTr - display node
* array node: _anHidden - hidden TD nodes
* string: _sRowStripe
*/
this.aoData = [];
/*
* Variable: aiDisplay
* Purpose: Array of indexes which are in the current display (after filtering etc)
* Scope: jQuery.dataTable.classSettings
*/
this.aiDisplay = [];
/*
* Variable: aiDisplayMaster
* Purpose: Array of indexes for display - no filtering
* Scope: jQuery.dataTable.classSettings
*/
this.aiDisplayMaster = [];
/*
* Variable: aoColumns
* Purpose: Store information about each column that is in use
* Scope: jQuery.dataTable.classSettings
*/
this.aoColumns = [];
/*
* Variable: iNextId
* Purpose: Store the next unique id to be used for a new row
* Scope: jQuery.dataTable.classSettings
*/
this.iNextId = 0;
/*
* Variable: asDataSearch
* Purpose: Search data array for regular expression searching
* Scope: jQuery.dataTable.classSettings
*/
this.asDataSearch = [];
/*
* Variable: oPreviousSearch
* Purpose: Store the previous search incase we want to force a re-search
* or compare the old search to a new one
* Scope: jQuery.dataTable.classSettings
*/
this.oPreviousSearch = {
"sSearch": "",
"bEscapeRegex": true
};
/*
* Variable: aoPreSearchCols
* Purpose: Store the previous search for each column
* Scope: jQuery.dataTable.classSettings
*/
this.aoPreSearchCols = [];
/*
* Variable: aaSorting
* Purpose: Sorting information
* Scope: jQuery.dataTable.classSettings
* Notes: Index 0 - column number
* Index 1 - current sorting direction
* Index 2 - index of asSorting for this column
*/
this.aaSorting = [ [0, 'asc', 0] ];
/*
* Variable: aaSortingFixed
* Purpose: Sorting information that is always applied
* Scope: jQuery.dataTable.classSettings
*/
this.aaSortingFixed = null;
/*
* Variable: asStripClasses
* Purpose: Classes to use for the striping of a table
* Scope: jQuery.dataTable.classSettings
*/
this.asStripClasses = [];
/*
* Variable: fnRowCallback
* Purpose: Call this function every time a row is inserted (draw)
* Scope: jQuery.dataTable.classSettings
*/
this.fnRowCallback = null;
/*
* Variable: fnHeaderCallback
* Purpose: Callback function for the header on each draw
* Scope: jQuery.dataTable.classSettings
*/
this.fnHeaderCallback = null;
/*
* Variable: fnFooterCallback
* Purpose: Callback function for the footer on each draw
* Scope: jQuery.dataTable.classSettings
*/
this.fnFooterCallback = null;
/*
* Variable: aoDrawCallback
* Purpose: Array of callback functions for draw callback functions
* Scope: jQuery.dataTable.classSettings
* Notes: Each array element is an object with the following parameters:
* function:fn - function to call
* string:sName - name callback (feature). useful for arranging array
*/
this.aoDrawCallback = [];
/*
* Variable: fnInitComplete
* Purpose: Callback function for when the table has been initalised
* Scope: jQuery.dataTable.classSettings
*/
this.fnInitComplete = null;
/*
* Variable: sTableId
* Purpose: Cache the table ID for quick access
* Scope: jQuery.dataTable.classSettings
*/
this.sTableId = "";
/*
* Variable: nTable
* Purpose: Cache the table node for quick access
* Scope: jQuery.dataTable.classSettings
*/
this.nTable = null;