PageSourceSearch

https://adm-zheleznovodsk.ru/static/uil/export/project_mo_theme_sh…/scripts/menu-desktop.js?20260220202336

js adm-zheleznovodsk.ru collected 2026-10-02 18:02:16 UTC 9,586 bytes, 237 lines download raw bytes

1$(window).on('load', function uil_init_menu_desktop() {
2
3    var SIDEBAR_MAX_WIDTH = 480,
4        SIDEBAR_MIN_WIDTH = 178,
5        DELAY = 1000;
6
7    var $instance = $('.uil-menu-desktop:visible'),
8        $topbar = $('.uil-mo-top-bar'),
9        $topbar_toggle = $topbar.find('.uil-mo-top-bar__menu-toggle__content');
10
11    if ($instance.length !== 1) {
12        // console.error('Need one instance ' + $instance.selector);
13        return;
14    }
15
16    if ($topbar_toggle.length !== 1) {
17        // console.error('Need one instance ' + $topbar_toggle.selector);
18        return;
19    }
20
21    var $wnd = $(window),
22        $parent = $instance.offsetParent(),
23        $offset = $instance.children('.uil-menu-desktop__offset'),
24        $menu = $offset.children('div').children('.uil-menu-desktop__menu'),
25        $addition = $offset.children('div').children('.uil-menu-desktop__addition');
26
27    function sidebar_stick(is_log) {
28
29        var action,
30            wnd_scroll = parseInt($wnd.scrollTop()),
31            wnd_height = parseInt($wnd.height()),
32            instance_top = parseInt($instance.offset().top),
33            instance_height = parseInt($instance.height()),
34            instance_bot = instance_top + instance_height,
35            instance_top_screen = instance_top - wnd_scroll,
36            instance_bot_screen = instance_bot - (wnd_scroll + wnd_height),
37            parent_top = parseInt($parent.offset().top),
38            parent_height = parseInt($parent.height()),
39            parent_bot = parent_top + parent_height,
40            parent_top_screen = parent_top - wnd_scroll,
41            parent_bot_screen = parent_bot - (wnd_scroll + wnd_height);
42
43        if (is_log === true) {
44            console.clear();
45            console.log(
46                'wnd_scroll:          ' + wnd_scroll + '\n' +
47                'wnd_height:          ' + wnd_height + '\n' +
48                '\n' +
49                'parent_top:          ' + parent_top + '\n' +
50                'parent_bot:          ' + parent_bot + '\n' +
51                'parent_height:       ' + parent_height + '\n' +
52                'parent_top_screen:   ' + parent_top_screen + '\n' +
53                'parent_bot_screen:   ' + parent_bot_screen + '\n' +
54                '\n' +
55                'instance_top:        ' + instance_top + '\n' +
56                'instance_bot:        ' + instance_bot + '\n' +
57                'instance_height:     ' + instance_height + '\n' +
58                'instance_top_screen: ' + instance_top_screen + '\n' +
59                'instance_bot_screen: ' + instance_bot_screen
60            );
61        }
62
63        if (instance_height <= wnd_height && parent_height <= wnd_height)
64            return;
65
66        if (instance_top < parent_top)
67            $instance.css({'top': 0, 'bottom': 'auto'});
68
69        if (instance_height > wnd_height) { // Меню выше экрана
70            if (parent_top_screen > 0 && parent_bot_screen > 0) { // Скролл выше родителя
71                action = 'parent_top';
72            }
73            else if (parent_top_screen < 0 && parent_bot_screen > 0) { // Скролл в пределах родителя
74                if (instance_top_screen > 0) {
75                    action = 'screen_top';
76                }
77                if (instance_bot_screen < 0) {
78                    action = 'screen_bot';
79                }
80            }
81            else if (parent_bot_screen < 0) { // Скролл ниже родителя
82                action = 'parent_bot';
83            }
84        } else { // Меню ниже экрана
85            if (parent_top_screen > 0 && parent_bot_screen > 0) { // Скролл выше родителя
86                action = 'parent_top';
87            }
88            else if (parent_top_screen < 0 && parent_bot_screen > 0) { // Скролл в пределах родителя
89                action = 'screen_top';
90            }
91            else if (parent_bot_screen < 0) { // Скролл ниже родителя
92                if (parent_bot > wnd_scroll + instance_height) { // Нижний край меню выше нижнего края родителя
93                    action = 'screen_top';
94                } else {
95                    action = 'parent_bot';
96                }
97            }
98        }
99
100        switch (action) {
101            case 'parent_top':
102                $instance.css({'top': 0, 'bottom': 'auto'});
103                break;
104            case 'parent_bot':
105                $instance.css({'top': 'auto', 'bottom': 0});
106                break;
107            case 'screen_top':
108                $instance.css({'top': parent_top_screen * -1, 'bottom': 'auto'});
109                break;
110            case 'screen_bot':
111                $instance.css({'top': 'auto', 'bottom': parent_bot_screen});
112                break;
113            default:
114                break;
115        }
116
117    }
118
119    function mode_topbar_click(e) {
120        var o = $menu.offset();
121        if (e.pageY > 0 && e.pageX > 0)
122            if (
123                e.pageY < o.top ||
124                e.pageX < o.left ||
125                e.pageY > o.top + $menu.height() ||
126                e.pageX > o.left + $menu.width()
127            )
128                instance_display('no');
129    }
130
131    function instance_display(state) {
132        if (state && typeof state === 'object') {
133            state.stopPropagation();
134            state.preventDefault();
135        }
136        if (state === 'yes')
137            state = 'no';
138        else if (state === 'no')
139            state = 'yes';
140        if (state === 'yes' || state === 'no')
141            localStorage[$topbar_toggle.selector] = state;
142        var value = localStorage[$topbar_toggle.selector];
143        if (value !== 'yes') {
144            localStorage[$topbar_toggle.selector] = 'yes';
145            $instance.removeClass('hide');
146            $(document).on('click', mode_topbar_click);
147        } else {
148            localStorage[$topbar_toggle.selector] = 'no';
149            $instance.addClass('hide');
150            $(document).off('click', mode_topbar_click);
151        }
152    }
153
154    function mode_sidebar(state) {
155        if (state === true) {
156            var width = Math.min(SIDEBAR_MAX_WIDTH, parseInt($parent.offset().left) - parseInt($offset.css('padding-left')) * 2);
157            $offset.width(width);
158            $.cookie('menu_desktop_width', width + 'px');
159            $parent.css('min-height', $instance.height());
160            if (parseInt($addition.css('min-width')) <= $menu.width()) {
161                if (!$addition.data('is_show')) {
162                    $addition.data('is_show', true);
163                    $addition.show();
164                    sidebar_stick();
165                }
166            } else {
167                if ($addition.data('is_show')) {
168                    $addition.data('is_show', false);
169                    $addition.hide();
170                    sidebar_stick();
171                }
172            }
173            $menu.css('margin-bottom', $addition.data('is_show') ? '' : '0');
174            if (!$instance.hasClass('uil-menu-desktop_mode_sidebar')) {
175                $instance.addClass('uil-menu-desktop_mode_sidebar');
176                instance_display('yes');
177                sidebar_stick();
178                // $wnd.on('scroll', $.throttle(100, sidebar_stick));
179                $wnd.on('scroll', sidebar_stick);
180            }
181        } else {
182            if ($instance.hasClass('uil-menu-desktop_mode_sidebar')) {
183                $parent.css('min-height', '');
184                $instance.css({'top': '', 'right': '', 'bottom': '', 'left': ''});
185                instance_display('yes');
186                $menu.css('margin-bottom', '');
187                $offset.css('width', '');
188                $instance.removeClass('uil-menu-desktop_mode_sidebar');
189                $wnd.off('scroll', sidebar_stick);
190            }
191        }
192    }
193
194    function mode_topbar(state) {
195        if (state) {
196            $topbar_toggle.parent().css('display', 'table-cell');
197            var toggle_offset = $topbar_toggle.offset(),
198                parent_offset = $parent.offset();
199            $instance.css({
200                'top': parseInt(parent_offset.top) * -1 + parseInt($topbar.height()) + 10,
201                'left': (parseInt(toggle_offset.left) - parseInt(parent_offset.left) - parseInt($offset.css('padding-left')))
202            });
203            if (!$instance.hasClass('uil-menu-desktop_mode_topbar')) {
204                instance_display(localStorage[$topbar_toggle.selector]);
205                $topbar_toggle.on('click', instance_display);
206                $instance.addClass('uil-menu-desktop_mode_topbar');
207            }
208            $menu.css('margin-bottom', '0');
209            $addition.hide();
210        } else {
211            if ($instance.hasClass('uil-menu-desktop_mode_topbar')) {
212                $topbar_toggle.parent().css('display', '');
213                $instance.css({'top': '', 'right': '', 'bottom': '', 'left': ''});
214                $menu.css('margin-bottom', '');
215                $topbar_toggle.off('click', instance_display);
216                $instance.removeClass('uil-menu-desktop_mode_topbar');
217            }
218        }
219    }
220
221    function detect_mode() {
222        if (parseInt($parent.offset().left) - parseInt($offset.css('padding-left')) * 2 >= SIDEBAR_MIN_WIDTH) {
223            mode_topbar(false);
224            mode_sidebar(true);
225        } else {
226            mode_sidebar(false);
227            mode_topbar(true);
228        }
229    }
230
231    setTimeout(function () {
232        detect_mode();
233        $wnd.on('resize scroll', $.throttle(DELAY, detect_mode));
234    }, DELAY / 4);
235
236
237});

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.