PageSourceSearch

https://www.parliament.gi/assets/js/accessibility.js

js parliament.gi collected 2026-09-25 00:51:49 UTC 5,302 bytes, 167 lines download raw bytes

1var $accesibilityPanel = null;
2function showAccessibilityPanel() {
3    if ($accesibilityPanel) {
4        $accesibilityPanel.animate({right: 0});
5    }
6}
7
8$(document).ready(function() {
9
10    $accesibilityPanel = $('#accesibilityPanel');
11    var $accesibilityArea = $('#accesibilityArea');
12    var $fontElements = null;
13    var fontSize = 0;
14    var colorFilter = null;
15    var highlight = null;
16    var colour = null;
17    var zoom = 1;
18
19    $('#closeAccesibilityPanel').click(function() {
20        var width = parseInt($accesibilityPanel.css('width').slice(0, -2));
21        $accesibilityPanel.animate({right: -(width + 25)});
22    });
23
24    function savePreferences() {
25        sessionStorage.setItem('acc-prefs', JSON.stringify({
26            font: fontSize,
27            filter: colorFilter,
28            highlight: highlight,
29            colour: colour,
30            zoom: zoom,
31        }));
32    }
33    function loadPreferences() {
34        var prefs = sessionStorage.getItem('acc-prefs');
35        if (prefs) {
36            try {
37                prefs = JSON.parse(prefs);
38
39                fontSize = prefs.font;
40                colorFilter = prefs.filter;
41                highlight = prefs.highlight;
42                colour = prefs.colour;
43                zoom = prefs.zoom;
44
45                updateForm();
46                
47                updateFontSize();
48                updateFilter();
49                updateHightlight();
50                updateColour();
51                updateZoom();
52            } catch (e) {
53            }
54        }
55        else {
56            updateLabels();
57        }
58    }
59    function updateForm() {
60        $('[name="accessibilityFiltersOptions"][value="' + colorFilter + '"]').prop("checked", true);
61        $('[name="accessibilityHighlightOptions"][value="' + highlight + '"]').prop("checked", true);
62        $('[name="accessibilityColourOptions"][value="' + colour + '"]').prop("checked", true);
63    }
64    function updateLabels() {
65        $('.accesibilityFontSize').html(20 + fontSize);
66        $('.accesibilityZoomScale').html(Math.round(zoom * 100) / 100);
67    }
68
69    // Font
70    $('.accesibilityFontIncrease').click(function() {
71        fontSize += 2;
72        updateFontSize();
73        savePreferences();
74    });
75    $('.accesibilityFontDecrease').click(function() {
76        fontSize = Math.max(fontSize - 2, -18);
77        updateFontSize();
78        savePreferences();
79    });
80    $('.accesibilityFontReset').click(function() {
81        fontSize = 0;
82        updateFontSize();
83        savePreferences();
84    });
85    function updateFontSize() {
86        if ($fontElements == null) {
87            $fontElements = $accesibilityArea.find('h1,h2,h3,h4,h5,h6,p,a,span,li');
88        }
89        $fontElements.each(function() {
90            var $this = $(this);
91            if (!$this.data('original-size')) {
92                var originalSize = parseInt($this.css('font-size').slice(0, -2));
93                $this.data('original-size', originalSize);
94            }
95            
96            $this
97                .css('font-size', $this.data('original-size') + fontSize + 'px')
98                .css('line-height', $this.data('original-size') + fontSize + 5 + 'px');
99        });
100        updateLabels();
101    }
102
103    // Filters
104    $('[name="accessibilityFiltersOptions"]').click(function() {
105        colorFilter = $(this).val();
106        updateFilter();
107        savePreferences();
108    });
109    function updateFilter() {
110        $accesibilityArea.removeClass('acc-filter-grayscale acc-filter-invert acc-filter-w-blue acc-filter-w-green');
111        if (colorFilter) {
112            $accesibilityArea.addClass('acc-filter-' + colorFilter);
113        }
114    }
115
116    // Highlight
117    $('[name="accessibilityHighlightOptions"]').click(function() {
118        highlight = $(this).val();
119        updateHightlight();
120        savePreferences();
121    });
122    function updateHightlight() {
123        $accesibilityArea.removeClass('acc-highlight-links acc-highlight-titles acc-highlight-text');
124        if (highlight) {
125            $accesibilityArea.addClass('acc-highlight-' + highlight);
126        }
127    }
128
129    // Colours
130    $('[name="accessibilityColourOptions"]').click(function() {
131        colour = $(this).val();
132        updateColour();
133        savePreferences();
134    });
135    function updateColour() {
136        $accesibilityArea.removeClass('acc-colour-black acc-colour-yellow acc-colour-green acc-colour-white');
137        if (colour) {
138            $accesibilityArea.addClass('acc-colour-' + colour);
139        }
140    }
141
142    // Zoom
143    $('.accesibilityZoomIncrease').click(function() {
144        zoom += 0.1;
145        updateZoom();
146        savePreferences();
147    });
148    $('.accesibilityZoomDecrease').click(function() {
149        zoom = Math.max(zoom - 0.1, 0.1);
150        updateZoom();
151        savePreferences();
152    });
153    $('.accesibilityZoomReset').click(function() {
154        zoom = 1;
155        updateZoom();
156        savePreferences();
157    });
158    function updateZoom() {
159        $accesibilityArea
160            .css('transform', 'scale(' + zoom + ')')
161            .css('transform-origin', '0 0 0');
162        updateLabels();
163    }
164
165    loadPreferences();
166
167});

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.