PageSourceSearch

https://www.hotel-louis2.com/wp-content/plugins/de-builder-evo-blo…/assets/js/a11y_patches.js?ver=1.0.2

js hotel-louis2.com collected 2026-09-27 01:16:47 UTC 9,354 bytes, 245 lines download raw bytes

1(function ($) {
2
3    function itemsHn() {
4        //things that shouldn't be a title
5        $('h2:has(+ h1), h1 + h2, h3:has(+ h2), h2 + h3').attr('role', 'generic');
6
7        //things that have to be a title
8        $('.title:not(.content_wrap, .collapsibleContent_btn, .no_aria, h1)').each(function () {
9            var ancestor = $(this).parents('.de_block, #slideshow-1');
10
11            if (ancestor.attr('id') !== 'slideshow-1') {
12
13                var mainTitle = ancestor.find('h2');
14                var lvl = mainTitle.length > 0 ? '3' : '2';
15                var txt = $(this).text();
16                $(this).empty();
17                $(this).append('<span class="aria-title" role="heading" aria-level="' + lvl + '">' + txt + '</span>')
18
19            } else {
20                $(this).attr('role', 'generic')
21            }
22
23        });
24    }
25
26    function slickArrows() {
27        $('.slick-arrow').each(function () {
28            $(this).attr('role', 'button');
29            $(this).addClass('link_button');
30            if ($(this).hasClass('prev')) {
31                $(this).attr('aria-label', a11yPatchesStrings.prev);
32            } else {
33                $(this).attr('aria-label', a11yPatchesStrings.next);
34            }
35        });
36
37        $('.slick-initialized').each(function () {
38            var wrap = $(this);
39            var controls = wrap.parent().find('.slick-dots button, .slick-arrow');
40            var items = wrap.find(' .slick-slide:not(.slick-cloned)');
41            var total = items.length;
42            var liveRegion = wrap.find('span.slick-live-region');
43
44            if (liveRegion.length === 0) {
45                wrap.append('<span class="sr-only slick-live-region" aria-live="polite"></span>');
46            }
47
48            //sometimes controls are not in the parent (ex offers_carousel)
49            if (controls.length === 0 && !wrap.parent().hasClass('slideshow_container')) {
50                controls = wrap.parent().parent().find('.slick-dots button, .slick-arrow');
51            }
52
53            controls.on('click', function () {
54
55                var iterator = parseInt(wrap.find('.slick-current').attr('data-slick-index')) + 1;
56                var label = iterator + '/' + total;
57                label += wrap.find('.slick-current .title').eq(0).text() !== '' ? ' - ' + wrap.find('.slick-current .title').eq(0).text() : '';
58                label += wrap.find('.slick-current .price_wrap').eq(0).text() !== '' ? '. ' + wrap.find('.slick-current .price_wrap').eq(0).text() : '';
59
60                wrap.find('span.slick-live-region').empty();
61                wrap.find('span.slick-live-region').text(label);
62
63                setTimeout(function () {
64                    redundantLinks();
65                }, 1000);
66
67            });
68
69            items.each(function () {
70                var iterator = parseInt($(this).attr('data-slick-index')) + 1;
71                var labelGroup = iterator + '/' + total;
72                $(this).attr('role', 'group');
73                $(this).attr('aria-label', labelGroup);
74            });
75
76        })
77    }
78
79    function readMore() {
80        var links = $('.read_more, .info, .pop_up')
81        links.each(function () {
82            var link = $(this);
83            if (!link.is('a')) {
84                link = $(this).find('> a');
85            }
86            if (link.attr('href') === '#') {
87                link.attr('role', 'button');
88            }
89            var title = link.closest('.item_wrap').find('.title').eq(0).text();
90            var label = link.text() + ' ' + a11yPatchesStrings.about + ' ' + title;
91            link.attr('aria-label', label);
92        });
93    }
94
95    function redundantLinks() {
96        $('a.thumb, a.plus_corner:not(.description)').each(function () {
97            $(this).attr('tabindex', '-1');
98            $(this).attr('aria-hidden', 'true');
99        });
100        $('a:has(.aria-title):not([aria-expanded]), a.price_wrap').each(function () {
101            $(this).attr('tabindex', '-1');
102        });
103    }
104
105    function buttonFix() {
106        const body = $('body');
107        body.keydown(function (e) {
108            let isSupposedToBeAButton = $(e.target).is('.link_button[role="button"]');
109            if ((e.keyCode === 32 || e.keyCode === 13) && isSupposedToBeAButton) {
110                e.preventDefault();
111            }
112            if (e.keyCode === 32 && isSupposedToBeAButton) {
113                $(e.target).click();
114            }
115
116        });
117        body.keyup(function (e) {
118            let isSupposedToBeAButton = $(e.target).is('.link_button[role="button"]');
119            if ((e.keyCode === 32 || e.keyCode === 13) && isSupposedToBeAButton) {
120                e.preventDefault();
121            }
122            if (e.keyCode === 13 && isSupposedToBeAButton) {
123                $(e.target).click();
124            }
125        });
126    }
127
128
129    $(document).ready(function () {
130        itemsHn();
131        slickArrows();
132        readMore();
133        redundantLinks();
134        buttonFix();
135    });
136
137    $(window).on('load', function () {
138        itemsHn();
139        slickArrows();
140        readMore();
141        redundantLinks();
142        buttonFix();
143    });
144
145    //webSdk offers block
146    $('.offers_carousel > div, .offers_grid > div').on('builder_offers_ready', function () {
147        itemsHn();
148        readMore();
149        setTimeout(function () {
150            slickArrows();
151            redundantLinks();
152            buttonFix();
153        }, 1000);
154    });
155
156    $('div[data-websdk="Offers"][id^="room_"]').on('builder_offers_ready', function (e) {
157        redundantLinks();
158        var target = $(e.target);
159        var card = target.closest('.slick-slide');
160        if (card.attr('aria-hidden') === 'true') {
161            target.find('a').attr('tabindex', '-1');
162        }
163        setTimeout(function () {
164            if (card.attr('aria-hidden') === 'true' && card.hasClass('.slick-cloned')) {
165                card.find('div[data-websdk="Offers"][id^="room_"] a').attr('tabindex', '-1');
166            }
167
168        }, 1000);
169    });
170
171    //some fix for gform
172    $(document).on('gform_post_render', function (event, form_id, current_page) {
173        //add reference to error message via aria-describeby
174        var fields = $('#gform_' + form_id + ' .gfield');
175        var submit = $('#gform_submit_button_' + form_id);
176        var captcha = $('#gform_' + form_id + ' .ginput_recaptcha');
177        var iframe = captcha.find('iframe');
178
179        fields.each(function () {
180            field = $(this);
181            var input = field.find('input, select, textarea');
182            input.removeAttr('tabindex');
183            if (input.attr('aria-invalid') === 'true') {
184                var id = field.attr('id').replace('field_', '');
185                input.attr('aria-describedby', 'validation_message_' + id);
186            }
187        });
188        submit.removeAttr('aria-label');
189        submit.removeAttr('tabindex');
190        //bloody captcha
191        captcha.removeAttr('data-tabindex');
192        iframe.removeAttr('tabindex');
193        if (captcha.parent().hasClass('gfield_error')) {
194            var id = field.attr('id').replace('field_', '');
195            captcha.attr('aria-describedby', 'validation_message_' + id);
196            iframe.removeAttr('tabindex');
197
198        }
199
200        submit.on('click', function () {
201            $(this).attr('aria-label', a11yPatchesStrings.submit);
202        });
203
204        //focus on error/success message after validation
205        var error = $('*[id^=input_' + form_id + '][aria-invalid=true], ' +
206            '.gfield_error .clear-multi input[id^=input_' + form_id + '],' +
207            '.gfield_error .gfield_checkbox input[id^=choice_' + form_id + '],' +
208            '.gfield_error .ginput_recaptcha[id^=input_' + form_id + ']').eq(0);
209
210
211        if (error.length > 0) {
212            //damned captcha
213            if (error.hasClass('ginput_recaptcha')) {
214                error.attr('tabindex', '-1');
215            }
216            //bloody multi input field
217            if (error.parent().hasClass('clear-multi')) {
218                error.attr('aria-describedby', 'validation_message_' + error.attr('id').replace('input_', ''));
219            }
220            error.focus();
221        }
222
223        //goddam datepicker I hate it
224        $('.hidden_fancybox:visible').find('.hasDatepicker').on('focus', function () {
225            var dp = $('#ui-datepicker-div');
226            dp.css('position', 'fixed');
227            dp.css('top', $(this)[0].offsetTop + $(this)[0].offsetHeight + $('.hidden_fancybox:visible')[0].offsetTop + 'px');
228            dp.css('left', $(this)[0].offsetLeft + $('.hidden_fancybox:visible').offsetLeft + 'px');
229            if (($(this)[0].offsetTop + $(this)[0].offsetHeight + dp.height()) > window_height) {
230                dp.css('transform', 'translateY(calc(-100% - ' + $(this)[0].offsetHeight + 'px)');
231            }
232        });
233    });
234
235    $(document).on('gform_confirmation_loaded', function (event, formId) {
236        var success = $('.gform_confirmation_wrapper');
237        if (success.length > 0) {
238            success.attr('tabindex', '-1');
239            success.focus();
240        }
241
242    });
243
244
245}(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.