PageSourceSearch

https://davidsonsgroup.co.uk/wp-content/plugins/bookly-responsive-…/resources/js/range-tools.js?ver=22.3.1

js davidsonsgroup.co.uk collected 2026-09-25 04:22:22 UTC 6,302 bytes, 140 lines download raw bytes

1(function ($) {
2    window.rangeTools = {
3        setVal: function ($select, text) {
4            $select.val($select.find('option').filter(function () {
5                return $(this).html() == text;
6            }).val());
7        },
8
9        ladda: function (elem) {
10            var ladda = Ladda.create(elem);
11            ladda.start();
12            return ladda;
13        },
14
15        hideUp24Hours: function ($start, $end) {
16            $start.on('change', function () {
17                var $start = $(this),
18                    start_time = $start.val();
19
20                // Hide end time options to keep them within 24 hours after start time.
21                var parts = start_time.split(':');
22                parts[0] = parseInt(parts[0]) + 24;
23                var end_time = parts.join(':');
24                var frag = document.createDocumentFragment();
25                var old_value = $end.val();
26                var new_value = null;
27                $('option', $end).each(function () {
28                    if (this.value <= start_time || this.value > end_time) {
29                        var span = document.createElement('span');
30                        span.style.display = 'none';
31                        span.appendChild(this.cloneNode(true));
32                        frag.appendChild(span);
33                    } else {
34                        frag.appendChild(this.cloneNode(true));
35                        if (new_value === null || old_value == this.value) {
36                            new_value = this.value;
37                        }
38                    }
39                });
40                $end.empty().append(frag).val(new_value);
41
42                // when the working day is disabled (working start time is set to 'OFF')
43                // hide all the elements inside the row
44                if (!$start.val()) {
45                    $start.closest('.bookly-js-range-row').find('.bookly-js-hide-on-off').hide().end()
46                        .find('.bookly-js-invisible-on-off').addClass('invisible');
47                } else {
48                    $start.closest('.bookly-js-range-row').find('.bookly-js-hide-on-off').show().end()
49                        .find('.bookly-js-invisible-on-off').removeClass('invisible');
50                }
51            }).trigger('change');
52        },
53
54        hideInaccessibleEndTime: function( $start, $end, force_keep_values ) {
55            var frag       = document.createDocumentFragment(),
56                old_value  = $end.val(),
57                new_value  = null,
58                start_time = $start.val(),
59                parts      = start_time.split(':');
60            parts[0] = parseInt(parts[0]) + 24;
61            var end_time = parts.join(':');
62
63            $('option', $end).each(function () {
64                if (((this.value <= start_time) && (!force_keep_values || this.value != old_value)) || this.value > end_time) {
65                    var span = document.createElement('span');
66                    span.style.display = 'none';
67                    span.appendChild(this.cloneNode(true));
68                    frag.appendChild(span);
69                } else {
70                    frag.appendChild(this.cloneNode(true));
71                    if (new_value === null || old_value == this.value) {
72                        new_value = this.value;
73                    }
74                }
75            });
76            $end.empty().append(frag).val(new_value);
77        },
78
79        // Hide unavailable time in range
80        hideInaccessibleBreaks: function ($start, $end, $parent, force_keep_values) {
81            var parent_range_start = $('.bookly-js-parent-range-start', $parent).val(),
82                parent_range_end   = $('.bookly-js-parent-range-end', $parent).val(),
83                frag1 = document.createDocumentFragment(),
84                frag2 = document.createDocumentFragment(),
85                old_value = $start.val(),
86                new_value = null;
87            $('option', $start).each(function () {
88                if ((this.value < parent_range_start || this.value >= parent_range_end) && (!force_keep_values || this.value != old_value)) {
89                    var span = document.createElement('span');
90                    span.style.display = 'none';
91                    span.appendChild(this.cloneNode(true));
92                    frag1.appendChild(span);
93                } else {
94                    frag1.appendChild(this.cloneNode(true));
95                    if (new_value === null || old_value == this.value) {
96                        new_value = this.value;
97                    }
98                }
99            });
100            $start.empty().append(frag1).val(new_value);
101
102            old_value = $end.val();
103            new_value = null;
104            $('option', $end).each(function () {
105                if ((this.value <= $start.val() || this.value > parent_range_end) && (!force_keep_values || this.value != old_value)) {
106                    var span = document.createElement('span');
107                    span.style.display = 'none';
108                    span.appendChild(this.cloneNode(true));
109                    frag2.appendChild(span);
110                } else {
111                    frag2.appendChild(this.cloneNode(true));
112                    if (new_value === null || old_value == this.value) {
113                        new_value = this.value;
114                    }
115                }
116            });
117            $end.empty().append(frag2).val(new_value);
118        },
119
120        // range_start = parent_range_start + 1h, range_end = parent_range_start + 2h
121        setPopoverRangeDefault: function ($start, $end, $row) {
122            var parent_range_start = $('.bookly-js-parent-range-start',$row).val(),
123                parts = parent_range_start.split(':'),
124                hours = parseInt(parts[0], 10),
125                start_hours = hours + 1;
126            if (start_hours < 10) {
127                start_hours = '0' + start_hours;
128            }
129            var end_hours = hours + 2;
130            if (end_hours < 10) {
131                end_hours = '0' + end_hours;
132            }
133            var end_str = end_hours + ':' + parts[1] + ':' + parts[2],
134                start_str = start_hours + ':' + parts[1] + ':' + parts[2];
135
136            $start.val(start_str);
137            $end.val(end_str);
138        }
139    }
140})(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.