jquery.checkboxShiftClick: Don't toggle disabled checkboxes
authorMatmaRex <matma.rex@gmail.com>
Sun, 16 Jun 2013 20:35:18 +0000 (22:35 +0200)
committerMatmarex <matma.rex@gmail.com>
Sat, 6 Jul 2013 13:18:14 +0000 (13:18 +0000)
They are not togglable via normal user interaction, so shouldn't be
togglable this way either.

Bug: 49648
Change-Id: I14b90c86007b583aa27ab5312768b51f3a25cdbb

resources/jquery/jquery.checkboxShiftClick.js

index aced063..b206566 100644 (file)
                $box.click( function ( e ) {
                        // And one has been clicked before...
                        if ( prevCheckbox !== null && e.shiftKey ) {
-                               // Check or uncheck this one and all in-between checkboxes
-                               $box.slice(
-                                       Math.min( $box.index( prevCheckbox ), $box.index( e.target ) ),
-                                       Math.max( $box.index( prevCheckbox ), $box.index( e.target ) ) + 1
-                               ).prop( 'checked', !!e.target.checked );
+                               // Check or uncheck this one and all in-between checkboxes,
+                               // except for disabled ones
+                               $box
+                                       .slice(
+                                               Math.min( $box.index( prevCheckbox ), $box.index( e.target ) ),
+                                               Math.max( $box.index( prevCheckbox ), $box.index( e.target ) ) + 1
+                                       )
+                                       .filter( function () {
+                                               return !this.disabled;
+                                       } )
+                                       .prop( 'checked', !!e.target.checked );
                        }
                        // Either way, update the prevCheckbox variable to the one clicked now
                        prevCheckbox = e.target;