2 * @class jQuery.plugin.checkboxShiftClick
7 * Enable checkboxes to be checked or unchecked in a row by clicking one,
8 * holding shift and clicking another one.
13 $.fn
.checkboxShiftClick = function () {
14 var prevCheckbox
= null,
16 // When our boxes are clicked..
17 $box
.click( function ( e
) {
18 // And one has been clicked before...
19 if ( prevCheckbox
!== null && e
.shiftKey
) {
20 // Check or uncheck this one and all in-between checkboxes,
21 // except for disabled ones
24 Math
.min( $box
.index( prevCheckbox
), $box
.index( e
.target
) ),
25 Math
.max( $box
.index( prevCheckbox
), $box
.index( e
.target
) ) + 1
27 .filter( function () {
28 return !this.disabled
;
30 .prop( 'checked', !!e
.target
.checked
);
32 // Either way, update the prevCheckbox variable to the one clicked now
33 prevCheckbox
= e
.target
;
40 * @mixins jQuery.plugin.checkboxShiftClick