PluginProbe
Booking Calendar / 10.10
Booking Calendar v10.10
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, at core/any/js/admin-support.js

789 lines 32.2 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 //<![CDATA[
323 function wpbc_verify_window_opening( us_id, window_id ){
324
325 var is_closed = 0;
326
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 }
333
334
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 }
351 //]]>
352
353
354
355 /**
356 * Ajax Request - Saving Custom Data for User
357 *
358 * @param {int} us_id
359 * @param {string} data_name
360 * @param {string} data_value - serialized data
361 * @param {int} is_reload - { 0 | 1 } reload or not page
362 */
363 //<![CDATA[
364 function wpbc_save_custom_user_data( us_id, data_name, data_value , is_reload ){
365
366 wpbc_admin_show_message_processing( 'saving' );
367
368 jQuery.ajax({ // Start Ajax Sending
369 url: wpbc_url_ajax,
370 type:'POST',
371 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'); } } ,
373 // beforeSend: someFunction,
374 data:{
375 action: 'USER_SAVE_CUSTOM_DATA',
376 user_id: us_id,
377 data_name: data_name,
378 data_value: decodeURIComponent( data_value ),
379 is_reload: is_reload,
380 wpbc_nonce: jQuery('#wpbc_admin_panel_nonce').val()
381 }
382 });
383
384 }
385 //]]>
386
387
388
389
390 ////////////////////////////////////////////////////////////////////////////////
391 // Contact Form
392 ////////////////////////////////////////////////////////////////////////////////
393 function wpbc_submit_client_form( submit_form, wpdev_active_locale ){
394
395 var count = submit_form.elements.length;
396 var formdata = '';
397 var inp_value;
398 var element;
399 var el_type;
400
401 for (var i=0; i<count; i++) {
402 element = submit_form.elements[i];
403
404 if ( (element.type !=='button') && (element.type !=='hidden') ) {
405
406 // Get Value of Element
407 if ( element.type == 'checkbox' ){
408
409 if ( element.value == '' ) {
410 inp_value = element.checked;
411 } else {
412 if ( element.checked )
413 inp_value = element.value;
414 else
415 inp_value = '';
416 }
417
418 } else if ( element.type == 'radio' ) {
419
420 if ( element.value == '' ) {
421 inp_value = element.checked;
422 } else {
423 if ( element.checked )
424 inp_value = element.value;
425 else
426 inp_value = '';
427 }
428 /*
429 if ( element.checked )
430 inp_value = element.value;
431 else
432 continue;
433 */
434
435 } else {
436 inp_value = element.value;
437 }
438
439 // Get value in selectbox of multiple selection
440 if ( (element.type == 'selectbox-multiple') || (element.type == 'select-multiple') ){
441 inp_value = jQuery('[name="'+element.name+'"]').val() ;
442 if ( ( inp_value == null ) || ( inp_value.toString() == '' ) )
443 inp_value='';
444 }
445
446 /*if ( element.name == ('phone') ) {
447 // 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
448 var reg = /^\d{10}$/;
449 var message_verif_phone = "Please enter correctly phone number";
450 if ( inp_value != '' )
451 if(reg.test(inp_value) == false) {wpbc_show_error_message( element , message_verif_phone);return;}
452 }*/
453
454
455 // Validation Check -- Requred fields
456 if ( element.className.indexOf( 'wpbc-validate-required' ) !== -1 ){
457
458 if ( ( element.type =='checkbox' ) && ( element.checked === false ) ) {
459 if ( ! jQuery(':checkbox[name="'+element.name+'"]', submit_form).is(":checked") ) {
460 wpbc_show_error_message( element , _wpbc.get_message( 'message_check_required_for_check_box' ) );
461 return;
462 }
463 }
464 if ( element.type =='radio' ) {
465 if ( ! jQuery(':radio[name="'+element.name+'"]', submit_form).is(":checked") ) {
466 wpbc_show_error_message( element , _wpbc.get_message( 'message_check_required_for_radio_box' ) );
467 return;
468 }
469 }
470 if ( ( element.type !='checkbox' ) && ( element.type !='radio' ) && ( inp_value === '' ) ) {
471 wpbc_show_error_message( element , _wpbc.get_message( 'message_check_required' ) );
472 return;
473 }
474 }
475
476 // Validation Check --- Email correct filling field
477 if ( element.className.indexOf( 'wpbc-validate-email' ) !== -1 ){
478 var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,})$/;
479 if ( ( inp_value != '' ) && ( reg.test(inp_value) == false ) ) {
480 wpbc_show_error_message( element , _wpbc.get_message( 'message_check_email' ) );
481 return;
482 }
483 }
484
485 /*
486 // Validation Check --- Same Email Field
487 if ( ( element.className.indexOf('wpdev-validates-as-email') !== -1 ) && ( element.className.indexOf('same_as_') !== -1 ) ) {
488
489 // Get the name of Primary Email field from the "same_as_NAME" class
490 var primary_email_name = element.className.match(/same_as_([^\s])+/gi);
491 if (primary_email_name != null) { // We found
492 primary_email_name = primary_email_name[0].substr(8);
493
494 // Recehck if such primary email field exist in the booking form
495 if (jQuery('[name="' + primary_email_name + '"]').length > 0) {
496
497 // Recheck the values of the both emails, if they do not equla show warning
498 if ( jQuery('[name="' + primary_email_name + '"]').val() !== inp_value ) {
499 wpbc_show_error_message( element , _wpbc.get_message( 'message_check_same_email' ) );return;
500 }
501 }
502 }
503 // Skip one loop for the email veryfication field
504 continue;
505 } */
506
507 /*
508 // Get Form Data
509 if ( element.name !== ('captcha_input' ) ) {
510 if (formdata !=='') formdata += '~'; // next field element
511
512 el_type = element.type;
513 if ( element.className.indexOf('wpdev-validates-as-email') !== -1 ) el_type='email';
514 if ( element.className.indexOf('wpdev-validates-as-coupon') !== -1 ) el_type='coupon';
515
516 inp_value = inp_value + '';
517 inp_value = inp_value.replace(new RegExp("\\^",'g'), '&#94;'); // replace registered characters
518 inp_value = inp_value.replace(new RegExp("~",'g'), '&#126;'); // replace registered characters
519
520 inp_value = inp_value.replace(/"/g, '&#34;'); // replace double quot
521 inp_value = inp_value.replace(/'/g, '&#39;'); // replace single quot
522
523 formdata += el_type + '^' + element.name + '^' + inp_value ; // element attr
524 } */
525 }
526
527 } // End Fields Loop
528
529
530 submit_form.submit(); // Submit Form, if previously was no interuptions
531 }
532
533
534 /**
535 * Show message under specific element
536 *
537 * @param {type} element - jQuery definition of the element
538 * @param {type} errorMessage - String message
539 * @param {type} message_type "" | "alert-warning" | "alert-success" | "alert-info" | "alert-danger"
540 */
541 function wpbc_show_message_under_element( element , errorMessage , message_type) {
542
543 wpbc_scroll_to( element );
544
545 if ( jQuery( element ).attr('type') == "radio" ) {
546 jQuery( element ).parent().parent().parent()
547 .after('<span class="wpbc-near-field-message alert '+ message_type +'">'+ errorMessage +'</span>'); // Show message
548
549 } else if (jQuery( element ).attr('type') == "checkbox") {
550 jQuery( element ).parent()
551 .after('<span class="wpbc-near-field-message alert '+ message_type +'">'+ errorMessage +'</span>'); // Show message
552
553 } else {
554 jQuery( element )
555 .after('<span class="wpbc-near-field-message alert '+ message_type +'">'+ errorMessage +'</span>'); // Show message
556 }
557 jQuery(".widget_wpbc .wpbc-near-field-message")
558 .css( {'vertical-align': 'sub' } ) ;
559 jQuery(".wpbc-near-field-message")
560 .animate( {opacity: 1}, 10000 )
561 .fadeOut( 2000 );
562 }
563
564
565 // Show Error Message in Booking Form at Front End
566 function wpbc_show_error_message( element , errorMessage) {
567
568 // Scroll to the element
569 wpbc_scroll_to( element );
570
571 jQuery("[name='"+ element.name +"']")
572 .fadeOut( 350 ).fadeIn( 300 )
573 .fadeOut( 350 ).fadeIn( 400 )
574 .fadeOut( 350 ).fadeIn( 300 )
575 .fadeOut( 350 ).fadeIn( 400 )
576 .animate( {opacity: 1}, 4000 )
577 ; // mark red border
578
579 if (jQuery("[name='"+ element.name +"']").attr('type') == "radio") {
580 jQuery("[name='"+ element.name +"']").parent().parent()//.parent()
581 .after('<span class="wpbc-near-field-message alert alert-warning">'+ errorMessage +'</span>'); // Show message
582
583 } else if (jQuery("[name='"+ element.name +"']").attr('type') == "checkbox") {
584 jQuery("[name='"+ element.name +"']").parent().parent()
585 .after('<span class="wpbc-near-field-message alert alert-warning">'+ errorMessage +'</span>'); // Show message
586
587 } else {
588 jQuery("[name='"+ element.name +"']")
589 .after('<span class="wpbc-near-field-message alert alert-warning">'+ errorMessage +'</span>'); // Show message
590 }
591 jQuery(".wpbc-near-field-message")
592 .css( {'padding' : '5px 5px 4px', 'margin' : '2px', 'vertical-align': 'top', 'line-height': '32px' } );
593
594 if ( element.type == 'checkbox' )
595 jQuery(".wpbc-near-field-message").css( { 'vertical-align': 'middle'} );
596
597 jQuery(".widget_wpbc .wpbc-near-field-message")
598 .css( {'vertical-align': 'sub' } ) ;
599 jQuery(".wpbc-near-field-message")
600 .animate( {opacity: 1}, 10000 )
601 .fadeOut( 2000 );
602 jQuery( element).trigger( 'focus' ); // FixIn: 8.7.11.12.
603 return;
604
605 }
606
607
608 /**
609 * Reload the page with new parameter value.
610 *
611 * @param {type} url - full URL of the page, can include or exclude that parameter
612 * @param {type} param - URL parameter name
613 * @param {type} value - URL parameter value
614 * @returns {undefined}
615 */
616 function wpbc_reload_page_with_paramater( url, param, value ) {
617 var hash = {};
618 var parser = document.createElement('a');
619
620 parser.href = url;
621
622 var parameters = parser.search.split(/\?|&/);
623
624 for(var i=0; i < parameters.length; i++) {
625 if(!parameters[i])
626 continue;
627
628 var ary = parameters[i].split('=');
629 hash[ary[0]] = ary[1];
630 }
631
632 hash[param] = value;
633
634 var list = [];
635 Object.keys(hash).forEach(function (key) {
636 list.push(key + '=' + hash[key]);
637 });
638
639 parser.search = '?' + list.join('&');
640 //return parser.href;
641 window.location.href = parser.href;
642 }
643
644 // jQuery(window).load(function(){
645 jQuery( window ).on( "load", function (){ // FixIn: 8.7.9.7.
646
647
648 // Color Text picker ///////////////////////////////////////////////////////
649 if ( jQuery('.field-text-color').length > 0 ) {
650 jQuery('.field-text-color').iris( {
651 change: function(event, ui){
652 jQuery(this).css( { backgroundColor: ui.color.toString() } );
653 jQuery(this).closest('.fields-color-group').find('.fieldvalue').css( { color: ui.color.toString() } );
654 }
655 , hide: true
656 , border: true
657 , palettes: ['#333', '#555', '#777', '#aaa', '#fff']
658 } ).each( function() {
659 jQuery(this).css( { backgroundColor: jQuery(this).val() } );
660 })
661 .on( 'click', function(){ // FixIn: 8.7.11.12.
662 jQuery('.iris-picker').hide();
663 jQuery(this).closest('div').find('.iris-picker').show();
664 });
665 }
666 // Color Background picker /////////////////////////////////////////////////
667 if ( jQuery('.field-background-color').length > 0 ) {
668 jQuery('.field-background-color').iris( {
669 change: function(event, ui){
670 jQuery(this).css( { backgroundColor: ui.color.toString() } );
671 jQuery(this).closest('.fields-color-group').find('.fieldvalue').css( { backgroundColor: ui.color.toString() } );
672 }
673 , hide: true
674 , border: true
675 , palettes: [ '#FFEE99', '#459', '#78b', '#ab0', '#df5d5d', '#f0f']
676 } ).each( function() {
677 jQuery(this).css( { backgroundColor: jQuery(this).val() } );
678 })
679 .on( 'click', function(){ // FixIn: 8.7.11.12.
680 jQuery('.iris-picker').hide();
681 jQuery(this).closest('div').find('.iris-picker').show();
682 });
683 // FixIn: 8.7.11.12.
684 jQuery('.field-text-color, .field-background-color' ).on( 'click', function(event){
685 event.stopPropagation();
686 });
687 }
688
689 // -----------------------------------------------------------------------------------------------------------------
690 // General Color picker in settings table //////////////////////////////////
691 // -----------------------------------------------------------------------------------------------------------------
692 if ( jQuery('.wpbc_colorpick').length > 0 ) {
693 jQuery('.wpbc_colorpick').iris( {
694 change: function(event, ui){
695 jQuery(this).css( { backgroundColor: ui.color.toString() } );
696 }
697 , hide: true
698 , border: true
699 , palettes: ['#125', '#459', '#78b', '#ab0', '#de3', '#f0f']
700 } ).each( function() {
701 jQuery(this).css( { backgroundColor: jQuery(this).val() } );
702 })
703 .on( 'click', function(){ // FixIn: 8.7.11.12.
704 jQuery('.iris-picker').hide();
705 jQuery(this).closest('td').find('.iris-picker').show();
706 });
707
708 jQuery('body' ).on( 'click', function() {
709 jQuery('.iris-picker').hide();
710 });
711 // FixIn: 8.7.11.12.
712 jQuery('.wpbc_colorpick' ).on( 'click', function(event){
713 event.stopPropagation();
714 });
715 }
716
717 });
718
719
720
721 ////////////////////////////////////////////////////////////////////////////
722 // Support Functions
723 ////////////////////////////////////////////////////////////////////////////
724
725 /**
726 * Reset of WP Editor or TextArea Content
727 * @param {string} editor_textarea_id - ID of element
728 * @param {string} editor_textarea_content - Content
729 */
730 function wpbc_reset_wp_editor_content( editor_textarea_id, editor_textarea_content ) {
731
732 // FixIn: 8.4.7.18.
733
734 if ( (typeof WPBC_CM !== 'undefined') && ( WPBC_CM.is_defined( '#' + editor_textarea_id ) ) ){
735
736 WPBC_CM.set_codemirror_value( '#' + editor_textarea_id , editor_textarea_content );
737 } else {
738
739 if( typeof tinymce != "undefined" ) {
740 var editor = tinymce.get( editor_textarea_id );
741 if( editor && editor instanceof tinymce.Editor ) {
742 editor.setContent( editor_textarea_content );
743 editor.save( { no_events: true } );
744 } else {
745 jQuery( '#' + editor_textarea_id ).val( editor_textarea_content );
746 }
747 } else {
748 jQuery( '#' + editor_textarea_id ).val( editor_textarea_content );
749 }
750 }
751 }
752
753 /**
754 * Dismiss window / panel in Welcome Page
755 *
756 * @param {type} us_id
757 * @param {type} window_id
758 * @returns {undefined}
759 */
760 //<![CDATA[
761 function wpbc_dismiss_window(us_id, window_id ){
762
763 jQuery.ajax({ // Start Ajax Sending
764 url: wpbc_url_ajax,
765 type:'POST',
766 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');}},
768 // beforeSend: someFunction,
769 data:{
770 //ajax_action : 'USER_SAVE_WINDOW_STATE',
771 action : 'USER_SAVE_WINDOW_STATE',
772 user_id: us_id ,
773 window: window_id,
774 is_closed: 1,
775 wpbc_nonce: document.getElementById('wpbc_admin_panel_dismiss_window_nonce').value
776 }
777 });
778 }
779 //]]>
780
781 /**
782 * Hide HTML element with animation during 0.5 second
783 *
784 * @param window_id - HTML ID of element, such as 'wpbc_my_window' - without # symbol
785 */
786 function wpbc_hide_window( window_id ){
787 jQuery( '#' + window_id ).slideUp( 800 );
788 }
789