2008-04-19 00:23:02 +02:00
|
|
|
function checkAll(jQ) { // use attr( checked, fn )
|
2008-09-11 00:47:03 +02:00
|
|
|
jQuery(jQ).find( 'tbody:visible .check-column :checkbox' ).attr( 'checked', function() {
|
2008-04-19 00:23:02 +02:00
|
|
|
return jQuery(this).attr( 'checked' ) ? '' : 'checked';
|
|
|
|
} );
|
2008-01-07 21:38:49 +01:00
|
|
|
}
|
|
|
|
|
2008-04-19 00:23:02 +02:00
|
|
|
jQuery( function($) {
|
|
|
|
var lastClicked = false;
|
2008-09-11 00:47:03 +02:00
|
|
|
$( 'tbody .check-column :checkbox' ).click( function(e) {
|
2008-04-19 00:23:02 +02:00
|
|
|
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 21:38:49 +01:00
|
|
|
}
|
2008-04-19 00:23:02 +02:00
|
|
|
lastClicked = this;
|
|
|
|
return true;
|
|
|
|
} );
|
2008-09-29 14:03:30 +02:00
|
|
|
$( 'thead :checkbox, tfoot :checkbox' ).click( function() {
|
2008-04-19 00:23:02 +02:00
|
|
|
checkAll( $(this).parents( 'form:first' ) );
|
|
|
|
} );
|
2008-09-04 19:53:14 +02:00
|
|
|
} );
|