PageSourceSearch

https://www.angelholmshem.se/js/news-archive-filter-interop.js?v=E9ObjPUEYX4YMbJCeuW9OoPDsXJDy5HmzoB78k5HdtE

js angelholmshem.se collected 2026-10-07 22:17:21 UTC 3,100 bytes, 75 lines download raw bytes

1window.NewsArchiveFilterInterop = {
2    // labels: { today, clear } — supplied from the component's translation system.
3    _initPicker: function (el, labels, setDateCallback, clearCallback) {
4        if (el.length === 0) return;
5
6        // Reuse the shared initializer so day/month names and culture handling
7        // live in one place (WebbCore.Form.initDateTimePicker -> GetCurrentCulture).
8        // autoApply=false shows the button footer; autoUpdateInput=false lets us set the value.
9        // NOTE: initDateTimePicker creates the picker asynchronously (after an AJAX culture
10        // lookup), so we must wait for the instance before touching its buttons.
11        WebbCore.Form.initDateTimePicker(el, false, false);
12
13        var attempts = 0;
14        var attach = function () {
15            var picker = el.data('daterangepicker');
16            if (!picker) {
17                if (attempts++ < 100) setTimeout(attach, 30);
18                return;
19            }
20
21            var buttons = picker.container.find('.drp-buttons');
22
23            // Relabel the built-in cancel button as "clear".
24            if (labels && labels.clear) buttons.find('.cancelBtn').html(labels.clear);
25
26            // Inject a "today" shortcut on the left of the footer.
27            if (!buttons.find('.idag-btn').length) {
28                var todayBtn = $('<button type="button" class="btn btn-sm btn-default idag-btn" style="float:left"></button>')
29                    .text(labels && labels.today ? labels.today : 'Idag');
30                buttons.prepend(todayBtn);
31                todayBtn.on('click', function () {
32                    var today = moment().format('YYYY-MM-DD');
33                    el.val(today);
34                    picker.hide();
35                    setDateCallback(today);
36                });
37            }
38
39            // Bind callbacks after the picker exists so they aren't wiped by re-init.
40            el.off('apply.daterangepicker cancel.daterangepicker');
41            el.on('apply.daterangepicker', function (ev, p) {
42                var val = p.startDate.format('YYYY-MM-DD');
43                el.val(val);
44                setDateCallback(val);
45            });
46            el.on('cancel.daterangepicker', function () {
47                el.val('');
48                clearCallback();
49            });
50        };
51        attach();
52    },
53
54    initDatePickers: function (dotNetRef, labels) {
55        var self = this;
56        var fromEl = $('#news-filter-from-date');
57        var toEl = $('#news-filter-to-date');
58
59        self._initPicker(
60            fromEl, labels,
61            function (d) { dotNetRef.invokeMethodAsync('SetFromDate', d); },
62            function () { dotNetRef.invokeMethodAsync('SetFromDate', null); }
63        );
64        self._initPicker(
65            toEl, labels,
66            function (d) { dotNetRef.invokeMethodAsync('SetToDate', d); },
67            function () { dotNetRef.invokeMethodAsync('SetToDate', null); }
68        );
69    },
70
71    clearDatePickers: function () {
72        $('#news-filter-from-date').val('');
73        $('#news-filter-to-date').val('');
74    }
75};

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.