diff options
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/_enqueues/admin/common.js | 59 | ||||
-rw-r--r-- | src/js/_enqueues/admin/edit-comments.js | 2 | ||||
-rw-r--r-- | src/js/_enqueues/admin/inline-edit-post.js | 2 | ||||
-rw-r--r-- | src/js/_enqueues/admin/media.js | 7 |
4 files changed, 62 insertions, 8 deletions
diff --git a/src/js/_enqueues/admin/common.js b/src/js/_enqueues/admin/common.js index eea96d3778..2a037d81db 100644 --- a/src/js/_enqueues/admin/common.js +++ b/src/js/_enqueues/admin/common.js @@ -1220,6 +1220,62 @@ $document.ready( function() { }); /** + * Marries a secondary control to its primary control. + * + * @param {jQuery} topSelector The top selector element. + * @param {jQuery} topSubmit The top submit element. + * @param {jQuery} bottomSelector The bottom selector element. + * @param {jQuery} bottomSubmit The bottom submit element. + * @return {void} + */ + function marryControls( topSelector, topSubmit, bottomSelector, bottomSubmit ) { + /** + * Updates the primary selector when the secondary selector is changed. + * + * @since 5.7.0 + * + * @return {void} + */ + function updateTopSelector() { + topSelector.val($(this).val()); + } + bottomSelector.on('change', updateTopSelector); + + /** + * Updates the secondary selector when the primary selector is changed. + * + * @since 5.7.0 + * + * @return {void} + */ + function updateBottomSelector() { + bottomSelector.val($(this).val()); + } + topSelector.on('change', updateBottomSelector); + + /** + * Triggers the primary submit when then secondary submit is clicked. + * + * @since 5.7.0 + * + * @return {void} + */ + function triggerSubmitClick(e) { + e.preventDefault(); + e.stopPropagation(); + + topSubmit.trigger('click'); + } + bottomSubmit.on('click', triggerSubmitClick); + } + + // Marry the secondary "Bulk actions" controls to the primary controls: + marryControls( $('#bulk-action-selector-top'), $('#doaction'), $('#bulk-action-selector-bottom'), $('#doaction2') ); + + // Marry the secondary "Change role to" controls to the primary controls: + marryControls( $('#new_role'), $('#changeit'), $('#new_role2'), $('#changeit2') ); + + /** * Shows row actions on focus of its parent container element or any other elements contained within. * * @return {void} @@ -1321,9 +1377,8 @@ $document.ready( function() { pageInput.closest('form').submit( function() { /* * action = bulk action dropdown at the top of the table - * action2 = bulk action dropdow at the bottom of the table */ - if ( $('select[name="action"]').val() == -1 && $('select[name="action2"]').val() == -1 && pageInput.val() == currentPage ) + if ( $('select[name="action"]').val() == -1 && pageInput.val() == currentPage ) pageInput.val('1'); }); } diff --git a/src/js/_enqueues/admin/edit-comments.js b/src/js/_enqueues/admin/edit-comments.js index 5afe2f793f..0dc393ef02 100644 --- a/src/js/_enqueues/admin/edit-comments.js +++ b/src/js/_enqueues/admin/edit-comments.js @@ -808,7 +808,7 @@ window.commentReply = { commentReply.toggle($(this).parent()); }); - $('#doaction, #doaction2, #post-query-submit').click(function(){ + $('#doaction, #post-query-submit').click(function(){ if ( $('#the-comment-list #replyrow').length > 0 ) commentReply.close(); }); diff --git a/src/js/_enqueues/admin/inline-edit-post.js b/src/js/_enqueues/admin/inline-edit-post.js index 98fdb6cf32..8205963fc3 100644 --- a/src/js/_enqueues/admin/inline-edit-post.js +++ b/src/js/_enqueues/admin/inline-edit-post.js @@ -139,7 +139,7 @@ window.wp = window.wp || {}; /** * Adds onclick events to the apply buttons. */ - $('#doaction, #doaction2').click(function(e){ + $('#doaction').click(function(e){ var n; t.whichBulkButtonId = $( this ).attr( 'id' ); diff --git a/src/js/_enqueues/admin/media.js b/src/js/_enqueues/admin/media.js index c992b5d3a4..e34718b466 100644 --- a/src/js/_enqueues/admin/media.js +++ b/src/js/_enqueues/admin/media.js @@ -178,13 +178,12 @@ $( '#find-posts-close' ).click( findPosts.close ); // Binds the bulk action events to the submit buttons. - $( '#doaction, #doaction2' ).click( function( event ) { + $( '#doaction' ).click( function( event ) { /* - * Retrieves all select elements for bulk actions that have a name starting with `action` - * and handle its action based on its value. + * Handle the bulk action based on its value. */ - $( 'select[name^="action"]' ).each( function() { + $( 'select[name="action"]' ).each( function() { var optionValue = $( this ).val(); if ( 'attach' === optionValue ) { |