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 | js/client.js +346 -626 10.1011.8.3 View file →
@@ -1,610 +1,264 @@
1 -// == Submit Booking Data ==============================================================================================
2 -
3 -// Check fields at form and then send request
4 -function mybooking_submit( submit_form , bk_type, wpdev_active_locale){
5 -
6 - var target_elm = jQuery( ".booking_form_div" ).trigger( "booking_form_submit_click", [bk_type, submit_form, wpdev_active_locale] ); // FixIn: 8.8.3.13.
7 - if (
8 - ( jQuery( target_elm ).find( 'input[name="booking_form_show_summary"]' ).length > 0 )
9 - && ( 'pause_submit' === jQuery( target_elm ).find( 'input[name="booking_form_show_summary"]' ).val() )
10 - )
11 - {
12 - return false;
13 - }
14 -
15 - // FixIn: 8.4.0.2.
16 - var is_error = wpbc_check_errors_in_booking_form( bk_type );
17 - if ( is_error ) { return false; }
18 -
19 - // Show message if no selected days in Calendar(s)
20 - if (document.getElementById('date_booking' + bk_type).value == '') {
21 -
22 - var arr_of_selected_additional_calendars = wpbc_get_arr_of_selected_additional_calendars( bk_type ); // FixIn: 8.5.2.26.
23 -
24 - if ( arr_of_selected_additional_calendars.length == 0 ) {
25 - wpbc_front_end__show_message__error_under_element( '#booking_form_div' + bk_type + ' .bk_calendar_frame', _wpbc.get_message( 'message_check_no_selected_dates' ), 3000 );
26 - return;
27 - }
28 - }
29 -
30 - var count = submit_form.elements.length;
31 - var formdata = '';
32 - var inp_value;
33 - var element;
34 - var el_type;
35 -
36 -
37 - // FixIn: 6.1.1.3.
38 - if( typeof( wpbc_is_this_time_selection_not_available ) == 'function' ) {
39 -
40 - if ( document.getElementById('date_booking' + bk_type).value == '' ) { // Primary calendar not selected.
41 -
42 - if ( document.getElementById('additional_calendars' + bk_type ) != null ) { // Checking additional calendars.
43 -
44 - var id_additional_str = document.getElementById('additional_calendars' + bk_type).value; //Loop have to be here based on , sign
45 - var id_additional_arr = id_additional_str.split(',');
46 - var is_times_dates_ok = false;
47 - for ( var ia=0;ia<id_additional_arr.length;ia++ ) {
48 - if (
49 - ( document.getElementById('date_booking' + id_additional_arr[ia] ).value != '' )
50 - && ( ! wpbc_is_this_time_selection_not_available( id_additional_arr[ia], submit_form.elements ) )
51 - ){
52 - is_times_dates_ok = true;
53 - }
54 - }
55 - if ( ! is_times_dates_ok ) return;
56 - }
57 - } else { //Primary calendar selected.
58 - if ( wpbc_is_this_time_selection_not_available( bk_type, submit_form.elements ) )
59 - return;
60 - }
61 - }
62 -
63 -
64 -
65 - // Serialize form here
66 - for ( var i = 0; i < count; i++ ){ // FixIn: 9.1.5.1.
67 - element = submit_form.elements[i];
68 -
69 - if ( jQuery( element ).closest( '.booking_form_garbage' ).length ) {
70 - continue; // Skip elements from garbage // FixIn: 7.1.2.14.
71 - }
72 -
73 - if (
74 - ( element.type !== 'button' )
75 - && ( element.type !== 'hidden' )
76 - && ( element.name !== ( 'date_booking' + bk_type ) )
77 - // && ( jQuery( element ).is( ':visible' ) ) //FixIn: 7.2.1.12.2 // Its prevent of saving hints, and some other hidden element
78 - ) { // Skip buttons and hidden element - type // FixIn: 7.2.1.12.
79 -
80 -
81 - // Get Element Value
82 - if ( element.type == 'checkbox' ){
83 -
84 - if (element.value == '') {
85 - inp_value = element.checked;
86 - } else {
87 - if (element.checked) inp_value = element.value;
88 - else inp_value = '';
89 - }
90 -
91 - } else if ( element.type == 'radio' ) {
92 -
93 - if (element.checked) {
94 - inp_value = element.value;
95 - } else {
96 - // Check if this radio required, and if it does not check, then show warning, otherwise if it is not required or some other option checked skip this loop
97 - // We need to check it here, because radio have the several options with same name and type, and otherwise we will save several options with selected and empty values.
98 - if ( // FixIn: 7.0.1.62.
99 - ( element.className.indexOf('wpdev-validates-as-required') !== -1 )
100 - && ( jQuery( element ).is( ':visible' ) ) //FixIn: 7.2.1.12.2 // Its prevent of saving hints, and some other hidden element
101 - && ( ! jQuery(':radio[name="'+element.name+'"]', submit_form).is(":checked") ) ) {
102 - wpbc_front_end__show_message__warning( element, _wpbc.get_message( 'message_check_required_for_radio_box' ) ); // FixIn: 8.5.1.3.
103 - return;
104 - }
105 - continue;
106 - }
107 - } else {
108 - inp_value = element.value;
109 - }
110 -
111 - var inp_title_value = '';
112 -
113 - var input_element_type = ('input' === jQuery( element )[0].tagName.toString().toLowerCase())
114 - ? jQuery( jQuery( element )[0] ).prop( "type" ).toLowerCase()
115 - : jQuery( element )[0].tagName.toLowerCase();
116 -
117 - switch ( input_element_type ) {
118 - case 'text':
119 - inp_title_value = inp_value;
120 - break;
121 - case 'email':
122 - inp_title_value = inp_value;
123 - break;
124 - case 'select':
125 - inp_title_value = jQuery( element ).find( "option:selected" ).text();
126 - break;
127 - case 'radio':
128 - if ( jQuery( element ).is( ':checked' ) ) {
129 - var label_element = jQuery( element ).parents( '.wpdev-list-item' ).find( '.wpdev-list-item-label' );
130 - if ( label_element.length ) {
131 - inp_title_value = label_element.html();
132 - }
133 - }
134 - break;
135 - case 'checkbox':
136 - if ( jQuery( element ).is( ':checked' ) ) {
137 - var label_element = jQuery( element ).parents( '.wpdev-list-item' ).find( '.wpdev-list-item-label' );
138 - if ( label_element.length ) {
139 - inp_title_value = label_element.html();
140 - }
141 - }
142 - break;
143 - default:
144 - inp_title_value = inp_value;
145 - }
146 -
147 -
148 - // Get value in selectbox of multiple selection
149 - if ( (element.type == 'selectbox-multiple') || (element.type == 'select-multiple') ){
150 - inp_value = jQuery('[name="'+element.name+'"]').val() ;
151 - if (( inp_value == null ) || (inp_value.toString() == '' ))
152 - inp_value='';
153 - }
154 -
155 - // Make validation only for visible elements
156 - if ( jQuery( element ).is( ':visible' ) ) { //FixIn: 7.2.1.12.2
157 -
158 -
159 - // Recheck for max num. available visitors selection
160 - if ( typeof (wpbc__is_less_than_required__of_max_available_slots__bl) == 'function' ){
161 - if ( wpbc__is_less_than_required__of_max_available_slots__bl( bk_type, element ) ){
162 - return;
163 - }
164 - }
165 -
166 -
167 - // Phone validation
168 - /*if ( element.name == ('phone'+bk_type) ) {
169 - // we validate a phone number of 10 digits with no comma, no spaces, no punctuation and there will be no + sign in front the number - See more at: http://www.w3resource.com/javascript/form/phone-no-validation.php#sthash.U9FHwcdW.dpuf
170 - var reg = /^\d{10}$/;
171 - var message_verif_phone = "Please enter correctly phone number";
172 - if ( inp_value != '' )
173 - if(reg.test(inp_value) == false) {wpbc_front_end__show_message__warning( element , message_verif_phone );return;}
174 - }*/
175 -
176 - // Validation Check --- Requred fields
177 - if ( element.className.indexOf('wpdev-validates-as-required') !== -1 ){
178 - if ((element.type =='checkbox') && ( element.checked === false)) {
179 - if ( ! jQuery(':checkbox[name="'+element.name+'"]', submit_form).is(":checked") ) {
180 - wpbc_front_end__show_message__warning( element , _wpbc.get_message( 'message_check_required_for_check_box' ) ); // FixIn: 8.5.1.3.
181 - return;
182 - }
183 - }
184 - if (element.type =='radio') {
185 - if ( ! jQuery(':radio[name="'+element.name+'"]', submit_form).is(":checked") ) {
186 - wpbc_front_end__show_message__warning( element , _wpbc.get_message( 'message_check_required_for_radio_box' ) ); // FixIn: 8.5.1.3.
187 - return;
188 - }
189 - }
190 -
191 - if ( (element.type != 'checkbox') && (element.type != 'radio') && ( '' === wpbc_trim( inp_value ) ) ){ //FixIn: 8.8.1.3 //FixIn:7.0.1.39 // FixIn: 8.7.11.12.
192 - wpbc_front_end__show_message__warning( element , _wpbc.get_message( 'message_check_required' ) ); // FixIn: 8.5.1.3.
193 - return;
194 - }
195 - }
196 -
197 - // Validation Check --- Email correct filling field
198 - if ( element.className.indexOf('wpdev-validates-as-email') !== -1 ){
199 - inp_value = inp_value.replace(/^\s+|\s+$/gm,''); // Trim white space //FixIn: 5.4.5
200 - var reg = /^([A-Za-z0-9_\-\.\+])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,})$/;
201 - if ( inp_value != '' )
202 - if(reg.test(inp_value) == false) {
203 - wpbc_front_end__show_message__warning( element , _wpbc.get_message( 'message_check_email' ) ); // FixIn: 8.5.1.3.
204 - return;
205 - }
206 - }
207 -
208 - // Validation Check --- Same Email Field
209 - if ( ( element.className.indexOf('wpdev-validates-as-email') !== -1 ) && ( element.className.indexOf('same_as_') !== -1 ) ) {
210 -
211 - // Get the name of Primary Email field from the "same_as_NAME" class
212 - var primary_email_name = element.className.match(/same_as_([^\s])+/gi);
213 - if (primary_email_name != null) { // We found
214 - primary_email_name = primary_email_name[0].substr(8);
215 -
216 - // Recehck if such primary email field exist in the booking form
217 - if (jQuery('[name="' + primary_email_name + bk_type + '"]').length > 0) {
218 -
219 - // Recheck the values of the both emails, if they do not equla show warning
220 - if ( jQuery('[name="' + primary_email_name + bk_type + '"]').val() !== inp_value ) {
221 - wpbc_front_end__show_message__warning( element , _wpbc.get_message( 'message_check_same_email' ) ); // FixIn: 8.5.1.3.
222 - return;
223 - }
224 - }
225 - }
226 - // Skip one loop for the email veryfication field
227 - continue; // FixIn: 8.1.2.15.
228 - }
229 -
230 - }
231 -
232 - // Get Form Data
233 - if ( element.name !== ('captcha_input' + bk_type) ) {
234 - if (formdata !=='') formdata += '~'; // next field element
235 -
236 - el_type = element.type;
237 - if ( element.className.indexOf('wpdev-validates-as-email') !== -1 ) el_type='email';
238 - if ( element.className.indexOf('wpdev-validates-as-coupon') !== -1 ) el_type='coupon';
239 -
240 - inp_value = inp_value + '';
241 - inp_value = inp_value.replace(new RegExp("\\^",'g'), '&#94;'); // replace registered characters
242 - inp_value = inp_value.replace(new RegExp("~",'g'), '&#126;'); // replace registered characters
243 -
244 - inp_value = inp_value.replace(/"/g, '&#34;'); // replace double quot
245 - inp_value = inp_value.replace(/'/g, '&#39;'); // replace single quot
246 -
247 - if ( 'select-one' == el_type ){
248 - el_type = 'selectbox-one';
249 - }
250 - if ( 'select-multiple' == el_type ){
251 - el_type = 'selectbox-multiple';
252 - }
253 -
254 - formdata += el_type + '^' + element.name + '^' + inp_value ; // element attr
255 -
256 - var clean_field_name = element.name;
257 - clean_field_name = clean_field_name.replaceAll( /\[\]/gi, '' );
258 - clean_field_name = clean_field_name.substr( 0, (clean_field_name.length - bk_type.toString().length) );
259 - formdata += '~' + el_type + '^' + clean_field_name + '_val' + bk_type + '^' + inp_title_value;
260 - }
261 - }
262 -
263 - } // End Fields Loop
264 -
265 -
266 - // TODO: here was function for 'Check if visitor finish dates selection.
267 -
268 -
269 - // Cpatch verify
270 - var captcha = document.getElementById('wpdev_captcha_challenge_' + bk_type);
271 -
272 - //Disable Submit button
273 - if (captcha != null) form_submit_send( bk_type, formdata, captcha.value, document.getElementById('captcha_input' + bk_type).value ,wpdev_active_locale);
274 - else form_submit_send( bk_type, formdata, '', '' , wpdev_active_locale);
275 - return;
276 -}
277 -
278 -
279 -// Gathering params for sending Ajax request and then send it
280 -function form_submit_send( bk_type, formdata, captcha_chalange, user_captcha ,wpdev_active_locale){
281 -
282 - var my_booking_form = '';
283 - if ( document.getElementById( 'booking_form_type' + bk_type ) != undefined ){
284 - my_booking_form = document.getElementById( 'booking_form_type' + bk_type ).value;
285 - }
286 -
287 - var my_booking_hash = '';
288 - if ( _wpbc.get_other_param( 'this_page_booking_hash' ) != '' ){
289 - my_booking_hash = _wpbc.get_other_param( 'this_page_booking_hash' );
290 - }
291 -
292 - var is_send_emeils = 1;
293 - if ( jQuery('#is_send_email_for_pending').length ) {
294 - is_send_emeils = jQuery( '#is_send_email_for_pending' ).is( ':checked' ); // FixIn: 8.7.9.5.
295 - if ( false === is_send_emeils ) { is_send_emeils = 0; }
296 - else { is_send_emeils = 1; }
297 - }
298 -
299 - if ( document.getElementById( 'date_booking' + bk_type ).value != '' ){ // FixIn: 6.1.1.3.
300 - send_ajax_submit( bk_type, formdata, captcha_chalange, user_captcha, is_send_emeils, my_booking_hash, my_booking_form, wpdev_active_locale ); // Ajax sending request
301 - } else {
302 - jQuery( '#booking_form_div' + bk_type ).hide();
303 - jQuery( '#submiting' + bk_type ).hide();
304 - }
305 -
306 - var formdata_additional_arr;
307 - var formdata_additional;
308 - var my_form_field;
309 - var id_additional;
310 - var id_additional_str;
311 - var id_additional_arr;
312 - if ( document.getElementById( 'additional_calendars' + bk_type ) != null ){
313 -
314 - id_additional_str = document.getElementById('additional_calendars' + bk_type).value; //Loop have to be here based on , sign
315 - id_additional_arr = id_additional_str.split(',');
316 - //FixIn: 10.9.4.1.
317 - for ( var ia = 0; ia < id_additional_arr.length; ia++ ) {
318 - id_additional_arr[ia] = parseInt( id_additional_arr[ia] );
319 - }
320 - if ( ! jQuery( '#booking_form_div' + bk_type ).is( ':visible' ) ) {
321 - wpbc_booking_form__spin_loader__show( bk_type ); // Show Spinner
322 - }
323 -
324 - for ( var ia = 0; ia < id_additional_arr.length; ia++ ){
325 - //FixIn: 10.9.4.1.
326 - if ( id_additional_arr[ia] <=0 ) {
327 - continue;
328 - }
329 -
330 -
331 - formdata_additional_arr = formdata;
332 - formdata_additional = '';
333 - id_additional = id_additional_arr[ia];
334 -
335 -
336 - formdata_additional_arr = formdata_additional_arr.split('~');
337 - for (var j=0;j<formdata_additional_arr.length;j++) {
338 - my_form_field = formdata_additional_arr[j].split('^');
339 - if (formdata_additional !=='') formdata_additional += '~';
340 -
341 - if (my_form_field[1].substr( (my_form_field[1].length -2),2)=='[]')
342 - my_form_field[1] = my_form_field[1].substr(0, (my_form_field[1].length - (''+bk_type).length ) - 2 ) + id_additional + '[]';
343 - else
344 - my_form_field[1] = my_form_field[1].substr(0, (my_form_field[1].length - (''+bk_type).length ) ) + id_additional ;
345 -
346 -
347 - formdata_additional += my_form_field[0] + '^' + my_form_field[1] + '^' + my_form_field[2];
348 - }
349 -
350 - if ( jQuery('#gateway_payment_forms' + bk_type).length > 0 ) { // If Payment form for main booking resources is showing then append payment form for additional calendars.
351 - jQuery('#gateway_payment_forms' + bk_type).after('<div id="gateway_payment_forms'+id_additional+'"></div>');
352 - jQuery('#gateway_payment_forms' + bk_type).after('<div id="ajax_respond_insert'+id_additional+'" style="display:none;"></div>');
353 - }
354 - // FixIn: 8.5.2.17.
355 - send_ajax_submit( id_additional ,formdata_additional,captcha_chalange,user_captcha,is_send_emeils,my_booking_hash,my_booking_form ,wpdev_active_locale ); // Submit
356 - }
357 - }
358 -}
359 -
360 -
361 -//<![CDATA[
362 -function send_ajax_submit( resource_id, formdata, captcha_chalange, user_captcha, is_send_emeils, my_booking_hash, my_booking_form, wpdev_active_locale ){
363 -
364 - // Disable Submit | Show spin loader
365 - wpbc_booking_form__on_submit__ui_elements_disable( resource_id )
366 -
367 - var is_exit = wpbc_ajx_booking__create( {
368 - 'resource_id' : resource_id,
369 - 'dates_ddmmyy_csv' : document.getElementById( 'date_booking' + resource_id ).value,
370 - 'formdata' : formdata,
371 - 'booking_hash' : my_booking_hash,
372 - 'custom_form' : my_booking_form,
373 - 'aggregate_resource_id_arr': ( ( null !== _wpbc.booking__get_param_value( resource_id, 'aggregate_resource_id_arr' ))
374 - ? _wpbc.booking__get_param_value( resource_id, 'aggregate_resource_id_arr' ).join( ',' ) : ''),
375 - 'captcha_chalange' : captcha_chalange,
376 - 'captcha_user_input' : user_captcha,
377 -
378 - 'is_emails_send' : is_send_emeils,
379 - 'active_locale' : wpdev_active_locale
380 - } );
381 - if ( true === is_exit ){
382 - return;
383 - }
384 -}
385 -//]]>
386 -
387 -
388 -// Hint labels inside of input boxes
389 -jQuery(document).ready( function(){
390 -
391 - jQuery('div.inside_hint').on( 'click', function(){ // FixIn: 8.7.11.12.
392 - jQuery(this).css('visibility', 'hidden').siblings('.has-inside-hint').trigger( 'focus' ); // FixIn: 8.7.11.12.
393 - });
394 -
395 - jQuery('input.has-inside-hint').on( 'blur', function(){ // FixIn: 8.7.11.12.
396 - if ( this.value == '' )
397 - jQuery(this).siblings('.inside_hint').css('visibility', '');
398 - }).on( 'focus', function(){ // FixIn: 8.7.11.12.
399 - jQuery(this).siblings('.inside_hint').css('visibility', 'hidden');
400 - });
401 -
402 - jQuery('.booking_form_div input[type=button]').prop("disabled", false);
403 -});
404 -
405 -
406 -// FixIn: 8.4.0.2.
407 1 /**
408 2 * Check errors in booking form fields, and show warnings if some errors exist.
409 - * Check errors, like not selected dates or not filled requred form fields, or not correct entering email or phone fields, etc...
3 + * Check errors, like not selected dates or not filled requred form fields, or not correct entering email or phone
4 + * fields, etc...
410 5 *
411 - * @param bk_type int (ID of booking resource)
6 + * @param resource_id int (ID of booking resource)
412 7 */
413 -function wpbc_check_errors_in_booking_form( bk_type ) {
8 +function wpbc_check_errors_in_booking_form( resource_id ) {
9 + var $form = jQuery( '#booking_form' + resource_id );
10 + var fields_with_errors_arr = [];
11 + var is_error_in_field = false;
12 + var skip_element_types = [ 'hidden', 'button' ];
414 13
415 - var is_error_in_field = false; // By default, all is good - no error
14 + if ( ! $form.length ) {
15 + return false;
16 + }
416 17
417 - var my_form = jQuery( '#booking_form' + bk_type );
18 + /**
19 + * Show a validation warning and register the related field as invalid.
20 + *
21 + * @param {HTMLElement|null} field Field to focus after validation.
22 + * @param {HTMLElement|jQuery|string} target Warning message target.
23 + * @param {string} message Warning message.
24 + */
25 + function add_validation_error( field, target, message ) {
26 + wpbc_front_end__show_message__warning( target, message, 'text' );
27 + is_error_in_field = true;
418 28
419 - if ( my_form.length ) {
29 + if ( field ) {
30 + fields_with_errors_arr.push( field );
31 + }
32 + }
420 33
421 - var fields_with_errors_arr = [];
34 + /**
35 + * Validate a required field.
36 + *
37 + * @param {HTMLElement} field Form field.
38 + * @param {jQuery} $field Cached jQuery field.
39 + * @param {string} field_type Field type.
40 + */
41 + function validate_required_field( field, $field, field_type ) {
42 + var warning_target;
422 43
423 - // Pseudo-selector that get form elements <input , <textarea , <select, <button...
424 - my_form.find( ':input' ).each( function( index, el ) {
44 + if ( ! $field.hasClass( 'wpdev-validates-as-required' ) ) {
45 + return;
46 + }
425 47
426 - // Skip some elements
427 - var skip_elements = [ 'hidden', 'button' ];
48 + if ( 'checkbox' === field_type ) {
49 + if ( ! $field.is( ':checked' ) && ! jQuery( ':checkbox[name="' + field.name + '"]', $form ).is( ':checked' ) ) {
50 + warning_target = $field.parents( '.wpdev-form-control-wrap' ).last();
428 51
429 - if ( -1 == skip_elements.indexOf( jQuery( el ).attr( 'type' ) ) ){
52 + if ( ! warning_target.length ) {
53 + warning_target = $field.parents( '.controls' ).last();
54 + }
55 + if ( ! warning_target.length ) {
56 + warning_target = $field;
57 + }
430 58
431 - // Check Calendar Dates Selection
432 - if ( ( 'date_booking' + bk_type ) == jQuery( el ).attr( 'name' ) ) {
59 + add_validation_error( field, warning_target, _wpbc.get_message( 'message_check_required_for_check_box' ) );
60 + }
61 + return;
62 + }
433 63
434 - // Show Warning only if the calendar visible ( we are at step with calendar)
435 - if (
436 - ( ( jQuery( '#calendar_booking' + bk_type ).is( ':visible' ) ) && ( '' == jQuery( el ).val() ) )
437 - && ( wpbc_get_arr_of_selected_additional_calendars( bk_type ).length == 0 ) // FixIn: 8.5.2.26.
438 - ){ // FixIn: 8.4.4.5.
64 + if ( 'radio' === field_type ) {
65 + if ( ! jQuery( ':radio[name="' + field.name + '"]', $form ).is( ':checked' ) ) {
66 + add_validation_error( field, $field.parents( '.wpdev-form-control-wrap' ), _wpbc.get_message( 'message_check_required_for_radio_box' ) );
67 + }
68 + return;
69 + }
439 70
440 - var notice_message_id = wpbc_front_end__show_message__error_under_element( '#booking_form_div' + bk_type + ' .bk_calendar_frame', _wpbc.get_message( 'message_check_no_selected_dates' ) , 3000 );
71 + if ( '' === wpbc_trim( $field.val() ) ) {
72 + add_validation_error( field, field, _wpbc.get_message( 'message_check_required' ) );
73 + }
74 + }
441 75
442 - //wpbc_do_scroll('#calendar_booking' + bk_type); // Scroll to the calendar // FixIn: 8.5.1.3.
443 - is_error_in_field = true; // Error
444 - }
445 - }
76 + /**
77 + * Validate an email field and return its trimmed value.
78 + *
79 + * @param {HTMLElement} field Form field.
80 + * @param {jQuery} $field Cached jQuery field.
81 + * @returns {string}
82 + */
83 + function validate_email_field( field, $field ) {
84 + var email_value = String( $field.val() || '' ).replace( /^\s+|\s+$/gm, '' );
85 + var email_regex = /^([A-Za-z0-9_\-\.\+])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,})$/;
446 86
447 - // Check only visible elements at this step
448 - if ( jQuery( el ).is( ':visible' ) ){
449 -// console.log( '|id, type, val, visible|::', jQuery( el ).attr( 'name' ), '|' + jQuery( el ).attr( 'type' ) + '|', jQuery( el ).val(), jQuery( el ).is( ':visible' ) );
87 + if ( '' !== email_value && ! email_regex.test( email_value ) ) {
88 + add_validation_error( field, field, _wpbc.get_message( 'message_check_email' ) );
89 + }
450 90
451 - // Is Required
452 - if ( jQuery( el ).hasClass( 'wpdev-validates-as-required' ) ){
91 + return email_value;
92 + }
453 93
454 - // Checkboxes
455 - if ( 'checkbox' == jQuery( el ).attr( 'type' ) ){
94 + /**
95 + * Validate a confirmation email field using its same_as_NAME class.
96 + *
97 + * @param {HTMLElement} field Form field.
98 + * @param {string} email_value Trimmed confirmation email value.
99 + */
100 + function validate_confirmation_email_field( field, email_value ) {
101 + var primary_email_match;
102 + var primary_email_name;
103 + var $primary_email_field;
456 104
457 - if (
458 - ( ! jQuery( el ).is( ':checked' ))
459 - && ( ! jQuery( ':checkbox[name="' + el.name + '"]', my_form ).is( ":checked" ) ) // FixIn: 8.5.2.12.
460 - ){
461 - var checkbox_parent_element;
105 + if ( field.className.indexOf( 'same_as_' ) === -1 ) {
106 + return;
107 + }
462 108
463 - if ( jQuery( el ).parents( '.wpdev-form-control-wrap' ).length > 0 ){
109 + primary_email_match = field.className.match( /same_as_([^\s])+/gi );
110 + if ( null === primary_email_match ) {
111 + return;
112 + }
464 113
465 - checkbox_parent_element = jQuery( el ).parents( '.wpdev-form-control-wrap' );
114 + primary_email_name = primary_email_match[ 0 ].substr( 8 );
115 + $primary_email_field = $form.find( '[name="' + primary_email_name + resource_id + '"]' );
466 116
467 - } else if ( jQuery( el ).parents( '.controls' ).length > 0 ){
117 + if ( $primary_email_field.length && $primary_email_field.val() !== email_value ) {
118 + add_validation_error( field, field, _wpbc.get_message( 'message_check_same_email' ) );
119 + }
120 + }
468 121
469 - checkbox_parent_element = jQuery( el ).parents( '.controls' );
122 + /**
123 + * Validate fields using the validate_as_date, validate_as_digit, or validate_digit_N classes.
124 + *
125 + * @param {HTMLElement} field Form field.
126 + * @param {jQuery} $field Cached jQuery field.
127 + */
128 + function validate_custom_field_classes( field, $field ) {
129 + var class_list = $field.attr( 'class' );
130 + var field_value;
470 131
471 - } else {
132 + if ( ! class_list ) {
133 + return;
134 + }
472 135
473 - checkbox_parent_element = jQuery( el );
474 - }
475 - var notice_message_id = wpbc_front_end__show_message__warning( checkbox_parent_element, _wpbc.get_message( 'message_check_required_for_check_box' ) );
136 + field_value = $field.val();
476 137
477 - fields_with_errors_arr.push( el );
478 - is_error_in_field = true; // Error
479 - }
138 + jQuery.each( class_list.split( /\s+/ ), function ( class_index, class_name ) {
139 + var digits_to_check;
140 + var message;
141 + var validation_regex;
480 142
481 - // Radio boxes
482 - } else if ( 'radio' == jQuery( el ).attr( 'type' ) ){
143 + if ( 'validate_as_date' === class_name ) {
144 + validation_regex = new RegExp( '^[0-3]?\\d{1}[\\/\\.\\-]+[0-3]?\\d{1}[\\/\\.\\-]+[0-2]+\\d{3}$' );
145 + message = _wpbc.get_message( 'message_check_valid_date' ).replace( '{date_example}', '09/25/2018' );
483 146
484 - if ( !jQuery( ':radio[name="' + jQuery( el ).attr( 'name' ) + '"]', my_form ).is( ':checked' ) ){
485 - var notice_message_id = wpbc_front_end__show_message__warning( jQuery( el ).parents('.wpdev-form-control-wrap'), _wpbc.get_message( 'message_check_required_for_radio_box' ) );
486 - fields_with_errors_arr.push( el );
487 - is_error_in_field = true; // Error
488 - }
147 + if ( '' !== field_value && ! validation_regex.test( field_value ) ) {
148 + add_validation_error( field, field, message );
149 + }
150 + return;
151 + }
489 152
490 - // Other elements
491 - } else {
153 + if ( 'validate_as_digit' === class_name ) {
154 + validation_regex = new RegExp( '^[0-9]+\\.?[0-9]*$' );
492 155
493 - var inp_value = jQuery( el ).val();
156 + if ( '' !== field_value && ! validation_regex.test( field_value ) ) {
157 + add_validation_error( field, field, _wpbc.get_message( 'message_check_digits_only' ) );
158 + }
159 + return;
160 + }
494 161
495 - if ( '' === wpbc_trim( inp_value ) ){ //FixIn: 8.8.1.3 // FixIn: 8.7.11.12.
162 + if ( 'validate_digit_' !== class_name.substring( 0, 15 ) ) {
163 + return;
164 + }
496 165
497 - var notice_message_id = wpbc_front_end__show_message__warning( el, _wpbc.get_message( 'message_check_required' ) );
166 + digits_to_check = parseInt( class_name.substring( 15 ), 10 );
167 + if ( isNaN( digits_to_check ) ) {
168 + return;
169 + }
498 170
499 - fields_with_errors_arr.push( el );
500 - is_error_in_field = true; // Error
501 - }
502 - }
503 - }
171 + validation_regex = new RegExp( '^\\d{' + digits_to_check + '}$' );
172 + message = _wpbc.get_message( 'message_check_digits_count' ).replace( '{digits}', digits_to_check );
504 173
505 - // Validate Email
506 - if ( jQuery( el ).hasClass( 'wpdev-validates-as-email' ) ){
507 - var inp_value = jQuery( el ).val();
508 - inp_value = inp_value.replace( /^\s+|\s+$/gm, '' ); // Trim white space //FixIn: 5.4.5
509 - var reg = /^([A-Za-z0-9_\-\.\+])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,})$/;
510 - if ( (inp_value != '') && (reg.test( inp_value ) == false) ){
174 + if ( '' !== field_value && ! validation_regex.test( field_value ) ) {
175 + add_validation_error( field, field, message );
176 + }
177 + } );
178 + }
511 179
512 - var notice_message_id = wpbc_front_end__show_message__warning( el, _wpbc.get_message( 'message_check_email' ) );
513 - fields_with_errors_arr.push( el );
514 - is_error_in_field = true; // Error
515 - }
516 - }
180 + $form.find( ':input' ).each( function () {
181 + var field = this;
182 + var $field = jQuery( field );
183 + var field_type = $field.attr( 'type' );
184 + var email_value;
517 185
518 - // Validate For digit entering - for example for - Phone
519 - // <p>Digit Field:<br />[text* dig_field class:validate_as_digit] </p>
520 - // <p>Phone:<br />[text* phone class:validate_digit_8] </p>
186 + if ( -1 !== skip_element_types.indexOf( field_type ) ) {
187 + return;
188 + }
521 189
522 - var classList = jQuery( el ).attr( 'class' );
190 + if ( '1' === String( $field.attr( 'data-wpbc-booking-submit-ignore' ) || '' ) ) {
191 + return;
192 + }
523 193
524 - if ( classList ){
194 + if (
195 + ( 'date_booking' + resource_id === $field.attr( 'name' ) ) &&
196 + jQuery( '#calendar_booking' + resource_id ).is( ':visible' ) &&
197 + ( '' === $field.val() ) &&
198 + ( 0 === wpbc_get_arr_of_selected_additional_calendars( resource_id ).length )
199 + ) {
200 + add_validation_error(
201 + null,
202 + '#booking_form_div' + resource_id + ' .bk_calendar_frame',
203 + _wpbc.get_message( 'message_check_no_selected_dates' )
204 + );
205 + }
525 206
526 - classList = classList.split( /\s+/ );
207 + if ( ! $field.is( ':visible' ) ) {
208 + return;
209 + }
527 210
528 - jQuery.each( classList, function ( cl_index, cl_item ){
211 + validate_required_field( field, $field, field_type );
529 212
530 - ////////////////////////////////////////////////////////////////////////////////////////////
213 + if ( $field.hasClass( 'wpdev-validates-as-email' ) ) {
214 + email_value = validate_email_field( field, $field );
215 + validate_confirmation_email_field( field, email_value );
216 + }
531 217
532 - // Validate field value as "Date" [CSS class - 'validate_as_digit']
533 - if ( 'validate_as_date' === cl_item ) {
218 + validate_custom_field_classes( field, $field );
219 + } );
534 220
535 - // Valid values: 09-25-2018, 09/25/2018, 09-25-2018, 31-9-1918 --- m/d/Y, m.d.Y, m-d-Y, d/m/Y, d.m.Y, d-m-Y
536 - var regex = new RegExp( '^[0-3]?\\d{1}[\\/\\.\\-]+[0-3]?\\d{1}[\\/\\.\\-]+[0-2]+\\d{3}$' ); // Check for Date 09/25/2018
537 - var message_verif_phone = 'This field must be valid date like this ' + '09/25/2018';
538 - var inp_value = jQuery( el ).val();
221 + if ( fields_with_errors_arr.length ) {
222 + jQuery( fields_with_errors_arr[ 0 ] ).trigger( 'focus' );
223 + }
539 224
540 - if ( ( inp_value != '' ) && ( regex.test( inp_value ) == false ) ){
541 - wpbc_front_end__show_message__warning( el, message_verif_phone );
542 - fields_with_errors_arr.push( el );
543 - is_error_in_field = true; // Error
544 - }
545 - }
225 + return is_error_in_field;
226 +}
546 227
547 - ////////////////////////////////////////////////////////////////////////////////////////////
228 +/**
229 + * Hint labels inside of input boxes.
230 + */
231 +jQuery( document ).ready(
232 + function () {
548 233
549 - // Validate field value as "DIGIT" [CSS class - 'validate_as_digit']
550 - if ( 'validate_as_digit' === cl_item ) {
234 + jQuery( 'div.inside_hint' ).on(
235 + 'click',
236 + function () {
237 + jQuery( this ).css( 'visibility', 'hidden' ).siblings( '.has-inside-hint' ).trigger( 'focus' );
238 + }
239 + );
551 240
552 - var regex = new RegExp( '^[0-9]+\\.?[0-9]*$' ); // Check for digits
553 - var message_verif_phone = 'This field must contain only digits';
554 - var inp_value = jQuery( el ).val();
555 -
556 - if ( ( inp_value != '' ) && ( regex.test( inp_value ) == false ) ){
557 - wpbc_front_end__show_message__warning( el, message_verif_phone );
558 - fields_with_errors_arr.push( el );
559 - is_error_in_field = true; // Error
560 - }
561 - }
562 -
563 - ////////////////////////////////////////////////////////////////////////////////////////////
564 -
565 - // Validate field value as "Phone" number or any other valid number wth specific number of digits [CSS class - 'validate_digit_8' || 'validate_digit_10' ]
566 - var is_validate_digit = cl_item.substring( 0, 15 );
567 -
568 - // Check if class start with 'validate_digit_'
569 - if ( 'validate_digit_' === is_validate_digit ){
570 -
571 - // Get number of digit in class: validate_digit_8 => 8 or validate_digit_10 => 10
572 - var digits_to_check = parseInt( cl_item.substring( 15 ) );
573 -
574 - // Check about any errors in
575 - if ( !isNaN( digits_to_check ) ){
576 -
577 - var regex = new RegExp( '^\\d{' + digits_to_check + '}$' ); // We was valid it as parseInt - only integer variable - digits_to_check
578 - var message_verif_phone = 'This field must contain ' + digits_to_check + ' digits';
579 - var inp_value = jQuery( el ).val();
580 -
581 - if ( ( inp_value != '' ) && ( regex.test( inp_value ) == false ) ){
582 - wpbc_front_end__show_message__warning( el, message_verif_phone );
583 - fields_with_errors_arr.push( el );
584 - is_error_in_field = true; // Error
585 - }
586 - }
587 - }
588 -
589 - ////////////////////////////////////////////////////////////////////////////////////////////
590 -
591 - });
592 - }
593 - }
241 + jQuery( 'input.has-inside-hint' ).on(
242 + 'blur',
243 + function () {
244 + if ( '' === this.value ) {
245 + jQuery( this ).siblings( '.inside_hint' ).css( 'visibility', '' );
246 + }
594 247 }
595 - } );
248 + ).on(
249 + 'focus',
250 + function () {
251 + jQuery( this ).siblings( '.inside_hint' ).css( 'visibility', 'hidden' );
252 + }
253 + );
596 254
597 - if ( fields_with_errors_arr.length > 0 ){
598 - jQuery( fields_with_errors_arr[ 0 ] ).trigger( 'focus' ); // FixIn: 9.3.1.9.
599 - }
255 + jQuery( '.booking_form_div input[type=button]' ).prop( "disabled", false );
600 256 }
257 +);
601 258
602 - return is_error_in_field;
603 -}
259 +// == WIZARD ===========================================================================================================
604 260
605 -
606 -// FixIn: 8.6.1.15.
607 261 /**
608 262 * Go to next specific step in Wizard style booking form, with
609 263 * check all required elements specific step, otherwise show warning message!
610 264 *
@@ -611,32 +265,34 @@
611 265 * @param el
612 266 * @param step_num
613 267 * @returns {boolean}
614 268 */
615 -function wpbc_wizard_step( el, step_num, step_from ){
616 - var br_id = jQuery( el ).closest( 'form' ).find( 'input[name^="bk_type"]' ).val();
269 +function wpbc_wizard_step(el, step_num, step_from) {
617 270
618 - // FixIn: 8.8.1.5.
619 - if ( ( undefined == step_from ) || ( step_num > step_from ) ){
620 - if ( 1 != step_num ){ // FixIn: 8.7.7.8.
621 - var is_error = wpbc_check_errors_in_booking_form( br_id );
622 - if ( is_error ){
623 - return false;
624 - }
625 - }
626 - }
271 + var br_id = jQuery( el ).closest( 'form' ).find( 'input[name^="bk_type"]' ).val();
627 272
628 - if ( wpbc_is_some_elements_visible( br_id, ['rangetime', 'durationtime', 'starttime', 'endtime'] ) ){
629 - if ( wpbc_is_this_time_selection_not_available( br_id, document.getElementById( 'booking_form' + br_id ) ) ){
630 - return false;
631 - }
632 - }
273 + // FixIn: 8.8.1.5.
274 + if ( (undefined == step_from) || (step_num > step_from) ) {
275 + if ( 1 != step_num ) { // FixIn: 8.7.7.8.
276 + var is_error = wpbc_check_errors_in_booking_form( br_id );
277 + if ( is_error ) {
278 + return false;
279 + }
280 + }
281 + }
633 282
634 - if ( br_id != undefined ){
635 - jQuery( "#booking_form" + br_id + " .wpbc_wizard_step" ).css( {"display": "none"} ).removeClass('wpbc_wizard_step_hidden');
636 - jQuery( "#booking_form" + br_id + " .wpbc_wizard_step" + step_num ).css( {"display": "block"} );
637 - return jQuery( "#booking_form" + br_id + " .wpbc_wizard_step" + step_num );
638 - }
283 + if ( wpbc_is_some_elements_visible( br_id, [ 'rangetime', 'durationtime', 'starttime', 'endtime' ] ) ) {
284 + if ( wpbc_is_this_time_selection_not_available( br_id, document.getElementById( 'booking_form' + br_id ) ) ) {
285 + return false;
286 + }
287 + }
288 +
289 + if ( br_id != undefined ) {
290 + jQuery( "#booking_form" + br_id + " .wpbc_wizard_step" ).css( { "display": "none" } )
291 + .removeClass( 'wpbc_wizard_step_hidden' );
292 + jQuery( "#booking_form" + br_id + " .wpbc_wizard_step" + step_num ).css( { "display": "block" } );
293 + return jQuery( "#booking_form" + br_id + " .wpbc_wizard_step" + step_num );
294 + }
639 295 }
640 296
641 297
642 298 /**
@@ -643,80 +299,98 @@
643 299 * Init Buttons in Booking form Wizard
644 300 */
645 301 function wpbc_hook__init_booking_form_wizard_buttons() {
646 302
647 - // CSS classes in Wizard Next / Prior links can be like this: <a class="wpbc_button_light wpbc_wizard_step_button wpbc_wizard_step_1">Step 1</a> | <a class="wpbc_button_light wpbc_wizard_step_button wpbc_wizard_step_2">Step 2</a>
303 + // CSS classes in Wizard Next / Prior links can be like this: <a class="wpbc_button_light wpbc_wizard_step_button wpbc_wizard_step_1">Step 1</a> | <a class="wpbc_button_light wpbc_wizard_step_button wpbc_wizard_step_2">Step 2</a> .
648 304
649 - jQuery( '.wpbc_wizard_step_button' ).attr( {
650 - href: 'javascript:void(0)'
651 - } );
305 + jQuery( '.wpbc_wizard_step_button' ).attr(
306 + {
307 + href: 'javascript:void(0)',
308 + }
309 + );
652 310
653 - jQuery( '.wpbc_wizard_step_button' ).on( 'click', function ( event ){
311 + jQuery( '.wpbc_wizard_step_button' ).off( 'click.wpbc_booking_form_wizard' ).on(
312 + 'click.wpbc_booking_form_wizard',
313 + function (event) {
314 + var found_steps_arr = jQuery( this ).attr( 'class' ).match( /wpbc\_wizard\_step\_([\d]+)([\s'"]+|$)/ );
654 315
655 - var found_steps_arr = jQuery( this ).attr( 'class' ).match( /wpbc\_wizard\_step\_([\d]+)([\s'"]+|$)/ );
656 -
657 - if ( (null !== found_steps_arr) && (found_steps_arr.length > 2) ){
658 - var step = parseInt( found_steps_arr[ 1 ] );
659 - if ( step > 0 ){
660 - var jq_step_element = wpbc_wizard_step( this, step );
661 - if ( false !== jq_step_element ) {
662 - wpbc_do_scroll( jq_step_element );
663 - // wpbc_do_scroll( jQuery('.wpbc_wizard_step:visible') );
664 - }
665 - }
666 - }
667 - } );
316 + if ( (null !== found_steps_arr) && (found_steps_arr.length > 2) ) {
317 + var step = parseInt( found_steps_arr[1] );
318 + if ( step > 0 ) {
319 + var jq_step_element;
320 + // Check actual step in booking form for getting step_from number.
321 + var this_formsteps_arr = jQuery( this ).parents( '.wpbc_wizard_step' ).attr( 'class' ).match( /wpbc\_wizard\_step([\d]+)([\s'"]+|$)/ );
322 + if ( (null !== this_formsteps_arr) && (this_formsteps_arr.length > 2) ) {
323 + var step_from = parseInt( this_formsteps_arr[1] );
324 + jq_step_element = wpbc_wizard_step( this, step, step_from );
325 + } else {
326 + jq_step_element = wpbc_wizard_step( this, step );
327 + }
328 + // Do Scroll.
329 + if ( false !== jq_step_element ) {
330 + wpbc_do_scroll( jq_step_element ); // wpbc_do_scroll( jQuery('.wpbc_wizard_step:visible') );.
331 + }
332 + }
333 + }
334 + }
335 + );
668 336 }
669 337
670 -// FixIn: 10.1.3.2.
671 -jQuery( document ).ready( function (){
672 - wpbc_hook__init_booking_form_wizard_buttons();
673 -} );
674 338
675 -
676 -// FixIn: 8.6.1.15.
677 339 /**
678 340 * Check if at least one element from array of elements names in booking form visible or not.
679 - * Usage Example: if ( wpbc_is_some_elements_visible( br_id, ['rangetime', 'durationtime', 'starttime', 'endtime'] ) ){ ... }
341 + * Usage Example: if ( wpbc_is_some_elements_visible( br_id, ['rangetime', 'durationtime', 'starttime', 'endtime'] )
342 + * ){ ... }
680 343 *
681 - * @param bk_type
344 + * @param resource_id
682 345 * @param elements_names
683 346 * @returns {boolean}
684 347 */
685 -function wpbc_is_some_elements_visible( bk_type, elements_names ){
348 +function wpbc_is_some_elements_visible(resource_id, elements_names) {
686 349
687 - var is_some_elements_visible = false;
350 + var my_form = jQuery( '#booking_form' + resource_id );
688 351
689 - var my_form = jQuery( '#booking_form' + bk_type );
352 + if ( ! my_form.length ) {
353 + return false;
354 + }
690 355
691 - if ( my_form.length ){
356 + var is_some_elements_visible = false;
357 + // Pseudo-selector that get form elements <input , <textarea , <select, <button...
358 + my_form.find( ':input' ).each(
359 + function (index, el) {
692 360
693 - // Pseudo-selector that get form elements <input , <textarea , <select, <button...
694 - my_form.find( ':input' ).each( function ( index, el ){
361 + // Skip some elements.
362 + var skip_elements = [ 'hidden', 'button' ];
695 363
696 - // Skip some elements
697 - var skip_elements = ['hidden', 'button'];
364 + if ( -1 == skip_elements.indexOf( jQuery( el ).attr( 'type' ) ) ) {
698 365
699 - if ( -1 == skip_elements.indexOf( jQuery( el ).attr( 'type' ) ) ){
366 + for ( var ei = 0; ei < (elements_names.length - 1); ei++ ) {
700 367
701 - for ( var ei = 0; ei < ( elements_names.length - 1) ; ei++ ){
368 + // Check Calendar Dates Selection.
369 + if ( (elements_names[ei] + resource_id) == jQuery( el ).attr( 'name' ) ) {
702 370
703 - // Check Calendar Dates Selection
704 - if ( (elements_names[ ei ] + bk_type) == jQuery( el ).attr( 'name' ) ){
371 + if ( jQuery( el ).is( ':visible' ) ) {
372 + is_some_elements_visible = true;
373 + }
374 + }
375 + }
376 + }
377 + }
378 + );
705 379
706 - if ( jQuery( el ).is( ':visible' ) ){
707 - is_some_elements_visible = true;
708 - }
709 - }
710 - }
711 - }
712 - } );
713 - }
714 - return is_some_elements_visible;
380 + return is_some_elements_visible;
715 381 }
716 382
717 -// == Days Selections - support functions ==============================================================================
718 383
384 +jQuery( document ).ready(
385 + function () {
386 + wpbc_hook__init_booking_form_wizard_buttons();
387 + }
388 +);
389 +
390 +
391 +// == DAYS_SELECTIONS ==================================================================================================
392 +
719 393 /**
720 394 * Get first day of selection
721 395 *
722 396 * @param dates
@@ -753,9 +427,15 @@
753 427 // Single day selection
754 428 return dates; //20.12.2013
755 429 }
756 430
757 -// Get last day of selection
431 +
432 +/**
433 + * Get last day of selection.
434 + *
435 + * @param dates
436 + * @returns {*|string}
437 + */
758 438 function get_last_day_of_selection(dates) {
759 439
760 440 // Multiple days selections
761 441 if ( dates.indexOf(',') != -1 ){
@@ -803,10 +483,8 @@
803 483
804 484 var id_additional_str = document.getElementById( 'additional_calendars' + bk_type ).value;
805 485 var id_additional_arr = id_additional_str.split( ',' );
806 486
807 - var is_all_additional_days_unselected = true;
808 -
809 487 for ( var ia = 0; ia < id_additional_arr.length; ia++ ){
810 488 if ( document.getElementById( 'date_booking' + id_additional_arr[ ia ] ).value != '' ){
811 489 selected_additionl_calendars.push( id_additional_arr[ ia ] );
812 490 }
@@ -813,4 +491,46 @@
813 491 }
814 492 }
815 493 return selected_additionl_calendars;
816 494 }
495 +
496 +
497 +// == ELEMENTOR Ready Widget Update ====================================================================================
498 +
499 +jQuery( function ($) {
500 + // FixIn: 10.14.15.1.
501 + if ( (window.elementorFrontend) && ('undefined' !== typeof (elementorFrontend.hooks)) ) {
502 +
503 + elementorFrontend.hooks.addAction( 'frontend/element_ready/wpbc_widget_booking_form_1.default', function ($scope) {
504 + // Simulate DOM ready, after updating Elementor Widget.
505 + jQuery( document ).trigger( 'wpbc_elementor_ready' );
506 + } );
507 +
508 + // Catch all widget re-renders.
509 + // elementorFrontend.hooks.addAction( 'frontend/element_ready/global', function ($scope) {
510 + // console.log( 'Some widget was re-rendered:', $scope );
511 + // } );
512 + }
513 +} );
514 +
515 +// Elementor widget reinit. So we need to reinit all "jQuery( document ).ready( ...) " again with custom 'wpbc_elementor_ready' event.
516 +jQuery( document ).on(
517 + 'wpbc_elementor_ready',
518 + function () {
519 +
520 + wpbc_hook__init_booking_form_wizard_buttons();
521 +
522 + if ( 'function' === typeof (wpbc_hook__init_timeselector) ) {
523 + wpbc_hook__init_timeselector();
524 + }
525 +
526 + if ( 'function' === typeof (wpbc_update_capacity_hint) ) {
527 + jQuery( '.booking_form_div' ).on(
528 + 'wpbc_booking_date_or_option_selected',
529 + function (event, resource_id) {
530 + wpbc_update_capacity_hint( resource_id );
531 + }
532 + );
533 + }
534 +
535 + }
536 +);