PageSourceSearch

https://www.natqc.com/wp-content/plugins/ecwid-shopping-cart/js/nav-menu-frontend.js?ver=7.0.9

js natqc.com collected 2026-09-24 09:56:32 UTC 3,066 bytes, 115 lines download raw bytes

1jQuery(document).ready(function() {
2
3	if (typeof Ecwid == 'undefined') return;
4
5	refreshEcwidMenuItemsSelection();
6
7	Ecwid.OnPageLoaded.add(function(page) {
8		if (page.type == 'CART') {
9			window.ecwidCurrentMenuPage = 'cart';
10		} else if (page.type == 'ACCOUNT_SETTINGS' || page.type == 'ORDERS' || page.type == 'ADDRESS_BOOK') {
11			window.ecwidCurrentMenuPage = 'my-account';
12		} else if (page.type == 'SEARCH') {
13			window.ecwidCurrentMenuPage = 'product-search';
14		} else {
15			window.ecwidCurrentMenuPage = 'store';
16		}
17		
18	});
19
20	Ecwid.OnPageLoaded.add(refreshEcwidMenuItemsSelection);
21
22	function refreshEcwidMenuItemsSelection(page) {
23		
24		$allMenus = jQuery('ul').has('li.menu-item');
25		$allMenus.each(function (idx, el) {
26			var current = findCurrentEcwidMenuItem(el, page);
27			if (current) {
28				highlightCurrentMenuItem(el, current);
29			}
30		});
31	}
32
33	function highlightCurrentMenuItem(menu, item) {
34		jQuery('.current_page_item', menu).removeClass('current_page_item');
35		jQuery('.current-menu-item', menu).removeClass('current-menu-item');
36
37		item.addClass('current-menu-item current_page_item');
38	}
39
40	function findCurrentEcwidMenuItem(menuElement, page) {
41		
42		if (page) {
43			var endswith = null;
44			if (page.type == 'CATEGORY') {
45				if (page.categoryId == 0) {
46					endswith = '';
47				} else {
48					endswith = 'c' + page.categoryId;
49                }
50			}else if (page.type == 'PRODUCT') {
51				endswith = 'p' + page.productId;
52			}
53			
54			if (endswith != null) {
55				
56				if (endswith == '') {
57					endswith = ec.config.baseUrl;
58				}
59				var selector = '>
59li a[href*="' + ec.config.baseUrl + '"]';
60				var exactCatalogPage = jQuery('>li a[href$="' + endswith + '"][href*="' + ec.config.baseUrl + '"]', menuElement).closest('li');
61				if (exactCatalogPage.length > 0) {
62					return exactCatalogPage;
63				}	
64			}
65        }
66        
67		var specificMenuItem = findSpecificMenuItem(menuElement);
68		if (specificMenuItem) {
69			return specificMenuItem;
70		}
71
72		var storeMenuItem = findStoreMenuItem(menuElement);
73		if (storeMenuItem) {
74			return storeMenuItem;
75		}
76
77		return null;
78	}
79
80	function findSpecificMenuItem(menuElement) {
81		var currentPage = getCurrentEcwidPage();
82		var currentMenuItem = null;
83
84		if (['my-account', 'product-search', 'cart'].indexOf(currentPage) != -1) {
85			currentMenuItem = jQuery('>li.menu-item-object-' + ecwid_menu_data.items['ecwid-' + currentPage]['classes'], menuElement);
86			if (currentMenuItem.length > 0) {
87				return currentMenuItem;
88			}
89		}
90
91		return null;
92	}
93
94	function findStoreMenuItem(menuElement) {
95		var currentMenuItem = null;
96
97		var storeItems = ['ecwid-store', 'ecwid-store-with-categories'];
98		for (var i = 0; i < storeItems.length; i++) {
99			currentMenuItem = jQuery('>li.menu-item-object-' + ecwid_menu_data.items[storeItems[i]]['classes'], menuElement);
100			if (currentMenuItem.length > 0) {
101				return currentMenuItem;
102			}
103		}
104
105		return null;
106	}
107
108	function getCurrentEcwidPage() {
109		if (!window.ecwidCurrentMenuPage) {
110			window.ecwidCurrentMenuPage = 'store';
111		}
112
113		return window.ecwidCurrentMenuPage;
114	}
115})

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.