3 * @class mw.plugin.pageready
6 * Enable checkboxes to be checked or unchecked in a row by clicking one,
7 * holding shift and clicking another one.
9 * @method checkboxShift
10 * @param {jQuery} $box
12 module
.exports = function ( $box
) {
14 // When our boxes are clicked..
15 $box
.on( 'click', function ( e
) {
16 // And one has been clicked before...
17 if ( prev
&& e
.shiftKey
) {
18 // Check or uncheck this one and all in-between checkboxes,
19 // except for disabled ones
22 Math
.min( $box
.index( prev
), $box
.index( e
.target
) ),
23 Math
.max( $box
.index( prev
), $box
.index( e
.target
) ) + 1
25 .filter( function () {
26 return !this.disabled
;
28 .prop( 'checked', e
.target
.checked
);
30 // Either way, remember this as the last clicked one