PageSourceSearch

https://korporat-v-spb.ru/bitrix/templates/gvozdevsoft_event_s1/lib/flmenu/flmenu.js

js korporat-v-spb.ru collected 2026-09-30 09:56:13 UTC 5,322 bytes, 141 lines download raw bytes

1let minwidth = 769;
2let flgmini = false;
3let lastWidth = window.innerWidth;
4
5window.onresize = function() {
6    const currentWidth = window.innerWidth;
7    if (currentWidth !== lastWidth) {
8        lastWidth = currentWidth;
9        CheckLis();
10    }
11};
12
13jQuery(document).ready(function() {
14    let lastli = "<li id='fllast'><a>. . .</a><ul></ul></li>";
15    jQuery("#flvmenu > ul").append(lastli);
16    jQuery("#flvmenu").prepend("<div class='minmenu'><i class='fa fa-bars'></i><a>&#1052;&#1045;&#1053;&#1070;</a></div>");
17    jQuery("#flvmenu > ul li ul").before("<a class='flarr'></a>");
18    CheckLis();
19    Setmini();
20    if (window.innerWidth <= minwidth) {
21        jQuery("#flvmenu > ul").css("display", "none");
22    }
23});
24
25function CheckLisOld() {
26    let navw, lastli, allw = 0, navItems, wdoc = window.innerWidth;
27
28    if (wdoc > minwidth) {
29        lastli = jQuery("#fllast").width();
30        let fllastlng = jQuery("#fllast > ul > li").length;
31        if (fllastlng == 0) lastli = 0;
32        navw = jQuery("#flvmenu").width();
33        jQuery('#flvmenu > ul > li').last().before(jQuery("#fllast > ul > li"));
34        jQuery("#flvmenu > ul > li:not(#fllast)").each(function() { allw += this.clientWidth; });
35        navItems = jQuery('#flvmenu > ul > li:not(#fllast)');
36        if (fllastlng == 1 && allw <= navw) lastli = 0;
37
38        while ((allw + lastli) > navw) {
39            allw -= navItems.last().width();
40            navItems.last().prependTo('#fllast > ul');
41            navItems.splice(-1, 1);
42            if (fllastlng == 0) lastli = jQuery("#fllast").width();
43        }
44        jQuery("#fllast").css("display", "none");
45        if (jQuery("#fllast > ul > li").length > 0) jQuery("#fllast").css("display", "inline-block");
46        jQuery(".flarr").html("");
47        jQuery('#flvmenu > ul > li ul').css("height", "auto");
48        jQuery("#flvmenu > ul").css("display", "flex");
49        SetAlignBl(wdoc);
50        if (flgmini) { flgmini = false; CheckLis(); }
51    } else {
52        jQuery('#flvmenu > ul > li').last().before(jQuery("#fllast > ul > li"));
53        jQuery("#fllast").css("display", "none");
54        jQuery('#flvmenu > ul > li ul').css("height", "0").css("right", "auto").css("left", "auto");
55        jQuery(".flarr").html("<i class='fa fa-plus'></i>");
56        jQuery("#flvmenu > ul").css("display", "none");
57        flgmini = true;
58    }
59}
60
61function CheckLis() {
62    let navw, lastli, allw = 0, navItems, wdoc = window.innerWidth;
63
64    if (wdoc > minwidth) {
65        // Убираем все пункты из fllast обратно в меню
66        jQuery('#flvmenu > ul > li').last().before(jQuery("#fllast > ul > li"));
67        
68        // Скрываем fllast — он нам не нужен
69        jQuery("#fllast").css("display", "none");
70
71        // УБРАЛИ: логику измерения и скрытия пунктов
72
73        jQuery(".flarr").html("");
74        jQuery('#flvmenu > ul > li ul').css("height", "auto");
75        jQuery("#flvmenu > ul").css("display", "flex"); // flex вместо block
76        SetAlignBl(wdoc);
77        if (flgmini) { flgmini = false; CheckLis(); }
78    } else {
79        jQuery('#flvmenu > ul > li').last().before(jQuery("#fllast > ul > li"));
80        jQuery("#fllast").css("display", "none");
81        jQuery('#flvmenu > ul > li ul').css("height", "0").css("right", "auto").css("left", "auto");
82        jQuery(".flarr").html("<i class='fa fa-plus'></i>");
83        jQuery("#flvmenu > ul").css("display", "none");
84        flgmini = true;
85    }
86}
87
88function Setmini() {
89    jQuery("#flvmenu").on("click", ".flarr", function() {
90        let wdoc = window.innerWidth;
91        if (minwidth > wdoc) {
92            let par = this.parentElement;
93            let chldul = par.getElementsByTagName('ul')[0];
94            let chght = chldul.style.height; 
95            if (chght === "0px") {
96                jQuery(this).html("<i class='fa fa-minus'></i>");
97                chldul.style.height = "auto";
98            } else {
99                jQuery(this).html("<i class='fa fa-plus'></i>");
100                chldul.style.height = "0px";
101            }
102        }
103    });
104
105    jQuery(".minmenu").click(function() {
106        let ul = jQuery("#flvmenu > ul");
107        if (ul.css("display") === "none") {
108            ul.css("display", "block");
109        } else {
110            ul.css("display", "none");
111        }
112    });
113}
114
115function SetAlignBl(wdoc) {
116    jQuery("#flvmenu > ul > li > ul").each(function() {
117        jQuery(this).css("left", "0").css("right", "auto");
118        let chldel = this.firstElementChild;
119        let chlwth = chldel ? jQuery(chldel).width() : 0;
120        if (getLeftSet(this) + chlwth > wdoc) {
121            jQuery(this).css("left", "auto").css("right", "0");
122        }
123    });
124    jQuery("#flvmenu > ul > li > ul > li > ul").each(function() {
125        jQuery(this).css("left", "100%").css("right", "auto");
126        let chldel = this.firstElementChild;
127        let chlwth = chldel ? jQuery(chldel).width() : 0;
128        if (getLeftSet(this) + jQuery(this.parentElement).width() + chlwth > wdoc) {
129            jQuery(this).css("left", "-100%");
130        }
131    });
132}
133
134function getLeftSet(elem) {
135    let left = 0;
136    while (elem) {
137        left += parseFloat(elem.offsetLeft);
138        elem = elem.parentElement;
139    }
140    return Math.round(left);
141}

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.