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-bookings/_src/bookings__listing.js +130 -42 10.10 → 11.9 View file →
@@ -103,8 +103,9 @@
103 103
104 104 console.groupCollapsed('AJX_BOOKING_LISTING'); console.log( ' == Before Ajax Send - search_get_all_params() == ' , wpbc_ajx_booking_listing.search_get_all_params() );
105 105
106 106 wpbc_booking_listing_reload_button__spin_start();
107 + wpbc_booking_listing_reload__message_show();
107 108
108 109 /*
109 110 //FixIn: forVideo
110 111 if ( ! is_this_action ){
@@ -141,12 +142,15 @@
141 142 function ( response_data, textStatus, jqXHR ) {
142 143 //FixIn: forVideo
143 144 //jQuery( '#wpbc_loading_section' ).wpbc_my_modal( 'hide' );
144 145
146 +try {
145 147 console.log( ' == Response WPBC_AJX_BOOKING_LISTING == ', response_data ); console.groupEnd();
146 148 // Probably Error
147 149 if ( (typeof response_data !== 'object') || (response_data === null) ){
148 150 jQuery( '.wpbc_ajx_under_toolbar_row' ).hide(); // FixIn: 9.6.1.5.
151 + wpbc_booking_listing_reload_button__spin_pause();
152 + wpbc_booking_listing_reload__message_hide();
149 153 jQuery( wpbc_ajx_booking_listing.get_other_param( 'listing_container' ) ).html(
150 154 '<div class="wpbc-settings-notice notice-warning" style="text-align:left">' +
151 155 response_data +
152 156 '</div>'
@@ -157,9 +161,11 @@
157 161 // Reload page, after filter toolbar was reseted
158 162 if ( ( undefined != response_data[ 'ajx_cleaned_params' ])
159 163 && ( 'reset_done' === response_data[ 'ajx_cleaned_params' ][ 'ui_reset' ])
160 164 ){
161 - location.reload();
165 + wpbc_booking_listing_reload__message_hide();
166 + window.location.href = response_data[ 'ajx_cleaned_params' ]['ui_reset_url'];
167 + // location.reload();
162 168 return;
163 169 }
164 170
165 171 // Show listing
@@ -168,14 +174,17 @@
168 174 wpbc_ajx_booking_show_listing( response_data[ 'ajx_items' ], response_data[ 'ajx_search_params' ], response_data[ 'ajx_booking_resources' ] );
169 175
170 176 wpbc_pagination_echo(
171 177 wpbc_ajx_booking_listing.get_other_param( 'pagination_container' ),
178 + wpbc_ajx_booking_listing.get_other_param( 'pagination_container_header' ),
179 + wpbc_ajx_booking_listing.get_other_param( 'pagination_container_footer' ),
172 180 {
173 181 'page_active': response_data[ 'ajx_search_params' ][ 'page_num' ],
174 182 'pages_count': Math.ceil( response_data[ 'ajx_count' ] / response_data[ 'ajx_search_params' ][ 'page_items_count' ] ),
175 183
176 184 'page_items_count': response_data[ 'ajx_search_params' ][ 'page_items_count' ],
177 - 'sort_type' : response_data[ 'ajx_search_params' ][ 'sort_type' ]
185 + 'sort_type' : response_data[ 'ajx_search_params' ][ 'sort_type' ],
186 + 'total_count' : response_data[ 'ajx_count' ],
178 187 }
179 188 );
180 189 wpbc_ajx_booking_define_ui_hooks(); // Redefine Hooks, because we show new DOM elements
181 190
@@ -182,13 +191,17 @@
182 191 } else {
183 192
184 193 wpbc_ajx_booking__actual_listing__hide();
185 194 jQuery( wpbc_ajx_booking_listing.get_other_param( 'listing_container' ) ).html(
186 - '<div class="wpbc-settings-notice0 notice-warning0" style="text-align:center;margin-left:-50px;">' +
187 - '<strong>' + 'No results found for current filter options...' + '</strong>' +
188 - //'<strong>' + 'No results found...' + '</strong>' +
189 - '</div>'
190 - );
195 + '<div class="wpbc-settings-notice0 notice-warning0" style="text-align:center;font-size: 15px;margin: 2em 0;">' +
196 + '<p><strong>No results found for current filter options...</strong></p>' +
197 + '<p><strong><a href="javascript:void(0)" ' +
198 + ' onclick="javascript:wpbc_ajx_booking_send_search_request_with_params( {' +
199 + ' \'ui_reset\': \'make_reset\', ' +
200 + ' \'page_num\': 1 ' +
201 + '} );">Reset filters</a> to show all bookings.</strong></p>' +
202 + '</div>'
203 + );
191 204 }
192 205
193 206 // Update new booking count
194 207 if ( undefined !== response_data[ 'ajx_new_bookings_count' ] ){
@@ -199,13 +212,20 @@
199 212 jQuery( '.bk-update-count' ).html( ajx_new_bookings_count );
200 213 }
201 214
202 215 wpbc_booking_listing_reload_button__spin_pause();
216 + wpbc_booking_listing_reload__message_hide();
203 217
204 218 jQuery( '#ajax_respond' ).html( response_data ); // For ability to show response, add such DIV element to page
219 +} finally {
220 + wpbc_booking_listing_reload_button__spin_pause();
221 + wpbc_booking_listing_reload__message_hide();
222 +}
205 223 }
206 224 ).fail( function ( jqXHR, textStatus, errorThrown ) { if ( window.console && window.console.log ){ console.log( 'Ajax_Error', jqXHR, textStatus, errorThrown ); }
207 225 jQuery( '.wpbc_ajx_under_toolbar_row' ).hide(); // FixIn: 9.6.1.5.
226 + wpbc_booking_listing_reload_button__spin_pause();
227 + wpbc_booking_listing_reload__message_hide();
208 228 var error_message = '<strong>' + 'Error!' + '</strong> ' + errorThrown ;
209 229 if ( jqXHR.responseText ){
210 230 error_message += jqXHR.responseText;
211 231 }
@@ -234,16 +254,19 @@
234 254
235 255 //console.log( 'json_items_arr' , json_items_arr, json_search_params );
236 256 jQuery( '.wpbc_ajx_under_toolbar_row' ).css( "display", "flex" ); // FixIn: 9.6.1.5.
237 257 var list_header_tpl = wp.template( 'wpbc_ajx_booking_list_header' );
258 + var list_footer_tpl = wp.template( 'wpbc_ajx_booking_list_footer' );
238 259 var list_row_tpl = wp.template( 'wpbc_ajx_booking_list_row' );
239 260
240 261
241 - // Header
262 + // Header.
242 263 jQuery( wpbc_ajx_booking_listing.get_other_param( 'listing_container' ) ).html( list_header_tpl() );
243 -
244 - // Body
264 + // Send to template all request params: jQuery( wpbc_ajx_booking_listing.get_other_param( 'listing_container' ) ).html( list_header_tpl(wpbc_ajx_booking_listing.search_get_all_params()) );
265 + // Body.
245 266 jQuery( wpbc_ajx_booking_listing.get_other_param( 'listing_container' ) ).append( '<div class="wpbc_selectable_body"></div>' );
267 + // Footer.
268 + jQuery( wpbc_ajx_booking_listing.get_other_param( 'listing_container' ) ).append( list_footer_tpl() );
246 269
247 270 // R o w s
248 271 console.groupCollapsed( 'LISTING_ROWS' ); // LISTING_ROWS
249 272 _.each( json_items_arr, function ( p_val, p_key, p_data ){
@@ -269,27 +292,32 @@
269 292 * @param json_booking_resources - JSON object with Resources
270 293 */
271 294 function wpbc_ajx_define_templates__resource_manipulation( json_items_arr, json_search_params, json_booking_resources ){
272 295
273 - // Change booking resource
274 - var change_booking_resource_tpl = wp.template( 'wpbc_ajx_change_booking_resource' );
296 + // -------------------------------------------------------------------------------------------------------------
297 + // New. 2025-04-21.
298 + // -------------------------------------------------------------------------------------------------------------
299 + // Change booking resource in Modal.
300 + var modal__change_booking_resource = wp.template( 'wpbc_ajx__modal__change_booking_resource' );
275 301
276 - jQuery( '#wpbc_hidden_template__change_booking_resource' ).html(
277 - change_booking_resource_tpl( {
302 + jQuery( '#section_in_in_modal__change_booking_resource' ).html(
303 + modal__change_booking_resource( {
278 304 'ajx_search_params' : json_search_params,
279 305 'ajx_booking_resources': json_booking_resources
280 306 } )
281 307 );
282 308
283 - // Duplicate booking resource
284 - var duplicate_booking_to_other_resource_tpl = wp.template( 'wpbc_ajx_duplicate_booking_to_other_resource' );
309 + // Duplicate booking into another resource in Modal. New. 2025-04-21.
310 + var modal__duplicate_booking_to_other_resource = wp.template( 'wpbc_ajx__modal__duplicate_booking_to_other_resource' );
285 311
286 - jQuery( '#wpbc_hidden_template__duplicate_booking_to_other_resource' ).html(
287 - duplicate_booking_to_other_resource_tpl( {
312 + jQuery( '#section_in_in_modal__duplicate_booking_to_other_resource' ).html(
313 + modal__duplicate_booking_to_other_resource( {
288 314 'ajx_search_params' : json_search_params,
289 315 'ajx_booking_resources': json_booking_resources
290 316 } )
291 317 );
318 + // -------------------------------------------------------------------------------------------------------------
319 +
292 320 }
293 321
294 322
295 323 /**
@@ -379,38 +407,46 @@
379 407
380 408 /**
381 409 * Define Dynamic Hooks (like pagination click, which renew each time with new listing showing) ------------- */
382 410
383 -/**
384 - * Define HTML ui Hooks: on KeyUp | Change | -> Sort Order & Number Items / Page
385 - * We are hcnaged it each time, when showing new listing, because DOM elements chnaged
386 - */
387 -function wpbc_ajx_booking_define_ui_hooks(){
411 + /**
412 + * Define HTML ui Hooks: on KeyUp | Change | -> Sort Order & Number Items / Page
413 + * We are hcnaged it each time, when showing new listing, because DOM elements chnaged
414 + */
415 + function wpbc_ajx_booking_define_ui_hooks() {
388 416
389 - if ( 'function' === typeof( wpbc_define_tippy_tooltips ) ) {
390 - wpbc_define_tippy_tooltips( '.wpbc_listing_container ' );
391 - }
417 + if ( 'function' === typeof (wpbc_define_tippy_tooltips) ) {
418 + wpbc_define_tippy_tooltips( '.wpbc__list__table ' );
419 + }
392 420
393 - wpbc_ajx_booking__ui_define__locale();
394 - wpbc_ajx_booking__ui_define__remark();
421 + wpbc_ajx_booking__ui_define__locale();
422 + wpbc_ajx_booking__ui_define__remark();
395 423
396 - // Items Per Page
397 - jQuery( '.wpbc_items_per_page' ).on( 'change', function( event ){
424 + wpbc_boo_listing__init_hook__sort_by();
398 425
399 - wpbc_ajx_booking_send_search_request_with_params( {
400 - 'page_items_count' : jQuery( this ).val(),
401 - 'page_num': 1
402 - } );
403 - } );
426 + // Items Per Page.
427 + jQuery( '.wpbc_items_per_page' ).on(
428 + 'change',
429 + function (event) {
430 + wpbc_ajx_booking_send_search_request_with_params(
431 + {
432 + 'page_items_count': jQuery( this ).val(),
433 + 'page_num' : 1
434 + }
435 + );
436 + }
437 + );
404 438
405 - // Sorting
406 - jQuery( '.wpbc_items_sort_type' ).on( 'change', function( event ){
439 + // Sorting.
440 + jQuery( '.wpbc_items_sort_type' ).on(
441 + 'change',
442 + function (event) {
443 + wpbc_ajx_booking_send_search_request_with_params( { 'sort_type': jQuery( this ).val() } );
444 + }
445 + );
446 + }
407 447
408 - wpbc_ajx_booking_send_search_request_with_params( {'sort_type': jQuery( this ).val()} );
409 - } );
410 -}
411 448
412 -
413 449 /**
414 450 * Show / Hide Listing --------------------------------------------------------------------------------------- */
415 451
416 452 /**
@@ -520,8 +556,60 @@
520 556 jQuery( '#wpbc_booking_listing_reload_button .menu_icon.wpbc_spin' ).addClass( 'wpbc_animation_pause' );
521 557 }
522 558
523 559 /**
560 + * Show visible feedback while Booking Listing is loading.
561 + */
562 +function wpbc_booking_listing_reload__message_show(){
563 +
564 + var ajax_working = document.getElementById( 'ajax_working' );
565 +
566 + if ( ! ajax_working ) {
567 + return;
568 + }
569 +
570 + wpbc_booking_listing_reload__message_hide();
571 +
572 + var listing_container = '';
573 + if (
574 + ( 'undefined' !== typeof wpbc_ajx_booking_listing )
575 + && ( 'function' === typeof wpbc_ajx_booking_listing.get_other_param )
576 + ) {
577 + listing_container = wpbc_ajx_booking_listing.get_other_param( 'listing_container' );
578 + }
579 +
580 + if (
581 + listing_container
582 + && jQuery( listing_container ).find( '.wpbc_spins_loading_container' ).length
583 + ) {
584 + return;
585 + }
586 +
587 + var unique_div_id = 'wpbc_notice_' + ( new Date() ).getTime();
588 +
589 + jQuery( ajax_working ).append(
590 + '<div id="' + unique_div_id + '" class="wpbc_booking_listing_reload_notice" style="opacity: 1;">' +
591 + '<div id="wpbc_alert_message" class="wpbc_alert_message">' +
592 + '<div class="wpbc_inner_message notice notice-info "> ' +
593 + '<a class="close" href="javascript:void(0)" onclick="javascript:jQuery(this).parent().hide();">&times;</a> ' +
594 + '<span class="wpdevelop wpbc_booking_listing_reload_processing">' +
595 + '<span class="wpbc_icn_rotate_right wpbc_spin wpbc_ajax_icon wpbc_processing wpbc_icn_autorenew" aria-hidden="true"></span>' +
596 + '</span> Loading bookings...' +
597 + '</div>' +
598 + '</div>' +
599 + '</div>'
600 + );
601 +}
602 +
603 +/**
604 + * Hide Booking Listing loading feedback.
605 + */
606 +function wpbc_booking_listing_reload__message_hide(){
607 + jQuery( '.wpbc_booking_listing_reload_notice' ).remove();
608 + jQuery( '.wpbc_booking_listing_reload_processing' ).closest( '[id^="wpbc_notice_"], .wpbc_inner_message' ).remove();
609 +}
610 +
611 +/**
524 612 * Spin button in Filter toolbar - is Spinning ?
525 613 *
526 614 * @returns {boolean}
527 615 */
@@ -530,5 +618,5 @@
530 618 return true;
531 619 } else {
532 620 return false;
533 621 }
534 -}
622 +}