PageSourceSearch

https://akks.no/wp-content/mu-plugins/IdiumPackageFull/V1/Module/A…/assets/js/accessibility.js?ver=5.8.17

js akks.no collected 2026-10-04 13:33:58 UTC 8,417 bytes, 264 lines download raw bytes

1"use_strict";
2
3/**
4 * Idium Accessibility module
5 * @param  object $                   jQuery
6 * @return object IdiumAccessibility  Accessibility module
7 */
8var IdiumAccessibility = (function ($) {
9
10    var IdiumAccessibility = {};
11
12    /**
13     * Setup 'hover' event for zoom information
14     */
15    IdiumAccessibility.zoomStyleInit = function() {
16        var zoomText    = $('.accessibility-tools .zoom-text-container'),
17            zoomTrigger = $('.accessibility-tools [data-accessibility-style="zoom"]');
18
19        // show info about zooming page on hover
20        zoomTrigger.hoverIntent({
21            over: function() {
22                window["IdiumAccessibility"].mouseOverZoomPopup = false;
23                zoomText.fadeIn();
24            },
25            timeout: 500,
26            out: function() {
27                if (!window["IdiumAccessibility"].mouseOverZoomPopup) {
28                    zoomText.fadeOut();
29                }
30            }
31        });
32
33        zoomText.mouseenter(function() {
34            window["IdiumAccessibility"].mouseOverZoomPopup = true;
35        });
36
37        zoomText.mouseleave(function() {
38            window["IdiumAccessibility"].mouseOverZoomPopup = false;
39            zoomText.fadeOut();
40        });
41
42        // show info about zooming page on focus for keyboard users
43        zoomTrigger.on('focus',function(event){
44            zoomText.fadeIn();
45        });
46
47        zoomTrigger.on('focusout',function(event){
48            zoomText.fadeOut();
49        });
50    }
51
52    /**
53     * Remove all TabIndex except accessibility tools or if tabindex=0
54     */
55    IdiumAccessibility.removeTabIndexing = function() {
56        jQuery(document).ready(function() {
57            var group = jQuery('*[tabindex]');
58            group.each(function() {
59                if( (jQuery(this).attr('data-accessibility-style') === undefined)
60                    && (parseInt(jQuery(this).attr('tabindex')) > 0)
61                ) {
62                    jQuery(this).attr('data-tabindex', jQuery(this).attr('tabindex')).removeAttr('tabindex');
63                }
64            });
65        });
66    }
67
68    /**
69     * Setup behavior on accessibility links when keypressed
70     */
71    IdiumAccessibility.linksKeypressHandlingInit = function() {
72        var links    = jQuery('.accessibility-top a');
73
74        links.on('click', function(event) {
75            var $this   = jQuery(this),
76                href    = $this.attr('href');
77
78            if (href == "#search") {
79                var $target = jQuery(href + ' #s');
80            } else {
81                var $target = jQuery(href);
82            }
83
84            $target
85                .attr('tabindex', -1)
86                .on('blur focusout', function () {
87                    $target.removeAttr('tabindex');
88                })
89                .focus();
90        });
91
92        links.on('keypress', function(event) {
93            // react only when space or enter is pressed
94            if (event.keyCode == 32 || event.keyCode == 13) {
95                event.preventDefault();
96                jQuery(this).trigger('click');
97            }
98
99        });
100
101    }
102
103    /**
104     * Space handling for slider
105     */
106    IdiumAccessibility.slidersKeyboardHandlingInit = function() {
107
108        // when cycle is fully initialized
109        jQuery('body').on('cycle-initialized', function(event){
110
111            // pause when pause button is focused
112            $('.cycle-slideshow .btn-pause').on('focus', function(event) {
113                var $this = jQuery(this);
114
115                $this.trigger('click');
116                event.preventDefault();
117            });
118
119            // let controls react to space key also
120            jQuery('.cycle-slideshow .btn-pause, .cycle-slideshow .btn-next, .cycle-slideshow .btn-prev, .cycle-slideshow .cycle-pager li > a').on('keydown', function(event) {
121                var $this   = jQuery(this);
122                // react only when space or enter is pressed
123                if (event.keyCode == 32 || event.keyCode == 13) {
124                    event.preventDefault();
125                    $this.trigger('click');
126                }
127            });
128        });
129
130
131    }
132
133    /**
134     * If function that extends accessibility for this style further exist - run it!
135     * @param  string style handle for accessibility style
136     */
137    IdiumAccessibility.runStyleLogic = function(style) {
138        if (typeof window["IdiumAccessibility"][style+"Stylelogic"] 
138== 'function') {
139            window["IdiumAccessibility"][style+"Stylelogic"]();
140        }
141    }
142
143    /**
144     * If function that turning off accesibility features for this style exists - run it!
145     * @param  string style handle for accessibility style
146     */
147    IdiumAccessibility.removeStyleLogic = function(style) {
148        if (typeof window["IdiumAccessibility"]["remove"+style+"Stylelogic"] == 'function') {
149            window["IdiumAccessibility"]["remove"+style+"Stylelogic"]();
150        }
151    }
152
153    /**
154     * Bind toggling and saving state of accessibility styles/features
155     */
156    IdiumAccessibility.bindStyleToggle = function() {
157
158        $('.accessibility-tools [data-accessibility-style]').on('click keypress',function(event){
159
160            event.preventDefault();
161
162            if (event.type == 'keypress') {
163                if (event.keyCode != 32) {
164                    return false;
165                }
166            }
167
168            // get style we want to toggle
169            var style  = $(this).attr('data-accessibility-style'),
170                cookie = $.cookie('idium_accessibility_styles'),
171                styles = cookie !== null ? cookie.split(',') : [],
172                save   = new Array(),
173                index  = -1,
174                addStyle = '',
175                rmStyle  = '';
176
177            // if styles are set
178            if (styles.length > 0) {
179                // check if clicked style is in array
180                index = styles.indexOf(style);
181                if (index !== -1 ) {
182                    // if exist, turn it off
183                    rmStyle = style;
184                    styles.splice(index, 1);
185                } else {
186                    // if not exists, turn it on
187                    addStyle = style;
188                    styles.push(style);
189                }
190            } else {
191                addStyle = style;
192                styles.push(style);
193            }
194
195            // remove empty elements
196            for(var i = 0; i<styles.length; i++){
197                if (styles[i]){
198                    save.push(styles[i]);
199                }
200            }
201            // implode
202            save = save.join(',');
203
204            // set cookie
205            $.cookie('idium_accessibility_styles', save, { expires: 365, path: '/'});
206
207            if (addStyle !== '') {
208                $('body').addClass(addStyle);
209                window['IdiumAccessibility']['runStyleLogic'](addStyle);
210            }
211
212            if (rmStyle !== '') {
213                $('body').removeClass(rmStyle);
214                window['IdiumAccessibility']['removeStyleLogic'](rmStyle);
215            }
216
217        });
218
219    }
220
221    // "autostart" of accessibility module
222    function initStyleLogic() {
223        IdiumAccessibility.linksKeypressHandlingInit();
224        IdiumAccessibility.slidersKeyboardHandlingInit();
225        IdiumAccessibility.zoomStyleInit();
226        IdiumAccessibility.removeTabIndexing();
227    }
228
229    // load styles saved in cookies
230    function loadSetStyles() {
231        jQuery(document).ready(function() {
232            var cookie = $.cookie("idium_accessibility_styles"),
233                styles = cookie !== null ? cookie.split(',') : [];
234
235            jQuery.each( styles, function( index, style ) {
236                $('body').addClass(style);
237                window['IdiumAccessibility']['runStyleLogic'](style);
238            });
239        });
240    }
241
242    // set focus on search input text field
243    function searchFocus() {
244        var focusClass = 'focus';
245        jQuery('form.search input[type="text"]').focus(function() {
246            jQuery(this).parent().addClass(focusClass);
247        }).blur(function() {
248            jQuery(this).parent().removeClass(focusClass);
249        });
250    }
251
252    // start module
253    IdiumAccessibility.start = function() {
254        IdiumAccessibility.bindStyleToggle();
255        loadSetStyles();
256        initStyleLogic();
257        searchFocus();
258    }
259
260    IdiumAccessibility.start();
261
262    return IdiumAccessibility;
263
264}(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.