PageSourceSearch

https://gorod-zarechny.ru/static/uil/export/project_mo_theme_short…/scripts/menu-mobile.js?20260220222336

js gorod-zarechny.ru collected 2026-10-02 12:15:41 UTC 5,909 bytes, 153 lines download raw bytes

1$(window).on('load', function uil_init_menu_mobile() {
2
3    var $top_bar = $('.uil-menu-mobile:visible');
4
5    if ($top_bar.length === 1) {
6
7        var is_scroll = true,
8            win_scroll_y,
9            $window = $(window),
10            $html_body = $('html, body'),
11            anchor_list = [];
12
13        $('a[href^="#"]').filter(function () {
14            return this.getAttribute('href').length > 1 && this.innerHTML.length > 0;
15        }).each(function () {
16            var $link = $(this),
17                $target = $('#' + $link.attr('href').split('#')[1]);
18            if ($target.length === 1)
19                anchor_list.push({'link': $link, 'title': $link.text(), 'target': $target});
20        });
21
22        function set_scroll_state(state) {
23            if (!state) {
24                if (is_scroll) {
25                    is_scroll = false;
26                    win_scroll_y = $window.scrollTop();
27                    var $body = $('body');
28                    $body.css({'top': '-' + win_scroll_y + 'px', 'left': $body.offset().left, 'position': 'fixed', 'overflow-y': 'scroll'});
29                }
30            } else {
31                if (!is_scroll) {
32                    is_scroll = true;
33                    $('body').css({'top': '', 'left': '', 'position': '', 'overflow-y': ''});
34                    $html_body.scrollTop(win_scroll_y);
35                }
36            }
37        }
38
39        // Инициализация
40
41        var $top_bar_body = $top_bar.find('.uil-menu-mobile__body'),
42            $top_bar_content = $top_bar_body.find('.uil-menu-mobile__body__content'),
43            $btn_anchor_title = $top_bar_content.find('.uil-menu-mobile__anchor-title'),
44            $menu_wrapper = $top_bar.find('.uil-menu-mobile__menu');
45
46        $top_bar.addClass('is-show-nav-controls');
47
48        // Интерфейс перехода по якорям
49
50        var anchor_prev,
51            anchor_current,
52            anchor_next;
53
54        function update_anchor_controls() {
55            if (anchor_list.length === 0)
56                return false;
57
58            var offset = 10,
59                w_top = $window.scrollTop(),
60                w_height = $window.height() - $top_bar.height() * 1.25;
61
62            anchor_prev = undefined;
63            anchor_current = undefined;
64            anchor_next = undefined;
65
66            $.each(anchor_list, function () {
67                var $target = this['target'],
68                    t_top = $target.offset().top - $top_bar.height() * 1.25;
69                if (w_top - offset >= t_top)
70                    anchor_prev = this;
71                if (t_top <= w_top - offset + w_height / 2)
72                    anchor_current = this;
73                if (t_top >= w_top + offset)
74                    if (anchor_next === undefined)
75                        anchor_next = this;
76            });
77
78            if (anchor_current === undefined)
79                anchor_current = anchor_next;
80            if (anchor_current === undefined)
81                $btn_anchor_title.text('').hide();
82            else
83                $btn_anchor_title.text(anchor_current['title']).show();
84
85        }
86
87        function scroll(value) {
88            $.smoothScroll(value);
89            // $html_body.stop(true, true).animate({scrollTop: value}, 500, 'easeInOutCirc');
90            // $body.scrollTop(value);
91            setTimeout(update_anchor_controls, 500);
92        }
93
94        // Показ/скрытие меню
95
96        function update_position() {
97            var val = $window.height() - $top_bar.height();
98            $menu_wrapper.css({
99                'bottom': -val + 'px',
100                'left': $top_bar_body.offset().left + 'px',
101                'height': val + 'px',
102                'max-width': $top_bar_body.outerWidth() + 'px'
103            });
104        }
105
106        $(document).on('click touchend', '.uil-menu-mobile', function (e) {
107            if (e.target.tagName.toLowerCase() !== 'a') {
108                e.stopPropagation();
109                e.preventDefault();
110            }
111            if (e.target.className.indexOf('uil-menu-mobile__btn_action_anchor-prev') > -1) {
112                if (anchor_prev !== undefined)
113                    scroll(anchor_prev['target'].offset().top - $top_bar.height() * 1.25);
114                else
115                    scroll(0);
116            }
117            else if (e.target.className.indexOf('uil-menu-mobile__anchor-title') > -1) {
118                if (anchor_current !== undefined)
119                    scroll(anchor_current['target'].offset().top - $top_bar.height() * 1.25);
120            }
121            else if (e.target.className.indexOf('uil-menu-mobile__btn_action_anchor-next') > -1) {
122                if (anchor_next !== undefined)
123                    scroll(anchor_next['target'].offset().top - $top_bar.height() * 1.25);
124                else
125                    scroll($(document).height() - $window.height());
126            }
127            else if (e.target.className.indexOf('uil-menu-mobile__btn_action_menu-toggle') > -1) {
128                if (!$top_bar.data('is_menu_show')) {
129                    $top_bar.data('is_menu_show', true);
130                    set_scroll_state(false);
131                    update_position();
132                    $window.on('resize', $.debounce(500, update_position));
133                    $top_bar.removeClass('is-show-nav-controls');
134                } else {
135                    $top_bar.data('is_menu_show', false);
136                    set_scroll_state(true);
137                    $menu_wrapper.css({
138                        'bottom': ''
139                    });
140                    $window.off('resize', update_position);
141                    $top_bar.addClass('is-show-nav-controls');
142                }
143            }
144        });
145
146        if (anchor_list.length > 0) {
147            update_anchor_controls();
148            $window.on('scroll', $.debounce(500, update_anchor_controls));
149        }
150
151    }
152
153});

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.