home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Blogs / wordpress2.6.exe / wordpress2.6 / wp-admin / js / forms.js < prev    next >
Encoding:
Text File  |  2008-07-30  |  859 b   |  26 lines

  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. } );