PluginProbe
Booking Calendar / 11.2
Booking Calendar v11.2
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 10.11 All 204 releases
booking / includes / elementor-booking-form / _src / wpbc-elementor.js

wpbc-elementor.js in Booking Calendar 11.2, at includes/elementor-booking-form/_src/wpbc-elementor.js

68 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery( document ).ready( function ($) {
2
3 /**
4 * Ajax save.
5 */
6 $( document ).on( 'click', '.elementor-save-skin', function () {
7
8
9 const $button = $( this );
10 const $controlWrapper = $button.closest( '.elementor-control-content' );
11 const $select = $controlWrapper.find( '.elementor-control-input-wrapper select' );
12 const selectedSkin = $select.val();
13
14 const html_id = $button.attr( 'id' );
15 const nonce = WPBC_Ajax.nonce;
16
17 // UI feedback: processing state.
18 $button.attr( 'saved_title', $button.text() );
19 $button.text( $button.attr( 'processing_title' ) + '...' );
20 $button.prop( 'disabled', true );
21
22 $.ajax(
23 {
24 url: WPBC_Ajax.ajax_url,
25 type: 'POST',
26 data: {
27 action: 'wpbc_save_calendar_skin',
28 skin: selectedSkin,
29 _ajax_nonce: nonce,
30 html_id: html_id,
31 },
32 success: function (response) {
33
34 // Restore button state.
35 if ( html_id ) {
36 const $btn = $( document.getElementById( html_id ) );
37 $btn.prop( 'disabled', false ).text( $btn.attr( 'saved_title' ) ).removeAttr( 'saved_title' );
38 }
39
40 if ( ! response.success ) {
41 console.warn( 'Skin save failed:', response.data || 'Unknown error' );
42 return;
43 }
44
45 const savedSkinUrl = response.data?.url_full;
46 console.log( 'Skin saved successfully:', savedSkinUrl );
47 },
48 error : function () {
49
50 console.error( 'AJAX error occurred during skin save.' );
51 // Optional: restore button UI.
52 if ( html_id ) {
53 const $btn = $( '#' + html_id );
54 $btn.prop( 'disabled', false ).text( $btn.attr( 'saved_title' ) ).removeAttr( 'saved_title' );
55 }
56 }
57 }
58 );
59 } );
60
61 $( document ).on( 'click', '.wpbc-reset-dates-button', function () {
62 // Clear input values directly
63 $( 'input[data-setting="wpbc_booking_calendar_dates_start"]' ).val( '' ).trigger( 'input' );
64 $( 'input[data-setting="wpbc_booking_calendar_dates_end"]' ).val( '' ).trigger( 'input' );
65 $( 'input[data-setting="wpbc_booking_calendar_startmonth"]' ).val( '' ).trigger( 'input' );
66 } );
67 } );
68