936aa62b5c
git-svn-id: https://develop.svn.wordpress.org/trunk@9029 602fd350-edb4-49c9-b593-d223f7449a82
27 lines
905 B
JavaScript
27 lines
905 B
JavaScript
function checkAll(jQ) { // use attr( checked, fn )
|
|
jQuery(jQ).find( 'tbody:visible .check-column :checkbox' ).attr( 'checked', function() {
|
|
return jQuery(this).attr( 'checked' ) ? '' : 'checked';
|
|
} );
|
|
}
|
|
|
|
jQuery( function($) {
|
|
var lastClicked = false;
|
|
$( 'tbody .check-column :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' : '' );
|
|
}
|
|
}
|
|
lastClicked = this;
|
|
return true;
|
|
} );
|
|
$( 'thead :checkbox, tfoot :checkbox' ).click( function() {
|
|
checkAll( $(this).parents( 'form:first' ) );
|
|
} );
|
|
} );
|