PageSourceSearch

https://rtclimburg.be/wp-content/plugins/booking/js/wpbc-free-date-hints.js?ver=11.5

js rtclimburg.be collected 2026-10-08 04:43:53 UTC 7,306 bytes, 228 lines download raw bytes

1/**
2 * Free date hints runtime.
3 *
4 * Mirrors the public Pro cost-hint trigger names when they are not already
5 * present, so existing integrations can call the same functions.
6 */
7// FixIn: 10.15.6.2.
8(function ( w, $ ) {
9	'use strict';
10
11	var knownHints = [
12		'check_in_date_hint',
13		'check_out_date_hint',
14		'selected_dates_hint',
15		'days_number_hint',
16		'start_time_hint',
17		'end_time_hint'
18	];
19
20	w.wpbc_free_date_hints__apply = function ( resourceId, hints ) {
21		resourceId = parseInt( resourceId, 10 ) || 1;
22		hints = hints || {};
23
24		$.each( hints, function ( hintName, hintValue ) {
25			var valueText = $( '<div />' ).html( hintValue ).text();
26
27			$( '#' + hintName + '_tip' + resourceId + ',.' + hintName + '_tip' + resourceId ).html( hintValue );
28			$( '#' + hintName + resourceId ).val( valueText );
29
30			if ( typeof w.wpbc__spin_loader__micro__hide === 'function' ) {
31				w.wpbc__spin_loader__micro__hide( hintName + '_tip' + resourceId );
32			}
33		} );
34	};
35
36	if ( typeof w.wpbc_send_ajax__show_cost_hints !== 'function' ) {
37		w.wpbc_send_ajax__show_cost_hints = function ( resourceId ) {
38			var allDates,
39				formData,
40				myBookingFormName = '',
41				nonceEl,
42				inst;
43
44			resourceId = parseInt( resourceId, 10 ) || 1;
45
46			$( '.booking_form_div' ).trigger( 'before_show_cost_hints', [ resourceId ] );
47
48			if ( document.getElementById( 'parent_of_additional_calendar' + resourceId ) !== null ) {
49				resourceId = parseInt( document.getElementById( 'parent_of_additional_calendar' + resourceId ).value, 10 ) || resourceId;
50			}
51
52			if ( 0 === $( '#booking_form' + resourceId ).find( '.wpbc_free_date_hint' ).length ) {
53				return false;
54			}
55
56			allDates = $( '#date_booking' + resourceId ).val() || '';
57
58			if (
59				'undefined' !== typeof _wpbc &&
60				'dynamic' === _wpbc.calendar__get_param_value( resourceId, 'days_select_mode' )
61			) {
62				inst = ( typeof w.wpbc_calendar__get_inst === 'function' ) ? w.wpbc_calendar__get_inst( resourceId ) : null;
63				if ( null !== inst && inst.stayOpen === true ) {
64					$( '.wpbc_free_date_hint' ).html( '...' );
65					return false;
66				}
67			}
68
69			$.each( knownHints, function ( index, hintName ) {
70				var hintId = hintName + '_tip' + resourceId;
71
72				if ( typeof w.wpbc__spin_loader__micro__show__inside === 'function' ) {
73					w.wpbc__spin_loader__micro__show__inside( hintId, '#' + hintId + ',.' + hintId );
74				} else {
75					$( '#' + hintId + ',.' + hintId ).html( '...' );
76				}
77			} );
78
79			if ( document.getElementById( 'booking_form_type' + resourceId ) !== null ) {
80				myBookingFormName = document.getElementById( 'booking_form_type' + resourceId ).value;
81			}
82
83			nonceEl = document.getElementById( 'wpbc_nonceCALCULATE_THE_COST' + resourceId );
84			if ( ! nonceEl ) {
85				return false;
86			}
87
88			formData = wpbc_free_date_hints__get_form_fields_as_string( resourceId );
89
90			$.ajax( {
91				url: w.wpbc_url_ajax,
92				type: 'POST',
93				success: function ( data, textStatus ) {
94					if ( 'success' === textStatus ) {
95						$( '#ajax_respond_insert' + resourceId ).html( data );
96					}
97					$( '.booking_form_div' ).trigger( 'after_show_cost_hints', [ resourceId ] );
98				},
99				error: function ( XMLHttpRequest, textStatus ) {
100					w.status = 'Ajax sending Error status:' + textStatus;
101					if ( w.console && w.console.error ) {
102						w.console.error( XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText );
103					}
104				},
105				data: {
106					action: 'CALCULATE_THE_COST',
107					form: formData,
108					all_dates: allDates,
109					bk_type: resourceId,
110					booking_form_type: myBookingFormName,
111					wpdev_active_locale: ( 'undefined' !== typeof _wpbc ) ? _wpbc.get_other_param( 'locale_active' ) : '',
112					wpbc_nonce: nonceEl.value
113				}
114			} );
115
116			$( '.booking_form_div' ).trigger( 'show_cost_hints', [ resourceId ] );
117			$( '.booking_form_div' ).trigger( 'wpbc_booking_date_or_option_selected', [ resourceId ] );
118
119			return false;
120		};
121	}
122
123	if ( typeof w.wpbc_show_cost_hints_after_few_seconds !== 'function' ) {
124		w.wpbc_show_cost_hints_after_few_seconds = (function () {
125			var closedTimer = 0;
126
127			return function ( resourceId, timerDelay ) {
128				timerDelay = typeof timerDelay !== 'undefined' ? timerDelay : 250;
129				clearTimeout( closedTimer );
130				closedTimer = setTimeout( w.wpbc_send_ajax__show_cost_hints.bind( null, resourceId ), timerDelay );
131			};
132		}());
133	}
134
135	if ( typeof w.showCostHintInsideBkForm !== 'function' ) {
136		w.showCostHintInsideBkForm = function ( resourceId ) {
137			w.wpbc_show_cost_hints_after_few_seconds( resourceId );
138		};
139	}
140
141	$( function () {
142		$( 'body' ).on( 'wpbc_calendar_ajx__loaded_data', function ( event, loadedResourceId ) {
143			w.wpbc_show_cost_hints_after_few_seconds( loadedResourceId );
144		} );
145
146		$( '.booking_form_div' ).on( 'date_selected', function ( event, resourceId ) {
147			w.wpbc_show_cost_hints_after_few_seconds( resourceId );
148		} );
149
150		$( document ).on( 'change', '.booking_form_div input, .booking_form_div select, .booking_form_div textarea', function () {
151			var form = $( this ).closest( 'form.booking_form' ),
152				resourceId;
153
154			if ( ! form.length || /^date_booking/.test( this.name || '' ) ) {
155				return;
156			}
157
158			resourceId = parseInt( form.attr( 'id' ).replace( 'booking_form', '' ), 10 );
159			if ( resourceId > 0 ) {
160				w.wpbc_show_cost_hints_after_few_seconds( resourceId );
161			}
162		} );
163	} );
164
165	function wpbc_free_date_hints__get_form_fields_as_string( resourceId ) {
166		var form = document.getElementById( 'booking_form' + resourceId ),
167			formData = '',
168			count,
169			i,
170			element,
171			elementType,
172			inputValue;
173
174		if ( ! form || ! form.elements ) {
175			return '';
176		}
177
178		count = form.elements.length;
179		for ( i = 0; i < count; i++ ) {
180			element = form.elements[ i ];
181
182			if ( ! element || ! element.name ) {
183				continue;
184			}
185
186			if (
187				'button' === element.type ||
188				'hidden' === element.type ||
189				element.name === ( 'date_booking' + resourceId ) ||
190				element.name === ( 'captcha_input' + resourceId )
191			) {
192				continue;
193			}
194
195			elementType = element.type;
196
197			if ( 'checkbox' === element.type ) {
198				inputValue = element.checked ? element.value : '';
199			} else if ( 'radio' === element.type ) {
200				if ( ! element.checked ) {
201					continue;
202				}
203				inputValue = element.value;
204			} else {
205				inputValue = $( element ).val();
206			}
207
208			if ( 'selectbox-multiple' === element.type || 'select-multiple' === element.type ) {
209				inputValue = $( '[name="' + element.name + '"]' ).val();
210				if ( inputValue === null || inputValue.toString() === '' ) {
211					inputValue = '';
212				}
213			}
214
215			elementType = ( element.className.indexOf( 'wpdev-validates-as-email' ) !== -1 ) ? 'email' : elementType;
216			elementType = ( element.className.indexOf( 'wpdev-validates-as-coupon' ) !== -1 ) ? 'coupon' : elementType;
217			elementType = ( 'select-one' === elementType ) ? 'selectbox-one' : elementType;
218			elementType = ( 'select-multiple' === elementType ) ? 'selectbox-multiple' : elementType;
219
220			if ( formData !== '' ) {
221				formData += '~';
222			}
223			formData += elementType + '^' + element.name + '^' + inputValue;
224		}
225
226		return formData;
227	}
228}( window, jQuery ));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.