PageSourceSearch

https://gkdialog.info/bitrix/templates/aspro-allcorp3/js/logo.js

js gkdialog.info collected 2026-10-07 18:10:18 UTC 7,456 bytes, 241 lines download raw bytes

1if (typeof window.JLogo  === 'undefined') {
2    window.JLogo = function(node, params) {
3        var _private = {
4            inited: false,
5        };
6
7        Object.defineProperties(this, {
8            inited: {
9                get: function() {
10                    return _private.inited;
11                },
12                set: function(value) {
13                    if (value) {
14                        _private.inited = true;
15                    }
16                }
17            },
18            node: {
19                get: function() {
20                    return node;
21                }
22            },
23            img: {
24                get: function() {
25                    return node ? node.querySelector('img') : null;
26                }
27            },
28            svg: {
29                get: function() {
30                    return node ? node.querySelector('svg') : null;
31                }
32            },
33        });
34
35        this.params = function(key) {
36            if (typeof params === 'object') {
37                if (typeof key !== 'undefined') {
38                    if (Object.keys(params).indexOf(key) > -1) {
39                        return params[key];
40                    }
41                }
42            }
43
44            return undefined;
45        }
46
47        this.init();
48    }
49
50    window.JLogo.prototype = {
51        get src() {
52            return this.img ? this.img.getAttribute('src') : '';
53        },
54
55        set src(value) {
56            if (this.img) {
57                this.img.setAttribute('src', value);
58            }
59        },
60
61        get srcDark() {
62            return arAsproOptions.THEME.LOGO_IMAGE;
63        },
64
65        get srcLight() {
66            return arAsproOptions.THEME.LOGO_IMAGE_WHITE;
67        },
68
69        get color() {
70            if (this.img) {
71                let src = this.src;
72
73                return src === this.srcDark ? 'dark' : (src === this.srcLight ? 'light' : '');
74            }
75
76            return '';
77        },
78
79        set color(value) {
80            if (this.canChangeColor) {
81                if (this.color !== value) {
82                    this.src = (value === 'light' ? this.srcLight : this.srcDark);
83                }
84            }
85        },
86
87        get isCustomHeader() {
88            return Boolean(this.node.closest('.header-custom'));
89        },
90
91        get isMainLogo() {
92            return Boolean(this.node.closest('header'));
93        },
94
95        get isMenuFilledDark() {
96            return this.img && Boolean(this.img.closest('.header--color_dark, .header--color_colored, .mobileheader--color-colored, .mobileheader--color-dark'));
97        },
98
99        get isHeaderHasOffset() {
100            return this.img && Boolean(this.img.closest('.header--offset'));
101        },
102
103        get onBanner() {
104            return this.isMainLogo && Boolean(BX.hasClass(document.body, 'header_opacity'));
105        },
106
107        get onTopPart() {
108            return this.img && Boolean(this.img.closest('.header__top-part'));
109        },
110
111        get onTransparentRow() {
112            return this.img && (Boolean(this.img.closest('.header--color_light.bg_none')) 
113                    || (this.onTopPart && this.isHeaderHasOffset)
114                    || (Boolean(this.img.closest('.header__main-inner.bg_none')) && !this.isHeaderHasOffset))
115        },
116
117        get allowChangeBySlider() {
118            return this.onBanner && this.onTransparentRow && !this.isCustomHeader;
119        },
120
121        get canChangeColor() {
122            return this.img && this.srcLight
123                && !this.allowChangeBySlider
124                && !(this.onTopPart && this.isMenuFilledDark && !this.isHeaderHasOffset)
125                && !(!this.onTopPart && this.isMenuFilledDark);
126        },
127
128        setColorOfBanner: function (banner) {
129            if (
130                this.img &&
131                banner
132            ) {
133                if (typeof window.headerLogo !== 'undefined') {
134                    value = BX.data(banner, 'color');
135                    value = value ? value : 'dark';
136                    if (this.color !== value) {
137                        this.node.setAttribute('src', value === 'light' ? this.srcLight : this.srcD
137ark);
138                    }
139                }
140            }
141        },
142
143        get isPreferColor() {
144            return BX.hasClass(document.body, 'theme-default');
145        },
146
147        get preferColor() {
148            return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
149        },
150
151        get themeColor () {
152            if (this.isPreferColor) {
153                return this.preferColor;
154            }
155            else {
156                return BX.hasClass(document.body, 'theme-dark') ? 'dark': 'light';
157            }
158        },
159
160        init: function() {
161            if (!this.inited) {
162                this.inited = true;
163
164                if (this.img && !this.isCustomHeader) {
165                    this.color = this.isMenuFilledDark ? 'light' : this.getInvertedColor(this.themeColor);
166
167                    this.bindEvents();
168                }
169            }
170        },
171
172        getInvertedColor: function(value) {
173            if (value === 'default') {
174                value = this.preferColor;
175            }
176
177            return value === 'light' ? 'dark' : (value === 'dark' ? 'light' : '');
178        },
179
180        bindEvents: function() {
181            if (typeof this.handlers.onChangePrefersColorScheme === 'function') {
182                window.matchMedia('(prefers-color-scheme: dark)').addEventListener(
183                    'change', 
184                    BX.proxy(
185                        this.handlers.onChangePrefersColorScheme,
186                        this
187                    )
188                );
189            }
190
191            if (typeof this.handlers.onChangeThemeColor === 'function') {
192                BX.addCustomEvent(
193                    'onChangeThemeColor',
194                    BX.proxy(
195                        this.handlers.onChangeThemeColor,
196                        this
197                    )
198                );
199            }
200        },
201
202        unbindEvents: function() {
203
204        },
205
206        handlers: {
207            onChangePrefersColorScheme: function(event) {
208                if (!event) {
209                    event = window.event;
210                }
211
212                let newColor = event.matches ? 'dark' : 'light';
213
214                if (this.isPreferColor) {
215                    this.color = this.getInvertedColor(newColor);
216                }
217
218                BX.setCookie('prefers-color-scheme', newColor);
219            },
220
221            onChangeThemeColor: function(eventdata) {
222                if (
223                    typeof eventdata === 'object' &&
224                    eventdata &&
225                    'value' in eventdata
226                ) {
227                    this.color = this.getInvertedColor(eventdata.value);
228                }
229            },
230        }
231    }
232
233    let readyFunc = typeof readyDOM === 'function' ? readyDOM : BX.ready;
234    readyFunc(function() {
235        window.headerLogo = new JLogo(document.querySelector('header .logo'));
236        window.headerfixedLogo = new JLogo(document.querySelector('#headerfixed .header .logo'));
237        window.mobileheaderLogo = new JLogo(document.querySelector('#mobileheader .mobileheader .logo'));
238        window.mobilemenuLogo = new JLogo(document.querySelector('#mobilemenu .mobilemenu .logo'));
239        BX.setCookie('prefers-color-scheme', window.headerLogo.preferColor);
240    });
241}

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.