PluginProbe
Booking Calendar / 11.8.4
Booking Calendar v11.8.4
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
← All changes | core/any/js/admin-support.js +133 -103 10.1011.8.4 View file →
@@ -10,20 +10,69 @@
10 10 *
11 11 * @modified 2015-04-09
12 12 */
13 13
14 +function wpbc_parse_url_and_get_params_arr( url ) {
15 +
16 + var url_parameters = url.split( '?' )[1];
17 + var result_params_arr = {};
18 + var url_parameters_arr = url_parameters.split( /\?|&/ );
19 + var param_length = url_parameters_arr.length;
20 + for ( var i = 0; i < param_length; i++ ) {
21 + if ( ! url_parameters_arr[i] ) {
22 + continue;
23 + }
24 + var ary = url_parameters_arr[i].split( '=' );
25 + result_params_arr[ary[0]] = ary[1];
26 + }
27 + return result_params_arr;
28 +}
29 +
30 +function wpbc_ui_settings__menu__click( url, left_vert_nav_menu_a, section_id_to_show, text_for_path ){
31 +
32 + var current_page_params = wpbc_parse_url_and_get_params_arr( window.location.href );
33 + var destination_page_params = wpbc_parse_url_and_get_params_arr( url );
34 +
35 + var is_this_same_page = 0;
36 +
37 + if (current_page_params['page'] === destination_page_params['page']){
38 + is_this_same_page++;
39 + }
40 + if (
41 + ( (typeof( current_page_params['tab'] ) === 'undefined') && (typeof( destination_page_params['tab'] ) === 'undefined') ) ||
42 + ( (current_page_params['tab'] === destination_page_params['tab']) )
43 + ) {
44 + is_this_same_page++;
45 + }
46 + if (
47 + ( (typeof( current_page_params['subtab'] ) === 'undefined') && (typeof( destination_page_params['subtab'] ) === 'undefined') ) ||
48 + ( (current_page_params['subtab'] === destination_page_params['subtab']) )
49 + ) {
50 + is_this_same_page++;
51 + }
52 +
53 + if ( 3 === is_this_same_page ) {
54 + wpbc_ui_settings__panel__click( left_vert_nav_menu_a, section_id_to_show, text_for_path )
55 + } else {
56 + window.location.href = url;
57 + }
58 +
59 +}
60 +
14 61 function wpbc_ui_settings__panel__click( left_vert_nav_menu_a, section_id_to_show, text_for_path ){
15 62
16 - // Update text in Top Menu
17 - jQuery( '.wpbc_settings_path_el_active' ).html(
18 - '<a onclick="javascript:wpbc_ui_settings__panel__click( \''+ left_vert_nav_menu_a +'\', \''+ section_id_to_show +'\', \''+ text_for_path +'\' );" href="javascript:void(0);">' + text_for_path + '</a>'
19 - );
63 + // Update text in Top Menu.
64 + jQuery( '.wpbc_settings_path_el_active' ).html(
65 + '<a onclick="javascript:wpbc_ui_settings__panel__click( \'' + left_vert_nav_menu_a + '\', \'' + section_id_to_show + '\', \'' + text_for_path + '\' );" href="javascript:void(0);">' + text_for_path + '</a>'
66 + );
20 67
21 68 // Show / Hide section and enable Left Vert Menu item
22 69 wpbc_navigation_click_show_section( left_vert_nav_menu_a, section_id_to_show , '.postbox' , false);
23 70
24 - //wpbc_scroll_to( '.wpbc_settings_path_el_active' ); // Scroll to path
25 - wpbc_scroll_to( '.wpbc_page_top__header_tabs' ); // Scroll to Top
71 + // wpbc_scroll_to( '.wpbc_settings_path_el_active' ); // Scroll to path.
72 + // wpbc_scroll_to( '.wpbc_page_top__header_tabs' ); // Scroll to Top.
73 + wpbc_scroll_to( '.wpbc_settings_page_header_title' ); // Scroll to Top.
74 +
26 75 }
27 76
28 77
29 78 /**
@@ -64,26 +113,40 @@
64 113 *
65 114 * @param {type} object_name
66 115 * @returns {undefined}
67 116 */
68 -function wpbc_scroll_to( object_name ) {
69 - if ( jQuery( object_name ).length > 0 ) {
70 - var targetOffset = jQuery( object_name ).offset().top;
71 - // targetOffset = targetOffset - 50;
72 - if (targetOffset<0) targetOffset = 0;
73 - if ( jQuery('#wpadminbar').length > 0 ) targetOffset = targetOffset - 50;
74 - else targetOffset = targetOffset - 20;
75 - jQuery('html,body').animate({scrollTop: targetOffset}, 500);
76 - return targetOffset;
77 - }
78 - return 0;
117 +function wpbc_scroll_to(object_name) {
118 +
119 + if ( jQuery( object_name ).length > 0 ) {
120 + var targetOffset = jQuery( object_name ).offset().top;
121 + if ( targetOffset < 0 ) {
122 + targetOffset = 0;
123 + }
124 + if ( jQuery( '#wpadminbar' ).length > 0 ) {
125 + targetOffset = targetOffset - 50 - 40;
126 + } else {
127 + targetOffset = targetOffset - 20;
128 + }
129 + jQuery( 'html,body' ).animate( { scrollTop: targetOffset }, 500 );
130 + return targetOffset;
131 + }
132 + return 0;
79 133 }
80 134
81 -jQuery( document ).ready(function(){
82 - setTimeout(function() {
83 - wpbc_scroll_to( window.location.hash );
84 - }, 100)
85 -});
135 +/**
136 + * Auto scroll to unchor after page loaded.
137 + */
138 +jQuery( document ).ready(
139 + function () {
140 + setTimeout(
141 + function () {
142 + // window.location.hash = #section_id / doc: https://developer.mozilla.org/en-US/docs/Web/API/Location .
143 + wpbc_scroll_to( window.location.hash );
144 + },
145 + 100
146 + );
147 + }
148 +);
86 149
87 150 function wpbc_animate_border( element, time, colors, x ) {
88 151
89 152 if ( x >= colors.length ) {
@@ -222,9 +285,10 @@
222 285 function wpbc_close_dropdown_selectbox( selector_id ) {
223 286 jQuery('#' + selector_id + '_container li input[type=checkbox],#' + selector_id + '_container li input[type=radio]').prop('checked', false);
224 287 jQuery('#' + selector_id + '_container').hide();
225 288 }
226 - // Show Container depend from the selected option in dropdown list
289 +
290 + // Show Container depend from the selected option in dropdown list.
227 291 function wpbc_show_selected_in_dropdown( selector_id, title, value ){
228 292 jQuery('#' + selector_id + '_selector .wpbc_selected_in_dropdown').html( title );
229 293 jQuery('#' + selector_id ).val( value );
230 294 jQuery('#' + selector_id ).trigger('change');
@@ -229,10 +293,10 @@
229 293 jQuery('#' + selector_id ).val( value );
230 294 jQuery('#' + selector_id ).trigger('change');
231 295 }
232 296
233 - // Show Container depend from the selected Radio Option and Selectbox value in dropdown list
234 - // Exmaple: wpbc_show_selected_in_dropdown__radio_select_option( 'wh_booking_date', 'wh_booking_date2', 'wh_booking_datedays_interval_Radios' );
297 + // Show Container depend from the selected Radio Option and Selectbox value in dropdown list.
298 + // Exmaple: wpbc_show_selected_in_dropdown__radio_select_option( 'wh_booking_date', 'wh_booking_date2', 'wh_booking_datedays_interval_Radios' );.
235 299 function wpbc_show_selected_in_dropdown__radio_select_option( selector_id, selector_id2, radio_name ){
236 300
237 301 // Get selected value in radio buttons
238 302 var rad_val = jQuery('input:radio[name="' + radio_name + '"]:checked').val();
@@ -288,31 +352,9 @@
288 352
289 353 /**
290 354 * End: Dropdown BS List elements -------------------------------------------------------------------------------- */
291 355
292 -// FixIn: 9.6.3.5.
293 356
294 -/* Mark rows in listing as selected by adding specific CLASS*/
295 -( function( $ ){
296 - $( document ).ready(function(){
297 -
298 -
299 - $('.wpbc-listing-row input[type="checkbox"]').on( 'change', function(){
300 -
301 - $('.wpbc-listing-row').find('.check-column').find(':checkbox').each( function() {
302 - if ( $(this).is(':checked') ) {
303 - $(this).parent().parent().parent().parent().addClass('row_selected_color');
304 - } else {
305 - $(this).parent().parent().parent().parent().removeClass('row_selected_color');
306 - }
307 -
308 - });
309 -
310 - } );
311 -
312 - });
313 -}( jQuery ) );
314 -
315 357 /**
316 358 * Ajax Request
317 359 *
318 360 * @param {type} us_id
@@ -318,41 +360,47 @@
318 360 * @param {type} us_id
319 361 * @param {type} window_id
320 362 * @returns {undefined}
321 363 */
322 -//<![CDATA[
323 -function wpbc_verify_window_opening( us_id, window_id ){
364 +function wpbc_verify_window_opening(us_id, window_id) {
324 365
325 - var is_closed = 0;
366 + var is_closed = 0;
326 367
327 - if (jQuery('#' + window_id ).hasClass('closed') == true){
328 - jQuery('#' + window_id ).removeClass('closed');
329 - } else {
330 - jQuery('#' + window_id ).addClass('closed');
331 - is_closed = 1;
332 - }
368 + if ( jQuery( '#' + window_id ).hasClass( 'closed' ) == true ) {
369 + jQuery( '#' + window_id ).removeClass( 'closed' );
370 + } else {
371 + jQuery( '#' + window_id ).addClass( 'closed' );
372 + is_closed = 1;
373 + }
333 374
375 + jQuery.ajax(
376 + {
377 + // Start Ajax Sending.
378 + url : wpbc_url_ajax,
379 + type : 'POST',
380 + success: function (data, textStatus) {
381 + if ( textStatus == 'success' ) jQuery( '#ajax_respond' ).html( data );
382 + },
383 + error : function (XMLHttpRequest, textStatus, errorThrown) {
384 + window.status = 'Ajax sending Error status:' + textStatus;
385 + alert( XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText );
386 + if ( XMLHttpRequest.status == 500 ) {
387 + alert( 'Error: 500' );
388 + }
389 + },
390 + // beforeSend: someFunction,
391 + data: {
392 + action : 'USER_SAVE_WINDOW_STATE',
393 + user_id : us_id,
394 + window : window_id,
395 + is_closed : is_closed,
396 + wpbc_nonce: jQuery( '#wpbc_admin_panel_nonce' ).val()
397 + }
398 + }
399 + );
334 400
335 - jQuery.ajax({ // Start Ajax Sending
336 - url: wpbc_url_ajax,
337 - type:'POST',
338 - success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond').html( data );},
339 - error:function (XMLHttpRequest, textStatus, errorThrown){ window.status = 'Ajax sending Error status:'+ textStatus; alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText); if ( XMLHttpRequest.status == 500 ) { alert('Error: 500'); } } ,
340 - // beforeSend: someFunction,
341 - data:{
342 - action: 'USER_SAVE_WINDOW_STATE',
343 - user_id: us_id ,
344 - window: window_id,
345 - is_closed: is_closed,
346 - wpbc_nonce: jQuery('#wpbc_admin_panel_nonce').val()
347 - }
348 - });
349 -
350 401 }
351 -//]]>
352 402
353 -
354 -
355 403 /**
356 404 * Ajax Request - Saving Custom Data for User
357 405 *
358 406 * @param {int} us_id
@@ -359,18 +407,17 @@
359 407 * @param {string} data_name
360 408 * @param {string} data_value - serialized data
361 409 * @param {int} is_reload - { 0 | 1 } reload or not page
362 410 */
363 -//<![CDATA[
364 411 function wpbc_save_custom_user_data( us_id, data_name, data_value , is_reload ){
365 412
366 - wpbc_admin_show_message_processing( 'saving' );
413 + wpbc_admin_show_message_processing( 'saving' );
367 414
368 415 jQuery.ajax({ // Start Ajax Sending
369 416 url: wpbc_url_ajax,
370 417 type:'POST',
371 418 success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond').html( data );},
372 - error:function (XMLHttpRequest, textStatus, errorThrown){ window.status = 'Ajax sending Error status:'+ textStatus; alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText); if ( XMLHttpRequest.status == 500 ) { alert('Error: 500'); } } ,
419 + error:function (XMLHttpRequest, textStatus, errorThrown){ window.status = 'Ajax sending Error status:'+ textStatus; console.error( XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText); if ( XMLHttpRequest.status == 500 ) { console.error( 'Error: 500'); } } ,
373 420 // beforeSend: someFunction,
374 421 data:{
375 422 action: 'USER_SAVE_CUSTOM_DATA',
376 423 user_id: us_id,
@@ -379,18 +426,11 @@
379 426 is_reload: is_reload,
380 427 wpbc_nonce: jQuery('#wpbc_admin_panel_nonce').val()
381 428 }
382 429 });
383 -
384 430 }
385 -//]]>
386 431
387 -
388 -
389 -
390 -////////////////////////////////////////////////////////////////////////////////
391 -// Contact Form
392 -////////////////////////////////////////////////////////////////////////////////
432 +// Contact Form.
393 433 function wpbc_submit_client_form( submit_form, wpdev_active_locale ){
394 434
395 435 var count = submit_form.elements.length;
396 436 var formdata = '';
@@ -529,9 +569,8 @@
529 569
530 570 submit_form.submit(); // Submit Form, if previously was no interuptions
531 571 }
532 572
533 -
534 573 /**
535 574 * Show message under specific element
536 575 *
537 576 * @param {type} element - jQuery definition of the element
@@ -560,10 +599,9 @@
560 599 .animate( {opacity: 1}, 10000 )
561 600 .fadeOut( 2000 );
562 601 }
563 602
564 -
565 -// Show Error Message in Booking Form at Front End
603 +// Show Error Message in Booking Form at Front End.
566 604 function wpbc_show_error_message( element , errorMessage) {
567 605
568 606 // Scroll to the element
569 607 wpbc_scroll_to( element );
@@ -640,12 +678,11 @@
640 678 //return parser.href;
641 679 window.location.href = parser.href;
642 680 }
643 681
644 -// jQuery(window).load(function(){
682 +// Deprecated:.
645 683 jQuery( window ).on( "load", function (){ // FixIn: 8.7.9.7.
646 684
647 -
648 685 // Color Text picker ///////////////////////////////////////////////////////
649 686 if ( jQuery('.field-text-color').length > 0 ) {
650 687 jQuery('.field-text-color').iris( {
651 688 change: function(event, ui){
@@ -712,17 +749,12 @@
712 749 jQuery('.wpbc_colorpick' ).on( 'click', function(event){
713 750 event.stopPropagation();
714 751 });
715 752 }
716 -
717 -});
753 +});
718 754
755 +// -- Support Functions ------------------------------------------------------------------------------------------------
719 756
720 -
721 -////////////////////////////////////////////////////////////////////////////
722 -// Support Functions
723 -////////////////////////////////////////////////////////////////////////////
724 -
725 757 /**
726 758 * Reset of WP Editor or TextArea Content
727 759 * @param {string} editor_textarea_id - ID of element
728 760 * @param {string} editor_textarea_content - Content
@@ -756,9 +788,8 @@
756 788 * @param {type} us_id
757 789 * @param {type} window_id
758 790 * @returns {undefined}
759 791 */
760 -//<![CDATA[
761 792 function wpbc_dismiss_window(us_id, window_id ){
762 793
763 794 jQuery.ajax({ // Start Ajax Sending
764 795 url: wpbc_url_ajax,
@@ -763,9 +794,9 @@
763 794 jQuery.ajax({ // Start Ajax Sending
764 795 url: wpbc_url_ajax,
765 796 type:'POST',
766 797 success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond').html( data );},
767 - error:function (XMLHttpRequest, textStatus, errorThrown){window.status = 'Ajax sending Error status:'+ textStatus;alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);if (XMLHttpRequest.status == 500) {alert('Please check at this page according this error:' + ' https://wpbookingcalendar.com/faq/#ajax-sending-error');}},
798 + error:function (XMLHttpRequest, textStatus, errorThrown){window.status = 'Ajax sending Error status:'+ textStatus;console.error( XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText);if (XMLHttpRequest.status == 500) {console.error( 'Please check at this page according this error:' + ' https://wpbookingcalendar.com/faq/#ajax-sending-error');}},
768 799 // beforeSend: someFunction,
769 800 data:{
770 801 //ajax_action : 'USER_SAVE_WINDOW_STATE',
771 802 action : 'USER_SAVE_WINDOW_STATE',
@@ -775,9 +806,8 @@
775 806 wpbc_nonce: document.getElementById('wpbc_admin_panel_dismiss_window_nonce').value
776 807 }
777 808 });
778 809 }
779 -//]]>
780 810
781 811 /**
782 812 * Hide HTML element with animation during 0.5 second
783 813 *
@@ -782,7 +812,7 @@
782 812 * Hide HTML element with animation during 0.5 second
783 813 *
784 814 * @param window_id - HTML ID of element, such as 'wpbc_my_window' - without # symbol
785 815 */
786 -function wpbc_hide_window( window_id ){
787 - jQuery( '#' + window_id ).slideUp( 800 );
788 -}
816 +function wpbc_hide_window(window_id) {
817 + jQuery( '#' + window_id ).slideUp( 800 );
818 +}