PluginProbe
Booking Calendar / 10.10.1
Booking Calendar v10.10.1
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 / core / any / js / admin-support.js

admin-support.js in Booking Calendar 10.10.1, at core/any/js/admin-support.js

794 lines 31.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * @version 1.0
3 * @package Support Functions
4 * @subpackage BackEnd Main Script Lib
5 * @category Scripts
6 * @author wpdevelop
7 *
8 * @web-site https://wpbookingcalendar.com/
9 * @email info@wpbookingcalendar.com
10 *
11 * @modified 2015-04-09
12 */
13
14 function wpbc_ui_settings__panel__click( left_vert_nav_menu_a, section_id_to_show, text_for_path ){
15
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 );
20
21 // Show / Hide section and enable Left Vert Menu item
22 wpbc_navigation_click_show_section( left_vert_nav_menu_a, section_id_to_show , '.postbox' , false);
23
24 //wpbc_scroll_to( '.wpbc_settings_path_el_active' ); // Scroll to path
25 wpbc_scroll_to( '.wpbc_page_top__header_tabs' ); // Scroll to Top
26 }
27
28
29 /**
30 * When click on Navigation Column menu
31 */
32 function wpbc_navigation_click_show_section( _this, section_id_to_show ){
33 var container_to_hide_class = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.postbox';
34 var is_scroll = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
35
36 // -- Set Left Nav Active ------------------------------------------------------------------------------------------
37 jQuery( _this ).parents( '.wpbc_settings_flex_container' ).find( '.wpbc_settings_navigation_item_active' ).removeClass( 'wpbc_settings_navigation_item_active' );
38 jQuery( _this ).parents( '.wpbc_settings_navigation_item' ).addClass( 'wpbc_settings_navigation_item_active' );
39 // -- Hide all and show selected ----------------------------------------------------------------------------------
40 jQuery( _this ).parents( '.wpbc_settings_flex_container' ).find( container_to_hide_class ).hide();
41 jQuery( '.wpbc_container_always_hide__on_left_nav_click' ).hide();
42 jQuery( section_id_to_show ).show();
43
44 // -- Scroll -------------------------------------------------------------------------------------------------------
45 //jQuery( _this ).trigger( 'blur' );
46 if ( is_scroll ) {
47 var targetOffset = wpbc_scroll_to( section_id_to_show );
48 }
49
50 // -- Set Value to Input about selected Nav element --------------------------------------------------------------- // FixIn: 9.8.6.1.
51 var section_id_tab = section_id_to_show.substring( 0, section_id_to_show.length - 8 ) + '_tab';
52 if ( container_to_hide_class == section_id_to_show ){
53 section_id_tab = '#wpbc_general_settings_all_tab'
54 }
55 if ('#wpbc_general_settings_capacity_metabox,#wpbc_general_settings_capacity_upgrade_metabox'== section_id_to_show){
56 section_id_tab = '#wpbc_general_settings_capacity_tab'
57 }
58 jQuery( '#form_visible_section' ).val( section_id_tab );
59 }
60
61
62 /**
63 * Scroll to specific HTML element
64 *
65 * @param {type} object_name
66 * @returns {undefined}
67 */
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;
79 }
80
81 jQuery( document ).ready(function(){
82 setTimeout(function() {
83 wpbc_scroll_to( window.location.hash );
84 }, 100)
85 });
86
87 function wpbc_animate_border( element, time, colors, x ) {
88
89 if ( x >= colors.length ) {
90 x = 0;
91 } else {
92 x++;
93 var color;
94 if ( colors[ x ] === '' ) {
95 color = '';
96 } else {
97 color = '#' + colors[ x ];
98 }
99 element.css( 'border-color', color );
100 element.css( 'color', color );
101 setTimeout( function () {
102 wpbc_animate_border( element, time, colors, x );
103 }, time );
104 }
105 }
106
107 function wpbc_field_highlight( object_name ) {
108
109 if ( jQuery( object_name ).length > 0 ) {
110
111 wpbc_scroll_to( object_name );
112
113 wpbc_animate_border(
114 jQuery( object_name ) // Element
115 , 200 // Time in ms
116 , ['d63637', '', 'd63637', '', 'd63637', '', 'd63637', '', 'd63637', '', 'd63637', ''] // Colors Array
117 , 0
118 );
119 }
120 }
121
122 /**
123 * Show Yes/No dialog
124 *
125 * @param {type} message_question
126 * @returns {Boolean}
127 */
128 function wpbc_are_you_sure( message_question ){
129 var answer = confirm( message_question );
130 if ( answer) { return true; }
131 else { return false;}
132 }
133
134 function wpbc_admin_show_message_processing( message_type ){
135
136 var message = '' ;
137
138 if ( message_type == 'saving' )
139 message += _wpbc.get_message( 'message_saving' );
140 else if ( message_type == 'updating' )
141 message += _wpbc.get_message( 'message_updating' );
142 else if ( message_type == 'deleting' )
143 message += _wpbc.get_message( 'message_deleting' );
144 else
145 message += _wpbc.get_message( 'message_processing' );
146
147 if ( message == 'undefined' )
148 message = 'Processing'
149
150 message = ' <span class="wpdevelop"><span class="wpbc_icn_rotate_right wpbc_spin wpbc_ajax_icon wpbc_processing wpbc_icn_autorenew" aria-hidden="true"></span></span> ' + message + '...';
151
152 wpbc_admin_show_message( message, 'info', 10000 );
153 }
154
155 /**
156 * Show Alert Messages
157 *
158 * @param {string} message
159 * @param {string} m_type - notice (default) | error | warning | info | success
160 * @param {tyintpe} m_delay - microseconds
161 * @param {bool} is_append (default true) - append notice instead of replacing
162 * @returns {undefined}
163 */
164 function wpbc_admin_show_message( message, m_type, m_delay, is_append ){ // FixIn: 7.2.1.16.
165
166 if ( is_append === undefined) { // FixIn: 8.0.1.100.
167 is_append = true;
168 }
169
170 var alert_class = 'notice '; //'alert ';
171 if (m_type == 'error'){
172 alert_class += 'notice-error ';
173 message = '<i style="margin-right: 0.5em;color: #d63638;" class="menu_icon icon-1x wpbc_icn_report_gmailerrorred"></i>' + message;
174 } //'alert-danger ';
175 if (m_type == 'warning'){
176 alert_class += 'notice-warning ';
177 message = '<i style="margin-right: 0.5em;color: #e9aa04;" class="menu_icon icon-1x wpbc_icn_warning"></i>' + message;
178 };
179 if (m_type == 'info') alert_class += 'notice-info '; //'alert-info ';
180 if ( m_type == 'success' ){
181 alert_class += 'alert-success updated ';
182 message = '<i style="margin-right: 0.5em;color: #64aa45;" class="menu_icon icon-1x wpbc_icn_done_outline"></i>' + message;
183 }
184
185 // var ajx_working_content = '';
186 // if ( is_append )
187 // ajx_working_content = jQuery('#ajax_working').html();
188
189 var unique_div_id = new Date();
190 unique_div_id = 'wpbc_notice_' + unique_div_id.getTime();
191
192 if ( is_append ){
193
194 jQuery( '#ajax_working .wpbc_processing' ).parent().parent().parent().hide();
195
196 jQuery( '#ajax_working' ).append(
197 '<div id="' + unique_div_id + '"><div id="wpbc_alert_message" class="wpbc_alert_message">' +
198 '<div class="wpbc_inner_message ' + alert_class + '"> ' +
199 '<a class="close" href="javascript:void(0)" onclick="javascript:jQuery(this).parent().hide();">&times;</a> ' +
200 message +
201 '</div>' +
202 '</div></div>'
203 );
204 } else
205 jQuery('#ajax_working').html(
206 '<div id="' + unique_div_id + '"><div id="wpbc_alert_message" class="wpbc_alert_message">' +
207 '<div class="wpbc_inner_message '+alert_class+'"> ' +
208 '<a class="close" href="javascript:void(0)" onclick="javascript:jQuery(this).parent().hide();">&times;</a> ' +
209 message +
210 '</div>' +
211 '</div></div>'
212 );
213 jQuery( '#' + unique_div_id ).animate( {opacity: 1}, m_delay ).fadeOut( 500 );
214 var closed_timer2 = setTimeout( function (){
215 jQuery( '#' + unique_div_id ).trigger( 'hide' );
216 }, ( parseInt( m_delay ) + 501 ) );
217 }
218
219 /**
220 * Start: Dropdown BS List elements -------------------------------------------------------------------------------- */
221
222 function wpbc_close_dropdown_selectbox( selector_id ) {
223 jQuery('#' + selector_id + '_container li input[type=checkbox],#' + selector_id + '_container li input[type=radio]').prop('checked', false);
224 jQuery('#' + selector_id + '_container').hide();
225 }
226 // Show Container depend from the selected option in dropdown list
227 function wpbc_show_selected_in_dropdown( selector_id, title, value ){
228 jQuery('#' + selector_id + '_selector .wpbc_selected_in_dropdown').html( title );
229 jQuery('#' + selector_id ).val( value );
230 jQuery('#' + selector_id ).trigger('change');
231 }
232
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' );
235 function wpbc_show_selected_in_dropdown__radio_select_option( selector_id, selector_id2, radio_name ){
236
237 // Get selected value in radio buttons
238 var rad_val = jQuery('input:radio[name="' + radio_name + '"]:checked').val();
239
240 if ( rad_val != 'undefined' ) {
241
242 var select_box = jQuery('input:radio[name="' + radio_name + '"]:checked').parents('.input-group').find('select');
243 // Selectbox exist
244 if ( select_box.length > 0 ) {
245 // Get label near selected radiobutton and selected Tilte in selectbox
246 var title = jQuery('input:radio[name="' + radio_name + '"]:checked').parent().find('label').html() + ' ' +
247 jQuery('input:radio[name="' + radio_name + '"]:checked').parents('.input-group').find('select option:selected').text();
248 // Get Value of selected option in selectbox
249 var value = jQuery('input:radio[name="' + radio_name + '"]:checked').parents('.input-group').find('select option:selected').val();
250 // Set Title in dropdown list
251 jQuery('#' + selector_id + '_selector .wpbc_selected_in_dropdown').html( title );
252 // Set value of radio button
253 jQuery('#' + selector_id ).val( rad_val );
254 // Set value of selectbox
255 jQuery('#' + selector_id2 ).val( value );
256 } else {
257 // 2 Text Fields
258 var text_box = jQuery('input:radio[name="' + radio_name + '"]:checked').parents('.text-group').find('input[type="text"]');
259 if ( text_box.length > 0 ) {
260 var text_divs = jQuery('input:radio[name="' + radio_name + '"]:checked').parents('.text-group').find('.dropdown-menu-text-element');
261
262 // Check if we have 2 DIV elements with text fields
263 if ( text_box.length > 0 ) {
264
265 var id_list = [ selector_id, selector_id2 ];
266 var title = '';
267 //Loop our text DIV elements
268 jQuery('input:radio[name="' + radio_name + '"]:checked').parents('.text-group').find('.dropdown-menu-text-element').each(function( i ) {
269
270 if ( title != '' )
271 title += ' - ';
272 title += jQuery(this).find('input[type="text"]').val();
273 jQuery('#' + id_list[ i ] ).val( jQuery(this).find('input[type="text"]').val() );
274 });
275 // Set Title in dropdown list
276 jQuery('#' + selector_id + '_selector .wpbc_selected_in_dropdown').html( title );
277
278 }
279 }
280 }
281 }
282
283 jQuery('#' + selector_id ).trigger( 'change' );
284
285 // Hide dropdown list
286 jQuery('#' + selector_id + '_container').hide();
287 }
288
289 /**
290 * End: Dropdown BS List elements -------------------------------------------------------------------------------- */
291
292 // FixIn: 9.6.3.5.
293
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 /**
316 * Ajax Request
317 *
318 * @param {type} us_id
319 * @param {type} window_id
320 * @returns {undefined}
321 */
322 function wpbc_verify_window_opening(us_id, window_id) {
323
324 var is_closed = 0;
325
326 if ( jQuery( '#' + window_id ).hasClass( 'closed' ) == true ) {
327 jQuery( '#' + window_id ).removeClass( 'closed' );
328 } else {
329 jQuery( '#' + window_id ).addClass( 'closed' );
330 is_closed = 1;
331 }
332
333 jQuery.ajax(
334 {
335 // Start Ajax Sending.
336 url : wpbc_url_ajax,
337 type : 'POST',
338 success: function (data, textStatus) {
339 if ( textStatus == 'success' ) jQuery( '#ajax_respond' ).html( data );
340 },
341 error : function (XMLHttpRequest, textStatus, errorThrown) {
342 window.status = 'Ajax sending Error status:' + textStatus;
343 alert( XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText );
344 if ( XMLHttpRequest.status == 500 ) {
345 alert( 'Error: 500' );
346 }
347 },
348 // beforeSend: someFunction,
349 data: {
350 action : 'USER_SAVE_WINDOW_STATE',
351 user_id : us_id,
352 window : window_id,
353 is_closed : is_closed,
354 wpbc_nonce: jQuery( '#wpbc_admin_panel_nonce' ).val()
355 }
356 }
357 );
358
359 }
360
361
362
363
364 /**
365 * Ajax Request - Saving Custom Data for User
366 *
367 * @param {int} us_id
368 * @param {string} data_name
369 * @param {string} data_value - serialized data
370 * @param {int} is_reload - { 0 | 1 } reload or not page
371 */
372 function wpbc_save_custom_user_data( us_id, data_name, data_value , is_reload ){
373
374 wpbc_admin_show_message_processing( 'saving' );
375
376 jQuery.ajax({ // Start Ajax Sending
377 url: wpbc_url_ajax,
378 type:'POST',
379 success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond').html( data );},
380 error:function (XMLHttpRequest, textStatus, errorThrown){ window.status = 'Ajax sending Error status:'+ textStatus; alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText); if ( XMLHttpRequest.status == 500 ) { alert('Error: 500'); } } ,
381 // beforeSend: someFunction,
382 data:{
383 action: 'USER_SAVE_CUSTOM_DATA',
384 user_id: us_id,
385 data_name: data_name,
386 data_value: decodeURIComponent( data_value ),
387 is_reload: is_reload,
388 wpbc_nonce: jQuery('#wpbc_admin_panel_nonce').val()
389 }
390 });
391 }
392
393
394
395
396
397 ////////////////////////////////////////////////////////////////////////////////
398 // Contact Form
399 ////////////////////////////////////////////////////////////////////////////////
400 function wpbc_submit_client_form( submit_form, wpdev_active_locale ){
401
402 var count = submit_form.elements.length;
403 var formdata = '';
404 var inp_value;
405 var element;
406 var el_type;
407
408 for (var i=0; i<count; i++) {
409 element = submit_form.elements[i];
410
411 if ( (element.type !=='button') && (element.type !=='hidden') ) {
412
413 // Get Value of Element
414 if ( element.type == 'checkbox' ){
415
416 if ( element.value == '' ) {
417 inp_value = element.checked;
418 } else {
419 if ( element.checked )
420 inp_value = element.value;
421 else
422 inp_value = '';
423 }
424
425 } else if ( element.type == 'radio' ) {
426
427 if ( element.value == '' ) {
428 inp_value = element.checked;
429 } else {
430 if ( element.checked )
431 inp_value = element.value;
432 else
433 inp_value = '';
434 }
435 /*
436 if ( element.checked )
437 inp_value = element.value;
438 else
439 continue;
440 */
441
442 } else {
443 inp_value = element.value;
444 }
445
446 // Get value in selectbox of multiple selection
447 if ( (element.type == 'selectbox-multiple') || (element.type == 'select-multiple') ){
448 inp_value = jQuery('[name="'+element.name+'"]').val() ;
449 if ( ( inp_value == null ) || ( inp_value.toString() == '' ) )
450 inp_value='';
451 }
452
453 /*if ( element.name == ('phone') ) {
454 // we validate a phone number of 10 digits with no comma, no spaces, no punctuation and there will be no + sign in front the number - See more at: http://www.w3resource.com/javascript/form/phone-no-validation.php#sthash.U9FHwcdW.dpuf
455 var reg = /^\d{10}$/;
456 var message_verif_phone = "Please enter correctly phone number";
457 if ( inp_value != '' )
458 if(reg.test(inp_value) == false) {wpbc_show_error_message( element , message_verif_phone);return;}
459 }*/
460
461
462 // Validation Check -- Requred fields
463 if ( element.className.indexOf( 'wpbc-validate-required' ) !== -1 ){
464
465 if ( ( element.type =='checkbox' ) && ( element.checked === false ) ) {
466 if ( ! jQuery(':checkbox[name="'+element.name+'"]', submit_form).is(":checked") ) {
467 wpbc_show_error_message( element , _wpbc.get_message( 'message_check_required_for_check_box' ) );
468 return;
469 }
470 }
471 if ( element.type =='radio' ) {
472 if ( ! jQuery(':radio[name="'+element.name+'"]', submit_form).is(":checked") ) {
473 wpbc_show_error_message( element , _wpbc.get_message( 'message_check_required_for_radio_box' ) );
474 return;
475 }
476 }
477 if ( ( element.type !='checkbox' ) && ( element.type !='radio' ) && ( inp_value === '' ) ) {
478 wpbc_show_error_message( element , _wpbc.get_message( 'message_check_required' ) );
479 return;
480 }
481 }
482
483 // Validation Check --- Email correct filling field
484 if ( element.className.indexOf( 'wpbc-validate-email' ) !== -1 ){
485 var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,})$/;
486 if ( ( inp_value != '' ) && ( reg.test(inp_value) == false ) ) {
487 wpbc_show_error_message( element , _wpbc.get_message( 'message_check_email' ) );
488 return;
489 }
490 }
491
492 /*
493 // Validation Check --- Same Email Field
494 if ( ( element.className.indexOf('wpdev-validates-as-email') !== -1 ) && ( element.className.indexOf('same_as_') !== -1 ) ) {
495
496 // Get the name of Primary Email field from the "same_as_NAME" class
497 var primary_email_name = element.className.match(/same_as_([^\s])+/gi);
498 if (primary_email_name != null) { // We found
499 primary_email_name = primary_email_name[0].substr(8);
500
501 // Recehck if such primary email field exist in the booking form
502 if (jQuery('[name="' + primary_email_name + '"]').length > 0) {
503
504 // Recheck the values of the both emails, if they do not equla show warning
505 if ( jQuery('[name="' + primary_email_name + '"]').val() !== inp_value ) {
506 wpbc_show_error_message( element , _wpbc.get_message( 'message_check_same_email' ) );return;
507 }
508 }
509 }
510 // Skip one loop for the email veryfication field
511 continue;
512 } */
513
514 /*
515 // Get Form Data
516 if ( element.name !== ('captcha_input' ) ) {
517 if (formdata !=='') formdata += '~'; // next field element
518
519 el_type = element.type;
520 if ( element.className.indexOf('wpdev-validates-as-email') !== -1 ) el_type='email';
521 if ( element.className.indexOf('wpdev-validates-as-coupon') !== -1 ) el_type='coupon';
522
523 inp_value = inp_value + '';
524 inp_value = inp_value.replace(new RegExp("\\^",'g'), '&#94;'); // replace registered characters
525 inp_value = inp_value.replace(new RegExp("~",'g'), '&#126;'); // replace registered characters
526
527 inp_value = inp_value.replace(/"/g, '&#34;'); // replace double quot
528 inp_value = inp_value.replace(/'/g, '&#39;'); // replace single quot
529
530 formdata += el_type + '^' + element.name + '^' + inp_value ; // element attr
531 } */
532 }
533
534 } // End Fields Loop
535
536
537 submit_form.submit(); // Submit Form, if previously was no interuptions
538 }
539
540
541 /**
542 * Show message under specific element
543 *
544 * @param {type} element - jQuery definition of the element
545 * @param {type} errorMessage - String message
546 * @param {type} message_type "" | "alert-warning" | "alert-success" | "alert-info" | "alert-danger"
547 */
548 function wpbc_show_message_under_element( element , errorMessage , message_type) {
549
550 wpbc_scroll_to( element );
551
552 if ( jQuery( element ).attr('type') == "radio" ) {
553 jQuery( element ).parent().parent().parent()
554 .after('<span class="wpbc-near-field-message alert '+ message_type +'">'+ errorMessage +'</span>'); // Show message
555
556 } else if (jQuery( element ).attr('type') == "checkbox") {
557 jQuery( element ).parent()
558 .after('<span class="wpbc-near-field-message alert '+ message_type +'">'+ errorMessage +'</span>'); // Show message
559
560 } else {
561 jQuery( element )
562 .after('<span class="wpbc-near-field-message alert '+ message_type +'">'+ errorMessage +'</span>'); // Show message
563 }
564 jQuery(".widget_wpbc .wpbc-near-field-message")
565 .css( {'vertical-align': 'sub' } ) ;
566 jQuery(".wpbc-near-field-message")
567 .animate( {opacity: 1}, 10000 )
568 .fadeOut( 2000 );
569 }
570
571
572 // Show Error Message in Booking Form at Front End
573 function wpbc_show_error_message( element , errorMessage) {
574
575 // Scroll to the element
576 wpbc_scroll_to( element );
577
578 jQuery("[name='"+ element.name +"']")
579 .fadeOut( 350 ).fadeIn( 300 )
580 .fadeOut( 350 ).fadeIn( 400 )
581 .fadeOut( 350 ).fadeIn( 300 )
582 .fadeOut( 350 ).fadeIn( 400 )
583 .animate( {opacity: 1}, 4000 )
584 ; // mark red border
585
586 if (jQuery("[name='"+ element.name +"']").attr('type') == "radio") {
587 jQuery("[name='"+ element.name +"']").parent().parent()//.parent()
588 .after('<span class="wpbc-near-field-message alert alert-warning">'+ errorMessage +'</span>'); // Show message
589
590 } else if (jQuery("[name='"+ element.name +"']").attr('type') == "checkbox") {
591 jQuery("[name='"+ element.name +"']").parent().parent()
592 .after('<span class="wpbc-near-field-message alert alert-warning">'+ errorMessage +'</span>'); // Show message
593
594 } else {
595 jQuery("[name='"+ element.name +"']")
596 .after('<span class="wpbc-near-field-message alert alert-warning">'+ errorMessage +'</span>'); // Show message
597 }
598 jQuery(".wpbc-near-field-message")
599 .css( {'padding' : '5px 5px 4px', 'margin' : '2px', 'vertical-align': 'top', 'line-height': '32px' } );
600
601 if ( element.type == 'checkbox' )
602 jQuery(".wpbc-near-field-message").css( { 'vertical-align': 'middle'} );
603
604 jQuery(".widget_wpbc .wpbc-near-field-message")
605 .css( {'vertical-align': 'sub' } ) ;
606 jQuery(".wpbc-near-field-message")
607 .animate( {opacity: 1}, 10000 )
608 .fadeOut( 2000 );
609 jQuery( element).trigger( 'focus' ); // FixIn: 8.7.11.12.
610 return;
611
612 }
613
614
615 /**
616 * Reload the page with new parameter value.
617 *
618 * @param {type} url - full URL of the page, can include or exclude that parameter
619 * @param {type} param - URL parameter name
620 * @param {type} value - URL parameter value
621 * @returns {undefined}
622 */
623 function wpbc_reload_page_with_paramater( url, param, value ) {
624 var hash = {};
625 var parser = document.createElement('a');
626
627 parser.href = url;
628
629 var parameters = parser.search.split(/\?|&/);
630
631 for(var i=0; i < parameters.length; i++) {
632 if(!parameters[i])
633 continue;
634
635 var ary = parameters[i].split('=');
636 hash[ary[0]] = ary[1];
637 }
638
639 hash[param] = value;
640
641 var list = [];
642 Object.keys(hash).forEach(function (key) {
643 list.push(key + '=' + hash[key]);
644 });
645
646 parser.search = '?' + list.join('&');
647 //return parser.href;
648 window.location.href = parser.href;
649 }
650
651 // jQuery(window).load(function(){
652 jQuery( window ).on( "load", function (){ // FixIn: 8.7.9.7.
653
654
655 // Color Text picker ///////////////////////////////////////////////////////
656 if ( jQuery('.field-text-color').length > 0 ) {
657 jQuery('.field-text-color').iris( {
658 change: function(event, ui){
659 jQuery(this).css( { backgroundColor: ui.color.toString() } );
660 jQuery(this).closest('.fields-color-group').find('.fieldvalue').css( { color: ui.color.toString() } );
661 }
662 , hide: true
663 , border: true
664 , palettes: ['#333', '#555', '#777', '#aaa', '#fff']
665 } ).each( function() {
666 jQuery(this).css( { backgroundColor: jQuery(this).val() } );
667 })
668 .on( 'click', function(){ // FixIn: 8.7.11.12.
669 jQuery('.iris-picker').hide();
670 jQuery(this).closest('div').find('.iris-picker').show();
671 });
672 }
673 // Color Background picker /////////////////////////////////////////////////
674 if ( jQuery('.field-background-color').length > 0 ) {
675 jQuery('.field-background-color').iris( {
676 change: function(event, ui){
677 jQuery(this).css( { backgroundColor: ui.color.toString() } );
678 jQuery(this).closest('.fields-color-group').find('.fieldvalue').css( { backgroundColor: ui.color.toString() } );
679 }
680 , hide: true
681 , border: true
682 , palettes: [ '#FFEE99', '#459', '#78b', '#ab0', '#df5d5d', '#f0f']
683 } ).each( function() {
684 jQuery(this).css( { backgroundColor: jQuery(this).val() } );
685 })
686 .on( 'click', function(){ // FixIn: 8.7.11.12.
687 jQuery('.iris-picker').hide();
688 jQuery(this).closest('div').find('.iris-picker').show();
689 });
690 // FixIn: 8.7.11.12.
691 jQuery('.field-text-color, .field-background-color' ).on( 'click', function(event){
692 event.stopPropagation();
693 });
694 }
695
696 // -----------------------------------------------------------------------------------------------------------------
697 // General Color picker in settings table //////////////////////////////////
698 // -----------------------------------------------------------------------------------------------------------------
699 if ( jQuery('.wpbc_colorpick').length > 0 ) {
700 jQuery('.wpbc_colorpick').iris( {
701 change: function(event, ui){
702 jQuery(this).css( { backgroundColor: ui.color.toString() } );
703 }
704 , hide: true
705 , border: true
706 , palettes: ['#125', '#459', '#78b', '#ab0', '#de3', '#f0f']
707 } ).each( function() {
708 jQuery(this).css( { backgroundColor: jQuery(this).val() } );
709 })
710 .on( 'click', function(){ // FixIn: 8.7.11.12.
711 jQuery('.iris-picker').hide();
712 jQuery(this).closest('td').find('.iris-picker').show();
713 });
714
715 jQuery('body' ).on( 'click', function() {
716 jQuery('.iris-picker').hide();
717 });
718 // FixIn: 8.7.11.12.
719 jQuery('.wpbc_colorpick' ).on( 'click', function(event){
720 event.stopPropagation();
721 });
722 }
723
724 });
725
726
727
728 ////////////////////////////////////////////////////////////////////////////
729 // Support Functions
730 ////////////////////////////////////////////////////////////////////////////
731
732 /**
733 * Reset of WP Editor or TextArea Content
734 * @param {string} editor_textarea_id - ID of element
735 * @param {string} editor_textarea_content - Content
736 */
737 function wpbc_reset_wp_editor_content( editor_textarea_id, editor_textarea_content ) {
738
739 // FixIn: 8.4.7.18.
740
741 if ( (typeof WPBC_CM !== 'undefined') && ( WPBC_CM.is_defined( '#' + editor_textarea_id ) ) ){
742
743 WPBC_CM.set_codemirror_value( '#' + editor_textarea_id , editor_textarea_content );
744 } else {
745
746 if( typeof tinymce != "undefined" ) {
747 var editor = tinymce.get( editor_textarea_id );
748 if( editor && editor instanceof tinymce.Editor ) {
749 editor.setContent( editor_textarea_content );
750 editor.save( { no_events: true } );
751 } else {
752 jQuery( '#' + editor_textarea_id ).val( editor_textarea_content );
753 }
754 } else {
755 jQuery( '#' + editor_textarea_id ).val( editor_textarea_content );
756 }
757 }
758 }
759
760 /**
761 * Dismiss window / panel in Welcome Page
762 *
763 * @param {type} us_id
764 * @param {type} window_id
765 * @returns {undefined}
766 */
767 function wpbc_dismiss_window(us_id, window_id ){
768
769 jQuery.ajax({ // Start Ajax Sending
770 url: wpbc_url_ajax,
771 type:'POST',
772 success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond').html( data );},
773 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');}},
774 // beforeSend: someFunction,
775 data:{
776 //ajax_action : 'USER_SAVE_WINDOW_STATE',
777 action : 'USER_SAVE_WINDOW_STATE',
778 user_id: us_id ,
779 window: window_id,
780 is_closed: 1,
781 wpbc_nonce: document.getElementById('wpbc_admin_panel_dismiss_window_nonce').value
782 }
783 });
784 }
785
786 /**
787 * Hide HTML element with animation during 0.5 second
788 *
789 * @param window_id - HTML ID of element, such as 'wpbc_my_window' - without # symbol
790 */
791 function wpbc_hide_window(window_id) {
792 jQuery( '#' + window_id ).slideUp( 800 );
793 }
794