jQuery(document).ready( function(){
if( jQuery('.wpdev-validates-as-time').length > 0 ) {
jQuery('.wpdev-validates-as-time').attr('alt','time');
jQuery('.wpdev-validates-as-time').setMask();
}
});
// Send booking Cacel by visitor
function bookingCancelByVisitor(booking_hash, bk_type, wpdev_active_locale){
if (booking_hash!='') {
document.getElementById('submiting' + bk_type).innerHTML =
'
/div>';
var wpdev_ajax_path = wpdev_bk_plugin_url+'/' + wpdev_bk_plugin_filename;
var ajax_type_action='DELETE_BY_VISITOR';
jQuery.ajax({ // Start Ajax Sending
// url: wpdev_ajax_path,
url: wpbc_ajaxurl,
type:'POST',
success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond_insert' + bk_type).html( data ) ;},
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:' + ' http://wpbookingcalendar.com/faq/#ajax-sending-error');}},
// beforeSend: someFunction,
data:{
// ajax_action : ajax_type_action,
action : ajax_type_action,
booking_hash : booking_hash,
bk_type : bk_type,
wpdev_active_locale:wpdev_active_locale,
wpbc_nonce: document.getElementById('wpbc_nonce_delete'+bk_type).value
}
});
return false;
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
// Set cehckbox in booking form Exclusive on click
function wpdevExclusiveCheckbox(element){
jQuery('[name="'+element.name+'"]').prop("checked", false); // Uncheck all checkboxes with this name
element.checked = true;
}
// Set selectbox with multiple selections - Exclusive
function wpdevExclusiveSelectbox(element){
// Get all selected elements.
var selectedOptions = jQuery.find('[name="'+element.name+'"] option:selected');
// Check if we are have more than 1 selection
if ( selectedOptions.length > 1 ) {
var ind = selectedOptions[0].index; // Get index of the first selected element
jQuery('[name="'+element.name+'"] option').prop("selected", false); // Uncheck all checkboxes with this name
jQuery('[name="'+element.name+'"] option:eq('+ind+')').prop("selected", true); // Set the first element selected
}
}
////////////////////////////////////////////////////////////////////////////////
function showErrorTimeMessage(my_message, element){
var element_name = element.name
jQuery("[name='"+ element_name +"']")
.css( {'border' : '1px solid red'} )
.fadeOut( 350 )
.fadeIn( 500 )
.animate( {opacity: 1}, 4000 )
.animate({border : '1px solid #DFDFDF'},100)
; // mark red border
jQuery("[name='"+ element_name +"']")
.after('
'+ my_message +'
'); // Show message
jQuery(".wpdev-help-message")
.css( {'color' : 'red'} )
.animate( {opacity: 1}, 10000 )
.fadeOut( 2000 ); // hide message
element.focus(); // make focus to elemnt
return true;
}
function isValidTimeTextField(timeStr) {
// Checks if time is in HH:MM AM/PM format.
// The seconds and AM/PM are optional.
var timePat = /^(\d{1,2}):(\d{2})(\s?(AM|am|PM|pm))?$/;
var matchArray = timeStr.match(timePat);
if (matchArray == null) {
return false; //("");
}
var hour = matchArray[1];
var minute = matchArray[2];
var ampm = matchArray[4];
if (ampm=="") {ampm = null}
if (hour < 0 || hour > 23) {
return false; //("");
}
if (hour > 12 && ampm != null) {
return false; //("");
}
if (minute<0 || minute > 59) {
return false; //("");
}
return true;
}
function is_this_time_selections_not_available(bk_type, form_elements ) {
if (location.href.indexOf('wpdev-booking.phpwpdev-booking-reservation')>0) return false; //Skip this checking if we are in the Admin panel at Add booking page
var count = form_elements.length;
var start_time = false;
var end_time = false;
var element; var element_start=false; var element_end=false; var element_duration=false; var element_rangetime=false;
var duration = false;
// Get Start and End time from this form, if they exist.
for (var i=0; i
\n\
'+ajax_bk_message+'
\n\
\n\
\n\
\n\
';
var wpdev_ajax_path = wpdev_bk_plugin_url+'/' + wpdev_bk_plugin_filename ;
jQuery.ajax({ // Start Ajax Sending
// url: wpdev_ajax_path,
url: wpbc_ajaxurl,
type:'POST',
success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond').html( data );},
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:' + ' http://wpbookingcalendar.com/faq/#ajax-sending-error'); } },
// beforeSend: someFunction,
data:{
// ajax_action : 'UPDATE_REMARK',
action : 'UPDATE_REMARK',
remark_id : id,
remark_text : text,
wpbc_nonce: document.getElementById('wpbc_admin_panel_nonce').value
}
});
return false;
}
function wpdev_change_bk_resource( booking_id, resource_id ){
document.getElementById("changing_bk_res_in_booking" + booking_id ).style.display="none";
var ajax_bk_message = 'Changing resource...';
document.getElementById('ajax_working').innerHTML =
'