From e00cb4d4290974878040eda408baa513942fc62d Mon Sep 17 00:00:00 2001 From: azaozz Date: Sat, 15 Nov 2008 07:07:59 +0000 Subject: [PATCH] Improve the check all: click to check all checkboxes, click again to uncheck all, Shift/click to toggle. Shift/clicking two consecutive boxes checks the range between them as before. Fixes #8217 git-svn-id: http://svn.automattic.com/wordpress/trunk@9708 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/common.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js index 91d07e3ce8..860a9d9c2d 100644 --- a/wp-admin/js/common.js +++ b/wp-admin/js/common.js @@ -200,11 +200,17 @@ jQuery(document).ready( function($) { return true; } ); - $( 'thead :checkbox, tfoot :checkbox' ).click( function() { - $(this).parents( 'form:first' ).find( 'tbody:visible .check-column :checkbox' ).attr( 'checked', function() { - return $(this).attr( 'checked' ) ? '' : 'checked'; + $( 'thead :checkbox, tfoot :checkbox' ).click( function(e) { + var c = $(this).attr('checked'); + + $(this).parents( 'form:first' ).find( 'table .check-column :checkbox' ).attr( 'checked', function() { + if ( e.shiftKey ) + return $(this).attr( 'checked' ) ? '' : 'checked'; + else if (c) + return 'checked'; + + return ''; }); - return false; }); });