PluginProbe
Booking Calendar / 10.10.2
Booking Calendar v10.10.2
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 10.11.2 All 203 releases
booking / includes / page-setup / _src / setup_show.js

setup_show.js in Booking Calendar 10.10.2, at includes/page-setup/_src/setup_show.js

316 lines 11.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2
3 /**
4 * Parameters usually defined in Ajax Response or Front-End for == _wpbc_settings.get_all_params__setup_wizard():
5 *
6 * In Front-End side as JavaScript :: wpbc_ajx__setup_wizard_page__send_request_with_params( { 'current_step': 'optional_other_settings', 'do_action': 'none', 'ui_clicked_element_id': 'btn__toolbar__buttons_prior' } );
7 *
8 * After Ajax response in setup_ajax.js as :: _wpbc_settings.set_params_arr__setup_wizard( response_data[ 'ajx_data' ] );
9 *
10 */
11
12 // =====================================================================================================================
13 // == Set Request for Ajax ==
14 // =====================================================================================================================
15 /**
16 * Send Ajax Request after Updating Request Parameters
17 *
18 * @param params_arr
19 *
20 * Example 1:
21 *
22 * wpbc_ajx__setup_wizard_page__send_request_with_params( {
23 * 'page_num': page_number
24 * } );
25 * Example 2:
26 *
27 * wpbc_ajx__setup_wizard_page__send_request_with_params( {
28 * 'current_step': '{{data.steps[ data.current_step ].prior}}',
29 * 'do_action': 'none',
30 * 'ui_clicked_element_id': 'btn__toolbar__buttons_prior'
31 * } );
32 *
33 */
34 function wpbc_ajx__setup_wizard_page__send_request_with_params ( params_arr ){
35
36 // Define Params Array to Request
37 _wpbc_settings.set_params_arr__setup_wizard( params_arr );
38
39 // Send Ajax Request
40 wpbc_ajx__setup_wizard_page__send_request();
41 }
42 // Example 1: wpbc_ajx__setup_wizard_page__send_request_with_params( { 'page_num': page_number } );
43 // Example 2: wpbc_ajx__setup_wizard_page__send_request_with_params( { 'current_step': 'optional_other_settings', 'do_action': 'none', 'ui_clicked_element_id': 'btn__toolbar__buttons_prior' } );
44
45
46 // =====================================================================================================================
47 // == Show / Hide Content ==
48 // =====================================================================================================================
49 /**
50 * Show Main Content ... _wpbc_settings.get_all_params__setup_wizard() - must be defined!
51 */
52 function wpbc_setup_wizard_page__show_content() {
53
54 var wpbc_template__stp_wiz__main_content = wp.template( 'wpbc_template__stp_wiz__main_content' );
55
56 jQuery( _wpbc_settings.get_param__other( 'container__main_content' ) ).html( wpbc_template__stp_wiz__main_content( _wpbc_settings.get_all_params__setup_wizard() ) );
57
58 // Hide 'Processing' Notice
59 jQuery( '.wpbc_processing.wpbc_spin').parent().parent().parent().parent( '[id^="wpbc_notice_"]' ).hide();
60
61 //var header_menu_text = ' Step ' + wpbc_setup_wizard_page__get_actual_step_number() + ' / ' + wpbc_setup_wizard_page__get_steps_count();
62 //jQuery( '.wpbc_header_menu_tabs .nav-tab-active .nav-tab-text').html( header_menu_text );
63 //
64 //jQuery( '.wpbc_navigation_menu_left_item ' ).removeClass( 'wpbc_active' );
65 //jQuery( '#' + _wpbc_settings.get_param__setup_wizard( 'current_step' ) ).addClass( 'wpbc_active' );
66
67 // Recheck Full Screen mode, by removing top tab
68 wpbc_check_full_screen_mode();
69
70 // Scroll to top
71 wpbc_scroll_to( '.wpbc_page_top__header_tabs' );
72 }
73
74 /**
75 * Hide Main Content
76 */
77 function wpbc_setup_wizard_page__hide_content(){
78
79 jQuery( _wpbc_settings.get_param__other( 'container__main_content' ) ).html( '' );
80 }
81
82
83 /**
84 * Update Plugin menu progress -> Progress line at "Left Main Menu"
85 */
86 function wpbc_setup_wizard_page__update_plugin_menu_progress( plugin_menu__setup_progress__html ){
87 if ( 'undefined' != typeof (plugin_menu__setup_progress__html) ){
88 jQuery( '.setup_wizard_page_container' ).parent().html( plugin_menu__setup_progress__html );
89 }
90 }
91
92 // ---------------------------------------------------------------------------------------------------------------------
93 // == Steps Number Functions ==
94 // Gets data in _wpbc_settings.get_all_params__setup_wizard().steps
95 // which defined in setup_ajax.php Ajax
96 // as $data_arr ['steps'] = new WPBC_SETUP_WIZARD_STEPS(); $this->get_steps_arr(); from setup_steps.php structure.
97 // ---------------------------------------------------------------------------------------------------------------------
98
99 function wpbc_setup_wizard_page__get_steps_count() {
100
101 var params_arr = _wpbc_settings.get_all_params__setup_wizard().steps
102 var steps_count = 0
103 _.each( params_arr, function ( p_val, p_key, p_data ) {
104 steps_count++;
105 } );
106 return steps_count;
107 }
108
109 function wpbc_setup_wizard_page__get_actual_step_number() {
110
111 var params_arr = _wpbc_settings.get_all_params__setup_wizard().steps
112 var steps_finished = 1
113 _.each( params_arr, function ( p_val, p_key, p_data ) {
114 if ( p_val.is_done ){
115 steps_finished++;
116 }
117 } );
118 return steps_finished;
119 }
120
121 function wpbc_setup_wizard_page__update_steps_status( steps_is_done_arr ){
122
123 var params_arr = _wpbc_settings.get_all_params__setup_wizard().steps
124
125 _.each( steps_is_done_arr, function ( p_val, p_key, p_data ) {
126 if ( "undefined" !== typeof ( params_arr[ p_key ] ) ) {
127 params_arr[ p_key ].is_done = (true === steps_is_done_arr[ p_key ]);
128 }
129 } );
130
131 return params_arr;
132
133 }
134
135
136 function wpbc_setup_wizard_page__is_all_steps_completed(){
137
138 var params_arr = _wpbc_settings.get_all_params__setup_wizard().steps
139 var status = true;
140
141 _.each( params_arr, function ( p_val, p_key, p_data ) {
142 if ( ! p_val.is_done ){
143 status = false;
144 }
145 } );
146
147 return status;
148 }
149
150
151 /**
152 * Define UI hooks for elements, after showing in Ajax.
153 *
154 * Because each time, when we show content in Ajax, all Hooks needs re-defined.
155 */
156 function wpbc_setup_wizard_page__define_ui_hooks(){
157
158 // -----------------------------------------------------------------------------------------------------------------
159 // Tooltips
160 if ( 'function' === typeof( wpbc_define_tippy_tooltips ) ) {
161 var parent_css_class = _wpbc_settings.get_param__other( 'container__main_content' ) + ' '
162 wpbc_define_tippy_tooltips( parent_css_class );
163 }
164
165 // -----------------------------------------------------------------------------------------------------------------
166 // Change Radio Containers
167 jQuery( '.wpbc_ui_radio_choice_input' ).on( 'change', function( event ){
168
169 wpbc_ui_el__radio_container_selection( this );
170
171 //wpbc_ajx__setup_wizard_page__send_request_with_params( { 'page_items_count': jQuery( this ).val(), 'page_num': 1 } );
172 } );
173
174 jQuery( '.wpbc_ui_radio_choice_input' ).each(function (index ){
175 wpbc_ui_el__radio_container_selection( this );
176 });
177
178 // Define ability to click on Radio Containers (not only radio-buttons)
179 jQuery( '.wpbc_ui_radio_container' ).on( 'click', function( event ){
180 wpbc_ui_el__radio_container_click( this );
181 } );
182
183 // -----------------------------------------------------------------------------------------------------------------
184
185
186 }
187
188
189 //TODO: maybe relocate this functions in other utils js file ?
190
191 // =====================================================================================================================
192 // == Full Screen - support functions ==
193 // =====================================================================================================================
194
195 /**
196 * Check Full screen mode, by removing top tab
197 */
198 function wpbc_check_full_screen_mode(){
199 if ( jQuery( 'body' ).hasClass( 'wpbc_admin_full_screen' ) ) {
200 jQuery( 'html' ).removeClass( 'wp-toolbar' );
201 } else {
202 jQuery( 'html' ).addClass( 'wp-toolbar' );
203 }
204 }
205 jQuery( document ).ready( function () {
206 wpbc_check_full_screen_mode();
207 } );
208
209
210
211 // ---------------------------------------------------------------------------------------------------------------------
212 // == M e s s a g e ==
213 // ---------------------------------------------------------------------------------------------------------------------
214
215 /**
216 * Show message in content
217 *
218 * @param message Message HTML
219 * @param params = {
220 * ['type'] 'warning' | 'info' | 'error' | 'success' default: 'warning'
221 * ['container'] '.wpbc_ajx_cstm__section_left' default: _wpbc_settings.get_param__other( 'container__main_content')
222 * ['is_append'] true | false default: true
223 * }
224 * Example:
225 * var html_id = wpbc_setup_wizard_page__show_message( 'You can test days selection in calendar', 'info', '.wpbc_ajx_cstm__section_left', true );
226 *
227 *
228 * @returns string - HTML ID
229 */
230 function wpbc_setup_wizard_page__show_message( message, params = {} ){
231
232 var params_default = {
233 'type' : 'warning',
234 'container': _wpbc_settings.get_param__other( 'container__main_content'),
235 'is_append': true,
236 'style' : 'text-align:left;',
237 'delay' : 0
238 };
239 _.each( params, function ( p_val, p_key, p_data ){
240 params_default[ p_key ] = p_val;
241 } );
242 params = params_default;
243
244 var unique_div_id = new Date();
245 unique_div_id = 'wpbc_notice_' + unique_div_id.getTime();
246
247 var alert_class = 'notice ';
248 if ( params['type'] == 'error' ){
249 alert_class += 'notice-error ';
250 message = '<i style="margin-right: 0.5em;color: #d63638;" class="menu_icon icon-1x wpbc_icn_report_gmailerrorred"></i>' + message;
251 }
252 if ( params['type'] == 'warning' ){
253 alert_class += 'notice-warning ';
254 message = '<i style="margin-right: 0.5em;color: #e9aa04;" class="menu_icon icon-1x wpbc_icn_warning"></i>' + message;
255 }
256 if ( params['type'] == 'info' ){
257 alert_class += 'notice-info ';
258 }
259 if ( params['type'] == 'success' ){
260 alert_class += 'notice-info alert-success updated ';
261 message = '<i style="margin-right: 0.5em;color: #64aa45;" class="menu_icon icon-1x wpbc_icn_done_outline"></i>' + message;
262 }
263
264 message = '<div id="' + unique_div_id + '" class="wpbc-settings-notice ' + alert_class + '" style="' + params[ 'style' ] + '">' + message + '</div>';
265
266 if ( params['is_append'] ){
267 jQuery( params['container'] ).append( message );
268 } else {
269 jQuery( params['container'] ).html( message );
270 }
271
272 params['delay'] = parseInt( params['delay'] );
273 if ( params['delay'] > 0 ){
274
275 var closed_timer = setTimeout( function (){
276 jQuery( '#' + unique_div_id ).fadeOut( 1500 );
277 }
278 , params[ 'delay' ]
279 );
280 }
281 return unique_div_id;
282 }
283
284
285 // ---------------------------------------------------------------------------------------------------------------------
286 // == Support Functions - Spin Icon in Top Bar Menu -> ' Initial Setup' ==
287 // ---------------------------------------------------------------------------------------------------------------------
288
289 /**
290 * Spin button in Filter toolbar - Start
291 */
292 function wpbc_setup_wizard_page_reload_button__spin_start(){
293 return false; // Currently disabled, maybe activate it for some other element.
294 jQuery( '#wpbc_initial_setup_top_menu_item .menu_icon.wpbc_spin').removeClass( 'wpbc_animation_pause' );
295 }
296
297 /**
298 * Spin button in Filter toolbar - Pause
299 */
300 function wpbc_setup_wizard_page_reload_button__spin_pause(){
301 jQuery( '#wpbc_initial_setup_top_menu_item .menu_icon.wpbc_spin' ).addClass( 'wpbc_animation_pause' );
302 }
303
304 /**
305 * Spin button in Filter toolbar - is Spinning ?
306 *
307 * @returns {boolean}
308 */
309 function wpbc_setup_wizard_page_reload_button__is_spin(){
310 if ( jQuery( '#wpbc_initial_setup_top_menu_item .menu_icon.wpbc_spin' ).hasClass( 'wpbc_animation_pause' ) ){
311 return true;
312 } else {
313 return false;
314 }
315 }
316