Skip to content

Commit

Permalink
Fix: replace deprecated jQuery functions (#750)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmigf authored Apr 18, 2024
1 parent 8b36fd9 commit d013ccb
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
20 changes: 9 additions & 11 deletions assets/js/admin-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,12 @@ jQuery( function( $ ) {
$previewOrderIdInput.val( '' ).trigger( 'change' );
}

$( document ).ready( function() {
resetDocumentType(); // force document type reset
resetOrderId(); // force order ID reset
loadPreviewData(); // load preview data
resetDocumentType(); // force document type reset
resetOrderId(); // force order ID reset
loadPreviewData(); // load preview data

previousWindowWidth = $(window).width();
determinePreviewStates(); // determine preview states based on screen size
} );
previousWindowWidth = $( window ).width();
determinePreviewStates(); // determine preview states based on screen size

$( window ).on( 'resize', determinePreviewStates );

Expand Down Expand Up @@ -294,7 +292,7 @@ jQuery( function( $ ) {
} );

// Preview on page load
$( document ).ready( triggerPreview() );
triggerPreview();

// Custom trigger to signify settings have changed (will show save button and refresh preview)
$( document ).on( 'wpo-wcpdf-settings-changed', function( event, delay ) {
Expand All @@ -311,7 +309,7 @@ jQuery( function( $ ) {
$( document ).on( 'click', '#preview-order-search-results a', function( event ) {
event.preventDefault();
$( '.preview-document .order-search-label').text( '#' + $( this ).data( 'order_id' ) );
$previewOrderIdInput.val( $( this ).data( 'order_id' ) ).change();
$previewOrderIdInput.val( $( this ).data( 'order_id' ) ).trigger( 'change' );
$( this ).closest( 'div' ).hide(); // hide results div
$( this ).closest( 'div' ).children( 'a' ).remove(); // remove all results
triggerPreview();
Expand Down Expand Up @@ -359,8 +357,8 @@ jQuery( function( $ ) {
}

// Submit settings form when clicking on secondary save button
$( document ).on( 'click', '.preview-data-wrapper .save-settings p input', function( event ) {
$('#wpo-wcpdf-settings input#submit').click();
$( document.body ).on( 'click', '.preview-data-wrapper .save-settings p input', function( event ) {
$( '#wpo-wcpdf-settings input#submit' ).trigger( 'click' );
} );

// Trigger the Preview
Expand Down
2 changes: 1 addition & 1 deletion assets/js/admin-script.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions assets/js/confetti.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ jQuery(document).ready(function($) {
}
var confetti = new confetti.Context('confetti');
confetti.start();
$(window).resize(function() {
confetti.resize();
});
$( window ).on( 'resize', function() {
confetti.trigger( 'resize' );
} );
});
2 changes: 1 addition & 1 deletion assets/js/confetti.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/debug-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jQuery( function( $ ) {
$( '#renumber-date-from, #renumber-date-to, #delete-date-from, #delete-date-to' ).datepicker( { dateFormat: 'yy-mm-dd' } );

// danger zone tools
$( '#debug-tools .number-tools-btn' ).click( function( event ) {
$( document.body ).on( 'click', '#debug-tools .number-tools-btn', function( event ) {
event.preventDefault();

let documentType = '';
Expand Down
Loading

0 comments on commit d013ccb

Please sign in to comment.