PageSourceSearch

https://decodiversmiami.com/wp-content/plugins/quickcal/includes/a…/js/frontend-functions.js

js decodiversmiami.com collected 2026-10-06 09:25:50 UTC 3,136 bytes, 128 lines download raw bytes

1;(function($, window, document, undefined) {
2	var $win = $(window);
3	var $doc = $(document);
4	var $field_container;
5
6	$doc.ready(function() {
7
8		$(document).on("booked-on-new-app", function(event) {
9			$field_container = $('.field.field-paid-service');
10			booked_wc_products_field($field_container);
11		});
12
13		booked_wc_btn_pay_appointment_shortcode();
14
15		$(document).on("booked-on-requested-appointment", function(event,redirectObj) {
16			redirectObj.redirect = booked_wc_redirect_to_checkout_if_product_option();
17		});
18
19	});
20
21	function booked_wc_products_field(field_container) {
22
23		var $dropdown = $('select', field_container);
24
25		if ( $dropdown.find( 'option' ).length < 3 ){
26			$dropdown.find( 'option:first-child' ).remove();
27			var calendar_id = parseInt( $dropdown.data('calendar-id') ),
28				product_id = $dropdown.val(),
29				field_name = $dropdown.attr('name'),
30				$variations_container = $dropdown.parent().find('.paid-variations');
31				booked_wc_load_variations(product_id, field_name, calendar_id, $variations_container);
32		}
33
34		$dropdown.on('change', function() {
35			var $this = $(this),
36				calendar_id = parseInt( $this.data('calendar-id') ),
37				product_id = $this.val(),
38				field_name = $this.attr('name'),
39				$variations_container = $this.parent().find('.paid-variations');
40
41			booked_wc_load_variations(product_id, field_name, calendar_id, $variations_container);
42		});
43	}
44
45	function booked_wc_load_variations( product_id, field_name, calendar_id, variations_container ) {
46
47		if ( !product_id ) {
48			variations_container.html('');
49			return;
50		};
51
52		var data = {
53			'action': booked_wc_variables.prefix + 'load_variations',
54			'product_id': parseInt(product_id),
55			'calendar_id': calendar_id,
56			'field_name': field_name
57		};
58
59		$.post(
60			booked_wc_variables.ajaxurl,
61			data,
62			function(response) {
63				variations_container.html(response);
64				resize_booked_modal();
65			}
66		);
67	}
68
69
70	function booked_wc_btn_pay_appointment_shortcode() {
71		$('.booked-profile-appt-list .appt-block .pay').on('click', function(event) {
72
73			event.preventDefault();
74
75			var $button = $(this),
76				appt_id = $button.attr('data-appt-id');
77
78			confirm_edit = confirm(booked_wc_variables.i18n_pay);
79			if ( confirm_edit===true ){
80
81				var data = {
82					'action': booked_wc_variables.prefix + 'add_to_cart',
83					'app_id': appt_id
84				};
85
86				jQuery.post(booked_wc_variables.ajaxurl, data, function(response) {
87					if ( response.status === 'success' ) {
88						window.location.href = booked_wc_variables.checkout_page;
89					} else {
90						alert( response.messages[0] );
91					};
92				}, 'json');
93			}
94
95			return false;
96		});
97	}
98
99	
100
101	function booked_wc_redirect_to_checkout_if_product_option() {
102
103		var redirect = false,
104			$form = $('form#newAppointmentForm');
105
106		$('.field-paid-service', $form).each(function() {
107			var $this = $(this);
108
109			$('select', $this).each(function() {
110				var $this_select = $(this);
111
112				if ( $this_select.val()!=='' ) {
113					redirect = true;
114				};
115			});
116		});
117
118		if ( redirect ) {
119			window.location = booked_wc_variables.checkout_page;
120			return true;
121		}
122
123		return false;
124
125	}
126
127
128})(jQuery, window, document);

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.