PageSourceSearch

https://st-i.ru/wp-content/themes/Theme%20STI/assets/scripts/woo.js

js st-i.ru collected 2026-10-08 01:22:30 UTC 5,155 bytes, 163 lines download raw bytes

1function showWooReviewDialog() {
2	const dialog = $(".woo-single-add-review-dialog");
3	const showButton = $(".woo-single-add-review-btn");
4	const closeButton = $(".woo-single-close-review-btn");
5
6	if (dialog) {
7		if (showButton) {
8			showButton.on( "click", function() {
9				dialog.css("visibility", "visible");
10				dialog.css("opacity", "1");
11			});
12		}
13
14		if (closeButton) {
15			closeButton.on( "click", function() {
16				dialog.css("visibility", "hidden");
17				dialog.css("opacity", "0");
18			});
19		}
20	}
21}
22
23function toggleWooSidebarWidget() {
24	const titles = $(".wpc-filters-widget-wrapper > .wpc-filters-section > .wpc-filter-header > .wpc-filter-title");
25	const firstWidget = $(".wpc-filters-widget-wrapper > .wpc-filters-section.wpc-filter-pa_manufacturer");	
26	
27	$(".wpc-filters-widget-wrapper > .wpc-filters-section").each(function() {
28		if (localStorage.getItem($(this).attr("data-fid")) === "active") {
29			$(this).addClass("woo-sidebar-widget-active");
30		} else {
31			$(this).removeClass("woo-sidebar-widget-active");
32		}
33	})
34	
35	if (!firstWidget.hasClass("woo-sidebar-widget-active")) {
36		firstWidget.addClass("woo-sidebar-widget-active");
37	}
38	
39	titles.on("click", function() {
40		$(this).closest(".wpc-filters-section").toggleClass("woo-sidebar-widget-active");
41		
42		if ($(this).closest(".wpc-filters-section").hasClass("woo-sidebar-widget-active")) {
43			localStorage.setItem($(this).closest(".wpc-filters-section").attr("data-fid"), "active");
44		} else {
45			localStorage.setItem($(this).closest(".wpc-filters-section").attr("data-fid"), "inactive");
46		}
47	})
48}
49
50function woocommercePaginationStyles() {
51	const pageNumberCurrent = $(".woocommerce-pagination > .page-numbers > li > span.current");
52	const pageNumberPrev = $(".woocommerce-pagination > .page-numbers > li > a.prev");
53	const pageNumberNext = document.querySelector(".woocommerce-pagination > .page-numbers > li > a.next");
54	
55	if (pageNumberCurrent) {
56		pageNumberCurrent.parent().css("border-color", "#FF4903");
57	}
58	
59	if (pageNumberPrev) {
60		pageNumberPrev.html("<img src='/wp-content/themes/Theme STI/assets/images/buttons/pagination-arrow.svg'/>");
61	}
62	
63	if (pageNumberNext) {
64		pageNumberNext.innerHTML = "<img src='/wp-content/themes/Theme STI/assets/images/buttons/pagination-arrow.svg'/>";
65		
66		setTimeout(() => {
67			pageNumberNext.children[0].style.transform = "rotate(0.5turn)";
68		}, 0);
69	}
70}
71
72function addCloseBtnInCommentDialog() {
73	const title = $(".comment-reply-title");
74	const closeBtn = "<button class='woo-single-close-review-btn'><img src='/wp-content/themes/Theme STI/assets/images/buttons/close-feedback.svg'/></button>";
75
76	title.append(closeBtn);
77}
78
79function sliceBreadcrumbItem() {
80	const $lastItem = $(".woocommerce-breadcrumb > .woocommerce-breadcrumb-item").last();
81
82	// Проверяем, что внутри нет ссылки
83	if ($lastItem.find("a").length === 0) {
84		const text = $lastItem.text();
85
86		if (text.length > 29) {
87			$lastItem
88				.addClass("woocommerce-breadcrumb-item-gradient")
89				.text(text.slice(0, 30));
90		}
91	}
92}
93
94function addBarInMobileSidebar() {
95	if (window.innerWidth < 900) {
96		const sidebar = document.querySelector('#woo-sidebar');
97		const header = document.querySelector('.woocommerce-products-header');
98    
99		if (sidebar) {
100			if (header) {
101				const filtersBtn = document.createElement('div');
102				filtersBtn.textContent = 'Фильтры';
103				filtersBtn.classList.add('filters-button');
104
105				header.appendChild(filtersBtn);
106
107				filtersBtn.addEventListener('click', function() {
108					sidebar.style.display = "block";
109				});
110			}
111			
112			const container = document.createElement('div');
113			container.classList.add('filter-container');
114
115			const title = document.createElement('div');
116			title.textContent = 'Все фильтры';
117			title.classList.add('filter-title');
118
119			const closeBtn = document.createElement('div');
120			closeBtn.classList.add('close-button');
121
122			container.appendChild(title);
123			container.appendChild(closeBtn);
124
125			sidebar.insertBefore(container, sidebar.firstChild);
126
127			closeBtn.addEventListener('click', function() {
128				sidebar.style.display = "none";
129			});
130			
131			function updateFilterCount() {
132                const selectedCount = Array.from(checkboxes).filter(checkbox => checkbox.checked).length;
133                const filtersBtn = document.querySelector('.woocommerce-products-header > .filters-button');
134				
135                if (selectedCount > 0) {
136                    filtersBtn.textContent = `Фильтры (${selectedCount})`;
137                } else {
138                    filtersBtn.textContent = 'Фильтры';
139                }
140            }
141			
142			const checkboxes = sidebar.querySelectorAll('.wpc-checkbox-item input[type="checkbox"]');
143            checkboxes.forEach(checkbox => {
144                checkbox.addEventListener('change', updateFilterCount);
145            });
146			
147			updateFilterCount();
148		}
149	}
150}
151
152$(document).ready(function() {
153	showWooReviewDialog();
154	toggleWooSidebarWidget();
155	woocommercePaginationStyles();
156	addCloseBtnInCommentDialog();
157	sliceBreadcrumbItem();
158	addBarInMobileSidebar();
159});
160
161$(document).ajaxSuccess(function(e) {
162  	toggleWooSidebarWidget();
163});

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.