2008-04-18 18:23:02 -04:00
|
|
|
function checkAll(jQ) { // use attr( checked, fn )
|
2008-07-29 18:16:39 -04:00
|
|
|
jQuery(jQ).find( 'tbody:visible :checkbox' ).attr( 'checked', function() {
|
2008-04-18 18:23:02 -04:00
|
|
|
return jQuery(this).attr( 'checked' ) ? '' : 'checked';
|
|
|
|
} );
|
2008-01-07 15:38:49 -05:00
|
|
|
}
|
|
|
|
|
2008-04-18 18:23:02 -04:00
|
|
|
jQuery( function($) {
|
|
|
|
var lastClicked = false;
|
|
|
|
$( 'tbody :checkbox' ).click( function(e) {
|
|
|
|
if ( 'undefined' == e.shiftKey ) { return true; }
|
|
|
|
if ( e.shiftKey ) {
|
|
|
|
if ( !lastClicked ) { return true; }
|
|
|
|
var checks = $( lastClicked ).parents( 'form:first' ).find( ':checkbox' );
|
|
|
|
var first = checks.index( lastClicked );
|
|
|
|
var last = checks.index( this );
|
|
|
|
if ( 0 < first && 0 < last && first != last ) {
|
|
|
|
checks.slice( first, last ).attr( 'checked', $( this ).is( ':checked' ) ? 'checked' : '' );
|
|
|
|
}
|
2008-01-07 15:38:49 -05:00
|
|
|
}
|
2008-04-18 18:23:02 -04:00
|
|
|
lastClicked = this;
|
|
|
|
return true;
|
|
|
|
} );
|
|
|
|
$( 'thead :checkbox' ).click( function() {
|
|
|
|
checkAll( $(this).parents( 'form:first' ) );
|
|
|
|
} );
|
|
|
|
} );
|