plugin updates

This commit is contained in:
Tony Volpe
2024-09-05 11:04:01 -04:00
parent ed6b060261
commit 50cd64dd3d
925 changed files with 16918 additions and 13003 deletions

View File

@@ -90,11 +90,11 @@
} );
// Edit prompt
$( function () {
function editPrompt () {
var changed = false;
let $check_column = $( '.wp-list-table .check-column' );
$( 'input, textarea, select, checkbox' ).on( 'change', function (
$( 'input, textarea, select, checkbox' ).on( 'change input', function (
event
) {
// Toggling WP List Table checkboxes should not trigger navigation warnings.
@@ -110,6 +110,14 @@
return params.i18n_nav_warning;
};
changed = true;
$( '.woocommerce-save-button' ).removeAttr( 'disabled' );
}
} );
$( '.iris-picker' ).on( 'click', function () {
if ( ! changed ) {
changed = true;
$( '.woocommerce-save-button' ).removeAttr( 'disabled' );
}
} );
@@ -119,8 +127,35 @@
window.onbeforeunload = '';
}
);
}
$( editPrompt );
const nodeListContainsFormElements = ( nodes ) => {
if ( ! nodes.length ) {
return false;
}
return Array.from( nodes ).some( ( element ) => {
return $( element ).find( 'input, textarea, select, checkbox' ).length;
} );
}
const form = document.querySelector( '#mainform' );
const observer = new MutationObserver( ( mutationsList ) => {
for ( const mutation of mutationsList ) {
if ( mutation.type === 'childList' ) {
if ( nodeListContainsFormElements( mutation.addedNodes ) ) {
editPrompt();
$( '.woocommerce-save-button' ).removeAttr( 'disabled' );
} else if ( nodeListContainsFormElements( mutation.removedNodes ) ) {
$( '.woocommerce-save-button' ).removeAttr( 'disabled' );
}
}
}
} );
observer.observe( form, { childList: true, subtree: true } );
// Sorting
$( 'table.wc_gateways tbody, table.wc_shipping tbody' ).sortable( {
items: 'tr',
@@ -140,7 +175,7 @@
},
stop: function ( event, ui ) {
ui.item.removeAttr( 'style' );
ui.item.trigger( 'updateMoveButtons' );
ui.item.trigger( 'updateMoveButtons', { isInitialLoad: false } );
},
} );
@@ -192,12 +227,12 @@
}
moveBtn.trigger( 'focus' ); // Re-focus after the container was moved.
moveBtn.closest( 'table' ).trigger( 'updateMoveButtons' );
moveBtn.closest( 'table' ).trigger( 'updateMoveButtons', { isInitialLoad: false } );
} );
$( '.wc-item-reorder-nav' )
.closest( 'table' )
.on( 'updateMoveButtons', function () {
.on( 'updateMoveButtons', function ( event, data ) {
var table = $( this ),
lastRow = $( this ).find( 'tbody tr:last' ),
firstRow = $( this ).find( 'tbody tr:first' );
@@ -214,11 +249,14 @@
.find( '.wc-item-reorder-nav .wc-move-down' )
.addClass( 'wc-move-disabled' )
.attr( { tabindex: '-1', 'aria-hidden': 'true' } );
if ( ! data.isInitialLoad ) {
$( '.woocommerce-save-button' ).removeAttr( 'disabled' );
}
} );
$( '.wc-item-reorder-nav' )
.closest( 'table' )
.trigger( 'updateMoveButtons' );
.trigger( 'updateMoveButtons', { isInitialLoad: true } );
$( '.submit button' ).on( 'click', function () {
if (