summaryrefslogtreecommitdiffstatshomepage
path: root/src/js/_enqueues/admin/common.js
diff options
context:
space:
mode:
authorJohn Blackbourn <johnbillion@git.wordpress.org>2021-01-07 16:21:09 +0000
committerJohn Blackbourn <johnbillion@git.wordpress.org>2021-01-07 16:21:09 +0000
commit9010454dfe44df99c89d98696c0c152848e5e7af (patch)
tree9bb97c0f446a5aa5b3a68728bb520a2be1b8cd88 /src/js/_enqueues/admin/common.js
parent6409904a19cd9768dc3a53a0b38755bc2f81204a (diff)
downloadwordpress-9010454dfe44df99c89d98696c0c152848e5e7af.tar.gz
wordpress-9010454dfe44df99c89d98696c0c152848e5e7af.zip
Quick/Bulk Edit: By the power vested in me, I hereby declare the top bulk actions and the bottom bulk actions joined forever in MatrimonyScript.
This joyous marriage means that users will no longer find a selected top bulk action on a list table unexpectedly being applied instead of their selected bottom bulk action. The top and bottom controls for changing user roles are equally wedded forever too. Props clayray, subrataemfluence, garrett-eclipse, pbiron, hareesh-pillai Fixes #46872 git-svn-id: https://develop.svn.wordpress.org/trunk@49944 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'src/js/_enqueues/admin/common.js')
-rw-r--r--src/js/_enqueues/admin/common.js59
1 files changed, 57 insertions, 2 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');
});
}