PluginProbe
Booking Calendar / 11.1
Booking Calendar v11.1
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
booking / includes / _feedback / feedback.js

feedback.js in Booking Calendar 11.1, at includes/_feedback/feedback.js

268 lines 8.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Open feedback Modal window
3 */
4 function wpbc_open_feedback_modal(){
5 if ( 'function' === typeof( jQuery('#wpbc_modal__feedback_01__section').wpbc_my_modal ) ) {
6
7 // Insert Feedback modal after 'wpbc-admin-page' section, for ability to blur this content
8 var wpbc_modal__feedback_01 = jQuery( '#wpbc_modal__feedback_01__section_mover' ).detach();
9 wpbc_modal__feedback_01.appendTo( '.wrap.wpbc_page' );
10
11 // Add blur
12 jQuery( '.wpbc_admin_page,.wpbc_admin_message,.wpbc_header' ).css( { filter: 'blur(3px)' } );
13
14 // Show Modal
15 jQuery('#wpbc_modal__feedback_01__section').wpbc_my_modal('show');
16 } else {
17 console.log( 'Warning! wpbc_my_modal module has not found. Please, recheck about any conflicts by deactivating other plugins.');
18 }
19
20 }
21
22 // Remove blur, after closing modal
23 jQuery('#wpbc_modal__feedback_01__section').on('hide.wpbc.modal', function (event) {
24 //var modal = jQuery(this);
25 jQuery( '.wpbc_admin_page,.wpbc_admin_message,.wpbc_header' ).css( {filter: 'none'} );
26 })
27
28
29 /**
30 * Click on Stars to rate
31 *
32 * @param int star_num_over - star number
33 * @param string is_over - mouse action 'click' | 'over' | 'out'
34 */
35 function wpbc_feedback_01__over_star( star_num_over , is_over ){
36
37 var star_fill = 'wpbc-bi-star-fill'; //'wpbc_icn_star';
38 var star_outline = 'wpbc-bi-star'; //'wpbc_icn_star_outline';
39
40 if ( 'click' == is_over ){
41 jQuery( '.wpbc_mouseover_star_selected' ).removeClass( 'wpbc_mouseover_star_selected' );
42 jQuery( '#wpbc_modal__feedback_01__button_next__step_1').removeClass('disabled');
43 }
44 if ( 'over' == is_over ){
45 jQuery( '.wpbc_mouseover_star_selected' ).removeClass( star_fill ).addClass( star_outline );
46 }
47
48 for ( var star_num = 1; star_num <= star_num_over; star_num++ ){
49
50 if ( 'click' == is_over ){
51
52 jQuery( '#wpbc_feedback_01_star_' + star_num + ' i' ).removeClass( star_outline ).addClass( star_fill+ ' wpbc_mouseover_star_selected' );
53 }
54 if ( 'over' == is_over ){
55 jQuery( '#wpbc_feedback_01_star_' + star_num + ' i' ).removeClass( star_outline ).addClass( star_fill );
56 }
57 if ( 'out' == is_over ){
58 jQuery( '#wpbc_feedback_01_star_' + star_num + ' i' ).removeClass( star_fill ).addClass( star_outline );
59 }
60 }
61 if ( 'out' == is_over ){
62 jQuery( '.wpbc_mouseover_star_selected' ).removeClass( star_outline ).addClass( star_fill );
63 }
64
65 }
66
67
68 /**
69 * Click on Next button to show next section.
70 *
71 * @param _this
72 * @param go_to_this_step 'class' of section to show
73 * @returns {boolean}
74 */
75 function wpbc_ajx_booking__ui_click__send_feedback_01(_this, go_to_this_step = ''){
76
77 if ( jQuery( _this ).hasClass( 'disabled' ) ){
78 return false;
79 }
80
81 jQuery( '.wpbc_modal__feedback_01__steps').hide();
82
83 if ( '' != go_to_this_step ){
84 jQuery( go_to_this_step ).show();
85 return;
86 }
87
88 var stars_selected = jQuery( '.wpbc_mouseover_star_selected').length;
89
90
91
92 switch (stars_selected) {
93 case 1:
94 case 2:
95 jQuery( '.wpbc_modal__feedback_01__step_2').show();
96 break;
97 case 3:
98 case 4:
99 jQuery( '.wpbc_modal__feedback_01__step_4').show();
100 break;
101 case 5:
102 jQuery( '.wpbc_modal__feedback_01__step_6').show();
103 break;
104 default:
105
106 }
107
108 return;
109
110 var visible_step = jQuery( '.wpbc_modal__feedback_01__steps:visible');
111 jQuery( '.wpbc_modal__feedback_01__steps').hide();
112 visible_step.next().show();
113 }
114
115 function wpbc_ajx_booking__ui_click__close_feedback_01(){
116 // Close modal
117 if ( 'function' === typeof( jQuery('#wpbc_modal__feedback_01__section').wpbc_my_modal ) ){
118 jQuery( '#wpbc_modal__feedback_01__section' ).wpbc_my_modal( 'hide' );
119 }
120 }
121
122
123 // Ajax Sending:
124
125 /**
126 * Click on Remind later link
127 * Send ajax request for opening feedback in few days
128 */
129 function wpbc_ajx_booking__ui_click__feedback_01_remind_later(){
130
131
132 wpbc_feedback__ajax_action_request( {
133 'booking_action' : 'feedback_01',
134 'feedback_stars' : jQuery( '.wpbc_mouseover_star_selected').length,
135 'feedback__note' : 'remind_later',
136 'ui_clicked_element_id': 'wpbc_modal__feedback_01__button_next__step_1'
137 } );
138 wpbc_button_enable_loading_icon( jQuery( '#wpbc_modal__feedback_01__button_next__step_1' ).get( 0 ) );
139
140 wpbc_ajx_booking__ui_click__close_feedback_01(); // Close modal
141 }
142
143
144 /**
145 * Click on Done | Submit button to send feedback
146 *
147 * @param _this
148 * @param go_to_this_step 'class' of last section
149 */
150 function wpbc_ajx_booking__ui_click__submit_feedback_01( _this, go_to_this_step){
151
152 if ( jQuery( _this ).hasClass( 'disabled' ) ){
153 return false;
154 }
155
156 var stars_selected = jQuery( '.wpbc_mouseover_star_selected').length;
157 var feedback__note = '';
158
159 switch ( go_to_this_step ) {
160
161 case '.wpbc_modal__feedback_01__step_3':
162 feedback__note = jQuery( '#wpbc_modal__feedback_01__reason_of_action__step_2').val();
163 break;
164
165 case '.wpbc_modal__feedback_01__step_5':
166 feedback__note = jQuery( '#wpbc_modal__feedback_01__reason_of_action__step_4').val();
167 break;
168
169 case '.wpbc_modal__feedback_01__step_7':
170 feedback__note = jQuery( '#wpbc_modal__feedback_01__reason_of_action__step_7').val();
171 break;
172
173 default:
174
175 }
176
177 // Send Ajax
178 wpbc_feedback__ajax_action_request( {
179 'booking_action' : 'feedback_01',
180 'feedback_stars' : stars_selected,
181 'feedback__note' : feedback__note,
182 'ui_clicked_element_id': jQuery( _this ).attr( 'id' )
183 } );
184 wpbc_button_enable_loading_icon( jQuery( _this ).get( 0 ) );
185
186 //wpbc_ajx_booking__ui_click__close_feedback_01(); // Close modal
187 }
188
189
190 function wpbc_feedback__ajax_action_request( action_param ){
191
192 wpbc_admin_show_message_processing( '' );
193
194 var jq_el = jQuery( '#wpbc_ajax__feedback_01' );
195
196 var action_post_params = {
197 action : 'WPBC_AJX_FEEDBACK',
198 nonce : jq_el.attr( 'data-nonce' ),
199 wpbc_ajx_user_id: jq_el.attr( 'data-user-id' ),
200
201 action_params : action_param
202 };
203
204 // Start Ajax
205 jQuery.post( wpbc_url_ajax ,
206
207 action_post_params ,
208
209 /**
210 * S u c c e s s
211 *
212 * @param response_data - its object returned from Ajax - class-live-searcg.php
213 * @param textStatus - 'success'
214 * @param jqXHR - Object
215 */
216 function ( response_data, textStatus, jqXHR ) {
217
218 console.log( ' == Ajax Feedback :: Response WPBC_AJX_BOOKING_ACTIONS == ', response_data );
219
220 // Probably Error
221 if ( (typeof response_data !== 'object') || (response_data === null) ){
222
223 wpbc_admin_show_message(
224 '<div class="wpbc-settings-notice notice-warning" style="text-align:left">' +
225 response_data +
226 '</div>'
227 );
228 return;
229 }
230
231 wpbc_admin_show_message(
232 response_data[ 'ajx_after_action_message' ].replace( /\n/g, "<br />" )
233 , ( '1' == response_data[ 'ajx_after_action_result' ] ) ? 'success' : 'error'
234 , 10000
235 );
236
237 var closed_timer = setTimeout( function (){
238 if ( 5 == response_data['ajx_after_action_result_all_params_arr'][ 'feedback_stars' ] ){
239 document.location.href = 'https://wordpress.org/support/plugin/booking/reviews/#new-post';
240 // document.location.href = 'https://wordpress.org/plugins/booking/#reviews';
241 // document.location.href = 'https://wordpress.org/support/plugin/booking/reviews/?filter=5#new-post'
242 }
243 }
244 , 2000 );
245
246 // Remove spin icon from button and Enable this button.
247 wpbc_button__remove_spin( response_data[ 'ajx_cleaned_params' ][ 'ui_clicked_element_id' ] )
248
249 // Hide modals
250 wpbc_popup_modals__hide();
251
252 jQuery( '#ajax_respond' ).html( response_data ); // For ability to show response, add such DIV element to page
253 }
254 ).fail( function ( jqXHR, textStatus, errorThrown ) { if ( window.console && window.console.log ){ console.log( 'Ajax_Error', jqXHR, textStatus, errorThrown ); }
255
256 var error_message = '<strong>' + 'Error!' + '</strong> ' + errorThrown ;
257 if ( jqXHR.responseText ){
258 error_message += jqXHR.responseText;
259 }
260 error_message = error_message.replace( /\n/g, "<br />" );
261
262 wpbc_ajx_booking_show_message( error_message );
263 })
264 // .done( function ( data, textStatus, jqXHR ) { if ( window.console && window.console.log ){ console.log( 'second success', data, textStatus, jqXHR ); } })
265 // .always( function ( data_jqXHR, textStatus, jqXHR_errorThrown ) { if ( window.console && window.console.log ){ console.log( 'always finished', data_jqXHR, textStatus, jqXHR_errorThrown ); } })
266 ; // End Ajax
267
268 }