PageSourceSearch

https://lavenderblush-swan-341415.hostingersite.com/wp-content/plu…/resources/js/staff-services.js?ver=28.3

js lavenderblush-swan-341415.hostingersite.com collected 2026-10-03 04:30:15 UTC 10,223 bytes, 214 lines download raw bytes

1(function ($) {
2
3    var Services = function($container, options) {
4        var obj  = this;
5        jQuery.extend(obj.options, options);
6
7        // Load services form
8        if (options.reload) {
9            $container.html('<div class="bookly-loading"></div>');
10            $.ajax({
11                type: 'POST',
12                url: ajaxurl,
13                data: $.extend({csrf_token: BooklyL10nGlobal.csrf_token}, obj.options.get_staff_services),
14                dataType: 'json',
15                xhrFields: {withCredentials: true},
16                crossDomain: 'withCredentials' in new XMLHttpRequest(),
17                success: function (response) {
18                    $container.html('');
19                    $container.append(response.data.html);
20                    $container.removeData('init');
21                    obj.options.onLoad();
22                    init($container, obj);
23                }
24            });
25        } else {
26            init($container, obj);
27        }
28    };
29
30    function init($container, obj) {
31        $(document.body).trigger('special_hours.tab_init', [$container, obj.options]);
32        let $services_form = $('form', $container);
33        var autoTickCheckboxes = function () {
34            // Handle 'select category' checkbox.
35            $('.bookly-js-category-checkbox').each(function () {
36                $(this).prop(
37                    'checked',
38                    $('.bookly-js-category-services .bookly-js-service-checkbox[data-category-id="' + $(this).data('category-id') + '"]:not(:checked)').length == 0
39                );
40            });
41            // Handle 'select all services' checkbox.
42            $('#bookly-check-all-entities').prop(
43                'checked',
44                $('.bookly-js-service-checkbox:not(:checked)').length == 0
45            );
46        };
47        var checkCapacityError = function ($form_group) {
48            obj.options.validation(false, '');
49            if (parseInt($form_group.find('.bookly-js-capacity-min').val()) > parseInt($form_group.find('.bookly-js-capacity-max').val())) {
50                $form_group.find('input').addClass('is-invalid');
51                $services_form.find('.bookly-js-services-error').html(obj.options.l10n.capacity_error);
52                $services_form.find('#bookly-services-save').prop('disabled', true);
53                obj.options.validation(true, obj.options.l10n.capacity_error);
54            } else if (!(parseInt($form_group.find('.bookly-js-capacity-min').val()) > 0)) {
55                $form_group.find('input').addClass('is-invalid');
56                $services_form.find('.bookly-js-services-error').html(obj.options.l10n.capacity_error);
57                $services_form.find('#bookly-services-save').prop('disabled', true);
58                obj.options.validation(true, '');
59            } else {
60                $form_group.find('input').removeClass('is-invalid');
61                $services_form.find('.bookly-js-services-error').html('');
62                $services_form.find('#bookly-services-save').prop('disabled', false);
63            }
64        };
65
66        $services_form
67            // Select all services related to chosen category
68            .on('click', '.bookly-js-category-checkbox', function () {
69                $('.bookly-js-category-services [data-category-id="' + $(this).data('category-id') + '"]').prop('checked', $(this).is(':checked')).change();
70                autoTickCheckboxes();
71            })
72            // Check and uncheck all services
73            .on('click', '#bookly-check-all-entities', function () {
74                $('.bookly-js-service-checkbox', $services_form).prop('checked', $(this).is(':checked')).change();
75                $('.bookly-js-category-checkbox').prop('checked', $(this).is(':checked'));
76            })
77            // Select service
78            .on('click', '.bookly-js-service-checkbox', function () {
79                autoTickCheckboxes();
80            })
81            // Save services
82            .on('click', '#bookly-services-save', function (e) {
83                e.preventDefault();
84                let ladda = Ladda.create(this);
85                ladda.start();
86                $.ajax({
87                    type: 'POST',
88                    url: ajaxurl,
89                    data: booklySerialize.buildRequestDataFromForm('bookly_update_staff_services', $services_form),
90                    dataType: 'json',
91                    xhrFields: {withCredentials: true},
92                    crossDomain: 'withCredentials' in new XMLHttpRequest(),
93                    success: function (response) {
94                        ladda.stop();
95                        if (response.success) {
96                            obj.options.saving({success: [obj.options.l10n.saved]});
97                        }
98                    }
99                });
100            })
101            // After reset auto tick group checkboxes.
102            .on('click', '#bookly-services-reset', function () {
103                setTimeout(function () {
104                    autoTickCheckboxes();
105                    $('.bookly-js-capacity-form-group', $services_form).each(function () {
106                        checkCapacityError($(this));
107                    });
108                    $('.bookly-js-service-checkbox', $services_form).trigger('change');
109                }, 0);
110            })
111            // Change location
112            .on('change', '#staff_location_id', function () {
113                let get_staff_services = {
114                    action: obj.options.get_staff_services.action,
115                    staff_id: obj.options.get_staff_services.staff_id,
116                };
117                if (this.value != '') {
118                    get_staff_services.location_id = this.value;
119                }
120                new BooklyStaffServices($container, {
121                    reload: true,
122                    get_staff_services: get_staff_services,
123                    l10n: obj.options.l10n,
124                });
125            })
126            // Change default/custom settings for location
127            .on('change', '#custom_location_settings', function () {
128                if ($(this).val() == 1) {
129                    $('#bookly-staff-services', $services_form).show();
130                } else {
131                    $('#bookly-staff-services', $services_form).hide();
132                }
133            });
134
135        $('.bookly-js-service-checkbox').on('change', function () {
136            let $this = $(this),
137                $service = $this.closest('li'),
138                $inputs = $service.find('input:not(:checkbox)'),
139                $modal = $('#bookly-packages-tip');
140
141            $inputs.attr('disabled', !$this.is(':checked'));
142
143            // Handle package-service connections
144            if ($(this).is(':checked') && $service.data('service-type') == 'package') {
145                let $checkboxes = $('li[data-service-type="simple"][data-service-id="' + $service.data('sub-service') + '"] .bookly-js-service-checkbox:not(:checked)', $services_form);
146                if ($checkboxes.length) {
147                    $checkboxes.prop('checked', true).trigger('change');
148                    if (obj.options.l10n.hideTip !== '1') {
149                        $modal.booklyModal();
150                    }
151                }
152                $('.bookly-js-capacity-min', $service).val($('li[data-service-type="simple"][data-service-id="' + $service.data('sub-service') + '"] .bookly-js-capacity-min', $services_form).val());
153                $('.bookly-js-capacity-max', $service).val($('li[data-service-type="simple"][data-service-id="' + $service.data('sub-service') + '"] .bookly-js-capacity-max', $services_form).val());
154            }
155            if (!$(this).is(':checked') && $service.data('service-type') == 'simple') {
156                let $checkboxes = $('li[data-service-type="package"][data-sub-service="' + $service.data('service-id') + '"] .bookly-js-service-checkbox:checked', $services_form);
157                if ($checkboxes.length) {
158                    $checkboxes.prop('checked', false).trigger('change');
159                    if (obj.options.l10n.hideTip !== '1') {
160                        $modal.booklyModal();
161                    }
162                }
163            }
164        });
165
166        $('#bookly-packages-tip').on('hide.bs.modal', function () {
167            if ($(this).find('.bookly-js-dont-show-packages-tip:checked').length) {
168                obj.options.l10n.hideTip = '1';
169                $.ajax({
170                    type: 'POST',
171                    url: ajaxurl,
172                    data: {
173                        action: 'bookly_packages_hide_staff_services_tip',
174                        csrf_token: BooklyL10nGlobal.csrf_token
175                    },
176                    dataType: 'json',
177                });
178            }
179        });
180
181        $('.bookly-js-capacity').on('keyup change', function () {
182            var $service = $(this).closest('li');
183            if ($service.data('service-type') == 'simple') {
184                if ($(this).hasClass('bookly-js-capacity-min')) {
185                    $('li[data-service-type="package"][data-sub-service="' + $service.data('service-id') + '"] .bookly-js-capacity-min', $services_form).val($(this).val());
186                } else {
187                    $('li[data-service-type="package"][data-sub-service="' + $service.data('service-id') + '"] .bookly-js-capacity-max', $services_form).val($(this).val());
188                }
189            }
190            checkCapacityError($(this).closest('.form-group'));
191        });
192        $('#custom_location_settings', $services_form).trigger('change');
193        autoTickCheckboxes();
194    }
195
196    Services.prototype.options = {
197        reload: false,
198        get_staff_services: {
199            action  : 'bookly_get_staff_services',
200            staff_id: -1,
201        },
202        booklyAlert: window.booklyAlert,
203        saving: function (alerts) {
204            $(document.body).trigger('staff.saving', [alerts]);
205        },
206        validation: function (has_error, info) {
207            $(document.body).trigger('staff.validation', ['staff-services', has_error, info]);
208        },
209        onLoad: function () {},
210        l10n: {}
211    };
212
213    window.BooklyStaffServices = Services;
214})(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.