From 2a2c99578ca8ba0ba3c78017d3decc47bd44f274 Mon Sep 17 00:00:00 2001 From: Savvas Hadjigeorgiou Date: Fri, 14 Oct 2022 13:38:10 +0300 Subject: [PATCH] FIX: toggle between absolute and relative dates not working at shortcodes, widgets and calendars --- assets/js/admin/sportspress-admin.js | 2 +- assets/js/admin/widgets.js | 2 +- includes/class-sp-ajax.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/assets/js/admin/sportspress-admin.js b/assets/js/admin/sportspress-admin.js index ae575fc2..856f223b 100644 --- a/assets/js/admin/sportspress-admin.js +++ b/assets/js/admin/sportspress-admin.js @@ -841,7 +841,7 @@ jQuery( document ).ready( $relative = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-relative" ).toggle( 0, $( this ).attr( "checked" ) ); $absolute = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-absolute" ).toggle( 0, $( this ).attr( "checked" ) ); - if ($( this ).attr( "checked" )) { + if ( $( this ).is( ":checked" ) ) { $relative.show(); $absolute.hide(); } else { diff --git a/assets/js/admin/widgets.js b/assets/js/admin/widgets.js index 057dd5df..deddb1d5 100644 --- a/assets/js/admin/widgets.js +++ b/assets/js/admin/widgets.js @@ -46,7 +46,7 @@ jQuery( document ).ready( $relative = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-relative" ).toggle( 0, $( this ).attr( "checked" ) ); $absolute = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-absolute" ).toggle( 0, $( this ).attr( "checked" ) ); - if ($( this ).attr( "checked" )) { + if ( $( this ).is( ":checked" ) ) { $relative.show(); $absolute.hide(); } else { diff --git a/includes/class-sp-ajax.php b/includes/class-sp-ajax.php index 0a78485e..d57680b2 100644 --- a/includes/class-sp-ajax.php +++ b/includes/class-sp-ajax.php @@ -1437,10 +1437,10 @@ class SP_AJAX { // Toggle date range selectors $(".sp-date-relative input").change(function() { - $relative = $(this).closest(".sp-date-relative").siblings(".sp-date-range-relative").toggle(0, $(this).attr("checked")); - $absolute = $(this).closest(".sp-date-relative").siblings(".sp-date-range-absolute").toggle(0, $(this).attr("checked")); - - if ($(this).attr("checked")) { + $relative = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-relative" ).toggle( 0, $( this ).attr( "checked" ) ); + $absolute = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-absolute" ).toggle( 0, $( this ).attr( "checked" ) ); + + if ( $( this ).is( ":checked" ) ) { $relative.show(); $absolute.hide(); } else {