PageSourceSearch

https://davidsonsgroup.co.uk/wp-content/plugins/bookly-addon-staff…/js/staff-cabinet-calendar.js?ver=22.3.1

js davidsonsgroup.co.uk collected 2026-09-25 04:22:16 UTC 4,334 bytes, 111 lines download raw bytes

1(function ($) {
2    window.booklyStaffCalendar = function (Options) {
3        let $container = $('.bookly-js-calendar.' + Options.calendar_id);
4        if (!$container.length) {
5            return;
6        }
7        let options = {
8            calendar: {
9                headerToolbar: {
10                    start: 'prev,next today',
11                    center: 'title',
12                    end: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
13                },
14                view: 'dayGridMonth',
15            },
16            getCurrentStaffId: function () {
17                return Options.staff_id;
18            },
19            viewChanged: function (view) {
20                calendar.ec.setOption('height', heightEC(view.type));
21            },
22            l10n: BooklySCCalendarL10n
23        },
24        $footer = $('.bookly-js-calendar-footer', $container.closest('.bookly-staff-cabinet')),
25        calendarTimer = null;
26
27        // Init EventCalendar.
28        let calendar = new BooklyCalendar($container, options);
29
30        // Export to CSV modal
31        let $exportDialog = $('#bookly-js-export-dialog'),
32            $exportSelectAll = $('#bookly-js-export-select-all', $exportDialog);
33        $('.bookly-js-export-btn').click(function () {
34            $exportDialog.booklyModal('show');
35        });
36
37        $exportDialog.find('form').on('submit', function () {
38            $exportDialog.booklyModal('hide');
39        });
40
41        $exportSelectAll
42            .on('click', function () {
43                let checked = this.checked;
44                $('.bookly-js-columns input', $exportDialog).each(function () {
45                    $(this).prop('checked', checked);
46                });
47            });
48
49        $('.bookly-js-columns input', $exportDialog)
50            .on('change', function () {
51                $exportSelectAll.prop('checked', $('.bookly-js-columns input:checked', $exportDialog).length == $('.bookly-js-columns input', $exportDialog).length);
52            });
53
54        $exportDialog.on('show.bs.modal', function () {
55            let calendar_view = calendar.ec.view;
56            $('.bookly-js-export-start').val(moment(calendar_view.activeStart).format('YYYY-MM-DD'));
57            $('.bookly-js-export-end').val(moment(calendar_view.activeEnd).format('YYYY-MM-DD'));
58        });
59
60        function heightEC(view_type) {
61            let calendar_tools_height = 71,
62                day_head_height = 28,
63                slot_height = 17.85,
64                weeks_rows = 5,
65                day_slots_count = 5,
66                height = (calendar_tools_height + (day_slots_count * slot_height + day_head_height) * weeks_rows)
67            ;
68            if (view_type != 'dayGridMonth') {
69                if ($('.ec-content', $container).height() < height) {
70                    height = 'auto';
71                }
72            }
73            return height === 'auto' ? 'auto' : (calendar_tools_height + height) + 'px';
74        }
75
76        $(window).on('resize', function () {
77            calendar.ec.setOption('height', heightEC(calendar.ec.getOption('view')));
78        });
79
80        function refreshBooklyCalendar() {
81            let $refresh = $('input[name="bookly_calendar_refresh_rate"]:checked',$footer);
82            clearTimeout(calendarTimer);
83            if ($refresh.val() > 0) {
84                calendarTimer = setInterval(function () {
85                    calendar.ec.refetchEvents();
86                }, $refresh.val() * 1000);
87            }
88        }
89
90        $('input[name="bookly_calendar_refresh_rate"]', $footer).change(function () {
91            $.post(
92                ajaxurl,
93                {action: 'bookly_update_calendar_refresh_rate', csrf_token: BooklyL10nGlobal.csrf_token, rate: this.value},
94                function (response) {},
95                'json'
96            );
97            if (this.value > 0) {
98                $(this).closest('.btn-group').find('button').addClass('btn-success').removeClass('btn-default');
99            } else {
100                $(this).closest('.btn-group').find('button').addClass('btn-default').removeClass('btn-success');
101            }
102            refreshBooklyCalendar();
103        });
104
105        $('.bookly-js-calendar-refresh', $footer).on('click', function () {
106            calendar.ec.refetchEvents();
107        });
108
109        refreshBooklyCalendar();
110    }
111})(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.