Plugins: Fix checkbox selection when searching for installed plugins.

Since the plugin search works via Ajax, the JavaScript events need to delegated in order for the checkboxes to work properly.

Props afercia.
Fixes #37973.
Built from https://develop.svn.wordpress.org/trunk@38703


git-svn-id: http://core.svn.wordpress.org/trunk@38646 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler 2016-10-03 06:37:30 +00:00
parent f424977028
commit b570b4b18c
3 changed files with 10 additions and 8 deletions

View File

@ -426,10 +426,11 @@ $document.ready( function() {
// Init screen meta // Init screen meta
screenMeta.init(); screenMeta.init();
// check all checkboxes // This event needs to be delegated. Ticket #37973.
$('tbody').children().children('.check-column').find(':checkbox').click( function(e) { $body.on( 'click', 'tbody .check-column :checkbox', function( even ) {
if ( 'undefined' == e.shiftKey ) { return true; } // Shift click to select a range of checkboxes.
if ( e.shiftKey ) { if ( 'undefined' == event.shiftKey ) { return true; }
if ( event.shiftKey ) {
if ( !lastClicked ) { return true; } if ( !lastClicked ) { return true; }
checks = $( lastClicked ).closest( 'form' ).find( ':checkbox' ).filter( ':visible:enabled' ); checks = $( lastClicked ).closest( 'form' ).find( ':checkbox' ).filter( ':visible:enabled' );
first = checks.index( lastClicked ); first = checks.index( lastClicked );
@ -447,7 +448,7 @@ $document.ready( function() {
} }
lastClicked = this; lastClicked = this;
// toggle "check all" checkboxes // Toggle the "Select all" checkboxes depending if the other ones are all checked or not.
var unchecked = $(this).closest('tbody').find(':checkbox').filter(':visible:enabled').not(':checked'); var unchecked = $(this).closest('tbody').find(':checkbox').filter(':visible:enabled').not(':checked');
$(this).closest('table').children('thead, tfoot').find(':checkbox').prop('checked', function() { $(this).closest('table').children('thead, tfoot').find(':checkbox').prop('checked', function() {
return ( 0 === unchecked.length ); return ( 0 === unchecked.length );
@ -456,7 +457,8 @@ $document.ready( function() {
return true; return true;
}); });
$('thead, tfoot').find('.check-column :checkbox').on( 'click.wp-toggle-checkboxes', function( event ) { // This event needs to be delegated. Ticket #37973.
$body.on( 'click.wp-toggle-checkboxes', 'thead .check-column :checkbox, tfoot .check-column :checkbox', function( event ) {
var $this = $(this), var $this = $(this),
$table = $this.closest( 'table' ), $table = $this.closest( 'table' ),
controlChecked = $this.prop('checked'), controlChecked = $this.prop('checked'),

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.7-alpha-38702'; $wp_version = '4.7-alpha-38703';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.