Shift-click to select a range of checkboxes. Props mdawaffe. fixes #6541 for trunk

git-svn-id: https://develop.svn.wordpress.org/trunk@7745 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-04-18 22:23:02 +00:00
parent a40491ce38
commit f74903d3c2
9 changed files with 33 additions and 38 deletions

View File

@ -147,7 +147,7 @@ endif; ?>
<table class="widefat">
<thead>
<tr>
<th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th>
<th scope="col" class="check-column"><input type="checkbox" /></th>
<th scope="col"><?php _e('Name') ?></th>
<th scope="col"><?php _e('Description') ?></th>
<th scope="col" class="num"><?php _e('Posts') ?></th>

View File

@ -185,7 +185,7 @@ if ($comments) {
<table class="widefat">
<thead>
<tr>
<th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('comments-form'));" /></th>
<th scope="col" class="check-column"><input type="checkbox" /></th>
<th scope="col"><?php _e('Comment') ?></th>
<th scope="col"><?php _e('Date') ?></th>
<th scope="col" class="action-links"><?php _e('Actions') ?></th>

View File

@ -101,7 +101,7 @@ if ( $page_links )
<table class="widefat">
<thead>
<tr>
<th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th>
<th scope="col" class="check-column"><input type="checkbox" /></th>
<th scope="col"><?php _e('Name') ?></th>
<th scope="col"><?php _e('Description') ?></th>
<th scope="col" class="num" style="width: 90px;"><?php _e('Links') ?></th>

View File

@ -172,7 +172,7 @@ if ( $page_links )
<table class="widefat">
<thead>
<tr>
<th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th>
<th scope="col" class="check-column"><input type="checkbox" /></th>
<th scope="col"><?php _e('Name') ?></th>
<th scope="col" class="num" style="width: 90px"><?php _e('Posts') ?></th>
</tr>

View File

@ -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'] = '<input type="checkbox" onclick="checkAll(document.getElementById(\'posts-filter\'));" />';
$posts_columns['cb'] = '<input type="checkbox" />';
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'] = '<input type="checkbox" onclick="checkAll(document.getElementById(\'posts-filter\'));" />';
$posts_columns['cb'] = '<input type="checkbox" />';
$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'] = '<input type="checkbox" onclick="checkAll(document.getElementById(\'posts-filter\'));" />';
$posts_columns['cb'] = '<input type="checkbox" />';
if ( 'draft' === $_GET['post_status'] )
$posts_columns['modified'] = __('Modified');
elseif ( 'pending' === $_GET['post_status'] )

View File

@ -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;
}
lastClicked = this;
return true;
} );
$( 'thead :checkbox' ).click( function() {
checkAll( $(this).parents( 'form:first' ) );
} );
} );

View File

@ -141,7 +141,7 @@ if ( $links ) {
<table class="widefat">
<thead>
<tr>
<th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th>
<th scope="col" class="check-column"><input type="checkbox" /></th>
<?php foreach($link_columns as $column_display_name) {
echo $column_display_name;
} ?>

View File

@ -330,7 +330,7 @@ unset($role_links);
<table class="widefat">
<thead>
<tr class="thead">
<th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /> </th>
<th scope="col" class="check-column"><input type="checkbox" /></th>
<th><?php _e('Username') ?></th>
<th><?php _e('Name') ?></th>
<th><?php _e('E-mail') ?></th>

View File

@ -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' );