Merge "Clear shallowFallbacks in LocalisationCache::unload"
[mediawiki.git] / resources / jquery / jquery.checkboxShiftClick.js
blobaced0633dc2cd20185a5b2e231c412724918b541
1 /**
2  * jQuery checkboxShiftClick
3  *
4  * This will enable checkboxes to be checked or unchecked in a row by clicking one,
5  * holding shift and clicking another one.
6  *
7  * @author Timo Tijhof, 2011 - 2012
8  * @license GPL v2
9  */
10 ( function ( $ ) {
11         $.fn.checkboxShiftClick = function () {
12                 var prevCheckbox = null,
13                         $box = this;
14                 // When our boxes are clicked..
15                 $box.click( function ( e ) {
16                         // And one has been clicked before...
17                         if ( prevCheckbox !== null && e.shiftKey ) {
18                                 // Check or uncheck this one and all in-between checkboxes
19                                 $box.slice(
20                                         Math.min( $box.index( prevCheckbox ), $box.index( e.target ) ),
21                                         Math.max( $box.index( prevCheckbox ), $box.index( e.target ) ) + 1
22                                 ).prop( 'checked', !!e.target.checked );
23                         }
24                         // Either way, update the prevCheckbox variable to the one clicked now
25                         prevCheckbox = e.target;
26                 } );
27                 return $box;
28         };
29 }( jQuery ) );