From: MatmaRex Date: Sun, 16 Jun 2013 20:35:18 +0000 (+0200) Subject: jquery.checkboxShiftClick: Don't toggle disabled checkboxes X-Git-Tag: 1.31.0-rc.0~19256^2 X-Git-Url: https://git.cyclocoop.org/admin/?a=commitdiff_plain;h=d34ac897df8c5b5534ba25fa8aa9afb9280440e5;p=lhc%2Fweb%2Fwiklou.git jquery.checkboxShiftClick: Don't toggle disabled checkboxes They are not togglable via normal user interaction, so shouldn't be togglable this way either. Bug: 49648 Change-Id: I14b90c86007b583aa27ab5312768b51f3a25cdbb --- diff --git a/resources/jquery/jquery.checkboxShiftClick.js b/resources/jquery/jquery.checkboxShiftClick.js index aced0633dc..b206566541 100644 --- a/resources/jquery/jquery.checkboxShiftClick.js +++ b/resources/jquery/jquery.checkboxShiftClick.js @@ -15,11 +15,17 @@ $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;