PluginProbe
Booking Calendar / 11.8.2
Booking Calendar v11.8.2
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 10.11.3 All 202 releases
← All changes | js/client.js +269 -234 11.211.8.2 View file →
@@ -1,241 +1,264 @@
1 -
2 -// Hint labels inside of input boxes.
3 -jQuery( document ).ready(
4 - function () {
5 -
6 - jQuery( 'div.inside_hint' ).on(
7 - 'click',
8 - function () {
9 - jQuery( this ).css( 'visibility', 'hidden' ).siblings( '.has-inside-hint' ).trigger( 'focus' ); // FixIn: 8.7.11.12.
10 - }
11 - );
12 -
13 - jQuery( 'input.has-inside-hint' ).on(
14 - 'blur',
15 - function () {
16 - if ( '' === this.value ) {
17 - jQuery( this ).siblings( '.inside_hint' ).css( 'visibility', '' ); // FixIn: 8.7.11.12.
18 - }
19 - }
20 - ).on(
21 - 'focus',
22 - function () {
23 - jQuery( this ).siblings( '.inside_hint' ).css( 'visibility', 'hidden' ); // FixIn: 8.7.11.12.
24 - }
25 - );
26 -
27 - jQuery( '.booking_form_div input[type=button]' ).prop( "disabled", false );
28 - }
29 -);
30 -
31 -
32 -// FixIn: 8.4.0.2.
33 1 /**
34 2 * Check errors in booking form fields, and show warnings if some errors exist.
35 3 * Check errors, like not selected dates or not filled requred form fields, or not correct entering email or phone
36 4 * fields, etc...
37 5 *
38 - * @param bk_type int (ID of booking resource)
6 + * @param resource_id int (ID of booking resource)
39 7 */
40 -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' ];
41 13
42 - var is_error_in_field = false; // By default, all is good - no error.
14 + if ( ! $form.length ) {
15 + return false;
16 + }
43 17
44 - 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;
45 28
46 - if ( my_form.length ) {
29 + if ( field ) {
30 + fields_with_errors_arr.push( field );
31 + }
32 + }
47 33
48 - 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;
49 43
50 - // Pseudo-selector that get form elements <input , <textarea , <select, <button...
51 - my_form.find( ':input' ).each( function( index, el ) {
44 + if ( ! $field.hasClass( 'wpdev-validates-as-required' ) ) {
45 + return;
46 + }
52 47
53 - // Skip some elements
54 - 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();
55 51
56 - if ( -1 == skip_elements.indexOf( jQuery( el ).attr( 'type' ) ) ){
57 -
58 - if ( '1' === String( jQuery( el ).attr( 'data-wpbc-booking-submit-ignore' ) || '' ) ) {
59 - return true;
52 + if ( ! warning_target.length ) {
53 + warning_target = $field.parents( '.controls' ).last();
60 54 }
55 + if ( ! warning_target.length ) {
56 + warning_target = $field;
57 + }
61 58
62 - // Check Calendar Dates Selection
63 - 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 + }
64 63
65 - // Show Warning only if the calendar visible ( we are at step with calendar)
66 - if (
67 - ( ( jQuery( '#calendar_booking' + bk_type ).is( ':visible' ) ) && ( '' == jQuery( el ).val() ) )
68 - && ( wpbc_get_arr_of_selected_additional_calendars( bk_type ).length == 0 ) // FixIn: 8.5.2.26.
69 - ){ // 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 + }
70 70
71 - 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 + }
72 75
73 - //wpbc_do_scroll('#calendar_booking' + bk_type); // Scroll to the calendar // FixIn: 8.5.1.3.
74 - is_error_in_field = true; // Error
75 - }
76 - }
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,})$/;
77 86
78 - // Check only visible elements at this step
79 - if ( jQuery( el ).is( ':visible' ) ){
80 -// 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 + }
81 90
82 - // Is Required
83 - if ( jQuery( el ).hasClass( 'wpdev-validates-as-required' ) ){
91 + return email_value;
92 + }
84 93
85 - // Checkboxes
86 - 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;
87 104
88 - if (
89 - ( ! jQuery( el ).is( ':checked' ))
90 - && ( ! jQuery( ':checkbox[name="' + el.name + '"]', my_form ).is( ":checked" ) ) // FixIn: 8.5.2.12.
91 - ){
92 - var checkbox_parent_element;
105 + if ( field.className.indexOf( 'same_as_' ) === -1 ) {
106 + return;
107 + }
93 108
94 - 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 + }
95 113
96 - 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 + '"]' );
97 116
98 - } 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 + }
99 121
100 - 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;
101 131
102 - } else {
132 + if ( ! class_list ) {
133 + return;
134 + }
103 135
104 - checkbox_parent_element = jQuery( el );
105 - }
106 - 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();
107 137
108 - fields_with_errors_arr.push( el );
109 - is_error_in_field = true; // Error
110 - }
138 + jQuery.each( class_list.split( /\s+/ ), function ( class_index, class_name ) {
139 + var digits_to_check;
140 + var message;
141 + var validation_regex;
111 142
112 - // Radio boxes
113 - } 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' );
114 146
115 - if ( !jQuery( ':radio[name="' + jQuery( el ).attr( 'name' ) + '"]', my_form ).is( ':checked' ) ){
116 - 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' ) );
117 - fields_with_errors_arr.push( el );
118 - is_error_in_field = true; // Error
119 - }
147 + if ( '' !== field_value && ! validation_regex.test( field_value ) ) {
148 + add_validation_error( field, field, message );
149 + }
150 + return;
151 + }
120 152
121 - // Other elements
122 - } else {
153 + if ( 'validate_as_digit' === class_name ) {
154 + validation_regex = new RegExp( '^[0-9]+\\.?[0-9]*$' );
123 155
124 - 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 + }
125 161
126 - 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 + }
127 165
128 - 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 + }
129 170
130 - fields_with_errors_arr.push( el );
131 - is_error_in_field = true; // Error
132 - }
133 - }
134 - }
171 + validation_regex = new RegExp( '^\\d{' + digits_to_check + '}$' );
172 + message = _wpbc.get_message( 'message_check_digits_count' ).replace( '{digits}', digits_to_check );
135 173
136 - // Validate Email
137 - if ( jQuery( el ).hasClass( 'wpdev-validates-as-email' ) ){
138 - var inp_value = jQuery( el ).val();
139 - inp_value = inp_value.replace( /^\s+|\s+$/gm, '' ); // Trim white space //FixIn: 5.4.5
140 - var reg = /^([A-Za-z0-9_\-\.\+])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,})$/;
141 - 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 + }
142 179
143 - var notice_message_id = wpbc_front_end__show_message__warning( el, _wpbc.get_message( 'message_check_email' ) );
144 - fields_with_errors_arr.push( el );
145 - is_error_in_field = true; // Error
146 - }
147 - }
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;
148 185
149 - // Validate For digit entering - for example for - Phone
150 - // <p>Digit Field:<br />[text* dig_field class:validate_as_digit] </p>
151 - // <p>Phone:<br />[text* phone class:validate_digit_8] </p>
186 + if ( -1 !== skip_element_types.indexOf( field_type ) ) {
187 + return;
188 + }
152 189
153 - var classList = jQuery( el ).attr( 'class' );
190 + if ( '1' === String( $field.attr( 'data-wpbc-booking-submit-ignore' ) || '' ) ) {
191 + return;
192 + }
154 193
155 - 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 + }
156 206
157 - classList = classList.split( /\s+/ );
207 + if ( ! $field.is( ':visible' ) ) {
208 + return;
209 + }
158 210
159 - jQuery.each( classList, function ( cl_index, cl_item ){
211 + validate_required_field( field, $field, field_type );
160 212
161 - ////////////////////////////////////////////////////////////////////////////////////////////
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 + }
162 217
163 - // Validate field value as "Date" [CSS class - 'validate_as_digit']
164 - if ( 'validate_as_date' === cl_item ) {
218 + validate_custom_field_classes( field, $field );
219 + } );
165 220
166 - // 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
167 - var regex = new RegExp( '^[0-3]?\\d{1}[\\/\\.\\-]+[0-3]?\\d{1}[\\/\\.\\-]+[0-2]+\\d{3}$' ); // Check for Date 09/25/2018
168 - var message_verif_phone = 'This field must be valid date like this ' + '09/25/2018';
169 - var inp_value = jQuery( el ).val();
221 + if ( fields_with_errors_arr.length ) {
222 + jQuery( fields_with_errors_arr[ 0 ] ).trigger( 'focus' );
223 + }
170 224
171 - if ( ( inp_value != '' ) && ( regex.test( inp_value ) == false ) ){
172 - wpbc_front_end__show_message__warning( el, message_verif_phone );
173 - fields_with_errors_arr.push( el );
174 - is_error_in_field = true; // Error
175 - }
176 - }
225 + return is_error_in_field;
226 +}
177 227
178 - ////////////////////////////////////////////////////////////////////////////////////////////
228 +/**
229 + * Hint labels inside of input boxes.
230 + */
231 +jQuery( document ).ready(
232 + function () {
179 233
180 - // Validate field value as "DIGIT" [CSS class - 'validate_as_digit']
181 - 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 + );
182 240
183 - var regex = new RegExp( '^[0-9]+\\.?[0-9]*$' ); // Check for digits
184 - var message_verif_phone = 'This field must contain only digits';
185 - var inp_value = jQuery( el ).val();
186 -
187 - if ( ( inp_value != '' ) && ( regex.test( inp_value ) == false ) ){
188 - wpbc_front_end__show_message__warning( el, message_verif_phone );
189 - fields_with_errors_arr.push( el );
190 - is_error_in_field = true; // Error
191 - }
192 - }
193 -
194 - ////////////////////////////////////////////////////////////////////////////////////////////
195 -
196 - // Validate field value as "Phone" number or any other valid number wth specific number of digits [CSS class - 'validate_digit_8' || 'validate_digit_10' ]
197 - var is_validate_digit = cl_item.substring( 0, 15 );
198 -
199 - // Check if class start with 'validate_digit_'
200 - if ( 'validate_digit_' === is_validate_digit ){
201 -
202 - // Get number of digit in class: validate_digit_8 => 8 or validate_digit_10 => 10
203 - var digits_to_check = parseInt( cl_item.substring( 15 ) );
204 -
205 - // Check about any errors in
206 - if ( !isNaN( digits_to_check ) ){
207 -
208 - var regex = new RegExp( '^\\d{' + digits_to_check + '}$' ); // We was valid it as parseInt - only integer variable - digits_to_check
209 - var message_verif_phone = 'This field must contain ' + digits_to_check + ' digits';
210 - var inp_value = jQuery( el ).val();
211 -
212 - if ( ( inp_value != '' ) && ( regex.test( inp_value ) == false ) ){
213 - wpbc_front_end__show_message__warning( el, message_verif_phone );
214 - fields_with_errors_arr.push( el );
215 - is_error_in_field = true; // Error
216 - }
217 - }
218 - }
219 -
220 - ////////////////////////////////////////////////////////////////////////////////////////////
221 -
222 - });
223 - }
224 - }
241 + jQuery( 'input.has-inside-hint' ).on(
242 + 'blur',
243 + function () {
244 + if ( '' === this.value ) {
245 + jQuery( this ).siblings( '.inside_hint' ).css( 'visibility', '' );
246 + }
225 247 }
226 - } );
248 + ).on(
249 + 'focus',
250 + function () {
251 + jQuery( this ).siblings( '.inside_hint' ).css( 'visibility', 'hidden' );
252 + }
253 + );
227 254
228 - if ( fields_with_errors_arr.length > 0 ){
229 - jQuery( fields_with_errors_arr[ 0 ] ).trigger( 'focus' ); // FixIn: 9.3.1.9.
230 - }
255 + jQuery( '.booking_form_div input[type=button]' ).prop( "disabled", false );
231 256 }
257 +);
232 258
233 - return is_error_in_field;
234 -}
259 +// == WIZARD ===========================================================================================================
235 260
236 -
237 -// FixIn: 8.6.1.15.
238 261 /**
239 262 * Go to next specific step in Wizard style booking form, with
240 263 * check all required elements specific step, otherwise show warning message!
241 264 *
@@ -243,8 +266,9 @@
243 266 * @param step_num
244 267 * @returns {boolean}
245 268 */
246 269 function wpbc_wizard_step(el, step_num, step_from) {
270 +
247 271 var br_id = jQuery( el ).closest( 'form' ).find( 'input[name^="bk_type"]' ).val();
248 272
249 273 // FixIn: 8.8.1.5.
250 274 if ( (undefined == step_from) || (step_num > step_from) ) {
@@ -262,9 +286,10 @@
262 286 }
263 287 }
264 288
265 289 if ( br_id != undefined ) {
266 - jQuery( "#booking_form" + br_id + " .wpbc_wizard_step" ).css( { "display": "none" } ).removeClass( 'wpbc_wizard_step_hidden' );
290 + jQuery( "#booking_form" + br_id + " .wpbc_wizard_step" ).css( { "display": "none" } )
291 + .removeClass( 'wpbc_wizard_step_hidden' );
267 292 jQuery( "#booking_form" + br_id + " .wpbc_wizard_step" + step_num ).css( { "display": "block" } );
268 293 return jQuery( "#booking_form" + br_id + " .wpbc_wizard_step" + step_num );
269 294 }
270 295 }
@@ -309,58 +334,63 @@
309 334 }
310 335 );
311 336 }
312 337
313 -// FixIn: 10.1.3.2.
314 -jQuery( document ).ready( function (){
315 - wpbc_hook__init_booking_form_wizard_buttons();
316 -} );
317 338
318 -
319 -// FixIn: 8.6.1.15.
320 339 /**
321 340 * Check if at least one element from array of elements names in booking form visible or not.
322 341 * Usage Example: if ( wpbc_is_some_elements_visible( br_id, ['rangetime', 'durationtime', 'starttime', 'endtime'] )
323 342 * ){ ... }
324 343 *
325 - * @param bk_type
344 + * @param resource_id
326 345 * @param elements_names
327 346 * @returns {boolean}
328 347 */
329 -function wpbc_is_some_elements_visible( bk_type, elements_names ){
348 +function wpbc_is_some_elements_visible(resource_id, elements_names) {
330 349
331 - var is_some_elements_visible = false;
350 + var my_form = jQuery( '#booking_form' + resource_id );
332 351
333 - var my_form = jQuery( '#booking_form' + bk_type );
352 + if ( ! my_form.length ) {
353 + return false;
354 + }
334 355
335 - 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) {
336 360
337 - // Pseudo-selector that get form elements <input , <textarea , <select, <button...
338 - my_form.find( ':input' ).each( function ( index, el ){
361 + // Skip some elements.
362 + var skip_elements = [ 'hidden', 'button' ];
339 363
340 - // Skip some elements
341 - var skip_elements = ['hidden', 'button'];
364 + if ( -1 == skip_elements.indexOf( jQuery( el ).attr( 'type' ) ) ) {
342 365
343 - if ( -1 == skip_elements.indexOf( jQuery( el ).attr( 'type' ) ) ){
366 + for ( var ei = 0; ei < (elements_names.length - 1); ei++ ) {
344 367
345 - 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' ) ) {
346 370
347 - // Check Calendar Dates Selection
348 - 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 + );
349 379
350 - if ( jQuery( el ).is( ':visible' ) ){
351 - is_some_elements_visible = true;
352 - }
353 - }
354 - }
355 - }
356 - } );
357 - }
358 - return is_some_elements_visible;
380 + return is_some_elements_visible;
359 381 }
360 382
361 -// == Days Selections - support functions ==============================================================================
362 383
384 +jQuery( document ).ready(
385 + function () {
386 + wpbc_hook__init_booking_form_wizard_buttons();
387 + }
388 +);
389 +
390 +
391 +// == DAYS_SELECTIONS ==================================================================================================
392 +
363 393 /**
364 394 * Get first day of selection
365 395 *
366 396 * @param dates
@@ -397,9 +427,15 @@
397 427 // Single day selection
398 428 return dates; //20.12.2013
399 429 }
400 430
401 -// Get last day of selection
431 +
432 +/**
433 + * Get last day of selection.
434 + *
435 + * @param dates
436 + * @returns {*|string}
437 + */
402 438 function get_last_day_of_selection(dates) {
403 439
404 440 // Multiple days selections
405 441 if ( dates.indexOf(',') != -1 ){
@@ -447,10 +483,8 @@
447 483
448 484 var id_additional_str = document.getElementById( 'additional_calendars' + bk_type ).value;
449 485 var id_additional_arr = id_additional_str.split( ',' );
450 486
451 - var is_all_additional_days_unselected = true;
452 -
453 487 for ( var ia = 0; ia < id_additional_arr.length; ia++ ){
454 488 if ( document.getElementById( 'date_booking' + id_additional_arr[ ia ] ).value != '' ){
455 489 selected_additionl_calendars.push( id_additional_arr[ ia ] );
456 490 }
@@ -458,11 +492,11 @@
458 492 }
459 493 return selected_additionl_calendars;
460 494 }
461 495
462 -// ---------------------------------------------------------------------------------------------------------------------
463 -// Elementor Ready Widget Update.
464 -// ---------------------------------------------------------------------------------------------------------------------
496 +
497 +// == ELEMENTOR Ready Widget Update ====================================================================================
498 +
465 499 jQuery( function ($) {
466 500 // FixIn: 10.14.15.1.
467 501 if ( (window.elementorFrontend) && ('undefined' !== typeof (elementorFrontend.hooks)) ) {
468 502
@@ -478,24 +512,25 @@
478 512 }
479 513 } );
480 514
481 515 // Elementor widget reinit. So we need to reinit all "jQuery( document ).ready( ...) " again with custom 'wpbc_elementor_ready' event.
482 -jQuery( document ).on( 'wpbc_elementor_ready', function () {
516 +jQuery( document ).on(
517 + 'wpbc_elementor_ready',
518 + function () {
483 519
484 - wpbc_hook__init_booking_form_wizard_buttons();
520 + wpbc_hook__init_booking_form_wizard_buttons();
485 521
486 - if ( 'function' === typeof (wpbc_hook__init_timeselector) ) {
487 - wpbc_hook__init_timeselector();
488 - }
522 + if ( 'function' === typeof (wpbc_hook__init_timeselector) ) {
523 + wpbc_hook__init_timeselector();
524 + }
489 525
490 - if ( 'function' === typeof (wpbc_update_capacity_hint) ) {
491 - jQuery( '.booking_form_div' ).on( 'wpbc_booking_date_or_option_selected', function (event, resource_id) {
492 - wpbc_update_capacity_hint( resource_id );
493 - } );
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 +
494 535 }
495 -
496 - // TODO:
497 - // <?php if ('wpbc_theme_dark_1' === get_bk_option( 'booking_form_theme' ) ){ ?>
498 - // jQuery( '.wpbc_widget_preview_booking_form .wpbc_center_preview,.wpbc_widget_preview_booking_form .wpbc_container.wpbc_container_booking_form,.wpbc_widget_preview_booking_form .wpbc_widget_content' ).addClass( 'wpbc_theme_dark_1' );
499 - // <?php } ?>
500 -
501 -} );
536 +);