PluginProbe
Booking Calendar / 11.2
Booking Calendar v11.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 / __js / admin / settings / ui_sidebar_left__actions.js

ui_sidebar_left__actions.js in Booking Calendar 11.2, at includes/__js/admin/settings/ui_sidebar_left__actions.js

304 lines 12.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2 // =====================================================================================================================
3 // == Left Bar - expand / colapse functions ==
4 // =====================================================================================================================
5
6 /**
7 * Expand Vertical Left Bar.
8 */
9 function wpbc_admin_ui__sidebar_left__do_max() {
10 jQuery( '.wpbc_settings_page_wrapper' ).removeClass( 'min max compact none' );
11 jQuery( '.wpbc_settings_page_wrapper' ).addClass( 'max' );
12 jQuery( '.wpbc_ui__top_nav__btn_open_left_vertical_nav' ).addClass( 'wpbc_ui__hide' );
13 jQuery( '.wpbc_ui__top_nav__btn_hide_left_vertical_nav' ).removeClass( 'wpbc_ui__hide' );
14
15 jQuery( '.wp-admin' ).removeClass( 'wpbc_page_wrapper_left_min wpbc_page_wrapper_left_max wpbc_page_wrapper_left_compact wpbc_page_wrapper_left_none' );
16 jQuery( '.wp-admin' ).addClass( 'wpbc_page_wrapper_left_max' );
17 }
18
19 /**
20 * Hide Vertical Left Bar.
21 */
22 function wpbc_admin_ui__sidebar_left__do_min() {
23 jQuery( '.wpbc_settings_page_wrapper' ).removeClass( 'min max compact none' );
24 jQuery( '.wpbc_settings_page_wrapper' ).addClass( 'min' );
25 jQuery( '.wpbc_ui__top_nav__btn_open_left_vertical_nav' ).removeClass( 'wpbc_ui__hide' );
26 jQuery( '.wpbc_ui__top_nav__btn_hide_left_vertical_nav' ).addClass( 'wpbc_ui__hide' );
27
28 jQuery( '.wp-admin' ).removeClass( 'wpbc_page_wrapper_left_min wpbc_page_wrapper_left_max wpbc_page_wrapper_left_compact wpbc_page_wrapper_left_none' );
29 jQuery( '.wp-admin' ).addClass( 'wpbc_page_wrapper_left_min' );
30 }
31
32 /**
33 * Colapse Vertical Left Bar.
34 */
35 function wpbc_admin_ui__sidebar_left__do_compact() {
36 jQuery( '.wpbc_settings_page_wrapper' ).removeClass( 'min max compact none' );
37 jQuery( '.wpbc_settings_page_wrapper' ).addClass( 'compact' );
38 jQuery( '.wpbc_ui__top_nav__btn_open_left_vertical_nav' ).removeClass( 'wpbc_ui__hide' );
39 jQuery( '.wpbc_ui__top_nav__btn_hide_left_vertical_nav' ).addClass( 'wpbc_ui__hide' );
40
41 jQuery( '.wp-admin' ).removeClass( 'wpbc_page_wrapper_left_min wpbc_page_wrapper_left_max wpbc_page_wrapper_left_compact wpbc_page_wrapper_left_none' );
42 jQuery( '.wp-admin' ).addClass( 'wpbc_page_wrapper_left_compact' );
43 }
44
45 /**
46 * Completely Hide Vertical Left Bar.
47 */
48 function wpbc_admin_ui__sidebar_left__do_hide() {
49 jQuery( '.wpbc_settings_page_wrapper' ).removeClass( 'min max compact none' );
50 jQuery( '.wpbc_settings_page_wrapper' ).addClass( 'none' );
51 jQuery( '.wpbc_ui__top_nav__btn_open_left_vertical_nav' ).removeClass( 'wpbc_ui__hide' );
52 jQuery( '.wpbc_ui__top_nav__btn_hide_left_vertical_nav' ).addClass( 'wpbc_ui__hide' );
53 // Hide top "Menu" button with divider.
54 jQuery( '.wpbc_ui__top_nav__btn_show_left_vertical_nav,.wpbc_ui__top_nav__btn_show_left_vertical_nav_divider' ).addClass( 'wpbc_ui__hide' );
55
56 jQuery( '.wp-admin' ).removeClass( 'wpbc_page_wrapper_left_min wpbc_page_wrapper_left_max wpbc_page_wrapper_left_compact wpbc_page_wrapper_left_none' );
57 jQuery( '.wp-admin' ).addClass( 'wpbc_page_wrapper_left_none' );
58 }
59
60 /**
61 * Action on click "Go Back" - show root menu
62 * or some other section in left sidebar.
63 *
64 * @param string menu_to_show - menu slug.
65 */
66 function wpbc_admin_ui__sidebar_left__show_section( menu_to_show ) {
67 jQuery( '.wpbc_ui_el__vert_left_bar__section' ).addClass( 'wpbc_ui__hide' )
68 jQuery( '.wpbc_ui_el__vert_left_bar__section_' + menu_to_show ).removeClass( 'wpbc_ui__hide' );
69 }
70
71 // =====================================================================================================================
72 // == Right Side Bar - expand / colapse functions ==
73 // =====================================================================================================================
74
75 /**
76 * Expand Vertical Right Bar.
77 */
78 function wpbc_admin_ui__sidebar_right__do_max() {
79 jQuery( '.wpbc_settings_page_wrapper' ).removeClass( 'min_right max_right compact_right none_right' );
80 jQuery( '.wpbc_settings_page_wrapper' ).addClass( 'max_right' );
81 jQuery( '.wpbc_ui__top_nav__btn_open_right_vertical_nav' ).addClass( 'wpbc_ui__hide' );
82 jQuery( '.wpbc_ui__top_nav__btn_hide_right_vertical_nav' ).removeClass( 'wpbc_ui__hide' );
83 }
84
85 /**
86 * Hide Vertical Right Bar.
87 */
88 function wpbc_admin_ui__sidebar_right__do_min() {
89 jQuery( '.wpbc_settings_page_wrapper' ).removeClass( 'min_right max_right compact_right none_right' );
90 jQuery( '.wpbc_settings_page_wrapper' ).addClass( 'min_right' );
91 jQuery( '.wpbc_ui__top_nav__btn_open_right_vertical_nav' ).removeClass( 'wpbc_ui__hide' );
92 jQuery( '.wpbc_ui__top_nav__btn_hide_right_vertical_nav' ).addClass( 'wpbc_ui__hide' );
93 }
94
95 /**
96 * Colapse Vertical Right Bar.
97 */
98 function wpbc_admin_ui__sidebar_right__do_compact() {
99 jQuery( '.wpbc_settings_page_wrapper' ).removeClass( 'min_right max_right compact_right none_right' );
100 jQuery( '.wpbc_settings_page_wrapper' ).addClass( 'compact_right' );
101 jQuery( '.wpbc_ui__top_nav__btn_open_right_vertical_nav' ).removeClass( 'wpbc_ui__hide' );
102 jQuery( '.wpbc_ui__top_nav__btn_hide_right_vertical_nav' ).addClass( 'wpbc_ui__hide' );
103 }
104
105 /**
106 * Completely Hide Vertical Right Bar.
107 */
108 function wpbc_admin_ui__sidebar_right__do_hide() {
109 jQuery( '.wpbc_settings_page_wrapper' ).removeClass( 'min_right max_right compact_right none_right' );
110 jQuery( '.wpbc_settings_page_wrapper' ).addClass( 'none_right' );
111 jQuery( '.wpbc_ui__top_nav__btn_open_right_vertical_nav' ).removeClass( 'wpbc_ui__hide' );
112 jQuery( '.wpbc_ui__top_nav__btn_hide_right_vertical_nav' ).addClass( 'wpbc_ui__hide' );
113 // Hide top "Menu" button with divider.
114 jQuery( '.wpbc_ui__top_nav__btn_show_right_vertical_nav,.wpbc_ui__top_nav__btn_show_right_vertical_nav_divider' ).addClass( 'wpbc_ui__hide' );
115 }
116
117 /**
118 * Action on click "Go Back" - show root menu
119 * or some other section in right sidebar.
120 *
121 * @param string menu_to_show - menu slug.
122 */
123 function wpbc_admin_ui__sidebar_right__show_section( menu_to_show ) {
124 jQuery( '.wpbc_ui_el__vert_right_bar__section' ).addClass( 'wpbc_ui__hide' )
125 jQuery( '.wpbc_ui_el__vert_right_bar__section_' + menu_to_show ).removeClass( 'wpbc_ui__hide' );
126 }
127
128 // =====================================================================================================================
129 // == End Right Side Bar section ==
130 // =====================================================================================================================
131
132 /**
133 * Get anchor(s) array from URL.
134 * Doc: https://developer.mozilla.org/en-US/docs/Web/API/Location
135 *
136 * @returns {*[]}
137 */
138 function wpbc_url_get_anchors_arr() {
139 var hashes = window.location.hash.replace( '%23', '#' );
140 var hashes_arr = hashes.split( '#' );
141 var result = [];
142 var hashes_arr_length = hashes_arr.length;
143
144 for ( var i = 0; i < hashes_arr_length; i++ ) {
145 if ( hashes_arr[i].length > 0 ) {
146 result.push( hashes_arr[i] );
147 }
148 }
149 return result;
150 }
151
152 /**
153 * Auto Expand Settings section based on URL anchor, after page loaded.
154 */
155 jQuery( document ).ready( function () { wpbc_admin_ui__redirect_legacy_general_availability_url(); } );
156 jQuery( document ).ready( function () { wpbc_admin_ui__do_expand_section(); setTimeout( 'wpbc_admin_ui__do_expand_section', 10 ); } );
157 jQuery( document ).ready( function () { wpbc_admin_ui__do_expand_section(); setTimeout( 'wpbc_admin_ui__do_expand_section', 150 ); } );
158
159 /**
160 * Redirect old Settings > Availability anchors to the dedicated General Availability page.
161 */
162 function wpbc_admin_ui__redirect_legacy_general_availability_url() {
163
164 if (
165 ( window.location.href.indexOf( 'page=wpbc-settings' ) > -1 )
166 && (
167 ( window.location.hash.indexOf( 'wpbc_general_settings_availability_metabox' ) > -1 )
168 || ( window.location.hash.indexOf( 'wpbc_general_settings_availability_tab' ) > -1 )
169 )
170 ) {
171 window.location.replace( window.location.href.split( '?' )[0] + '?page=wpbc-availability&tab=general_availability' );
172 }
173 }
174
175 /**
176 * Expand section in General Settings page and select Menu item.
177 */
178 function wpbc_admin_ui__do_expand_section() {
179
180 // window.location.hash = #section_id / doc: https://developer.mozilla.org/en-US/docs/Web/API/Location .
181 var anchors_arr = wpbc_url_get_anchors_arr();
182 var anchors_arr_length = anchors_arr.length;
183
184 if ( anchors_arr_length > 0 ) {
185 var one_anchor_prop_value = anchors_arr[0].split( 'do_expand__' );
186 if ( one_anchor_prop_value.length > 1 ) {
187
188 // 'wpbc_general_settings_calendar_metabox'
189 var section_to_show = one_anchor_prop_value[1];
190 var section_id_to_show = '#' + section_to_show;
191
192
193 // -- Remove selected background in all left menu items ---------------------------------------------------
194 jQuery( '.wpbc_ui_el__vert_nav_item ' ).removeClass( 'active' );
195 // Set left menu selected.
196 jQuery( '.do_expand__' + section_to_show + '_link' ).addClass( 'active' );
197 var selected_title = jQuery( '.do_expand__' + section_to_show + '_link a .wpbc_ui_el__vert_nav_title ' ).text();
198
199 // Expand section, if it colapsed.
200 if ( ! jQuery( '.do_expand__' + section_to_show + '_link' ).parents( '.wpbc_ui_el__level__folder' ).hasClass( 'expanded' ) ) {
201 jQuery( '.wpbc_ui_el__level__folder' ).removeClass( 'expanded' );
202 jQuery( '.do_expand__' + section_to_show + '_link' ).parents( '.wpbc_ui_el__level__folder' ).addClass( 'expanded' );
203 }
204
205 // -- Expand section ---------------------------------------------------------------------------------------
206 var container_to_hide_class = '.postbox';
207 // Hide sections '.postbox' in admin page and show specific one.
208 jQuery( '.wpbc_admin_page ' + container_to_hide_class ).hide();
209 jQuery( '.wpbc_container_always_hide__on_left_nav_click' ).hide();
210 jQuery( section_id_to_show ).show();
211
212 // Show all other sections, if provided in URL: ..?page=wpbc-settings#do_expand__wpbc_general_settings_capacity_metabox#wpbc_general_settings_capacity_upgrade_metabox .
213 for ( let i = 1; i < anchors_arr_length; i++ ) {
214 jQuery( '#' + anchors_arr[i] ).show();
215 }
216
217 if ( false ) {
218 var targetOffset = wpbc_scroll_to( section_id_to_show );
219 }
220
221 // -- Set Value to Input about selected Nav element --------------------------------------------------------------- // FixIn: 9.8.6.1.
222 var section_id_tab = section_id_to_show.substring( 0, section_id_to_show.length - 8 ) + '_tab';
223 if ( container_to_hide_class == section_id_to_show ) {
224 section_id_tab = '#wpbc_general_settings_all_tab'
225 }
226 if ( '#wpbc_general_settings_capacity_metabox,#wpbc_general_settings_capacity_upgrade_metabox' == section_id_to_show ) {
227 section_id_tab = '#wpbc_general_settings_capacity_tab'
228 }
229 jQuery( '#form_visible_section' ).val( section_id_tab );
230 }
231
232 // Like blinking some elements.
233 wpbc_admin_ui__do__anchor__another_actions();
234 }
235 }
236
237 function wpbc_admin_ui__is_in_mobile_screen_size() {
238 return wpbc_admin_ui__is_in_this_screen_size( 605 );
239 }
240
241 function wpbc_admin_ui__is_in_this_screen_size(size) {
242 return (window.screen.width <= size);
243 }
244
245 /**
246 * Open settings page | Expand section | Select Menu item.
247 */
248 function wpbc_admin_ui__do__open_url__expand_section(url, section_id) {
249
250 // window.location.href = url + '&do_expand=' + section_id + '#do_expand__' + section_id; //.
251 window.location.href = url + '#do_expand__' + section_id;
252
253 if ( wpbc_admin_ui__is_in_mobile_screen_size() ) {
254 wpbc_admin_ui__sidebar_left__do_min();
255 }
256
257 wpbc_admin_ui__do_expand_section();
258 }
259
260
261 /**
262 * Check for Other actions: Like blinking some elements in settings page. E.g. Days selection or change-over days.
263 */
264 function wpbc_admin_ui__do__anchor__another_actions() {
265
266 var anchors_arr = wpbc_url_get_anchors_arr();
267 var anchors_arr_length = anchors_arr.length;
268
269 // Other actions: Like blinking some elements.
270 for ( var i = 0; i < anchors_arr_length; i++ ) {
271
272 var this_anchor = anchors_arr[i];
273
274 var this_anchor_prop_value = this_anchor.split( 'do_other_actions__' );
275
276 if ( this_anchor_prop_value.length > 1 ) {
277
278 var section_action = this_anchor_prop_value[1];
279
280 switch ( section_action ) {
281
282 case 'blink_day_selections':
283 // wpbc_ui_settings__panel__click( '#wpbc_general_settings_calendar_tab a', '#wpbc_general_settings_calendar_metabox', 'Days Selection' );.
284 wpbc_blink_element( '.wpbc_tr_set_gen_booking_type_of_day_selections', 4, 350 );
285 wpbc_scroll_to( '.wpbc_tr_set_gen_booking_type_of_day_selections' );
286 break;
287
288 case 'blink_change_over_days':
289 // wpbc_ui_settings__panel__click( '#wpbc_general_settings_calendar_tab a', '#wpbc_general_settings_calendar_metabox', 'Changeover Days' );.
290 wpbc_blink_element( '.wpbc_tr_set_gen_booking_range_selection_time_is_active', 4, 350 );
291 wpbc_scroll_to( '.wpbc_tr_set_gen_booking_range_selection_time_is_active' );
292 break;
293
294 case 'blink_captcha':
295 wpbc_blink_element( '.wpbc_tr_set_gen_booking_is_use_captcha', 4, 350 );
296 wpbc_scroll_to( '.wpbc_tr_set_gen_booking_is_use_captcha' );
297 break;
298
299 default:
300 }
301 }
302 }
303 }
304