PluginProbe
Booking Calendar / 11.8.3
Booking Calendar v11.8.3
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 10.11 10.11.2 All 203 releases
← All changes | includes/page-setup/_src/setup_show.js +118 -6 11.211.8.3 View file →
@@ -1,4 +1,4 @@
1 1 "use strict";
2 2
3 3 /**
4 4 * Parameters usually defined in Ajax Response or Front-End for == _wpbc_settings.get_all_params__setup_wizard():
@@ -140,9 +140,9 @@
140 140
141 141 }
142 142
143 143
144 -function wpbc_setup_wizard_page__is_all_steps_completed(){
144 +function wpbc_setup_wizard_page__is_all_steps_completed(){
145 145
146 146 var params_arr = _wpbc_settings.get_all_params__setup_wizard().steps
147 147 var status = true;
148 148
@@ -152,9 +152,106 @@
152 152 }
153 153 } );
154 154
155 155 return status;
156 -}
156 +}
157 +
158 +/**
159 + * Show the configuration controls belonging to the selected booking behavior.
160 + *
161 + * @return {void}
162 + */
163 +function wpbc_setup_wizard_page__refresh_booking_type_details() {
164 +
165 + var booking_type = jQuery( '[name="wpbc_swp_booking_types"]:checked' ).val() || '';
166 + var fixed_appointment_type = jQuery( '[name="wpbc_swp_booking_mode"]:checked' )
167 + .closest( '.wpbc_setup_mode_choice' )
168 + .attr( 'data-wpbc-setup-fixed-appointment-type' ) || '';
169 + var is_fixed_appointment_mode = 'durationtime' === fixed_appointment_type;
170 + var $canonical_times_picker = jQuery( '[name="wpbc_swp_booking_timeslot_picker"]' );
171 + var $appointment_times_picker = jQuery( '[name="wpbc_swp_booking_timeslot_picker_appointment"]' );
172 +
173 + jQuery( '.wpbc_in_radio_container_selectbox' ).hide();
174 + jQuery( '.wpbc_setup_appointment_mode_configuration' ).hide();
175 +
176 + if ( is_fixed_appointment_mode ) {
177 + if ( $canonical_times_picker.length && $appointment_times_picker.length ) {
178 + $appointment_times_picker.val( $canonical_times_picker.val() );
179 + }
180 + jQuery( '.wpbc_setup_appointment_mode_configuration' ).show();
181 + } else if ( 'time_slots_appointments' === booking_type ) {
182 + jQuery( '.wpbc_ui_booking_timeslot_picker__get_on_off__div' ).show();
183 + } else if ( 'changeover_multi_dates_bookings' === booking_type ) {
184 + jQuery( '.wpbc_ui_booking_change_over__get_on_off__div' ).show();
185 + }
186 +}
187 +
188 +/**
189 + * Apply the selected presentation mode to the Step 4 behavior choices.
190 + *
191 + * The presentation mode and booking behavior are intentionally independent
192 + * values. This function limits the visible behaviors to valid combinations
193 + * without coupling mode switching to any QuickStart content mutation.
194 + *
195 + * @return {void}
196 + */
197 +function wpbc_setup_wizard_page__refresh_booking_mode_choices() {
198 +
199 + var $mode_input = jQuery( '[name="wpbc_swp_booking_mode"]:checked' ).first();
200 + var $mode_choice;
201 + var allowed_booking_types;
202 + var default_booking_type;
203 + var fixed_appointment_type;
204 + var is_fixed_appointment_mode;
205 + var $selected_booking_type;
206 +
207 + if ( ! $mode_input.length ) {
208 + $mode_input = jQuery( '[name="wpbc_swp_booking_mode"]' ).first().prop( 'checked', true );
209 + }
210 +
211 + $mode_choice = $mode_input.closest( '.wpbc_setup_mode_choice' );
212 + if ( ! $mode_choice.length ) {
213 + wpbc_setup_wizard_page__refresh_booking_type_details();
214 + return;
215 + }
216 +
217 + allowed_booking_types = String( $mode_choice.attr( 'data-wpbc-setup-booking-types' ) || '' ).split( ',' );
218 + default_booking_type = String( $mode_choice.attr( 'data-wpbc-setup-default-booking-type' ) || '' );
219 + fixed_appointment_type = String( $mode_choice.attr( 'data-wpbc-setup-fixed-appointment-type' ) || '' );
220 + is_fixed_appointment_mode = 'durationtime' === fixed_appointment_type;
221 +
222 + jQuery( '.wpbc_setup_preferences_heading' ).text( $mode_choice.attr( 'data-wpbc-setup-preference-title' ) || '' );
223 + jQuery( '.wpbc_setup_booking_type_choice' ).each( function() {
224 + var booking_type = String( jQuery( this ).attr( 'data-wpbc-setup-booking-type' ) || '' );
225 + jQuery( this ).toggle( -1 !== jQuery.inArray( booking_type, allowed_booking_types ) );
226 + } );
227 +
228 + $selected_booking_type = jQuery( '[name="wpbc_swp_booking_types"]:checked' );
229 + if (
230 + ! $selected_booking_type.length
231 + || -1 === jQuery.inArray( String( $selected_booking_type.val() || '' ), allowed_booking_types )
232 + || $selected_booking_type.is( ':disabled' )
233 + ) {
234 + $selected_booking_type = jQuery( '[name="wpbc_swp_booking_types"][value="' + default_booking_type + '"]:not(:disabled)' ).first();
235 + if ( ! $selected_booking_type.length ) {
236 + $selected_booking_type = jQuery( '.wpbc_setup_booking_type_choice:visible [name="wpbc_swp_booking_types"]:not(:disabled)' ).first();
237 + }
238 + $selected_booking_type.prop( 'checked', true );
239 + }
240 +
241 + if ( is_fixed_appointment_mode ) {
242 + jQuery( '[name="wpbc_swp_booking_appointments_type"][value="' + fixed_appointment_type + '"]' ).prop( 'checked', true );
243 + }
244 +
245 + jQuery( '.wpbc_setup_preferences_heading_row' ).toggle( ! is_fixed_appointment_mode );
246 + jQuery( '.wpbc_setup_booking_type_choices' ).toggle( ! is_fixed_appointment_mode );
247 +
248 + jQuery( '[name="wpbc_swp_booking_mode"], [name="wpbc_swp_booking_types"]' ).each( function() {
249 + wpbc_ui_el__radio_container_selection( this );
250 + } );
251 +
252 + wpbc_setup_wizard_page__refresh_booking_type_details();
253 +}
157 254
158 255
159 256 /**
160 257 * Define UI hooks for elements, after showing in Ajax.
@@ -160,9 +257,9 @@
160 257 * Define UI hooks for elements, after showing in Ajax.
161 258 *
162 259 * Because each time, when we show content in Ajax, all Hooks needs re-defined.
163 260 */
164 -function wpbc_setup_wizard_page__define_ui_hooks(){
261 +function wpbc_setup_wizard_page__define_ui_hooks(){
165 262
166 263 // -----------------------------------------------------------------------------------------------------------------
167 264 // Tooltips
168 265 if ( 'function' === typeof( wpbc_define_tippy_tooltips ) ) {
@@ -183,11 +280,26 @@
183 280 wpbc_ui_el__radio_container_selection( this );
184 281 });
185 282
186 283 // Define ability to click on Radio Containers (not only radio-buttons)
187 - jQuery( '.wpbc_ui_radio_container' ).on( 'click', function( event ){
188 - wpbc_ui_el__radio_container_click( this );
189 - } );
284 + jQuery( '.wpbc_ui_radio_container' ).on( 'click', function( event ){
285 + wpbc_ui_el__radio_container_click( this );
286 + } );
287 +
288 + jQuery( '[name="wpbc_swp_booking_mode"]' ).on( 'change', function() {
289 + wpbc_setup_wizard_page__refresh_booking_mode_choices();
290 + } );
291 +
292 + jQuery( '[name="wpbc_swp_booking_types"]' ).on( 'change', function() {
293 + wpbc_setup_wizard_page__refresh_booking_type_details();
294 + } );
295 +
296 + // Save the Appointment-only presentation control through the historical canonical field.
297 + jQuery( '[name="wpbc_swp_booking_timeslot_picker_appointment"]' ).on( 'change', function() {
298 + jQuery( '[name="wpbc_swp_booking_timeslot_picker"]' ).val( jQuery( this ).val() );
299 + } );
300 +
301 + wpbc_setup_wizard_page__refresh_booking_mode_choices();
190 302
191 303 // -----------------------------------------------------------------------------------------------------------------
192 304
193 305