mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-09 04:11:10 +01:00
25f206e01f
Props wonderboymusic, pareshradadiya. Fixes #31634. Built from https://develop.svn.wordpress.org/trunk@34467 git-svn-id: http://core.svn.wordpress.org/trunk@34431 1a063a9b-81f0-0310-95a4-ce76da25c4cd
46 lines
1.0 KiB
JavaScript
46 lines
1.0 KiB
JavaScript
/*globals jQuery */
|
|
|
|
(function ($) {
|
|
'use strict';
|
|
|
|
var listTable,
|
|
actions,
|
|
doActions;
|
|
|
|
function getChecked() {
|
|
return listTable.find( 'table .check-column input[type="checkbox"]:checked' );
|
|
}
|
|
|
|
/**
|
|
* Enable and Disable Apply button in wp-list
|
|
*
|
|
* @param {jQuery.Event} e
|
|
*/
|
|
function setApplyButton( e ) {
|
|
var checked = getChecked().length;
|
|
|
|
if ( 'SELECT' === e.target.tagName ) {
|
|
actions.val( e.target.value );
|
|
}
|
|
|
|
actions.prop( 'disabled', ! checked );
|
|
doActions.prop( 'disabled', ! checked || -1 === parseInt( actions.val(), 10 ) );
|
|
}
|
|
|
|
$(document).ready(function () {
|
|
listTable = $( '.wp-list-table' ).closest( 'form' );
|
|
if ( ! listTable.length ) {
|
|
return;
|
|
}
|
|
|
|
actions = listTable.find( 'select[name="action"], select[name="action2"]' )
|
|
.on( 'change', setApplyButton )
|
|
.prop( 'disabled', true );
|
|
|
|
doActions = listTable.find( '#doaction, #doaction2' )
|
|
.prop( 'disabled', true );
|
|
|
|
listTable.find( 'table' ).on( 'click', '.check-column :checkbox', setApplyButton );
|
|
});
|
|
|
|
}(jQuery)); |