From fbe04fbf90d04d369bc0132887e7d434d13d9680 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 18 Apr 2008 22:23:02 +0000 Subject: [PATCH] Shift-click to select a range of checkboxes. Props mdawaffe. fixes #6541 for trunk git-svn-id: http://svn.automattic.com/wordpress/trunk@7745 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/categories.php | 2 +- wp-admin/edit-comments.php | 2 +- wp-admin/edit-link-categories.php | 2 +- wp-admin/edit-tags.php | 2 +- wp-admin/includes/template.php | 6 ++-- wp-admin/js/forms.js | 51 ++++++++++++++----------------- wp-admin/link-manager.php | 2 +- wp-admin/users.php | 2 +- wp-includes/script-loader.php | 2 +- 9 files changed, 33 insertions(+), 38 deletions(-) diff --git a/wp-admin/categories.php b/wp-admin/categories.php index 945da0c63..bf6c382a8 100644 --- a/wp-admin/categories.php +++ b/wp-admin/categories.php @@ -147,7 +147,7 @@ endif; ?> - + diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index 8ed4df569..7a3635676 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -185,7 +185,7 @@ if ($comments) {
- + diff --git a/wp-admin/edit-link-categories.php b/wp-admin/edit-link-categories.php index b8dfebcfa..ab1dc9a22 100644 --- a/wp-admin/edit-link-categories.php +++ b/wp-admin/edit-link-categories.php @@ -101,7 +101,7 @@ if ( $page_links )
- + diff --git a/wp-admin/edit-tags.php b/wp-admin/edit-tags.php index b50269be0..340174d2b 100644 --- a/wp-admin/edit-tags.php +++ b/wp-admin/edit-tags.php @@ -172,7 +172,7 @@ if ( $page_links )
- + diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 7ed2d03d9..fc1b68873 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -279,7 +279,7 @@ function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) { // define the columns to display, the syntax is 'internal name' => 'display name' function wp_manage_posts_columns() { $posts_columns = array(); - $posts_columns['cb'] = ''; + $posts_columns['cb'] = ''; if ( 'draft' === $_GET['post_status'] ) $posts_columns['modified'] = __('Modified'); elseif ( 'pending' === $_GET['post_status'] ) @@ -301,7 +301,7 @@ function wp_manage_posts_columns() { // define the columns to display, the syntax is 'internal name' => 'display name' function wp_manage_media_columns() { $posts_columns = array(); - $posts_columns['cb'] = ''; + $posts_columns['cb'] = ''; $posts_columns['icon'] = ''; $posts_columns['media'] = _c('Media|media column header'); $posts_columns['desc'] = _c('Description|media column header'); @@ -316,7 +316,7 @@ function wp_manage_media_columns() { function wp_manage_pages_columns() { $posts_columns = array(); - $posts_columns['cb'] = ''; + $posts_columns['cb'] = ''; if ( 'draft' === $_GET['post_status'] ) $posts_columns['modified'] = __('Modified'); elseif ( 'pending' === $_GET['post_status'] ) diff --git a/wp-admin/js/forms.js b/wp-admin/js/forms.js index b1d8ce272..5d6c35ddd 100644 --- a/wp-admin/js/forms.js +++ b/wp-admin/js/forms.js @@ -1,31 +1,26 @@ -function checkAll(form) { - for (i = 0, n = form.elements.length; i < n; i++) { - if(form.elements[i].type == "checkbox" && !(form.elements[i].getAttribute('onclick',2))) { - if(form.elements[i].checked == true) - form.elements[i].checked = false; - else - form.elements[i].checked = true; - } - } +function checkAll(jQ) { // use attr( checked, fn ) + jQuery(jQ).find( 'tbody :checkbox' ).attr( 'checked', function() { + return jQuery(this).attr( 'checked' ) ? '' : 'checked'; + } ); } -function getNumChecked(form) { - var num = 0; - for (i = 0, n = form.elements.length; i < n; i++) { - if (form.elements[i].type == "checkbox") { - if (form.elements[i].checked == true) - num++; +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' : '' ); + } } - } - return num; -} - -function checkAllUsers(role) { - var checkboxs = document.getElementsByTagName('input'); - for(var i = 0, inp; inp = checkboxs[i]; i++) - if(inp.type.toLowerCase() == 'checkbox' && inp.className == role) - if(inp.checked == false) - inp.checked = true; - else - inp.checked = false; -} \ No newline at end of file + lastClicked = this; + return true; + } ); + $( 'thead :checkbox' ).click( function() { + checkAll( $(this).parents( 'form:first' ) ); + } ); +} ); \ No newline at end of file diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php index 42ec2017c..0fb7b8636 100644 --- a/wp-admin/link-manager.php +++ b/wp-admin/link-manager.php @@ -141,7 +141,7 @@ if ( $links ) {
- + diff --git a/wp-admin/users.php b/wp-admin/users.php index d8089b4cd..7aa7873d8 100644 --- a/wp-admin/users.php +++ b/wp-admin/users.php @@ -330,7 +330,7 @@ unset($role_links);
- + diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 11faca2f7..fda125916 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -131,7 +131,7 @@ class WP_Scripts { 'pending' => __('%i% pending') // must look like: "# blah blah" ) ); $this->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20070823' ); - $this->add( 'admin-forms', '/wp-admin/js/forms.js', false, '20080317' ); + $this->add( 'admin-forms', '/wp-admin/js/forms.js', false, '20080401'); $this->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' ); $this->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' ); $this->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery'), '20080128' );