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

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