PageSourceSearch

https://www.perfumeshopping.com.br/wp-content/themes/woodmart/js/scripts/menu/menuOffsets.js?ver=8.0.6

js perfumeshopping.com.br collected 2026-10-06 03:59:54 UTC 4,950 bytes, 164 lines download raw bytes

1/* global woodmart_settings */
2(function($) {
3	woodmartThemeModule.menuOffsets = function() {
4		var setOffset = function(li) {
5			var $dropdown = li.find(' > .wd-dropdown-menu');
6			var dropdownWidth = $dropdown.outerWidth();
7			var dropdownOffset = $dropdown.offset();
8			var toRight;
9			var viewportWidth;
10			var dropdownOffsetRight;
11
12			$dropdown.attr('style', '');
13
14			if (!dropdownWidth || !dropdownOffset) {
15				return;
16			}
17
18			if ($dropdown.hasClass('wd-design-full-width') || $dropdown.hasClass('wd-design-aside')) {
19				viewportWidth = woodmartThemeModule.$window.width();
20
21				if (woodmartThemeModule.$body.hasClass('rtl')) {
22					dropdownOffsetRight = viewportWidth - dropdownOffset.left - dropdownWidth;
23
24					if (dropdownOffsetRight + dropdownWidth >= viewportWidth) {
25						toRight = dropdownOffsetRight + dropdownWidth - viewportWidth;
26
27						$dropdown.css({
28							right: -toRight
29						});
30					}
31				} else {
32					if (dropdownOffset.left + dropdownWidth >= viewportWidth) {
33						toRight = dropdownOffset.left + dropdownWidth - viewportWidth;
34
35						$dropdown.css({
36							left: -toRight
37						});
38					}
39				}
40			} else if ($dropdown.hasClass('wd-design-sized') || $dropdown.hasClass('wd-design-full-height')) {
41				viewportWidth = woodmart_settings.site_width;
42
43				if (woodmartThemeModule.$window.width() < viewportWidth || ! viewportWidth || li.parents('.whb-header').hasClass('whb-full-width')) {
44					viewportWidth = woodmartThemeModule.$window.width();
45				}
46
47				dropdownOffsetRight = viewportWidth - dropdownOffset.left - dropdownWidth;
48
49				var extraSpace = 15;
50				var containerOffset = (woodmartThemeModule.$window.width() - viewportWidth) / 2;
51				var dropdownOffsetLeft;
52				var $stickyCat = $('.wd-sticky-nav');
53
54				if (woodmartThemeModule.$body.hasClass('wd-sticky-nav-enabled') && $stickyCat.length) {
55					extraSpace -= $stickyCat.width() / 2;
56				}
57
58				if (woodmartThemeModule.$body.hasClass('rtl')) {
59					dropdownOffsetLeft = containerOffset + dropdownOffsetRight;
60
61					if (dropdownOffsetLeft + dropdownWidth >= viewportWidth) {
62						toRight = dropdownOffsetLeft + dropdownWidth - viewportWidth;
63
64						$dropdown.css({
65							right: -toRight - extraSpace
66						});
67					}
68				} else {
69					dropdownOffsetLeft = dropdownOffset.left - containerOffset;
70
71					if (dropdownOffsetLeft + dropdownWidth >= viewportWidth) {
72						toRight = dropdownOffsetLeft + dropdownWidth - viewportWidth;
73
74						$dropdown.css({
75							left: -toRight - extraSpace
76						});
77					}
78				}
79			}
80		};
81
82		$('.wd-header-main-nav ul.menu > li, .wd-header-secondary-nav ul.menu > li, .widget_nav_mega_menu ul.menu:not(.wd-nav-vertical) > li, .wd-header-main-nav .wd-dropdown.wd-design-aside ul > li').each(function() {
83			var $menu = $(this);
84
85			if ($menu.hasClass('menu-item')) {
86				$menu = $(this).parent();
87			}
88
89			function recalc() {
90				if ($menu.hasClass('wd-offsets-calculated') || $menu.parents('.wd-design-aside').length) {
91					return;
92				}
93
94				$menu.find(' > .menu-item-has-children').each(function() {
95					setOffset($(this));
96				});
97
98				woodmartThemeModule.$document.trigger('resize.vcRowBehaviour');
99
100				$menu.addClass('wd-offsets-calculated');
101			}
102
103			$menu.on('mouseenter mousemove', function() {
104				recalc()
105			});
106
107			woodmartThemeModule.$window.on('wdHeaderBuilderStickyChanged', recalc);
108
109			if ('yes' === woodmart_settings.clear_menu_offsets_on_resize) {
110				setTimeout(function() {
111					woodmartThemeModule.$window.on('resize', woodmartThemeModule.debounce(function() {
112						$menu.removeClass('wd-offsets-calculated');
113						$menu.find(' > .menu-item-has-children > .wd-dropdown-menu').attr('style', '');
114					}, 300));
115				}, 2000);
116			}
117		});
118	};
119
120	woodmartThemeModule.menuDropdownAside = function() {
121		$('.wd-nav .wd-design-aside, .wd-header-cats.wd-open-dropdown .wd-nav').each( function () {
122			var $links = $(this).find('.menu-item');
123
124			if (!$links.length) {
125				return;
126			}
127
128			var $firstLink = $links.first();
129
130			if (!$firstLink.hasClass('menu-item-has-children')) {
131				$firstLink.parents('.wd-sub-menu-wrapp').addClass('wd-empty-item');
132			}
133
134			$firstLink.addClass('wd-opened').find('.wd-dropdown').addClass('wd-opened');
135
136			$links.on('mouseover', function () {
137				var $this = $(this);
138				var $wrap = $this.parents('.wd-sub-menu-wrapp');
139
140				if ($this.hasClass('wd-opened')) {
141					return;
142				}
143
144				if ( $this.hasClass('item-level-1') ) {
145					if (!$this.hasClass('menu-item-has-children')) {
146						$wrap.addClass('wd-empty-item');
147					} else {
148						$wrap.removeClass('wd-empty-item');
149					}
150				}
151
152				$this.siblings().removeClass('wd-opened').find('.wd-dropdown').removeClass('wd-opened');
153				$this.addClass('wd-opened').find('.wd-dropdown').addClass('wd-opened');
154			});
155		});
156	}
157
158	window.addEventListener('wdEventStarted', function () {
159		setTimeout(function () {
160			woodmartThemeModule.menuDropdownAside();
161			woodmartThemeModule.menuOffsets();
162		}, 100);
163	});
164})(jQuery);

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.