PluginProbe
Booking Calendar / 11.6
Booking Calendar v11.6
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
booking / includes / page-bookings / _src / bookings__hooks.js

bookings__hooks.js in Booking Calendar 11.6, at includes/page-bookings/_src/bookings__hooks.js

189 lines 8.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2
3 /**
4 * Define HTML ui Hooks: on KeyUp | Change | -> Sort Order & Number Items / Page
5 * * We are chnaged it once, because such elements always the same
6 */
7 function wpbc_ajx_booking_define_ui_hooks_once(){
8
9 //------------------------------------------------------------------------------------------------------------------
10 // Booked dates
11 //------------------------------------------------------------------------------------------------------------------
12 jQuery( '#wh_booking_date' ).on( 'change', function( event ){
13
14 var changed_value = JSON.parse( jQuery( '#wh_booking_date' ).val() );
15
16 wpbc_ajx_booking_send_search_request_with_params( {
17 'wh_booking_date': changed_value,
18 'page_num' : 1,
19 // Frontend selected elements (saving for future use, after F5)
20 'ui_wh_booking_date_radio' : jQuery( 'input[name="ui_wh_booking_date_radio"]:checked' ).val(),
21 'ui_wh_booking_date_next' : jQuery( '#ui_wh_booking_date_next' ).val(),
22 'ui_wh_booking_date_prior' : jQuery( '#ui_wh_booking_date_prior' ).val(),
23 'ui_wh_booking_date_checkin' : jQuery( '#ui_wh_booking_date_checkin' ).val(),
24 'ui_wh_booking_date_checkout': jQuery( '#ui_wh_booking_date_checkout' ).val()
25 } );
26 } );
27
28 //------------------------------------------------------------------------------------------------------------------
29 // Approved | Pending | All
30 //------------------------------------------------------------------------------------------------------------------
31 jQuery( '#wh_approved' ).on( 'change', function( event ){
32
33 var changed_value = jQuery( '#wh_approved' ).val();
34
35 changed_value = JSON.parse( changed_value );
36
37 wpbc_ajx_booking_send_search_request_with_params( {
38 'wh_approved': changed_value[ 0 ],
39 'page_num' : 1
40 } );
41 } );
42
43 //------------------------------------------------------------------------------------------------------------------
44 // Keywords
45 //------------------------------------------------------------------------------------------------------------------
46 jQuery( '#wpbc_search_field' ).on( "keyup", function ( event ){
47 if ( 13 !== event.which ){
48 wpbc_ajx_booking_searching_after_few_seconds( '#wpbc_search_field' ); // Searching after 1.5 seconds after Key Up
49 } else {
50 wpbc_ajx_booking_searching_after_few_seconds( '#wpbc_search_field', 0 ); // Immediate search
51 }
52 } );
53
54 //------------------------------------------------------------------------------------------------------------------
55 // Existing | Trash | Any
56 //------------------------------------------------------------------------------------------------------------------
57 jQuery( '#wh_trash' ).on( 'change', function( event ){
58
59 var changed_value = JSON.parse( jQuery( '#wh_trash' ).val() );
60
61 wpbc_ajx_booking_send_search_request_with_params( {
62 'wh_trash': changed_value[ 0 ],
63 'page_num': 1
64 } );
65 } );
66
67 //------------------------------------------------------------------------------------------------------------------
68 // All bookings | New bookings
69 //------------------------------------------------------------------------------------------------------------------
70 jQuery( '#wh_what_bookings' ).on( 'change', function( event ){
71
72 var changed_value = JSON.parse( jQuery( '#wh_what_bookings' ).val() );
73
74 wpbc_ajx_booking_send_search_request_with_params( {
75 'wh_what_bookings': changed_value[ 0 ],
76 'page_num': 1
77 } );
78 } );
79
80 //------------------------------------------------------------------------------------------------------------------
81 // "Creation Date" of bookings
82 //------------------------------------------------------------------------------------------------------------------
83 jQuery( '#wh_modification_date' ).on( 'change', function( event ){
84
85 var changed_value = JSON.parse( jQuery( '#wh_modification_date' ).val() );
86
87 wpbc_ajx_booking_send_search_request_with_params( {
88 'wh_modification_date': changed_value,
89 'page_num' : 1,
90 // Frontend selected elements (saving for future use, after F5)
91 'ui_wh_modification_date_radio' : jQuery( 'input[name="ui_wh_modification_date_radio"]:checked' ).val(),
92 'ui_wh_modification_date_prior' : jQuery( '#ui_wh_modification_date_prior' ).val(),
93 'ui_wh_modification_date_checkin' : jQuery( '#ui_wh_modification_date_checkin' ).val(),
94 'ui_wh_modification_date_checkout': jQuery( '#ui_wh_modification_date_checkout' ).val()
95 } );
96 } );
97
98 //------------------------------------------------------------------------------------------------------------------
99 // Payment Status
100 //------------------------------------------------------------------------------------------------------------------
101 jQuery( '#wh_pay_status' ).on( 'change', function( event ){
102
103 var changed_value = JSON.parse( jQuery( '#wh_pay_status' ).val() );
104
105 wpbc_ajx_booking_send_search_request_with_params( {
106 'wh_pay_status': changed_value,
107 'page_num' : 1,
108 // Frontend selected elements (saving for future use, after F5)
109 'ui_wh_pay_status_radio' : ( ( undefined === jQuery( 'input[name="ui_wh_pay_status_radio"]:checked' ).val() )
110 ? ''
111 : jQuery( 'input[name="ui_wh_pay_status_radio"]:checked' ).val()
112 ),
113 'ui_wh_pay_status_custom': jQuery( '#ui_wh_pay_status_custom' ).val()
114 } );
115
116
117 } );
118
119 //------------------------------------------------------------------------------------------------------------------
120 // Min Cost
121 //------------------------------------------------------------------------------------------------------------------
122 jQuery( '#wh_cost' ).on( 'change', function( event ){
123
124 var changed_value = jQuery( '#wh_cost' ).val();
125
126 wpbc_ajx_booking_send_search_request_with_params( {
127 'wh_cost' : changed_value,
128 'page_num': 1
129 } );
130 } );
131
132 //------------------------------------------------------------------------------------------------------------------
133 // Max Cost
134 //------------------------------------------------------------------------------------------------------------------
135 jQuery( '#wh_cost2' ).on( 'change', function( event ){
136
137 var changed_value = jQuery( '#wh_cost2' ).val();
138
139 wpbc_ajx_booking_send_search_request_with_params( {
140 'wh_cost2' : changed_value,
141 'page_num': 1
142 } );
143 } );
144
145 //------------------------------------------------------------------------------------------------------------------
146 // Reusable Chosen listing filters, such as Booking resources/Providers and Appointment Services.
147 //------------------------------------------------------------------------------------------------------------------
148 jQuery( 'select[data-wpbc-listing-filter-param]' ).on( 'change', function(){
149
150 var listing_filter_param = jQuery( this ).attr( 'data-wpbc-listing-filter-param' );
151 var changed_value;
152 var request_updates;
153
154 if ( ! listing_filter_param ) {
155 return;
156 }
157
158 changed_value = ( 'function' === typeof window.wpbc_ui_chosen_filter_get_request_value )
159 ? window.wpbc_ui_chosen_filter_get_request_value( this )
160 : jQuery( this ).val();
161 request_updates = {
162 'page_num': 1
163 };
164 request_updates[ listing_filter_param ] = changed_value;
165
166 wpbc_ajx_booking_send_search_request_with_params( request_updates );
167 } );
168
169
170 //------------------------------------------------------------------------------------------------------------------
171 // Sorting
172 //------------------------------------------------------------------------------------------------------------------
173 jQuery( '#wh_sort' ).on( 'change', function( event ){
174
175 var changed_value = jQuery( '#wh_sort' ).val();
176
177 changed_value = JSON.parse( changed_value );
178
179 wpbc_ajx_booking_send_search_request_with_params( {
180 'wh_sort': changed_value[ 0 ]
181 } );
182 } );
183
184 }
185
186 jQuery(document).ready(function(){
187 wpbc_ajx_booking_define_ui_hooks_once();
188 });
189