]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/forms.js
Wordpress 2.6.2
[autoinstalls/wordpress.git] / wp-admin / js / forms.js
1 function checkAll(jQ) { // use attr( checked, fn )
2         jQuery(jQ).find( 'tbody:visible :checkbox' ).attr( 'checked', function() {
3                 return jQuery(this).attr( 'checked' ) ? '' : 'checked';
4         } );
5 }
6
7 jQuery( function($) {
8         var lastClicked = false;
9         $( 'tbody :checkbox' ).click( function(e) {
10                 if ( 'undefined' == e.shiftKey ) { return true; }
11                 if ( e.shiftKey ) {
12                         if ( !lastClicked ) { return true; }
13                         var checks = $( lastClicked ).parents( 'form:first' ).find( ':checkbox' );
14                         var first = checks.index( lastClicked );
15                         var last = checks.index( this );
16                         if ( 0 < first && 0 < last && first != last ) {
17                                 checks.slice( first, last ).attr( 'checked', $( this ).is( ':checked' ) ? 'checked' : '' );
18                         }
19                 }
20                 lastClicked = this;
21                 return true;
22         } );
23         $( 'thead :checkbox' ).click( function() {
24                 checkAll( $(this).parents( 'form:first' ) );
25         } );
26 } );