PageSourceSearch

https://www.1c-bitrix.ru/bitrix/templates/1c_bitrix_2018/js/functions.js?17518810325922

js 1c-bitrix.ru collected 2026-09-24 08:30:23 UTC 5,922 bytes, 217 lines download raw bytes

1BX.ready(function(){
2	new SBWrapper.Manager({
3		nestedMaxLevel: 1,
4		wrapperClassName: 'bx-ui-table-wrapper',
5		includeSelectors: ['table'],
6		excludeSelectors: [
7			'.bx-interface-toolbar *', '.bx-interface-filter *',
8			'.bx-interface-grid', '.bx-grid-sorting',
9			'.main-grid', '.main-grid *',
10			'.bx-edit-tab', '.bx-edit-tab *',
11			'.bx-edit-tabs', '.bx-edit-tabs *',
12			'.bx-learn-rank-table',
13		],
14	}).run();
15});
16
17BX.ready(function(){
18	let topMenu = document.querySelector(".header-row-level-1");
19
20	BX.bind(window, 'scroll', function()
21	{
22		let scrollTop = BX.GetWindowScrollPos(document).scrollTop;
23		if(scrollTop >= BX.pos(topMenu).height)
24		{
25			BX.addClass(document.body, "fixed-mine-menu");
26		}
27		else
28		{
29			BX.removeClass(document.body, "fixed-mine-menu");
30		}
31	});
32});
33
34// Smooth Scroll
35BX.ready(function() {
36	'use strict';
37
38	let anchors = document.querySelectorAll('.js-anchor');
39
40	if (!anchors || anchors.length <= 0) return;
41
42	for(let i = 0; i < anchors.length; i++) {
43		let anchor = anchors[i],
44			target = anchor.dataset.target,
45			setHistory = anchor.dataset.setHistory;
46
47		if (BX.type.isElementNode(anchor))
48		{
49			let destination = document.querySelector(`.${target}`);
50
51			if (!destination) return;
52
53			BX.bind(anchor, 'click', function(e) {
54				e.preventDefault();
55
56				let generatedAnchor = document.createElement('div');
57				generatedAnchor.classList.add('anchors__generated');
58
59				let firstChild = destination.firstChild;
60				destination.insertBefore(generatedAnchor, firstChild);
61
62				generatedAnchor.scrollIntoView({
63					behavior: "smooth",
64					block: "start"
65				});
66
67				setTimeout(function() {
68					destination.removeChild(generatedAnchor);
69				}, 1);
70
71				if(setHistory) {
72					history.pushState(null, null, "#" + setHistory);
73				}
74			});
75		}
76	}
77});
78
79
80/**
81 * Another (Common) Smooth Scroll
82 * Processing simple link anchors without special selectors
83 */
84document.addEventListener('DOMContentLoaded', (event) => {
85	let anchorLinks = document.querySelectorAll('a[href^="#"], a[href*="#"]');
86
87	if (anchorLinks.length <= 0)
88		return;
89
90	let topMenuNode = document.querySelector('.js-main-menu-section');
91
92	const defaultTopOffset  = 100;
93	const promisedTopOffset = 20;
94	const currentTopOffset = (topMenuNode)
95		? topMenuNode.offsetHeight + promisedTopOffset
96		: defaultTopOffset;
97
98	// List of classes whose elements should be excluded from the selection,
99	// because have an anchor (href="your-id") but are linked to other scripts
100	let excludedClassNames = ['js-anchor', 'tab-btn'];
101
102	for(let i = 0; i < anchorLinks.length; i++)
103	{
104		let linkNode = anchorLinks[i];
105		let linkHref = linkNode.getAttribute('href');
106
107		// exclude link nodes that have listeners in other scripts.
108		for (let j = 0; j < excludedClassNames; j++)
109		{
110			let excludedClassName = excludedClassNames[j];
111			if (linkNode.classList.contains(excludedClassName))
112			{
113				linkNode = null;
114			}
115		}
116
117		// do not skip an obviously incorrect link or an incorrect hash
118		if (linkNode === null
119			||!linkHref.includes('#')
120			|| linkHref.length <= 1
121		) {
122			continue;
123		}
124
125		let anchor = linkHref.substring(linkHref.indexOf('#'));
126		let target;
127
128		// try/catch for incorrect selectors,
129		// for example, like #fccf8e=tab-1
130		try {
131			target = document.querySelector(anchor);
132		}
133		catch (e) {}
134
135		if (target && target.nodeType === Node.ELEMENT_NODE)
136		{
137			// Scroll on load/reload/transition
138			if (location.hash && anchor === location.hash)
139			{
140				let targetRect  = target.getBoundingClientRect();
141				let scrollPoint = targetRect.top + window.pageYOffset - currentTopOffset;
142				window.scrollTo({top: scrollPoint, behavior: 'smooth'});
143			}
144
145			linkNode.addEventListener('click', (event) => {
146				event.preventDefault();
147
148				let targetRect  = target.getBoundingClientRect();
149				let scrollPoint = targetRect.top + window.pageYOffset - currentTopOffset;
150				window.scrollTo({top: scrollPoint, behavior: 'smooth'});
151				history.pushState(null, null, linkHref);
152			});
153		}
154	}
155});
156
157
158/**
159 * Smooth Scroll Up
160 */
161document.addEventListener('DOMContentLoaded', (event) => {
162	let requestAnimationFrame = window.requestAnimationFrame
163		|| window.mozRequestAnimationFrame
164		|| window.msRequestAnimationFrame;
165
166	const scrollUpButton = document.querySelector('[data-action="scrollUp"]');
167	const windowViewPortHeight = window.innerHeight;
168	let isRequestingAnimationFrame = false;
169
170	if (scrollUpButton) {
171		window.addEventListener('scroll', function() {
172			if (!isRequestingAnimationFrame) {
173				requestAnimationFrame(filterGoTopButtonVisibility);
174				isRequestingAnimationFrame = true;
175			}
176		});
177
178		function filterGoTopButtonVisibility(timestamp) {
179			let windowPageYOffset = window.pageYOffset || document.documentElement.scrollTop;
180			if (windowPageYOffset > windowViewPortHeight)
181			{
182				scrollUpButton.classList.add('show');
183				isRequestingAnimationFrame = false;
184			}
185			else
186			{
187				scrollUpButton.classList.remove('show');
188				requestAnimationFrame(filterGoTopButtonVisibility);
189			}
190		}
191	}
192});
193
194
195function tabToggle(obj, index){
196	var wrapper =  BX.findParent(obj, {"class": "tabs-wrapper"}, true);
197	var tabTabsList = BX.findChild(wrapper, {"class": "tabs-btn-list"}, true);
198	var tabPageList = BX.findChild(wrapper, {"class": "tabs-body-list"}, true);
199	BX.removeClass(BX.findChild(tabTabsList, {"class": "tab-btn-current"}, true), "tab-btn-current");
200	BX.addClass(obj, "tab-btn-current");
201
202	BX.addClass(BX.findChild(tabPageList, {"class": "tab-body-page-opened"}, true), "tab-body-page-clossed");
203	BX.removeClass(BX.findChild(tabPageList, {"class": "tab-body-page-opened"}, true), "tab-body-page-opened");
204	BX.addClass(tabPageList.children[index], "tab-body-page-opened");
205};
206
207// Borrowed from everywhere
208if (typeof BX.foreach !== "function") {
209	BX.foreach = function(nodes,callback)
210	{
211		if(BX.type.isElementNode(nodes))
212			callback(nodes);
213		if(BX.type.isArray(nodes))
214			for(key in nodes)
215				callback(nodes[key]);
216	}
217}

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.