PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9 11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 All 205 releases
← All changes | includes/booking-appointment/_src/booking-appointment.js +50 -0 11.6 → 11.9 View file →
@@ -13,8 +13,45 @@
13 13 function get_selected_id( $form, name ) {
14 14 return Number( $form.find( '[name="' + name + '"]:checked, [name="' + name + '"][type="hidden"]' ).first().val() || 0 );
15 15 }
16 16
17 + /**
18 + * Apply public text search to one server-authorized Appointment catalog.
19 + *
20 + * @param {jQuery} $catalog Appointment catalog root.
21 + * @return {void}
22 + */
23 + function filter_appointment_catalog( $catalog ) {
24 + var search_term = String( $catalog.find( '[data-wpbc-appointment-catalog-search]' ).val() || '' ).toLocaleLowerCase().trim();
25 + var catalog_type = String( $catalog.attr( 'data-catalog-type' ) || 'services' );
26 + var visible_count = 0;
27 +
28 + $catalog.find( '[data-wpbc-appointment-catalog-card]' ).each( function () {
29 + var $card = $( this );
30 + var searchable_text = String( $card.attr( 'data-appointment-catalog-search' ) || '' ).toLocaleLowerCase();
31 + var is_visible = ! search_term || searchable_text.indexOf( search_term ) !== -1;
32 + var $choice_input = $card.find( 'input[type="radio"]' ).first();
33 +
34 + $card.prop( 'hidden', ! is_visible );
35 + $choice_input.prop( 'disabled', ! is_visible );
36 + if ( is_visible ) {
37 + visible_count += 1;
38 + } else if ( $choice_input.prop( 'checked' ) ) {
39 + $choice_input.prop( 'checked', false );
40 + $card.removeClass( 'is-selected' );
41 + }
42 + } );
43 +
44 + $catalog.find( '[data-wpbc-appointment-catalog-empty]' ).prop( 'hidden', 0 !== visible_count );
45 + $catalog.find( '[data-wpbc-appointment-catalog-status]' ).text(
46 + String( visible_count ) + ' ' + (
47 + 'providers' === catalog_type
48 + ? ( 1 === visible_count ? ( config.provider_found || 'Provider found.' ) : ( config.providers_found || 'Providers found.' ) )
49 + : ( 1 === visible_count ? ( config.service_found || 'Service found.' ) : ( config.services_found || 'Services found.' ) )
50 + )
51 + );
52 + }
53 +
17 54 /** Toggle one component loading state without clearing its current stage. */
18 55 function set_loading( $root, is_loading ) {
19 56 $root.toggleClass( 'is-loading', is_loading ).attr( 'aria-busy', is_loading ? 'true' : 'false' );
20 57 $root.find( '> .wpbc_booking_appointment__stage' ).attr( 'aria-busy', is_loading ? 'true' : 'false' );
@@ -19,8 +56,13 @@
19 56 $root.toggleClass( 'is-loading', is_loading ).attr( 'aria-busy', is_loading ? 'true' : 'false' );
20 57 $root.find( '> .wpbc_booking_appointment__stage' ).attr( 'aria-busy', is_loading ? 'true' : 'false' );
21 58 $root.find( '> .wpbc_booking_appointment__loading' ).prop( 'hidden', ! is_loading ).attr( 'aria-hidden', is_loading ? 'false' : 'true' );
22 59 $root.find( '.wpbc_booking_appointment__selection_form :input' ).prop( 'disabled', is_loading );
60 + if ( ! is_loading ) {
61 + $root.find( '[data-wpbc-appointment-catalog]' ).each( function () {
62 + filter_appointment_catalog( $( this ) );
63 + } );
64 + }
23 65 }
24 66
25 67 /**
26 68 * Display and focus an AJAX or initialization error in one component.
@@ -875,8 +917,13 @@
875 917 $input.closest( '.wpbc_booking_appointment__choices' ).find( '.wpbc_booking_appointment__choice' ).removeClass( 'is-selected' );
876 918 $input.closest( '.wpbc_booking_appointment__choice' ).addClass( 'is-selected' );
877 919 } );
878 920
921 + /** Filter Service and Provider cards without changing the signed catalog. */
922 + $( document ).on( 'input search', '[data-wpbc-appointment-catalog-search]', function () {
923 + filter_appointment_catalog( $( this ).closest( '[data-wpbc-appointment-catalog]' ) );
924 + } );
925 +
879 926 /** Return to Service selection while preserving the last valid Service. */
880 927 $( document ).on( 'click', '.wpbc_booking_appointment [data-appointment-back="service"]', function () {
881 928 var $root = $( this ).closest( '.wpbc_booking_appointment' );
882 929 if ( $root.hasClass( 'is-loading' ) ) {
@@ -923,8 +970,11 @@
923 970
924 971 $( function () {
925 972 $( '.wpbc_booking_appointment' ).each( function () {
926 973 var $root = $( this );
974 + $root.find( '[data-wpbc-appointment-catalog]' ).each( function () {
975 + filter_appointment_catalog( $( this ) );
976 + } );
927 977 var $native = $root.find( '.wpbc_booking_appointment__native_form' ).first();
928 978 if ( $native.length ) {
929 979 $root.attr( 'data-selected-service-id', Number( $native.data( 'service-id' ) || 0 ) );
930 980 $root.attr( 'data-selected-provider-id', Number( $native.data( 'provider-id' ) || 0 ) );