1/** 2 * RENDER CHOSEN JS ON LOAD 3 */ 4jQuery(window).load(function() { 5 jQuery(".chosen-select").chosen(); 6}); 7 8/** 9 * GF AJAX RENDER CHOSEN 10 */ 11jQuery(document).bind('gform_post_render', function(){ 12 jQuery(".chosen-select").chosen(); 13}); 14 15 16jQuery( document ).ready(function() { 17 /** 18 * Select Service Event - AJAX 19 */ 20 jQuery('body').on('change', '.appointment_service_id', function() { 21 // Remove value to gform input 22 jQuery(".appointment_booking_date, .appointment_booking_time").val( '' ); 23 jQuery("#ga_selected_bookings").fadeOut(300, function() { jQuery(this).html('').removeAttr("style"); }); 24 25 // Add spinner to calendar 26 jQuery('.ga_monthly_schedule_wrapper').addClass('ga_spinner'); 27 28 jQuery('.appointment_provider_id').each(function() { 29 //jQuery(this).hide(); 30 jQuery(this).html('<option value="">Please wait...</option>'); 31 32 if( jQuery(this).hasClass('chosen-select') ) { 33 jQuery(this).trigger("chosen:updated"); 34 } 35 36 }); 37 38 // service id 39 var service_id = jQuery(this).val(); 40 var form_id = jQuery(this).attr('form_id'); 41 42 // wp ajax 43 var data = { 44 'action': 'ga_calendar_select_service', 45 'service_id': service_id, 46 'form_id': form_id, 47 }; 48 49 jQuery.post(ga_calendar_services_obj.ajax_url, data, function(response) { 50 if ( typeof response !== 'undefined' ) { 51 52 if( response.success == true ) { 53 54 jQuery('.appointment_provider_id').each(function() { 55 56 jQuery(this).html( response.data['providers'] ); 57 58 if( jQuery(this).hasClass('chosen-select') ) { 59 jQuery(this).trigger("chosen:updated"); 60 } 61 62 }); 63 64 65 jQuery('#gappointments_calendar').find('.ga_monthly_schedule_wrapper').html( response.data['calendar'] ); 66 67 // Remove spinner from calendar 68 jQuery('.ga_monthly_schedule_wrapper').removeClass('ga_spinner'); 69 70 gform_appointment_cost_filter(); 71 } 72 73 } 74 75 //console.log(response); 76 //ga_ajax_response(response); 77 }); 78 // wp ajax 79 }); 80 81 /** 82 * Select Provider Event - AJAX 83 */ 84 jQuery('body').on('change', '.appointment_provider_id', function() { 85 // Remove value to gform input 86 jQuery(".appointment_booking_date, .appointment_booking_time").val( '' ); 87 jQuery("#ga_selected_bookings").fadeOut(300, function() { jQuery(this).html('').removeAttr("style"); }); 88 89 // Add spinner to calendar 90 jQuery('.ga_monthly_schedule_wrapper').addClass('ga_spinner'); 91 92 // service id 93 var provider_id = jQuery(this).val(); 94 var service_id = jQuery('.appointment_service_id').val(); 95 var form_id = jQuery(this).attr('form_id'); 96 97 //alert( service_id ); 98 99 // wp ajax 100 var data = { 101 'action': 'ga_calendar_select_provider', 102 'service_id': service_id, 103 'provider_id': provider_id, 104 'form_id': form_id, 105 }; 106 107 jQuery.post(ga_calendar_providers_obj.ajax_url, data, function(response) { 108 ga_ajax_response(response); 109 110 111 // Remove spinner from calendar 112 jQuery('.ga_monthly_schedule_wrapper').removeClass('ga_spinner'); 113 114 gform_appointment_cost_filter(); 115 }); 116 }); 117 118 /** 119 * Calendar Previous Month Event - AJAX 120 */ 121 jQuery('body').on('click', '#ga_calendar_prev_month', function() { 122 // Remove value to gform input 123 jQuery(".appointment_booking_date, .appointment_booking_time").val( '' ); 124 125 // Add spinner to calendar 126 jQuery('.ga_monthly_schedule_wrapper').addClass('ga_spinner'); 127 128 var current_month = jQuery(this).attr('date-go'); 129 var service_id = jQuery(this).attr('service_id'); 130 var provider_id = jQuery(this).attr('provider_id'); 131 var form_id = jQuery('#ga_appointments_calendar').attr('form_id'); 132 133 var data = { 134 'action': 'ga_calendar_prev_month', 135 'current_month': current_month, 136 'service_id': service_id, 137 'provider_id': provider_id, 138 'form_id': form_id, 139 }; 140 141 jQuery.post(ga_calendar_prev_month_obj.ajax_url, data, function(response) { 142 ga_ajax_response(response); 143 144 // Remove spinner from calendar 145 jQuery('.ga_monthly_schedule_wrapper').removeClass('ga_spinner'); 146 }); 147 }); 148 149 /** 150 * Calendar Next Month Event - AJAX 151 */ 152 jQuery('body').on('click', '#ga_calendar_next_month', function() { 153 // Remove value to gform input 154 jQuery(".appointment_booking_date, .appointment_booking_time").val( '' ); 155 156 // Add spinner to calendar 157 jQuery('.ga_monthly_schedule_wrapper').addClass('ga_spinner'); 158
159 var current_month = jQuery(this).attr('date-go'); 160 var service_id = jQuery(this).attr('service_id'); 161 var provider_id = jQuery(this).attr('provider_id'); 162 var form_id = jQuery('#ga_appointments_calendar').attr('form_id'); 163 164 var data = { 165 'action': 'ga_calendar_next_month', 166 'current_month': current_month, 167 'service_id': service_id, 168 'provider_id': provider_id, 169 'form_id': form_id, 170 }; 171 172 jQuery.post(ga_calendar_next_month_obj.ajax_url, data, function(response) { 173 ga_ajax_response(response); 174 175 // Remove spinner from calendar 176 jQuery('.ga_monthly_schedule_wrapper').removeClass('ga_spinner'); 177 }); 178 }); 179 180 /** 181 * Time Slots Event - AJAX 182 */ 183 jQuery('body').on('click', '#service-working-days td.day_available', function(e) { 184 e.preventDefault(); 185 var dateGo = jQuery(this).attr('date-go'); 186 187 // Remove value to gform input 188 jQuery(".appointment_booking_date, .appointment_booking_time").val( '' ); 189 190 if ( jQuery(this).hasClass("selected") ) { 191 var $_this = jQuery(this); 192 jQuery("#gappointments_calendar_slots").slideUp(0, function() { 193 jQuery(this).html(''); 194 }); 195 196 // Remove selected class 197 jQuery($_this).removeClass('selected'); 198 gform_appointment_cost_filter(); 199 return; 200 } 201 202 // Removing all available siblings 203 jQuery('#service-working-days td').each(function() { 204 jQuery(this).removeClass('selected'); 205 }); 206 207 // Adding selected class 208 jQuery(this).addClass('selected'); 209 210 // Add value to gform input 211 jQuery(".appointment_booking_date").val( jQuery(this).attr('date-go') ); 212 213 // Disable time slots if date slots class found 214 if ( jQuery(this).hasClass("ga_date_slots") ) { 215 jQuery(".appointment_booking_time").val( jQuery(this).attr('date-go') ); 216 217 218 // Multiple Dates Selection 219 if( jQuery(this).attr('multi-select') == 'enabled' ) { 220 var valid = true; 221 var inputs = jQuery("#ga_selected_bookings .ga_selected_booking"); 222 var total = jQuery(this).attr('select-total'); 223 var capacity = jQuery(this).attr('capacity'); 224 var no_double = jQuery(this).attr('no_double'); 225 var slot_cost = jQuery(this).attr('service_cost'); 226 var date = jQuery(".appointment_booking_date").val(); 227 var input_date = date; 228 var input_time = jQuery(".appointment_booking_time").val(); 229 var input_value = input_date + ' ' + input_time; 230 231 var d = 0; // Doubles counter 232 jQuery(inputs).each(function() { 233 var dateField = jQuery(this).find( '.ga_selected_booking_date' ).val(); 234 var timeField = jQuery(this).find( '.ga_selected_booking_time' ).val(); 235 var dateTime = dateField + ' ' + timeField; 236 if( inputs.length >= total ) { 237 valid = false; 238 return; 239 } 240 241 // Prevent Double Selections 242 if( no_double == 'yes' ) { 243 if( dateTime == input_value ) { 244 valid = false; 245 } 246 } else { 247 // Doubles Count 248 if( dateTime == input_value ) { 249 d++; 250 } 251 252 if( d >= capacity ) { 253 valid = false; 254 } 255 256 } 257 258 }); 259 260 if(valid) { 261 var human_date = jQuery(this).attr('lang_slot'); 262 var name_date = jQuery(".appointment_booking_date").attr('name').replace("[date]", "[bookings][date][]"); 263 var name_time = jQuery(".appointment_booking_date").attr('name').replace("[date]", "[bookings][time][]"); 264 var input_html = '<div class="ga_selected_booking"><div class="ga_delete_booking"><i class="fa fa-times-circle"></i></div><input type="hidden" class="ga_hidden_input ga_selected_booking_date" name="' + name_date + '" value="' + input_date + '" slot_cost="' + slot_cost + '"><input type="hidden" class="ga_hidden_input ga_selected_booking_time" name="' + name_time + '" value="' + input_time + '" slot_cost="' + slot_cost + '">' + human_date + '</div></div>'; 265 jQuery(input_html).hide().appendTo("#ga_selected_bookings").fadeIn(700); 266 } 267 } 268 // Multiple Dates Selection 269 270 gform_appointment_cost_filter(); 271 272 return; 273 } 274 275 jQuery("#gappointments_calendar_slots").each( function() { 276 jQuery( this ).remove(); 277 }); 278 279 jQuery(this).parent('tr').after('<tr id="gappointments_calendar_slots"><td colspan="7" class="calendar_slots"><div class="calendar_time_slots"><div class="app_hours_loading"><div class="ajax-spinner-bars"> <div class="bar-1"></div><div class="bar-2"></div><div class="bar-3"></div><div class="bar-4"></div><div class="bar-5"></div><div class="bar-6"></div><div class="bar-7"></div><div class="bar-8"></div><div class="bar-9"></div><div class="bar-10"></div><div class="bar-11"></div><div class="bar-12"></div><div class="bar-13"></div><div class="bar-14"></div><div class="bar-15"></div><div class="bar-16"></div></div></div></div></td></tr>'); 280 281 setTimeout( function() { 282 var timeSlots = jQuery( '#' + dateGo ).html(); 283 jQuery('#gappointments_calendar_slots .calendar_time_slots').html(timeSlots); 284 }, 500 ); 285 286 }); 287 288 /** 289 * Ajax Response 290 */ 291 function ga_ajax_response(response) { 292 jQuery('#gappointments_calendar').find('.ga_monthly_schedule_wrapper').html(response); 293 } 294 295 /**
296 * Close Modal Button 297 */ 298 jQuery('body').on('click', '#ga_model .ga_modal_wrapper .ga_remove, form#ga_cancel_appointment .ga_btn_close', function(e) { 299 e.preventDefault(); 300 301 jQuery(this).parents('#ga_model').fadeIn(100, function() { 302 jQuery(this).remove(); 303 jQuery('html, body').removeClass('ga_modal_open'); 304 }); 305 306 }); 307 308 /** 309 * Cancel/Confirm Appointment Modal 310 */ 311 jQuery('body').on('click', '.appointment-status .appointment-action', function(e) { 312 e.preventDefault(); 313 var appID = jQuery(this).attr('app-id'); 314 var title = jQuery(this).attr('title'); 315 var optional_text = jQuery(this).attr('optional_text'); 316 var action = 'ga_cancel_appointment'; 317 var message = '<textarea name="ga_cancel_message" placeholder="' + optional_text + '"></textarea><div class="hr"></div>'; 318 var btn_title = jQuery(this).text(); 319 320 if( jQuery(this).hasClass('provider-cancel') ) { 321 var action = 'ga_provider_cancel_appointment'; 322 } 323 324 if( jQuery(this).hasClass('provider-confirm') ) { 325 var title = jQuery(this).attr('title'); 326 var action = 'ga_provider_confirm'; 327 var message = ''; 328 var btn_title = jQuery(this).text(); 329 } 330 331 var modal_output = '<div id="ga_model" class="ga_modal_bg"><div class="ga_dialog"><div class="ga_dialog_wrapper"><div class="ga_modal_wrapper"><div class="ga_modal_container"><span title="Close" class="ga_close ga_remove"></span><h3 class="modal-title">'+title+'</h3><div class="hr"></div><form id="ga_cancel_appointment" action="" method="post" class="clearfix"><div class="ajax-response"></div><input type="hidden" name="app-id" value="'+appID+'"><input type="hidden" name="action" value="'+action+'">'+message+'<div class="ga_modal_footer"><button type="submit" class="ga-button">'+btn_title+'</button></div></form><div class="modal_overlay"></div></div></div></div></div></div>'; 332 333 jQuery('#ga_appointment_modal').hide().html(modal_output).fadeIn(100, function() { 334 jQuery('html, body').addClass('ga_modal_open'); 335 }); 336 337 window.appointmentID = jQuery(this).parent('.appointment-status'); 338 339 }); 340 341 /** 342 * Cancel/Confirm Appointment - Ajax 343 */ 344 jQuery(document).on("submit", "form#ga_cancel_appointment", function(e) { 345 e.preventDefault(); 346 var modal_wrapper = jQuery(this); 347 var action = modal_wrapper.find('input[name=action]').val(); 348 349 modal_wrapper.parent('.ga_modal_container').find('.modal_overlay').show(); 350 351 var data = jQuery("form#ga_cancel_appointment").serialize(); 352 353 jQuery.post(ga_update_appointment_status_obj.ajax_url, data, function(response) { 354 if ( typeof response !== 'undefined' ) { 355 356 modal_wrapper.parent('.ga_modal_container').find('.modal_overlay').hide(); 357 358 if( response.success == false ) { 359 jQuery("form#ga_cancel_appointment").html(response.data['message']); 360 } 361 362 if( response.success == true ) { 363 jQuery("form#ga_cancel_appointment").html(response.data['message']); 364 jQuery( window.appointmentID ).html(response.data['app_status']); 365 } 366 367 } 368 }).fail(function() { 369 jQuery("form#ga_cancel_appointment .ajax-response").html('<div class="ga_alert ga_alert_danger">Error sending form!</div>'); 370 modal_wrapper.parent('.ga_modal_container').find('.modal_overlay').hide(); 371 }); 372 }); 373 374 375 376 /** 377 * Init Service Cost 378 */ 379 jQuery('body').on('click', '#gappointments_calendar_slots label.time_slot', function() { 380 var time_slot = jQuery(this).attr('time_slot'); 381 jQuery(".appointment_booking_time").val( time_slot ); 382 383 // Removing all available siblings 384 jQuery('#gappointments_calendar_slots label.time_slot').each(function() { 385 jQuery(this).removeClass('time_selected'); 386 }); 387 388 // Adding selected class 389 jQuery(this).addClass('time_selected'); 390 391 // Multiple Selection 392 if( jQuery(this).attr('multi-select') == 'enabled' ) { 393 var valid = true; 394 var inputs = jQuery("#ga_selected_bookings .ga_selected_booking"); 395 var max = jQuery(this).attr('select-max'); 396 var total = jQuery(this).attr('select-total'); 397 var time_format = jQuery(this).attr('time_format'); 398 var remove_am_pm = jQuery(this).attr('remove_am_pm'); 399 var capacity = jQuery(this).attr('capacity'); 400 var no_double = jQuery(this).attr('no_double'); 401 var slot_cost = jQuery(this).attr('slot_cost'); 402 var date = jQuery(".appointment_booking_date").val(); 403 var input_date = date; 404 var input_time = jQuery(".appointment_booking_time").val(); 405 var input_value = input_date + ' ' + input_time; 406 407 var x = 0; 408 var d = 0; // Doubles counter 409 jQuery(inputs).each(function() { 410 var dateField = jQuery(this).find( '.ga_selected_booking_date' ).val(); 411 var timeField = jQuery(this).find( '.ga_selected_booking_time' ).val(); 412 var dateTime = dateField + ' ' + timeField; 413 414 //console.log( dateTime ); 415 //console.log( input_value ); 416 417 // Total max selection is reached
418 if( inputs.length >= total ) { 419 valid = false; 420 return; 421 } 422 423 // Same date is found 424 if( jQuery(this).val().match(date) ) { 425 x++; 426 } 427 428 // Prevent Double Selections 429 if( no_double == 'yes' ) { 430 if( dateTime == input_value || x >= max ) { 431 valid = false; 432 } 433 } else { 434 // Doubles Count 435 if( dateTime == input_value ) { 436 d++; 437 } 438 439 if( d >= capacity ) { 440 valid = false; 441 } 442 } 443 }); 444 445 //console.log( valid ); 446 447 if(valid) { 448 var human_date = jQuery(this).attr('lang_slot'); 449 var name_date = jQuery(".appointment_booking_date").attr('name').replace("[date]", "[bookings][date][]"); 450 var name_time = jQuery(".appointment_booking_date").attr('name').replace("[date]", "[bookings][time][]"); 451 var input_html = '<div class="ga_selected_booking"><div class="ga_delete_booking"><i class="fa fa-times-circle"></i></div><input type="hidden" class="ga_hidden_input ga_selected_booking_date" name="' + name_date + '" value="' + input_date + '" slot_cost="' + slot_cost + '"><input type="hidden" class="ga_hidden_input ga_selected_booking_time" name="' + name_time + '" value="' + input_time + '" slot_cost="' + slot_cost + '">' + human_date + '</div></div>'; 452 jQuery(input_html).hide().appendTo("#ga_selected_bookings").fadeIn(700); 453 } 454 } 455 // Multiple Selection 456 457 gform_appointment_cost_filter(); 458 }); 459 460 461 462 /** 463 * Remove a Selected Booking 464 */ 465 jQuery('body').on('click', '#ga_selected_bookings .ga_selected_booking .ga_delete_booking', function() { 466 jQuery(this).parent('.ga_selected_booking').fadeOut(150, function() { 467 jQuery(this).remove(); 468 gform_appointment_cost_filter(); 469 470 if( !jQuery( '#ga_selected_bookings .ga_selected_booking .ga_delete_booking' ).lenght ) 471 jQuery( '.appointment_booking_time' ).val( '' ); 472 }); 473 }); 474 475 /** 476 * Calculate appointment cost 477 */ 478 function gform_appointment_cost_filter() { 479 var $costFields = jQuery( '.ginput_appointment_cost_input' ); 480 var total = 0; 481 var service_cost = jQuery("#service-working-days td.day_available").attr('service_cost'); 482 483 // Date Slot Selected 484 var dateSelected = jQuery("#service-working-days td.ga_date_slots.selected"); 485 486 // Time Slot Selected 487 var slotSelected = jQuery('#gappointments_calendar_slots label.time_selected'); 488 489 // Mulitple Bookings 490 var bookings = jQuery("#ga_selected_bookings .ga_selected_booking input.ga_selected_booking_date"); 491 492 if( bookings && bookings.length ) { 493 jQuery("#ga_selected_bookings .ga_selected_booking input.ga_selected_booking_date").each(function() { 494 total += Math.max( 0, parseFloat( jQuery(this).attr('slot_cost') ) ); 495 }); 496 } else if( dateSelected && dateSelected.length && jQuery.isNumeric(service_cost) ) { 497 total = service_cost; 498 } else if( slotSelected && slotSelected.length ) { 499 total = slotSelected.attr('slot_cost'); 500 } 501 502 // Add appointment total to cost inputs 503 $costFields.each( function() { 504 jQuery( this ).val( total ).change(); 505 }); 506 507 // Trigger gf total 508 if( typeof gformInitPriceFields == 'function' ) { 509 gformInitPriceFields(); // will trigger "gform_product_total" filter 510 } 511 } 512 513}); // end doc ready 514 515 516 517 518/** 519 * Trigger appointment cost & add cost to total 520 */ 521( function( $ ) { 522 /** 523 * Init Service Cost On AJAX Form Trigger 524 */ 525 jQuery(document).bind('gform_post_render', function() { 526 var $costFields = $( '.ginput_appointment_cost_input' ).change(); 527 $costFields.each( function() { 528 $( this ).change(); 529 }); 530 }); 531 532} )( jQuery );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.