1
- /*! Checkboxes 1.2.4
1
+ /*! Checkboxes 1.2.5-dev
2
2
* Copyright (c) Gyrocode (www.gyrocode.com)
3
3
* License: MIT License
4
4
*/
5
5
6
6
/**
7
7
* @summary Checkboxes
8
8
* @description Checkboxes extension for jQuery DataTables
9
- * @version 1.2.4
9
+ * @version 1.2.5-dev
10
10
* @file dataTables.checkboxes.js
11
11
* @author Gyrocode (http://www.gyrocode.com/projects/jquery-datatables-checkboxes/)
12
12
* @contact http://www.gyrocode.com/contacts
@@ -368,14 +368,11 @@ Checkboxes.prototype = {
368
368
} ,
369
369
370
370
// Updates array holding data for selected checkboxes
371
- updateData : function ( type , selector , isSelected , allowDups ) {
371
+ updateData : function ( type , selector , isSelected ) {
372
372
var self = this ;
373
373
var dt = self . s . dt ;
374
374
var ctx = self . s . ctx ;
375
375
376
- // By default, duplicate data is not allowed
377
- if ( typeof allowDups === 'undefined' ) { allowDups = false ; }
378
-
379
376
var cellSelector ;
380
377
381
378
if ( type === 'cell' ) {
@@ -399,30 +396,13 @@ Checkboxes.prototype = {
399
396
// Get cell data
400
397
var cellData = this . data ( ) ;
401
398
402
- // Determine whether data is in the list
403
- var hasData = ctx . checkboxes . s . data [ cellCol ] . hasOwnProperty ( cellData ) ;
404
-
405
- // If checkbox is checked and data is not in the list
399
+ // If checkbox is checked
406
400
if ( isSelected ) {
407
- // If data is available and duplicates are allowed
408
- if ( hasData && allowDups ) {
409
- ctx . checkboxes . s . data [ cellCol ] [ cellData ] ++ ;
410
-
411
- // Otherwise, if data is not available or duplicates are not allowed
412
- } else {
413
- ctx . checkboxes . s . data [ cellCol ] [ cellData ] = 1 ;
414
- }
401
+ ctx . checkboxes . s . data [ cellCol ] [ cellData ] = 1 ;
415
402
416
- // Otherwise, if checkbox is not checked and data is in the list
417
- } else if ( ! isSelected && hasData ) {
418
- // If only data counter equals to 1 or duplicates are not allowed
419
- if ( ctx . checkboxes . s . data [ cellCol ] [ cellData ] === 1 || ! allowDups ) {
420
- delete ctx . checkboxes . s . data [ cellCol ] [ cellData ] ;
421
-
422
- // Otherwise, if data counter is greater than 1 and duplicates are allowed
423
- } else {
424
- ctx . checkboxes . s . data [ cellCol ] [ cellData ] -- ;
425
- }
403
+ // Otherwise, if checkbox is not checked
404
+ } else {
405
+ delete ctx . checkboxes . s . data [ cellCol ] [ cellData ] ;
426
406
}
427
407
}
428
408
} ) ;
@@ -607,21 +587,7 @@ Checkboxes.prototype = {
607
587
if ( self . s . ignoreSelect ) { return ; }
608
588
609
589
if ( type === 'row' ) {
610
- // By default, allow duplicate data
611
- var allowDup = true ;
612
-
613
- // WORKAROUND:
614
- // Select extension may generate multiple select events for the same row
615
- // when selecting rows using SHIFT key and the following styles are used
616
- // 'os', 'multi+shift'.
617
- //
618
- // If user is selecting/deselecting multiple rows using SHIFT key
619
- if ( ( ctx . _select . style === 'os' || ctx . _select . style === 'multi+shift' ) && indexes . length > 1 ) {
620
- // Disallow handling of rows with duplicate data
621
- allowDup = false ;
622
- }
623
-
624
- self . updateData ( 'row' , indexes , ( e . type === 'select' ) ? true : false , allowDup ) ;
590
+ self . updateData ( 'row' , indexes , ( e . type === 'select' ) ? true : false ) ;
625
591
self . updateCheckbox ( 'row' , indexes , ( e . type === 'select' ) ? true : false ) ;
626
592
627
593
// Get index of the first column that has checkbox and row selection enabled
@@ -906,7 +872,7 @@ Api.register( 'checkboxes()', function () {
906
872
return this ;
907
873
} ) ;
908
874
909
- Api . registerPlural ( 'columns().checkboxes.select()' , 'column().checkboxes.select()' , function ( select , allowDups ) {
875
+ Api . registerPlural ( 'columns().checkboxes.select()' , 'column().checkboxes.select()' , function ( select ) {
910
876
if ( typeof select === 'undefined' ) { select = true ; }
911
877
912
878
return this . iterator ( 'column-rows' , function ( ctx , colIdx , i , j , rowsIdx ) {
@@ -916,7 +882,7 @@ Api.registerPlural( 'columns().checkboxes.select()', 'column().checkboxes.select
916
882
selector . push ( { row : rowIdx , column : colIdx } ) ;
917
883
} ) ;
918
884
919
- ctx . checkboxes . updateData ( 'cell' , selector , ( select ) ? true : false , allowDups ) ;
885
+ ctx . checkboxes . updateData ( 'cell' , selector , ( select ) ? true : false ) ;
920
886
ctx . checkboxes . updateCheckbox ( 'cell' , selector , ( select ) ? true : false ) ;
921
887
922
888
// If row selection is enabled
@@ -939,14 +905,14 @@ Api.registerPlural( 'columns().checkboxes.select()', 'column().checkboxes.select
939
905
} , 1 ) ;
940
906
} ) ;
941
907
942
- Api . registerPlural ( 'cells().checkboxes.select()' , 'cell().checkboxes.select()' , function ( select , allowDups ) {
908
+ Api . registerPlural ( 'cells().checkboxes.select()' , 'cell().checkboxes.select()' , function ( select ) {
943
909
if ( typeof select === 'undefined' ) { select = true ; }
944
910
945
911
return this . iterator ( 'cell' , function ( ctx , rowIdx , colIdx ) {
946
912
if ( ctx . checkboxes ) {
947
913
var selector = [ { row : rowIdx , column : colIdx } ] ;
948
914
949
- ctx . checkboxes . updateData ( 'cell' , selector , ( select ) ? true : false , allowDups ) ;
915
+ ctx . checkboxes . updateData ( 'cell' , selector , ( select ) ? true : false ) ;
950
916
ctx . checkboxes . updateCheckbox ( 'cell' , selector , ( select ) ? true : false ) ;
951
917
952
918
// If row selection is enabled
@@ -969,12 +935,12 @@ Api.registerPlural( 'cells().checkboxes.select()', 'cell().checkboxes.select()',
969
935
} , 1 ) ;
970
936
} ) ;
971
937
972
- Api . registerPlural ( 'columns().checkboxes.deselect()' , 'column().checkboxes.deselect()' , function ( allowDups ) {
973
- return this . checkboxes . select ( false , allowDups ) ;
938
+ Api . registerPlural ( 'columns().checkboxes.deselect()' , 'column().checkboxes.deselect()' , function ( ) {
939
+ return this . checkboxes . select ( false ) ;
974
940
} ) ;
975
941
976
- Api . registerPlural ( 'cells().checkboxes.deselect()' , 'cell().checkboxes.deselect()' , function ( allowDups ) {
977
- return this . checkboxes . select ( false , allowDups ) ;
942
+ Api . registerPlural ( 'cells().checkboxes.deselect()' , 'cell().checkboxes.deselect()' , function ( ) {
943
+ return this . checkboxes . select ( false ) ;
978
944
} ) ;
979
945
980
946
Api . registerPlural ( 'columns().checkboxes.deselectAll()' , 'column().checkboxes.deselectAll()' , function ( ) {
@@ -983,7 +949,7 @@ Api.registerPlural( 'columns().checkboxes.deselectAll()', 'column().checkboxes.d
983
949
if ( ctx . aoColumns [ colIdx ] . checkboxes ) {
984
950
ctx . checkboxes . s . data [ colIdx ] = { } ;
985
951
986
- this . column ( colIdx ) . checkboxes . select ( false , false ) ;
952
+ this . column ( colIdx ) . checkboxes . select ( false ) ;
987
953
}
988
954
} , 1 ) ;
989
955
} ) ;
@@ -1013,7 +979,7 @@ Api.registerPlural( 'columns().checkboxes.selected()', 'column().checkboxes.sele
1013
979
* @name Checkboxes.version
1014
980
* @static
1015
981
*/
1016
- Checkboxes . version = '1.2.3 ' ;
982
+ Checkboxes . version = '1.2.5-dev ' ;
1017
983
1018
984
1019
985
0 commit comments