mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-05 02:10:45 +01:00
fbe04fbf90
git-svn-id: http://svn.automattic.com/wordpress/trunk@7745 1a063a9b-81f0-0310-95a4-ce76da25c4cd
26 lines
851 B
JavaScript
26 lines
851 B
JavaScript
function checkAll(jQ) { // use attr( checked, fn )
|
|
jQuery(jQ).find( 'tbody :checkbox' ).attr( 'checked', function() {
|
|
return jQuery(this).attr( 'checked' ) ? '' : 'checked';
|
|
} );
|
|
}
|
|
|
|
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' : '' );
|
|
}
|
|
}
|
|
lastClicked = this;
|
|
return true;
|
|
} );
|
|
$( 'thead :checkbox' ).click( function() {
|
|
checkAll( $(this).parents( 'form:first' ) );
|
|
} );
|
|
} ); |