PageSourceSearch

https://courses.zrozumilo.in.ua/static/js/utils/navigation.5a78fd05918f.js

js zrozumilo.in.ua collected 2026-09-24 10:47:33 UTC 4,406 bytes, 129 lines download raw bytes

1var edx = edx || {},
2
3    Navigation = (function() {
4        var navigation = {
5
6            init: function() {
7                if ($('.accordion').length) {
8                    navigation.loadAccordion();
9                }
10            },
11
12            loadAccordion: function() {
13                navigation.checkForCurrent();
14                navigation.listenForClick();
15                navigation.listenForKeypress();
16            },
17
18            getActiveIndex: function() {
19                var index = $('.accordion .button-chapter:has(.active)').index('.accordion .button-chapter'),
20                    button = null;
21
22                if (index > -1) {
23                    button = $('.accordion .button-chapter:eq(' + index + ')');
24                }
25
26                return button;
27            },
28
29            checkForCurrent: function() {
30                var button = navigation.getActiveIndex();
31
32                navigation.closeAccordions();
33
34                if (button !== null) {
35                    navigation.setupCurrentAccordionSection(button);
36                }
37            },
38
39            listenForClick: function() {
40                $('.accordion').on('click', '.button-chapter', function(event) {
41                    event.preventDefault();
42
43                    var $button = $(event.currentTarget),
44                        section = $button.next('.chapter-content-container');
45
46                    navigation.closeAccordions($button, section);
47                    navigation.openAccordion($button, section);
48                });
49            },
50
51            listenForKeypress: function() {
52                $('.accordion').on('keydown', '.button-chapter', function(event) {
53                    // because we're changing the role of the toggle from an 'a' to a 'button'
54                    // we need to ensure it has the same keyboard use cases as a real button.
55                    // this is useful for screenreader users primarily.
56                    if (event.which == 32) { // spacebar
57                        event.preventDefault();
58                        $(event.currentTarget).trigger('click');
59                    } else {
60                        return true;
61                    }
62                });
63            },
64
65            closeAccordions: function(button, section) {
66                var menu = $(section).find('.chapter-menu'),
67                    toggle;
68
69                $('.accordion .button-chapter').each(function(index, element) {
70                    $toggle = $(element);
71
72                    $toggle
73                        .removeClass('is-open')
74                        .attr('aria-expanded', 'false');
75
76                    $toggle
77                        .children('.group-heading')
78                        .removeClass('active')
79                        .find('.icon')
80                        .addClass('fa-caret-right')
81                        .removeClass('fa-caret-down');
82
83                    $toggle
84                        .next('.chapter-content-container')
85                        .removeClass('is-open')
86                        .find('.chapter-menu').not(menu)
87                        .removeClass('is-open')
88                        .slideUp();
89                });
90            },
91
92            setupCurrentAccordionSection: function(button) {
93                var section = $(button).next('.chapter-content-container');
94
95                navigation.openAccordion(button, section);
96            },
97
98            openAccordion: function(button, section) {
99                var $sectionEl = $(section),
100                    firstLink = $sectionEl.find('.menu-item').first(),
101                    $buttonEl = $(button);
102
103                $buttonEl
104                    .addClass('is-open')
105                    .attr('aria-expanded', 'true');
106
107                $buttonEl
108                    .children('.group-heading')
109                    .addClass('active')
110                    .find('.icon')
111                    .removeClass('fa-caret-right')
112                    .addClass('fa-caret-down');
113
114                $sectionEl
115                    .addClass('is-open')
116                    .find('.chapter-menu')
117                    .addClass('is-open')
118                    .slideDown();
119            }
120        };
121
122        return {
123            init: navigation.init
124        };
125    }());
126
127edx.util = edx.util || {};
128edx.util.navigation = Navigation;
129edx.util.navigation.init();

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.