PageSourceSearch

https://geschwister-pfister.de/wp-content/plugins/cws-megamenu/assets/js/cws_megamenu_front.js?ver=5.2.28

js geschwister-pfister.de collected 2026-10-02 19:40:56 UTC 5,674 bytes, 167 lines download raw bytes

1"use strict";
2(function ($){
3
4	window.cws_megamenu = cws_megamenu;
5
6	function cws_megamenu ( menu, args ){
7		if ( menu == undefined ) return false;
8
9		var def_args, fw_obj, items, item, item_data, item_id, i;
10		var that = this;
11		var args = typeof args === 'object' ? args : {};
12		def_args = {
13			'fw_sel'							: '.wide_container',
14			'bottom_level_sub_menu_width_adj' 	: 0
15		}
16
17		that.args = cws_merge_trees( args, def_args );
18		that.controller = cws_megamenu_controller;
19		that.update_vars = cws_megamenu_update_vars;
20		that.update_items_vars = cws_megamenu_update_items_vars;
21		that.reposition_items = cws_megamenu_reposition_items;
22		that.is_item_right = cws_megamenu_is_item_right;
23		that.is_item_top_level = cws_megamenu_is_item_top_level;		
24		that.is_rtl = cws_megamenu_is_rtl;
25		that.rtl = that.is_rtl();
26		that.mobile_init = false;
27		that.menu = menu;
28		if ( that.args.fw_sel.length ){
29			fw_obj = $( that.menu ).closest( that.args.fw_sel );
30			if ( fw_obj.length ){
31				that.fw = fw_obj[0];
32			}
33		}
34		else{
35			that.fw = that.menu.parentNode;
36		}
37		if ( !that.fw ) return false;
38		items = that.menu.getElementsByClassName( "menu-item-object-megamenu_item" );
39		that.vars = {};
40		that.vars.fw_width = null;
41		that.vars.fw_left = null;
42		that.vars.fw_right = null;
43		that.items = {};
44		for ( i = 0; i < items.length; i++ ){
45			item = items[i];
46			item_id = item.id;
47			that.items[item_id] = {};
48			item_data = that.items[item_id];
49			item_data['el'] = item;
50			item_data['sub_menu'] = item.querySelector( ".sub-menu" );
51			item_data['megamenu_item'] = item.querySelector( ".megamenu_item" );
52			item_data.vars = {
53				'width' : null,
54				'left' : null,
55				'right' : null
56			};
57			item_data['is_right'] = that.is_item_right( item );
58			item_data['is_top_level'] = that.is_item_top_level( item );
59		}
60		that.controller();
61	}
62	function cws_megamenu_controller (){
63		var that = this;
64		that.update_vars();	
65		that.update_items_vars();
66		that.reposition_items();
67		window.addEventListener( "resize", function (){
68			that.update_vars();	
69			that.update_items_vars();
70			that.reposition_items();
71		}, false );
72	}
73	function cws_megamenu_update_items_vars (){
74		var that = this;
75		var items, keys, i, item_data, vars, item_id, item;
76		items 	= that.items;
77		keys 	= Object.keys( items );
78		for ( i = 0; i < keys.length; i++ ){
79			item_id 		= keys[i];
80			item_data 		= items[item_id];
81			item 			= item_data['el'];
82			vars 			= item_data.vars;
83			vars['width'] 	= item.offsetWidth;
84			vars['left'] 	= $( item ).offset().left;
85			vars['right'] 	= vars['left'] + vars['width'];
86		}
87	}
88	function cws_megamenu_update_vars ( item ){
89		var that = this;
90		that.vars.fw_width 	= that.fw.offsetWidth;
91		that.vars.fw_left 	= $( that.fw ).offset().left;
92		that.vars.fw_right 	= that.vars.fw_left + that.vars.fw_width;	
93	}
94	function cws_megamenu_reposition_items (){
95		var that = this;
96		var items, keys, i, item_data, item_id, mm_item_width, mm_item_left, mm_item_right;
97		items = that.items;
98		keys = Object.keys( items );
99		for ( i = 0; i < keys.length; i++ ){
100			item_id = keys[i];
101			item_data = items[item_id];
102
103			if ($('li.cws_megamenu_item').hasClass('dis_full_width')) {
104				var that_item, that_per_item, mgmenu_pos, doc_w, item_pos, pos, item_per_w;
105				that_item = $('li.cws_megamenu_item')
106				that_per_item = that_item.parents('.menu-item-object-megamenu_item')
107				that_per_item.addClass('disable_fw');
108				mgmenu_pos = that_item.data('pos');
109				that_per_item.addClass('direction_'+mgmenu_pos+'');
110				mm_item_width = that_item.data('width');
111				item_data.sub_menu.style.width = mm_item_width + "px";
112				doc_w = jQuery(window).width();
113				$('.main-nav-container .menu-item-object-megamenu_item').each(function() {
114					item_pos = $(this).offset().left;
115					item_per_w = $(this).width();
116				});
117				if (mgmenu_pos == 'right') {
118					if (item_pos + mm_item_width > doc_w) {
119						mm_item_left = -1 * (item_pos + mm_item_width - doc_w + 30);
120						item_data.sub_menu.style.left = mm_item_left + "px";
121					} 
122				} else if (mgmenu_pos == 'left') {
123					if (item_pos < mm_item_width) {
124						mm_item_left = -1 * (item_pos - 30);
125						item_data.sub_menu.style.left = mm_item_left + "px";
126					}
127				} else if (mgmenu_pos == 'center') {
128					if ( (item_pos + mm_item_width / 2 < doc_w) && item_pos > mm_item_width / 2 ) {
129						mm_item_left = -1 * (mm_item_width / 2 - item_per_w / 2) ;
130						item_data.sub_menu.style.left = mm_item_left + "px";
131					} else if (item_pos + mm_item_width > doc_w) {
132						mm_item_left = -1 * (item_pos + mm_item_width - doc_w + 30);
133						item_data.sub_menu.style.left = mm_item_left + "px";
134					} else if (item_pos < mm_item_width) {
135						mm_item_left = -1 * (item_pos - 30);
136						item_data.sub_menu.style.left = mm_item_left + "px";
137					}
138				}
139			} else {
140				mm_item_width = that.vars.fw_width;
141				item_data.sub_menu.style.width = mm_item_width + "px";
142				if ( that.rtl ){
143					mm_item_right = item_data.vars.right - that.vars.fw_right;
144					item_data.sub_menu.style.right = mm_item_right + "px";
145				}
146				else{
147					mm_item_left = -1 * ( item_data.vars.left - that.vars.fw_left );
148					item_data.sub_menu.style.left = mm_item_left + "px";	
149				}
150			}
151		}
152	}
153	function cws_megamenu_is_item_right ( item ){
154		var that = this;
155		if ( item == undefined ) return false;
156		return cws_has_class( item, "right" ) || $( item ).closest( ".menu-item.right" ).length;
157	}
158	function cws_megamenu_is_item_top_level ( item ){
159		var that = this;
160		if ( item == undefined ) return false;
161		return !cws_has_class( item.parentNode, "sub-menu" );
162	}
163	function cws_megamenu_is_rtl (){
164		return cws_has_class( document.body, "rtl" );
165	}
166	
167}(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.