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/page-add-booking/_src/add_booking_page.js +75 -0 11.5 → 11.9 View file →
@@ -333,8 +333,79 @@
333 333 days_selection_enforcement_timers.push( window.setTimeout( synchronize_days_selection_mode, delay ) );
334 334 } );
335 335 }
336 336
337 + /**
338 + * Copy the authoritative cost-correction number into its convenience slider.
339 + *
340 + * The slider intentionally keeps its 0-1000 exploration range. Exact values,
341 + * including decimals and totals above 1000, remain unchanged in the number input.
342 + *
343 + * @return {void}
344 + */
345 + function synchronize_cost_correction_range() {
346 + var $number_field = $( '#wpbc_add_booking_cost_correction' );
347 + var $range = $( '.wpbc_add_booking__cost_correction [data-wpbc-admin-cost-correction-range="1"]' ).first();
348 + var number_value;
349 +
350 + if ( ! $number_field.length || ! $range.length ) {
351 + return;
352 + }
353 +
354 + number_value = Number( $number_field.val() );
355 + if ( '' === String( $number_field.val() || '' ).trim() || ! isFinite( number_value ) ) {
356 + $range.val( '0' );
357 + return;
358 + }
359 +
360 + $range.val( String( number_value ) );
361 + }
362 +
363 + /**
364 + * Copy the convenience slider into the authoritative number input.
365 + *
366 + * @return {void}
367 + */
368 + function synchronize_cost_correction_number() {
369 + var $number_field = $( '#wpbc_add_booking_cost_correction' );
370 + var $range = $( '.wpbc_add_booking__cost_correction [data-wpbc-admin-cost-correction-range="1"]' ).first();
371 +
372 + if ( ! $number_field.length || ! $range.length ) {
373 + return;
374 + }
375 +
376 + $number_field.val( $range.val() ).trigger( 'input' );
377 + }
378 +
379 + /**
380 + * Add an explicitly entered correction to the outgoing Add Booking request.
381 + *
382 + * The control is outside the Booking Form element and therefore is not part of
383 + * the legacy serialized form data. The server authorizes and normalizes this
384 + * dedicated value before it reaches the Business Small cost pipeline.
385 + *
386 + * @param {Event} event jQuery event.
387 + * @param {number} resource_id Submitted Booking resource ID.
388 + * @param {Object} params Mutable booking-create request parameters.
389 + * @return {void}
390 + */
391 + function add_cost_correction_to_booking_request( event, resource_id, params ) {
392 + var number_field = document.getElementById( 'wpbc_add_booking_cost_correction' );
393 + var raw_cost;
394 +
395 + if ( ! params || ! number_field ) {
396 + return;
397 + }
398 +
399 + delete params.wpbc_admin_cost_correction;
400 + raw_cost = String( number_field.value || '' ).trim();
401 + if ( '' === raw_cost || ! number_field.checkValidity() ) {
402 + return;
403 + }
404 +
405 + params.wpbc_admin_cost_correction = raw_cost;
406 + }
407 +
337 408 $( document ).on( 'click', '.wpbc_add_booking__rightbar_tabs [role="tab"]', function () {
338 409 switch_right_panel( $( this ) );
339 410 } );
340 411
@@ -343,8 +414,11 @@
343 414 open_settings_group( $( this ).attr( 'data-wpbc-add-booking-open-group' ), $( this ).attr( 'data-wpbc-add-booking-focus' ) || '' );
344 415 } );
345 416
346 417 $( document ).on( 'change', '#is_send_email_for_pending, #is_allow_bookings_in_past', refresh_booking_tools_summary );
418 + $( document ).on( 'input', '#wpbc_add_booking_cost_correction', synchronize_cost_correction_range );
419 + $( document ).on( 'input', '.wpbc_add_booking__cost_correction [data-wpbc-admin-cost-correction-range="1"]', synchronize_cost_correction_number );
420 + $( 'body' ).on( 'wpbc_before_booking_create.wpbc_add_booking_cost_correction', add_cost_correction_to_booking_request );
347 421 $( document ).on( 'click', 'input[name="wpbc_add_booking_days_selection_mode"]', function () {
348 422 active_days_selection_override = normalize_days_selection_mode( $( this ).val() );
349 423 apply_days_selection_mode( active_days_selection_override, true );
350 424 schedule_days_selection_synchronization();
@@ -349,6 +423,7 @@
349 423 apply_days_selection_mode( active_days_selection_override, true );
350 424 schedule_days_selection_synchronization();
351 425 } );
352 426 $( refresh_booking_tools_summary );
427 + $( synchronize_cost_correction_range );
353 428 $( schedule_days_selection_synchronization );
354 429 }( jQuery ) );