jQuery(document).ready(function() { /*//Jquery for Tabs jQuery('.ab-wrap').tabs(); //Jquery for datepicker jQuery("#holidayDate").datepicker({ dateFormat : 'dd-mm-yy' });*/ //allow to insert only numeric digits with some brackets in input box jQuery(document).on('keypress keydown', ".numeric",function(e) { var regex = new RegExp("^[0-9.()+\t\b -]+$"); //var str = String.fromCharCode(!e.charCode ? e.which : e.charCode); var str = String.fromCharCode(!e.keyCode ? e.which : e.keyCode); //alert(e.keyCode); if ( regex.test(str) || (e.keyCode>=37 && e.keyCode<=40) || (e.keyCode>=96 && e.keyCode<=105) || e.keyCode==46 || e.keyCode==9 || e.keyCode==173) { return true; } e.preventDefault(); return false; }); //allow to insert only numeric digits in input box jQuery(document).on('keypress keydown', ".onlyNumber",function(e) { var regex = new RegExp("^[0-9\t\b -]+$"); //var str = String.fromCharCode(!e.charCode ? e.which : e.charCode); var str = String.fromCharCode(!e.keyCode ? e.which : e.keyCode); //alert(e.keyCode); if ( regex.test(str) || (e.keyCode>=37 && e.keyCode<=40) || (e.keyCode>=96 && e.keyCode<=105) || e.keyCode==46 || e.keyCode==9) { return true; } e.preventDefault(); return false; }); //allow to insert only alphanumeric digits in input box jQuery(document).on('keypress keydown', ".alphaNumeric", function(e) { var regex = new RegExp("^[a-zA-Z0-9._()/+\t\b -]+$"); //var str = String.fromCharCode(!e.charCode ? e.which : e.charCode); var str = String.fromCharCode(!e.keyCode ? e.which : e.keyCode); //alert(e.keyCode); if (regex.test(str) || (e.keyCode>=37 && e.keyCode<=40) || (e.keyCode>=96 && e.keyCode<=105) || e.keyCode==46 || e.keyCode==9) { return true; } e.preventDefault(); return false; }); // OPEN LAST OPENED TAB /*jQuery('.tabbed-content').tabbedContent({ currentClass: 'current', });*/ var lastOpenTab = window.localStorage['lastOpenTab']; tabapi = jQuery('.tabbed-content').tabbedContent({ currentClass: 'current', history: false, onSwitch: function(tab, api){ window.localStorage['lastOpenTab'] = tab; }, onInit: function(api){ if (window.localStorage['lastOpenTab'] != undefined) { api.switch(lastOpenTab); } } }).data('api'); // TIMEPICKER & DATEPICKER attachDateTimePicker(); // AUTO HIDE NOTICE autohideNotice(); // SLOT MACHINE updateSlotId(); jQuery('.js-add-slot-btn').on('click', function(e){ addSlot(); updateSlotId(); e.preventDefault(); }); /*jQuery(document).on('click', '.js-remove-slot-btn', function(e){ removeSlot(e); updateSlotId(); e.preventDefault(); });*/ }); // document.ready // TIME SLOT FUNCTIONS function addSlot() { var slotCount = jQuery('tr.slot-row').length; jQuery('.time-slot-table > tbody').append(' '); } function removeSlot(e) { jQuery(e.target).parents('tr.slot-row').fadeOut(1000).remove(); } function updateSlotId() { jQuery('.slot-row').each(function(index, value){ jQuery(this).attr('data-slot-id', (index+1)); jQuery(this).find('td > strong').text(index+1); jQuery(this).find('input[name^="slotName"]').attr('name', 'slotName_'+(index+1)); jQuery(this).find('input[name^="slotId"]').attr('name', 'slotId_'+(index+1)); // jQuery(this).find('input[name^="slotName"]').val('Slot ' + (index+1)); jQuery(this).find('input[name^="start_time_slot_"]').attr('name', 'start_time_slot_'+(index+1)); jQuery(this).find('input[name^="end_time_slot_"]').attr('name', 'end_time_slot_'+(index+1)); jQuery(this).find('input[name^="slot_max_appointments_"]').attr('name', 'slot_max_appointments_'+(index+1)); jQuery(this).find('div[id^="error_start_time_slot_"]').attr('id', 'error_start_time_slot_'+(index+1)); //jQuery(this).find('input[id^="start_time_slot_"]').attr('id', 'start_time_slot_'+(index+1)); }); attachDateTimePicker(); } function attachDateTimePicker() { jQuery('.timedropper').datetimepicker({ timepicker: true, datepicker: false, format: 'H:i', step: 30 }); jQuery('.datedropper').datetimepicker({ timepicker: false, datepicker: true, format: 'd-m-Y', }); } function autohideNotice() { if( jQuery('.notice').length>0 ){ setTimeout(function(){ jQuery('.notice').fadeOut(1000, function(){ jQuery(this).remove(); }); }, 3000); } } //Common function to display message after ajax function abAlertMessage(resp) { var responseResult = jQuery.parseJSON(resp); if(responseResult.success === false) { jQuery(".ab-wrap").prepend('

'+responseResult.data+'

'); } else if(responseResult.success === true) { jQuery(".ab-wrap").prepend('

'+responseResult.data+'

'); } autohideNotice(); } function abSweetAlertMessage(resp, newthis) { var responseResult = jQuery.parseJSON(resp); if(responseResult.success === false) { swal({title:responseResult.data, type:"error"}); } else if(responseResult.success === true) { swal({title:responseResult.data, type:"success"}); newthis.closest(".search-fade").fadeOut(1000); } } function abAlertMessageList(responseResult) { if(responseResult == '1') { jQuery("#appointment-widget").html('

Appointment Successfully Deleted

'); } else if(responseResult == '0') { jQuery("#appointment-widget").html('

Appointment Successfully Deleted

'); } autohideNotice(); } //to get row id var i; function Drow(ii) { i = ii.rowIndex; // alert(i); } function ajaxPagination(tblId) { //Pagination jQuery(document).on('click', ".displaying-num a", (function(e) { e.preventDefault(); var link = jQuery(this).attr('href'); jQuery(tblId).fadeOut(500, function(){ jQuery(this).load(link + ' ' + tblId, function() { jQuery(this).fadeIn(500); }); }); })); }