PageSourceSearch

https://www.santuarioincoronatamontoro.it/wp-content/plugins/bookn…/step_service_extras.js?v=1.3.5&ver=1.3.5

js santuarioincoronatamontoro.it collected 2026-09-28 03:22:59 UTC 10,403 bytes, 239 lines download raw bytes

1(function ($) {
2
3    bookneticHooks.addAction('booking_panel_loaded', function (booknetic) {
4        let booking_panel_js = booknetic.panel_js;
5
6        booking_panel_js.on('click', '.booknetic_service_extra_card', function (e) {
7            // If view more button is clicked inside services card
8            if ($(e.target).is(".booknetic_view_more_service_notes_button")) {
9                $(this).find('.booknetic_service_card_description_wrapped, .booknetic_view_more_service_notes_button').css('display', 'none');
10                $(this).find('.booknetic_service_card_description_fulltext, .booknetic_view_less_service_notes_button').css('display', 'inline');
11                booknetic.handleScroll();
12            } else if ($(e.target).is('.booknetic_view_less_service_notes_button')) {
13                $(this).find('.booknetic_service_card_description_wrapped, .booknetic_view_more_service_notes_button').css('display', 'inline');
14                $(this).find('.booknetic_service_card_description_fulltext, .booknetic_view_less_service_notes_button').css('display', 'none');
15                booknetic.handleScroll();
16            }
17        }).on('click', '.booknetic_extra_on_off_mode', function (e) {
18            if ($(e.target).is('.booknetic_service_extra_quantity_inc, .booknetic_service_extra_quantity_dec'))
19                return;
20
21            if ($(this).hasClass('booknetic_service_extra_card_selected')) {
22                $(this).find('.booknetic_service_extra_quantity_dec').trigger('click');
23            } else {
24                $(this).find('.booknetic_service_extra_quantity_inc').trigger('click');
25            }
26        }).on('click', '.booknetic_service_extra_quantity_inc', function () {
27            var quantity = parseInt($(this).prev().val());
28            quantity = quantity > 0 ? quantity : 0;
29            var max_quantity = parseInt($(this).prev().data('max-quantity'));
30
31            if (max_quantity !== 0 && quantity >= max_quantity) {
32                quantity = max_quantity;
33            } else {
34                quantity++;
35            }
36
37            $(this).prev().val(quantity).trigger('keyup');
38        }).on('click', '.booknetic_service_extra_quantity_dec', function () {
39            var quantity = parseInt($(this).next().val());
40            quantity = quantity > 0 ? quantity : 0;
41            var min_quantity = parseInt($(this).next().attr('data-min-quantity'));
42
43            if (quantity > min_quantity) {
44                quantity--
45            }
46
47            $(this).next().val(quantity).trigger('keyup');
48        }).on('focusout', '.booknetic_service_extra_quantity_input', function () {
49            // prevent from bypassing restriction on manual input field type
50
51            const quantity = parseInt($(this).val());
52            const min_possible_input = $(this).data('min-quantity');
53            const max_possible_input = $(this).data('max-quantity');
54
55            let updated_quantity = quantity;
56
57            if (quantity > max_possible_input) {
58                updated_quantity = $(this).val(max_possible_input);
59                updated_quantity = max_possible_input;
60            } else if (quantity < min_possible_input) {
61                $(this).val(min_possible_input);
62                updated_quantity = min_possible_input;
63            }
64
65            if (updated_quantity > 0) {
66                $(this).closest('.booknetic_service_extra_card').addClass('booknetic_service_extra_card_selected');
67            } else {
68                $(this).closest('.booknetic_service_extra_card').removeClass('booknetic_service_extra_card_selected');
69            }
70        }).on('keyup', '.booknetic_service_extra_quantity_input', function () {
71            var quantity = parseInt($(this).val());
72            if (!(quantity > 0)) {
73                $(this).val('0');
74                $(this).closest('.booknetic_service_extra_card').removeClass('booknetic_service_extra_card_selected');
75            } else {
76                $(this).closest('.booknetic_service_extra_card').addClass('booknetic_service_extra_card_selected');
77            }
78        }).on('touchstart click', '.booknetic_number_of_brought_customers_inc', function (e) {
79            e.preventDefault();
80            e.stopPropagation();
81            handleQuantityChange($(this), true, booknetic.panel_js);
82        }).on('touchstart click', '.booknetic_number_of_brought_customers_dec', function (e) {
83            e.preventDefault();
84            e.stopPropagation();
85            handleQuantityChange($(this), false, booknetic.panel_js);
86        }).on('keyup', '.booknetic_number_of_brought_customers_quantity_input', function () {
87            let val = Number($(this).val());
88            let max = Number($(this).data('max-quantity')) || 0;
89
90            if (!Number.isInteger(val) || val < 0) {
91                $(this).val(0);
92            } else if (max !== 0 && val > max) {
93                $(this).val(max);
94            }
95        }).on('click', ".booknetic_category_accordion" /* doit bu services stepine de aiddi... */, function (e) {
96            //todo: refactor me, no jokes...
97            if ($(e.target).attr('data-parent') == 1) {
98                let node = $(this).closest('.booknetic_category_accordion').find('>div').not(':first-child')
99
100                if ($(e.target).hasClass('booknetic_service_category') && node.hasClass('booknetic_category_accordion_hidden')) {
101                    node.slideToggle('fast');
102                    node.removeClass('booknetic_category_accordion_hidden');
103                    node.slideToggle(function () {
104                        booknetic.handleScroll();
105                    });
106
107                    $(this).closest('.booknetic_category_accordion').toggleClass('active');
108                } else {
109                    if (node.hasClass('booknetic_category_accordion_hidden')) {
110                        node.css('display', 'none');
111                        node.removeClass('booknetic_category_accordion_hidden');
112                    }
113
114                    $(this).closest('.booknetic_category_accordion').toggleClass('active');
115                    $(this).closest('.booknetic_category_accordion').find('>div').not(':first-child').slideToggle(function () {
116                        booknetic.handleScroll();
117                    });
118                }
119
120            }
121
122        })
123
124    });
125
126    bookneticHooks.addFilter('step_validation_service_extras', function (result, booknetic) {
127        // Check quantity limits first
128        const selectedExtras = booknetic.getSelected.serviceExtras();
129        for (const extra of selectedExtras) {
130            if (extra.quantity > extra.max_quantity) {
131                return {
132                    status: false,
133                    errorMsg: booknetic.__('You have exceed the maximum value for extra service(s).')
134                };
135            }
136        }
137
138        // Get service extra limitations
139        const serviceExtraLimitations = booknetic.panel_js.find(".limitations").data("extra-limitations");
140
141        if(!serviceExtraLimitations){
142            return result
143        }
144
145        const { enabled: isServiceExtraLimiterEnabled, limitations } = serviceExtraLimitations;
146
147        if (!isServiceExtraLimiterEnabled) {
148            return result;
149        }
150
151        const minLimit = parseInt(limitations.min);
152        const maxLimit = parseInt(limitations.max);
153
154        // Count selected extras
155        const serviceExtraCards = booknetic.panel_js.find(`.booknetic_service_extra_card`);
156        let selectedServiceExtraCount = 0;
157
158        serviceExtraCards.each(function() {
159            if ($(this).hasClass(`booknetic_service_extra_card_selected`)) {
160                selectedServiceExtraCount++;
161            }
162        });
163
164        if (minLimit && selectedServiceExtraCount < minLimit) {
165            return {
166                status: false,
167                errorMsg: booknetic.__(`Please select at least ${minLimit} service ${minLimit === 1 ? "extra" : "extras"}`)
168            };
169        }
170
171        if (maxLimit && selectedServiceExtraCount > maxLimit) {
172            return {
173                status: false,
174                errorMsg: booknetic.__(`You can only select ${maxLimit} service ${maxLimit === 1 ? "extra" : "extras"} per booking`)
175            };
176        }
177
178        return result;
179    });
180
181    bookneticHooks.addAction('before_step_loading', function (booknetic, new_step_id, old_step_id) {
182        if (new_step_id !== 'service_extras')
183            return;
184
185        booknetic.stepManager.loadStandartSteps(new_step_id, old_step_id);
186    });
187
188    function onServiceExtrasLoaded(booknetic) {
189        const booking_panel_js = booknetic.panel_js;
190        const html = booking_panel_js.find('.booknetic_appointment_container_body [data-step-id="service_extras"]').html();
191
192        let accordion = booking_panel_js.find(".bkntc_service_extras_list .booknetic_category_accordion");
193
194        if (accordion.attr('data-accordion') === 'on') {
195            accordion.toggleClass('active');
196            accordion.attr('data-accordion', 'off');
197        }
198
199        if (BookneticData['skip_extras_step_if_need'] === 'on' && html.includes('booknetic_empty_box')) {
200            booking_panel_js
201                .find('.booknetic_appointment_step_element[data-step-id="service_extras"]:not(.booknetic_menu_hidden)')
202                .hide();
203
204            booknetic.stepManager.refreshStepNumbers();
205            booknetic.stepManager.goForward();
206        }
207    }
208
209    bookneticHooks.addAction('loaded_cached_step', function (booknetic, step_id) {
210        if (step_id !== 'service_extras') return;
211
212        onServiceExtrasLoaded(booknetic);
213    });
214
215    function handleQuantityChange(element, isIncrement, bookneticPanel) {
216        const $input = bookneticPanel.find('.booknetic_number_of_brought_customers_quantity_input');
217        const maxQuantity = parseInt($input.data('max-quantity')) || 0;
218
219        let quantity = parseInt($input.val()) || 0;
220        quantity += isIncrement ? 1 : -1;
221
222        if (quantity < 0) {
223            quantity = 0;
224        }
225
226        if (maxQuantity && quantity > maxQuantity) {
227            quantity = maxQuantity;
228        }
229
230        $input.val(quantity).trigger('keyup');
231    }
232
233    bookneticHooks.addAction('loaded_step', function (booknetic, new_step_id, old_step_i
233d, ajaxData) {
234        if (new_step_id !== 'service_extras') return;
235
236        onServiceExtrasLoaded(booknetic);
237    });
238
239})(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.