PageSourceSearch

https://www.mairiesquiffiec.fr/media/plg_system_mobilemenuck/assets/mobilemenuck.js?ver=17.1

js mairiesquiffiec.fr collected 2026-10-03 02:47:29 UTC 58,898 bytes, 1,419 lines download raw bytes

1/**
2 * @copyright	Copyright (C) 2018 Cedric KEIFLIN alias ced1870
3 * https://www.joomlack.fr
4 * Mobile Menu CK
5 * @license		GNU/GPL
6 * */
7 
8 /*
9  * 
10 - Version 1.2.22 : 03/02/26 improve the slide left and right effect
11 - Version 1.2.21 : 31/10/25 fix issue with mouseover event
12 - Version 1.2.20 : 12/11/24 add opened on active item feature in fade, and slide effect
13 - Version 1.2.19 : 16/01/24 add parent item text in the fade effect
14 - Version 1.2.18 : 16/01/24 add custom_position option
15 - Version 1.2.17 : 31/12/23 fix issue with custom text on active item in the menu bar title
16 - Version 1.2.16 : 27/11/23 fix issue with fade effect and more than 2 levels
17 - Version 1.2.15 : /23 fix issue with menu text in the slide effect
18 - Version 1.2.14 : 04/09/23 fix issue with module in Accordeon Menu CK not loaded
19 - Version 1.2.13 : 02/08/23 fix issue with mod_login ID
20 - Version 1.2.12 : 03/07/23 fix issue with href, use span instead of a
21 - Version 1.2.11 : 28/06/23 fix issue with href missing on separator item, duplicated id on mod_login
22 - Version 1.2.10 : 26/06/23 add script to manage the mod_login and the show password button
23 - Version 1.2.9 : 01/04/23 fix issue with overlay and multiple menus on the page
24 - Version 1.2.8 : 16/02/23 fix issue with click on the overlay
25 - Version 1.2.7 : 22/06/22 add feature to use a custom link to target any submenu in the mobile menu
26 - Version 1.2.6 : 01/06/22 fix issue with title not shown if a module is loaded in the bar
27 - Version 1.2.5 : 10/03/22 fix issue with locked icon
28 - Version 1.2.4 : 01/03/22 add icon and replacement text for mod_menu, counter option
29 - Version 1.2.3 : 15/02/22 fix issue with left position and slide effect + add title on anchor
30 - Version 1.2.2 : 29/11/21 add accordion effects and toggle options, and lock_forced
31 - Version 1.2.1 : 09/11/21 add topfixedeffect option
32 - Version 1.2.0 : 24/09/21 add flyout effect
33 - Version 1.1.7 : 21/09/21 add option for a lock button
34 - Version 1.1.6 : 18/05/21 add compatibility with scrollTo and lightbox to close the menu when using a merged menu
35 - Version 1.1.5 : fix issue with merged menu and fade effect
36 - Version 1.1.4 : fix issue with merged menu, add compatibility with Mediabox CK
37 - Version 1.1.3 : fix issue with maximenu pushdown layout
38 - Version 1.1.2 : fix issue with image only in the menu item
39 - Version 1.1.1 : fix issue with description shown in the menu bar
40 */
41
42(function($) {
43	// "use strict";
44	var MobileMenuCK = function(el, opts) {
45		if (!(this instanceof MobileMenuCK)) return new MobileMenuCK(el, opts);
46
47		if (! el.length) {
48			console.log('MOBILE MENU CK ERROR : Selector not found : ' + el.selector);
49			return;
50		}
51
52		var defaults = {
53			useimages: '0',
54			container: 'body', 						// body, menucontainer, topfixed, custom
55			showdesc: '0',
56			showlogo: '1',
57			usemodules: '0',
58			menuid: '',
59			mobilemenutext: 'Menu',
60			showmobilemenutext: '',
61			titletag: 'h3',
62			displaytype: 'accordion',				// flat, accordion, fade, push, flyout
63			displayeffect: 'normal',				// normal, slideleft, slideright, slideleftover, sliderightover, topfixed, open
64			menubarbuttoncontent : '',
65			topbarbuttoncontent : '',
66			uriroot : '',
67			mobilebackbuttontext : 'Back',
68			menuwidth : '300',
69			openedonactiveitem : '1',
70			loadanchorclass : '1',
71			langdirection : 'ltr',
72			menuselector: 'ul',
73			childselector: 'li',
74			merge: '',
75			beforetext: '',
76			aftertext: '',
77			tooglebaron: 'all', // all, button
78			tooglebarevent: 'click', // click, mouseover
79			mergeorder: ''
80			// Logo options
81			,logo_where : '1'										// 1, 2, 3
82			,logo_source : 'maximenuck'								// maximenuck, custom
83			,logo_image : ''										// the image src
84			,logo_link : ''											// the link url
85			,logo_alt : ''											// the alt tag
86			,logo_position : 'left'									// left, center, right
87			,logo_width : ''										// image width
88			,logo_height : ''										// image height
89			,logo_margintop : ''									// margin top
90			,logo_marginright : ''									// margin right
91			,logo_marginbottom : ''									// margin bototm
92			,logo_marginleft : ''									// margin left
93			,logo_class : ''
94			// lock button
95			,lock_button : '0'
96			,lock_forced : '0'
97			,topfixedeffect : 'always'								// always, onscroll
98			,accordion_use_effects : '0'
99			,accordion_toggle : '0'
100			,show_icons : '1'
101			,counter : '0'
102			,overlay : '0'
103			,custom_position : '.container-banner'
104			,search : '0'
105		};
106
107		var opts = $.extend(defaults, opts);
108		var t = this;
109		// store the menu
110		t.menu = (el[0].tagName.toLowerCase() == opts.menuselector) ? el : el.find(opts.menuselector).first();
111
112		// exit if no menu
113		if (! t.menu.length)
114			return false;
115
116		if (t.menu.length > 1) {
117			var MobileMenuCKs = window.MobileMenuCKs || [];
118			t.menu.each(function () {
119				MobileMenuCKs.push(new MobileMenuCK($(this), opts));
120			});
121			window.MobileMenuCKs = MobileMenuCKs;
122			return MobileMenuCKs;
123		}
124
125		// store all mobile menus in the page
126		window.MobileMenuCKs = window.MobileMenuCKs || [];
127		window.MobileMenuCKs.push(this);
128
129		if (! t.menu.attr('data-mobilemenuck-id')) {
130			// var now = new Date().getTime();
131			// var id = 'mobilemenuck-' + parseInt(now, 10);
132			t.menu.attr('data-mobilemenuck-id', opts.menuid);
133		} else {
134			return this;
135		}
136		t.mobilemenuid = opts.menuid + '-mobile'; 
137		t.mobilemenu = $('#' + t.mobilemenuid); 
138		t.mobilemenu.attr('data-id', opts.menuid);
139
140		// exit if mobile menu already exists
141		if (t.mobilemenu.length)
142			return this;
143
144		// store all mobile menus in the page by ID
145		window.MobileMenuCKByIds = window.MobileMenuCKByIds || [];
146		window.MobileMenuCKByIds[opts.menuid] = this;
147
148		t.MobilemenuckSettings = window.MobilemenuckSettings || null;
149
150		if (t.menu.prev(opts.titletag))
151			t.menu.prev(opts.titletag).addClass('mobilemenuck-hide');
152
153				// setup the topfixed effect only if needed
154		if (opts.container !== 'topfixed') {
155			opts.topfixedeffect = 'none';
156		}
157
158		// onscroll top fixed 
159		if (opts.topfixedeffect == 'onscroll') {
160			opts.container = 'menucontainer';
161			$(window).scroll(function() { t.floatItem(); });
162		}
163
164		t.floatItem = function() {
165			var winY = $(window).scrollTop();
166			var toTop = t.wrap.offset().top;
167			if (toTop < winY && t.wrap.attr('fixed') != '1') {
168				t.mobilemenubar.css('position', 'fixed');
169				t.wrap.attr('fixed', '1');
170			} else if (toTop > winY && t.wrap.attr('fixed') == '1') {
171				t.mobilemenubar.css('position', 'relative');
172				t.wrap.attr('fixed', '0');
173			}
174		}
175
176		t.init = function() {
177			var activeitem, logoitem;
178			if (t.menu.find('li.maximenuck').length) {
179				t.menutype = 'maximenuck';
180				t.updatelevel();
181			} else if (t.menu.find('li.accordeonck').length) {
182				t.menutype = 'accordeonck';
183			} else {
184				t.menutype = 'normal';
185			}
186
187			// for menuck
188			if ($('.maxipushdownck', t.menu.parent()).length) {
189				var menuitems = $(t.sortmenu(t.menu.parent()));
190			} else {
191				if (t.menutype == 'maximenuck') {
192					var menuitems = $('li.maximenuck', t.menu);
193				} else if (t.menutype == 'accordeonck') {
194					var menuitems = $('li.accordeonck', t.menu);
195				} else {
196					var menuitems = $(opts.childselector, t.menu);
197				}
198			}
199
200			// loop through the tree
201			t.setDataLevelRecursive(t.menu, 1);
202
203			// only add the menu bar if not merged with another
204			if (! opts.merge) {
205				if (opts.container == 'body' 
206					|| opts.container == 'topfixed'
207					|| opts.displayeffect == 'slideleft'
208					|| opts.displayeffect == 'slideright'
209					|| opts.displayeffect == 'topfixed'
210					) {
211					$(document.body).append('<div id="' + t.mobilemenuid + '" class="mobilemenuck ' + opts.langdirection + '"></div>');
212				} else if(opts.container == 'custom' && opts.custom_position) {
213					$(opts.custom_position).append('<div id="' + t.mobilemenuid + '" class="mobilemenuck ' + opts.langdirection + '"></div>');
214				} else {
215					el.after($('<div id="' + t.mobilemenuid + '" class="mobilemenuck ' + opts.langdirection + '"></div>'));
216				}
217			}
218			t.mobilemenu = $('#' + t.mobilemenuid);
219			t.mobilemenu.attr('data-id', opts.menuid);
220			// don't create the top bar if merged with another
221			if (opts.merge) {
222				t.mobilemenu.html = '';
223			} else {
224				// lock button
225				var lockbuttonhtml = '';
226				if (opts.lock_button == '1') {
227					let icon = sessionStorage.getItem('mobilemenuck-lock') == '1' ? t.getSvg('lock') : t.getSvg('unlock');
228					lockbuttonhtml = '<div class="mobilemenuck-lock-button mobilemenuck-button" role="button" tabindex="0" aria-label="' + Joomla.Text._('PLG_MOBILEMENUCK_LOCK_BUTTON_LABEL') + '">' + icon + '</div>';
229				}
230				t.mobilemenu.html = '<div class="mobilemenuck-topbar"><div class="mobilemenuck-title">' + opts.mobilemenutext + '</div>' + lockbuttonhtml + '<div class="mobilemenuck-button" role="button" tabindex="0" aria-label="' + Joomla.Text._('PLG_MOBILEMENUCK_MENU_BUTTON_LABEL') + '">' + opts.topbarbuttoncontent + '</div></div>';
231			}
232			t.mobilemenu.html += opts.beforetext ? '<div class="mobilemenuck-beforetext">' + opts.beforetext + '</div>' : '';
233			menuitems.each(function(i, itemtmp) {
234				itemtmp = $(itemtmp);
235				
236				// check for params from the menu item settings
237				var menuId = itemtmp.attr('class').match(/item-(\d+)/);
238				if (menuId && menuId[1] && t.MobilemenuckSettings && t.MobilemenuckSettings[opts.menuid]) {
239					var menuItemId = menuId[1];
240					var itemParams = t.MobilemenuckSettings[opts.menuid][menuItemId];
241					if (itemParams.enabled === '0') $(itemtmp).addClass('nomobileck')
242				} else {
243					var itemParams = false;
244				}
245
246				var itemanchor = t.validateitem(itemtmp);
247				if (itemanchor
248						) {
249					var itemlevel = $(itemtmp).attr('data-level');
250					t.mobilemenu.html += '<div class="mobilemenuck-item" data-level="' + itemlevel 
250+ '">';
251					// itemanchor = $('> a.menuck', itemtmp).length ? $('> a.menuck', itemtmp).clone() : $('> span.separator', itemtmp).clone();
252					if (opts.showdesc == '0') {
253						if ($('span.descck', itemanchor).length)
254							$('span.descck', itemanchor).remove();
255					}
256					var itemhref = itemanchor.attr('data-href') ? ' href="' + itemanchor.attr('data-href') + '"' : (itemanchor.attr('href') ? ' href="' + itemanchor.attr('href') + '"' : '');
257					if (itemanchor.attr('target')) itemhref += ' target="' + itemanchor.attr('target') + '"';
258
259					if (itemtmp.attr('data-mobiletext')) {
260						$('span.titreck', itemanchor).html(itemtmp.attr('data-mobiletext'));
261					} else if (itemParams) {
262						var itemmobiletext = t.getTextFromParams(itemParams);
263						if (itemmobiletext) $('span.titreck', itemanchor).html(itemmobiletext);
264					}
265					var itemmobileicon = '';
266					if (itemtmp.attr('data-mobileicon')) {
267						itemmobileicon = '<img class="mobilemenuck-icon" src="' + opts.uriroot + '/' + itemtmp.attr('data-mobileicon') + '" />';
268					} else if (itemParams) {
269						itemmobileicon = t.getIconFromParams(itemParams);
270					}
271					// var itemanchorClass = '';
272					var itemanchorClass = (opts.loadanchorclass == '1' && itemanchor.attr('class')) ? itemanchor.attr('class') : '';
273					// check for specific class on the anchor to apply to the mobile menu
274					if (itemanchor.hasClass('scrollTo') && opts.loadanchorclass != '1') {
275						itemanchorClass += 'scrollTo';
276					}
277					itemanchorClass = (itemanchorClass) ? ' class="' + itemanchorClass + '"' : '';
278					itemanchorRel = (itemanchor.attr('rel')) ? ' rel="' + itemanchor.attr('rel') + '"' : '';
279					itemanchorTitle = (itemanchor.attr('title')) ? ' title="' + itemanchor.attr('title') + '"' : '';
280					itemanchorTag = itemhref ? 'a' : 'span';
281					if (opts.useimages == '1' && ($('> * > img', itemtmp).length || $('> * > * > img', itemtmp).length)) {
282						datatocopy = itemanchor.html();
283						t.mobilemenu.html += '<div class="menuck ' + itemtmp.attr('class') + '"><' + itemanchorTag + itemhref + itemanchorClass + itemanchorRel + itemanchorTitle + '>' + itemmobileicon + '<span class="mobilemenuck-item-text">' + datatocopy + '</span></' + itemanchorTag + '></div>';
284					} else if (opts.usemodules == '1' && (
285								$('> div.menuck_mod', itemtmp).length
286								|| $('> div.maximenuck_mod', itemtmp).length
287								|| $('> div.accordeonckmod', itemtmp).length
288								|| $('> div.accordeonmenuck_mod', itemtmp).length
289								)
290							) {
291						datatocopy = itemanchor.html();
292						t.mobilemenu.html += '<div class="' + itemtmp.attr('class') + '">' + itemmobileicon + datatocopy + '</div>';
293					} else {
294						if (itemtmp.attr('data-mobiletext')) {
295							var datatocopy = itemtmp.attr('data-mobiletext');
296						} else if (itemParams) {
297							var datatocopy = t.getTextFromParams(itemParams) || itemanchor.html();
298						} else {
299							if (opts.useimages == '0') {
300								itemanchor.find('> img').remove();
301							}
302							var datatocopy = itemanchor.html();
303						}
304						t.mobilemenu.html += '<div class="menuck ' + itemtmp.attr('class') + '"><' + itemanchorTag + itemhref + itemanchorClass + itemanchorRel + itemanchorTitle + '>' + itemmobileicon + '<span class="mobilemenuck-item-text">' + datatocopy + '</span></' + itemanchorTag + '></div>';
305					}
306
307					// var itemlevel = $(itemtmp).attr('data-level');
308					var j = i;
309					while (menuitems[j + 1] && !t.validateitem(menuitems[j + 1]) && j < 1000) {
310						j++;
311					}
312					if (menuitems[j + 1] && t.validateitem(menuitems[j + 1])) {
313						var itemleveldiff = $(menuitems[i]).attr('data-level') - $(menuitems[j + 1]).attr('data-level');
314						if (itemleveldiff < 0) {
315							t.mobilemenu.html += '<div class="mobilemenuck-submenu">';
316						}
317						else if (itemleveldiff > 0) {
318							t.mobilemenu.html += '</div>';
319							t.mobilemenu.html += t.strRepeat('</div></div>', itemleveldiff);
320						} else {
321							t.mobilemenu.html += '</div>';
322						}
323					} else {
324						t.mobilemenu.html += t.strRepeat('</div></div>', itemlevel);
325					}
326
327					if (itemtmp.hasClass('current'))
328						activeitem = itemtmp.clone();
329					if (!opts.showdesc) {
330						if ($('span.descck', $(activeitem)).length)
331							$('span.descck', $(activeitem)).remove();
332					}
333
334				} //else if ($(itemtmp).hasClass('menucklogo')) {
335				//logoitem = $(itemtmp).clone();
336				//}
337			});
338
339			t.mobilemenu.html += opts.aftertext ? '<div class="mobilemenuck-aftertext">' + opts.aftertext + '</div>' : '';
340			if (opts.merge) {
341				var mergedmobilemenuid = opts.merge + '-mobile'; 
342				var mergedmobilemenu = $('#' + mergedmobilemenuid);
343				if (mergedmobilemenu.length) {
344					if (mergedmobilemenu.find('.mobilemenuck-itemwrap').length) {
345						mergedmobilemenu.find('.mobilemenuck-itemwrap').append(t.mobilemenu.html);
346					} else {
347						mergedmobilemenu.append(t.mobilemenu.html);
348					}
349				} else {
350					$(document.body).append($('<div style="display:none;" data-mobilemenuck-merged="' + mergedmobilemenuid + '" data-mobilemenuck-mergedorder="' + opts.mergeorder + '">' + t.mobilemenu.html + '</div>'));
351				}
352				// close the menu when scroll is needed
353				$('.scrollTo,[rel*="lightbox"]', mergedmobilemenu).click(function() {
354					t.closeMenu();
355				});
356			} else {
357				t.mobilemenu.append(t.mobilemenu.html);
358				if (opts.lock_button == '1') {
359					t.mobilemenu.find('.mobilemenuck-lock-button').on('click keypress', function(event) {
360						if (event.type === 'click' || (event.type === 'keypress' && event.keyCode === 13)) {
361							if (sessionStorage.getItem('mobilemenuck-lock') == '1') {
362								sessionStorage.removeItem('mobilemenuck-lock');
363								sessionStorage.removeItem('mobilemenuck-state');
364								this.innerHTML = t.getSvg('unlock');
365							} else {
366								sessionStorage.setItem('mobilemenuck-lock', '1');
367								t.storeLockedState();
368								this.innerHTML = t.getSvg('lock');
369							}
370						}
371					});
372				}
373				if (opts.lock_forced == '1') {
374					sessionStorage.setItem('mobilemenuck-lock', '1');
375				}
376
377				// if another menu has been created to be merged
378				if ($('[data-mobilemenuck-merged="' + t.mobilemenuid + '"]').length) {
379					$('[data-mobilemenuck-merged="' + t.mobilemenuid + '"]').each(function() {
380						var mergingmenu = $(this);
381						var mergedorder = $(this).attr('data-mobilemenuck-mergedorder');
382						$(this).find('.mobilemenuck-item').attr('data-mergedorder', mergedorder);
383						var merged = false;
384						t.mobilemenu.find('.mobilemenuck-item').each(function() {
385							if ($(this).attr('data-mergedorder') > mergedorder && merged == false) {
386								$(this).before(mergingmenu.html());
387								merged = true;
388							}
389						});
390						if (merged == false) t.mobilemenu.append(mergingmenu.html());
391						$('[data-mobilemenuck-merged="' + t.mobilemenuid + '"]').remove();
392					});
393				}
394			}
395			// add custom modules in the menu
396			if ($('#mobilemenuck-top-module').length) {
397				t.mobilemenu.find('.mobilemenuck-topbar').after($('#mobilemenuck-top-module').show());
398			}
399			if ($('#mobilemenuck-bottom-module').length) {
400				t.mobilemenu.append($('#mobilemenuck-bottom-module').show());
401			}
402
403			t.initCss();
404			var activeitemtext;
405			var activeitemhref;
406			if (activeitem && opts.showmobilemenutext != 'none' && opts.showmobilemenutext != 'custom') {
407				if (opts.showdesc == '0') {
408					activeitem.find('.descck').remove();
409				}
410				if (opts.useimages == '1') {
411					activeitemtext = activeitem.find('a.maximenuck').html();
412				} else {
413					if (activeitem.attr('data-mobiletext')) {
414						activeitemtext = activeitem.attr('data-mobiletext');
415					}	else {
416						activeitemtext = activeitem.find('span.titreck').html();
417					}
418//					activeitemhref = activeitem.find('a.maximenuck').attr('href');
419//					activeitemtext = activeitemhref ? '<a href="' + activeitemhref + '">' + activeitemtext + '</a>' : activeitemtext;
420				}
421				if (!activeitemtext || activeitemtext == 'undefined')
422					activeitemtext = opts.mobilemenutext;
423			} else {
424				activeitemtext = opts.mobilemenutext;
425			}
426
427			if (! opts.merge) {
428				var position = (opts.container == 'body') ? 'absolute' : ( (opts.container == 'topfixed') ? 'fixed' : 'relative' );
429				if (opts.container == 'topfixed') {
430					opts.container = 'body';
431					opts.containermemory = 'topfixed';
432				}
433				var mobilemenubar = '<div id="' + t.mobilemenuid + '-bar" class="mobilemenuck-bar ' + opts.langdirection + '" style="position:' + position + '"><div class="mobilemenuck-bar-title">' + activeitemtext + '</div>'
434						+ '<div class="mobilemenuck-bar-button" role="button" tabindex="0" aria-label="' + Joomla.Text._('PLG_MOBILEMENUCK_BAR_BUTTON_LABEL') + '">' + opts.menubarbuttoncontent + '</div>'
435						+ '</div>';
436				t.mobilemenubar = $(mobilemenubar);
437				// load custom module if loaded
438//				if ($('#' + t.mobilemenuid + '-bar-module').length) {
439				if ($('#mobilemenuck-bar-module').length) {
440//					t.mobilemenubar.find('.mobilemenuck-bar-title').text('');
441					t.mobilemenubar.find('.mobilemenuck-bar-title').append($('#mobilemenuck-bar-module').show());
442				}
443				t.mobilemenubar.attr('data-id', opts.menuid);
444
445				if (opts.container == 'body') {
446					$(document.body).append(t.mobilemenubar);
447				} else if(opts.container == 'custom' && opts.custom_position) {
448					$(opts.custom_position).append(t.mobilemenubar);
449					if (opts.displayeffect == 'normal' || opts.displayeffect == 'open')
450						t.mobilemenu.css('position', 'relative');
451				} else {
452					el.after(t.mobilemenubar);
453					if (opts.displayeffect == 'normal' || opts.displayeffect == 'open')
454						t.mobilemenu.css('position', 'relative');
455				}
456
457				// onscroll top fixed 
458				if (opts.topfixedeffect == 'onscroll') {
459					let wrapid = t.mobilemenubar.attr('id') + '-wrap-topfixed';
460					t.mobilemenubar.wrap('<div id="' + wrapid + '" class="mobilemenuck-wrap-topfixed"></div>');
461					t.wrap = $('#' + wrapid);
462
463					t.wrap.css('height', t.getHiddenDimensions(t.mobilemenubar).height );
464				}
465
466				t.menu.parents('.nav-collapse').css('height', 'auto').css('overflow', 'visible');
467				t.menu.parents('.navigation').find('.navbar').css('display', 'none');
468				t.mobilemenubar.parents('.nav-collapse').css('height', 'auto');
469				t.mobilemenubar.parents('.navigation').find('.navbar').css('display', 'none');
470
471				if (opts.showlogo == '0') {
472					
473				} else if (($('.maximenucklogo', t.menu).length && opts.showlogo)
474					|| opts.logo_source === 'custom'){
475					if (opts.logo_source === 'custom' && opts.logo_image !== '') {
476						var logo_style = (opts.logo_margintop  ? ' margin-top:' + opts.logo_margintop + ';' : '')
477										+ (opts.logo_marginright  ? ' margin-right:' + opts.logo_marginright + ';' : '')
478										+ (opts.logo_marginbottom  ? ' margin-bottom:' + opts.logo_marginbottom + ';' : '')
479										+ (opts.logo_marginleft  ? ' margin-left:' + opts.logo_marginleft + ';' : '')
480						logo_style = logo_style ? ' style="' + logo_style + '"' : '';
481						var logo_html = '<img src="' + opts.uriroot + '/' + opts.logo_image + '"'
482										 + (opts.logo_width  ? ' width="' + opts.logo_width + '"' : '')
483										 + (opts.logo_height  ? ' height="' + opts.logo_height + '"' : '')
484										 + (opts.logo_alt  ? ' alt="' + opts.logo_alt + '"' : '')
485										 + logo_style
486										 + ' data-position="' + opts.logo_position + '"'
487										 + ' class="' + opts.logo_class + '"'
488										 + '/>'
489						logo_html = opts.logo_link ? '<a href="' + opts.logo_link + '">' + logo_html + '</a>' : logo_html;
490						logoitem = '<div class="mobilemenuck-logo mobilemenuck-logo-' + opts.logo_position + '">' + logo_html + '</div>';
491						var floatlogo = '';
492					} else {
493						logoitem = $('.maximenucklogo', t.menu).clone();
494						var floatlogo = 'float:left;';
495					}
496					// convert to array
497					opts.logo_where = opts.logo_where.split(',');
498
499					if (opts.logo_where.includes('2')) {
500						t.mobilemenubar.prepend('<div style="float:left;" class="' + $(logoitem).attr('class') + '">' + $(logoitem).html() + '</div>');
501					} 
502					if (opts.logo_where.includes('3')) {
503						$('.mobilemenuck-topbar', t.mobilemenu).prepend('<div style="' + floatlogo + '" class="' + $(logoitem).attr('class') + '">' + $(logoitem).html() + '</div>');
504					} 
505					if (opts.logo_where.includes('1')) {
506						$('.mobilemenuck-topbar', t.mobilemenu).after('<div class="' + $(logoitem).attr('class') + '">' + $(logoitem).html() + '<div style="clear:both;"></div></div>');
507					}
508				}
509				if (opts.tooglebaron == 'button') {
510					$(t.mobilemenubar).find('.mobilemenuck-bar-button').on(opts.tooglebarevent + ' keypress', function(event) {
511						if (opts.tooglebarevent === 'mouseover' || event.type === 'click' || (event.type === 'keypress' && event.keyCode === 13)) t.toggleMenu();
512					});
513				} else {
514					$(t.mobilemenubar).on(opts.tooglebarevent + ' keypress', function(event) {
515						if (opts.tooglebarevent === 'mouseover' || event.type === 'click' || (event.type === 'keypress' && event.keyCode === 13)) t.toggleMenu();
516					});
517				}
518				$('.mobilemenuck-button:not(.mobilemenuck-lock-button)', t.mobilemenu).on('click keypress', function(event) {
519					if (event.type === 'click' || (event.type === 'keypress' && event.keyCode === 13)) t.closeMenu();
520				});
521				// close the menu when scroll is needed
522				$('.scrollTo,[rel="lightbox"]', t.mobilemenu).click(function() {
523					t.closeMenu();
524				});
525				if (typeof Scrolltock == 'function' && $('.scrollTo', t.mobilemenu).length) {
526					Scrolltock(t.mobilemenu);
527				}
528
529				$(window).on("click", function(event){
530					if (sessionStorage.getItem('mobilemenuck-lock') !== '1') {
531						var shallclose = true;
532						$('.mobilemenuck').each(function() {
533							var $this = $(this);
534							if ( 
535								$this.has(event.target).length == 0 //checks if descendants of submenu was clicked
536								&&
537								!$this.is(event.target) //checks if the submenu itself was clicked
538								&&
539								$('#' + t.mobilemenuid + '-bar').has(event.target).length == 0
540								&&
541								!$('#' + t.mobilemenuid + '-bar').is(event.target)
542	//							&&
543	//							$this.find('.mobilemenuck-lock-button').has(event.target).length == 0
544	//							&&
545	//							!$this.find('.mobilemenuck-lock-button').is(event.target)
546								){
547								// is outside
548								// closeMenu(opts.menuid);
549								// shallclose = true;
550							} else {
551								// is inside one of the mobile menus, do nothing
552								shallclose = false;
553							}
554						});
555						if (shallclose) {
556							t.closeMenu();
557							if (t.mobilemenu.css('display') == 'block') return false;
558						}
559					}
560				});
561			} // end merge condition
562
563			if (opts.counter === '1') t.loadCounter();
564			if (opts.search === '1') t.initSearch();
565
566			// add compatibility with Mediabox CK
567			if (typeof(Mediabox) != "undefined") {
568				Mediabox.scanPage();
569			}
570			if (typeof(scrolltock_mobilemenuck_compat) != "undefined") {
571				scrolltock_mobilemenuck_compat(t.mobilemenu);
572			}
573		}
574
575		t.initSearch = function() {
576			let searchTemplate = '<div class="mobilemenuck-search">'
577				+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 56.966 56.966" class="mobilemenuck-search-icon">'
578					+ '<path fill="currentColor" d="M55.146,51.887L41.588,37.786c3.486-4.144,5.396-9.358,5.396-14.786c0-12.682-10.318-23-23-23s-23,10.318-23,23s10.318,23,23,23c4.761,0,9.298-1.436,13.177-4.162l13.661,14.208c0.571,0.593,1.339,0.92,2.162,0.92c0.779,0,1.518-0.297,2.079-0.837C56.255,54.982,56.293,53.08,55.146,51.887z M23.984,6c9.374,0,17,7.626,17,17s-7.626,17-17,17s-17-7.626-17-17S14.61,6,23.984,6z"></path>'
579				+ '</svg>'
580				+ '<input type="text" placeholder="' + Joomla.JText._('PLG_MOBILEMENUCK_SEARCH') + '" aria-label="' + Joomla.Text._('PLG_MOBILEMENUCK_SEARCH_LABEL') + '" />'
581				+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 612 612" class="mobilemenuck-search-reset" role="button" tabindex="0" aria-label="' + Joomla.Text._('PLG_MOBILEMENUCK_SEARCH_RESET_LABEL') + '">'
582					+ '<path fill="currentColor" d="M561,76.5H178.5c-17.85,0-30.6,7.65-40.8,22.95L0,306l137.7,206.55c10.2,12.75,22.95,22.95,40.8,22.95H561c28.05,0,51-22.95,51-51v-357C612,99.45,589.05,76.5,561,76.5zM484.5,397.8l-35.7,35.7L357,341.7l-91.8,91.8l-35.7-35.7l91.8-91.8l-91.8-91.8l35.7-35.7l91.8,91.8l91.8-91.8l35.7,35.7L392.7,306L484.5,397.8z"></path>'
583				+ '</svg>'
584			+ '</div>';
585			$('.mobilemenuck-topbar', t.mobilemenu).after('<div class="mobilemenuck-search"></div>');
586			let searchContainer = $('.mobilemenuck-search', t.mobilemenu);
587			if (! searchContainer.length) return;
588
589			searchContainer.append(searchTemplate);
590			searchContainer.append('<div class="mobilemenuck-results"></div>');
591
592			var searchInput = searchContainer.find('input');
593			searchInput.on('keyup', function() {
594				t.doSearch(this.value);
595			});
596			searchContainer.find('button').on('click', function() {
597				searchInput.val('');
598				t.resetSearch();
599			});
600			$(window).on('keydown', function(event) {
601				if (event.which === 27) {
602					searchInput.val('');
603					t.resetSearch();
604				}
605			})
606			t.mobilemenu.find('.mobilemenuck-search-reset').on('click keypress', function(event) {
607				if (event.type === 'click' || (event.type === 'keypress' && event.keyCode === 13)) {
608					searchInput.val('');
609					t.resetSearch();
610				}
611			})
612		}
613
614		t.doSearch = function(txt) {
615			if (! txt) {
616				t.resetSearch();
617				return;
618			}
619			t.mobilemenu.find('> .mobilemenuck-item').hide();
620			let resultContainer = $('.mobilemenuck-results', t.mobilemenu);
621			resultContainer.empty().show();
622
623			let items = new Array();
624			[].slice.call(t.mobilemenu[0].querySelectorAll('div.mobilemenuck-item'))
625				.filter(a => a.textContent.toLowerCase().match(txt.toLowerCase()))
626				.forEach(function(a) { items.push(a); });
627
628			items.forEach(function(el) {
629				resultContainer.append('<div class="mobilemenuck-item mobilemenuck-result" data-level="1">' + el.innerHTML + '</div>');
630			})
631			
632			t.mobilemenu.find('.mobilemenuck-search-reset').show();
633		}
634
635		t.resetSearch = function() {
636			$('.mobilemenuck-results', t.mobilemenu).empty().hide();
637			t.mobilemenu.find('> .mobilemenuck-item').show();
638			t.mobilemenu.find('.mobilemenuck-search-reset').hide();
639		}
640
641		t.loadCounter = function() {
642			t.mobilemenu.find('.mobilemenuck-item').each(function() {
643				if ($(this).find('.mobilemenuck-submenu').length) {
644					var number = $(this).find('.mobilemenuck-submenu > .mobilemenuck-item').length;
645					var counter = '<span class="mobilemenuck-item-counter">' + number + '</span>';
646					$(this).find('> div:first-child .mobilemenuck-item-text').after(counter);
647				}
648			});
649		}
650
651		t.getIconFromParams = function(itemParams) {
652			if (! itemParams.icon) return '';
653
654			var icon;
655			switch(itemParams.iconType) {
656				case 'svg' :
657					icon = itemParams.icon;
658					break;
659				case 'css' :
660					icon = '<i class="mobilemenuck-icon ' + itemParams.icon + '"></i>'
661					break;
662				case 'image':
663				default :
664					var src = itemParams.icon.split('#')[0];
665					var width = itemParams.icon.match(/width=(\d+)/);
666					width = width && width[1] ? width[1] : '';
667					var height = itemParams.icon.match(/height=(\d+)/);
668					height = height && height[1] ? height[1] : '';
669					icon = '<img class="mobilemenuck-icon" src="' + opts.uriroot + '/' + src + '" width="' + width + '" height="' + height + '" />';
670					break;
671			}
672
673			return icon;
674		}
675
676		t.getTextFromParams = function(itemParams) {
677			return itemParams.text;
678		}
679
680		t.storeLockedState = function() {
681			if (opts.lock_button !== '1' && opts.lock_forced !== '1') return;
682			let opened = $.map(t.mobilemenu.find('.mobilemenuck-submenu'), function(n, i) {
683				return $(n).hasClass('ckopen') || $(n).prev().hasClass('open');
684			});
685			sessionStorage.setItem('mobilemenuck-state', opened);
686		}
687
688		t.setDataLevelRecursive = function(menu, level) {
689			$('> ' + opts.childselector, menu).each(function() {
690				var $li = $(this);
691				if (! $li.attr('data-level')) $li.attr('data-level', level).addClass('level' + level);
692				if ($li.find(opts.menuselector).length) t.setDataLevelRecursive($li.find(opts.menuselector), level 
692+ 1);
693			});
694		}
695
696		t.accordionOpen = function(item) {
697			if (opts.accordion_use_effects == '1') {
698				item.slideDown('fast');
699			} else {
700				item.css('display', 'block');
701			}
702		}
703
704		t.accordionClose = function(item) {
705			if (opts.accordion_use_effects == '1') {
706				item.slideUp('fast');
707			} else {
708				item.css('display', 'none');
709			}
710		}
711
712		t.setAccordion = function() {
713			if (opts.merge) {
714				t.mobilemenu = $('#' + opts.merge + '-mobile');
715			}
716			// mobilemenu = $('#' + opts.menuid + '-mobile');
717			$('.mobilemenuck-submenu', t.mobilemenu).hide();
718			$('.mobilemenuck-submenu', t.mobilemenu).each(function(i, submenu) {
719				submenu = $(submenu);
720				var itemparent = submenu.prev('.menuck');
721				if ($('+ .mobilemenuck-submenu > div.mobilemenuck-item', itemparent).length)
722					$(itemparent).append('<div class="mobilemenuck-togglericon" role="button" tabindex="0" aria-label="' + Joomla.Text._('PLG_MOBILEMENUCK_TOGGLER_ICON_LABEL') + '" />');
723			});
724			$('.mobilemenuck-togglericon', t.mobilemenu).on('click keypress', function(event) {
725				if (event.type === 'click' || (event.type === 'keypress' && event.keyCode === 13)) {
726					var itemparentsubmenu = $(this).parent().next('.mobilemenuck-submenu');
727					if (itemparentsubmenu.css('display') == 'none') {
728						if (opts.accordion_toggle == '1') {
729							if ($(this).parent().hasClass('level1')) {
730								t.accordionClose($('.mobilemenuck-submenu'));
731								$('.mobilemenuck-togglericon').parent().removeClass('open');
732							} else {
733								$($(this).parents('.mobilemenuck-submenu')[0]).find('.mobilemenuck-submenu').slideUp();
734								t.accordionClose($($(this).parents('.mobilemenuck-submenu')[0]).find('.mobilemenuck-submenu'));
735								$($(this).parents('.mobilemenuck-submenu')[0]).find('.mobilemenuck-togglericon').parent().removeClass('open');
736							}
737							t.accordionOpen(itemparentsubmenu);
738						} else {
739							t.accordionOpen(itemparentsubmenu);
740						}
741						$(this).parent().addClass('open');
742					} else {
743						t.accordionClose(itemparentsubmenu);
744						$(this).parent().removeClass('open');
745					}
746					t.storeLockedState();
747				}
748			});
749			// open the submenu on the active item
750			if (opts.openedonactiveitem == '1') {
751				$('.mobilemenuck-item > .active:not(.current) > .mobilemenuck-togglericon', t.mobilemenu).trigger('click');
752			}
753		}
754
755		t.setFlyout = function() {
756			if (opts.merge) {
757				t.mobilemenu = $('#' + opts.merge + '-mobile');
758			}
759			// mobilemenu = $('#' + opts.menuid + '-mobile');
760			$('.mobilemenuck-submenu', t.mobilemenu).hide();
761			$('.level1 + .mobilemenuck-submenu', t.mobilemenu)
762				.css('width', opts.menuwidth);
763//				.css('left', opts.menuwidth + 'px')
764			$('.level2 + .mobilemenuck-submenu', t.mobilemenu)
765				.css('width', opts.menuwidth);
766			$('.mobilemenuck-submenu', t.mobilemenu).each(function(i, submenu) {
767				submenu = $(submenu);
768				var itemparent = submenu.prev('.menuck');
769				if ($('+ .mobilemenuck-submenu > div.mobilemenuck-item', itemparent).length)
770					$(itemparent).append('<div class="mobilemenuck-togglericon" role="button" tabindex="0" aria-label="' + Joomla.Text._('PLG_MOBILEMENUCK_TOGGLER_ICON_LABEL') + '" />');
771			});
772			$('.level1 > .mobilemenuck-togglericon', t.mobilemenu).on('click keypress', function(event) {
773				if (event.type === 'click' || (event.type === 'keypress' && event.keyCode === 13)) {
774					$('.level1 + .mobilemenuck-submenu', t.mobilemenu).prev().removeClass('open');
775					var itemparentsubmenu = $(this).parent().next('.mobilemenuck-submenu');
776					$('.mobilemenuck-submenu', t.mobilemenu).not(itemparentsubmenu).hide();
777					if (itemparentsubmenu.css('display') == 'none') {
778						itemparentsubmenu.css('display', 'block');
779						$(this).parent().addClass('open');
780					} else {
781						itemparentsubmenu.css('display', 'none');
782						$(this).parent().removeClass('open');
783					}
784					t.storeLockedState();
785				}
786			});
787			$('.level2 > .mobilemenuck-togglericon', t.mobilemenu).on('click keypress', function(event) {
788				if (event.type === 'click' || (event.type === 'keypress' && event.keyCode === 13)) {
789					$('.level2 + .mobilemenuck-submenu', t.mobilemenu).prev().removeClass('open');
790					var itemparentsubmenu = $(this).parent().next('.mobilemenuck-submenu');
791					$('.level2 + .mobilemenuck-submenu', t.mobilemenu).not(itemparentsubmenu).hide();
792					if (itemparentsubmenu.css('display') == 'none') {
793						itemparentsubmenu.css('display', 'block');
794						$(this).parent().addClass('open');
795					} else {
796						itemparentsubmenu.css('display', 'none');
797						$(this).parent().removeClass('open');
798					}
799					t.storeLockedState();
800				}
801			});
802			$('.level3 .mobilemenuck-togglericon', t.mobilemenu).on('click keypress', function(event) {
803				if (event.type === 'click' || (event.type === 'keypress' && event.keyCode === 13)) {
804					var itemparentsubmenu = $(this).parent().next('.mobilemenuck-submenu');
805					// $('.level 2 .mobilemenuck-submenu', t.mobilemenu).not(itemparentsubmenu).hide();
806					if (itemparentsubmenu.css('display') == 'none') {
807						itemparentsubmenu.css('display', 'block');
808						$(this).parent().addClass('open');
809					} else {
810						itemparentsubmenu.css('display', 'none');
811						$(this).parent().removeClass('open');
812					}
813					t.storeLockedState();
814				}
815			});
816			// open the submenu on the active item
817			if (opts.openedonactiveitem == '1') {
818				$('.maximenuck.active:not(.current) > .mobilemenuck-togglericon', t.mobilemenu).trigger('click');
819			}
820		}
821
822		t.setFade = function() {
823			if (opts.merge) {
824				t.mobilemenu = $('#' + opts.merge + '-mobile');
825			}
826			if (! $('.mobilemenuck-backbutton', t.mobilemenu).length) {
827				var backicon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M41.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 256 246.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"/></svg>';
828				$('.mobilemenuck-topbar', t.mobilemenu).prepend('<div class="mobilemenuck-title mobilemenuck-backbutton" role="button" tabindex="0">'+backicon+opts.mobilebackbuttontext+'</div>');
829			}
830			$('.mobilemenuck-backbutton', t.mobilemenu).hide();
831			$('.mobilemenuck-submenu', t.mobilemenu).hide();
832			$('.mobilemenuck-submenu', t.mobilemenu).each(function(i, submenu) {
833				submenu = $(submenu);
834				itemparent = submenu.prev('.menuck');
835				if ($('+ .mobilemenuck-submenu > div.mobilemenuck-item', itemparent).length)
836					$(itemparent).append('<div class="mobilemenuck-togglericon" role="button" tabindex="0" aria-label="' + Joomla.Text._('PLG_MOBILEMENUCK_TOGGLER_ICON_LABEL') + '" />');
837			});
838			$('.mobilemenuck-togglericon', t.mobilemenu).on('click keypress', function(event) {
839				if (event.type === 'click' || (event.type === 'keypress' && event.keyCode === 13)) {
840					itemparentsubmenu = $(this).parent().next('.mobilemenuck-submenu');
841					parentitem = $(this).parents('.mobilemenuck-item')[0];
842					var parentText = $(parentitem).find('> div:first-child > * .mobilemenuck-item-text').text();
843					$('.ckopen', parentitem).removeClass('ckopen').hide();
844					$(itemparentsubmenu).addClass('ckopen');
845					$('.mobilemenuck-backbutton', t.mobilemenu).fadeIn();
846					$('.mobilemenuck-backbutton + .mobilemenuck-title').text(parentText)
847					// $('.mobilemenuck-title:not(.mobilemenuck-backbutton)', t.mobilemenu).hide();
848					// hides the current level items and displays the submenus
849					$(parentitem).parent().find('> .mobilemenuck-item > div.menuck').fadeOut(function() {
850						$('.ckopen', t.mobilemenu).fadeIn();
851					});
852					t.storeLockedState();
853				}
854			});
855			if (! opts.merge) {
856			$('.mobilemenuck-topbar .mobilemenuck-backbutton', t.mobilemenu).on('click keypress', function(event) {
857				if (event.type === 'click' || (event.type === 'keypress' && event.keyCode === 13)) {
858					backbutton = this;
859					let lastckopen = $('.ckopen', t.mobilemenu).last();
860					lastckopen.fadeOut(500, function() {
861						lastckopen.parent().parent().find('> .mobilemenuck-item > div.menuck').fadeIn();
862						oldopensubmenu = lastckopen;
863						if (! lastckopen.parents('.mobilemenuck-submenu').length) {
864							lastckopen.removeClass('ckopen');
865							$('.mobilemenuck-backbutton + .mobilemenuck-title').text(opts.mobilemenutext)
866							$('.mobilemenuck-title', t.mobilemenu).fadeIn();
867							$(backbutton).hide();
868						} else {
869							lastckopen.removeClass('ckopen');
870							$(oldopensubmenu.parents('.mobilemenuck-submenu')[0]).addClass('ckopen');
871						}
872						t.storeLockedState();
873					});
874				}
875			});
876			}
877			// open the submenu on the active item
878			if (opts.openedonactiveitem == '1') {
879				$('.maximenuck.active:not(.current) > .mobilemenuck-togglericon', t.mobilemenu).trigger('click');
880			}
881		}
882
883		t.setPush = function() {
884			if (opts.merge) {
885				mobilemenu = $('#' + opts.merge + '-mobile');
886			} else {
887				mobilemenu = $('#' + opts.menuid + '-mobile');
888			}
889			mobilemenu.css('height', '100%');
890			if (! $('.mobilemenuck-backbutton', mobilemenu).length) {
891				var backicon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M41.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 256 246.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"/></svg>';
892				$('.mobilemenuck-topbar', mobilemenu).prepend('<div class="mobilemenuck-title mobilemenuck-backbutton" role="button" tabindex="0">'+backicon+opts.mobilebackbuttontext+'</div>');
893			}
894			$('.mobilemenuck-backbutton', mobilemenu).hide();
895			$('.mobilemenuck-submenu', mobilemenu).hide();
896			// $('div.mobilemenuck-item', mobilemenu).css('position', 'relative');
897			mobilemenu.append('<div class="mobilemenuck-itemwrap" />');
898			$('.mobilemenuck-itemwrap', mobilemenu).css('position', 'absolute').width('100%');
899			$('> div.mobilemenuck-item', mobilemenu).each(function(i, item) {
900				$('.mobilemenuck-itemwrap', mobilemenu).append(item);
901			});
902			zindex = 10;
903			$('.mobilemenuck-submenu', mobilemenu).each(function(i, submenu) {
904				submenu = $(submenu);
905				itemparent = submenu.prev('.menuck');
906				submenu.css('left', '100%' ).css('width', '100%' ).css('top', '0' ).css('position', 'absolute').css('z-index', zindex);
907				if ($('+ .mobilemenuck-submenu > div.mobilemenuck-item', itemparent).length)
908					$(itemparent).append('<div class="mobilemenuck-togglericon" role="button" tabindex="0" aria-label="' + Joomla.Text._('PLG_MOBILEMENUCK_TOGGLER_ICON_LABEL') + '" />');
909				zindex++;
910			});
911			$('.mobilemenuck-togglericon', mobilemenu).on('click keypress', function(event) {
912				if (event.type === 'click' || (event.type === 'keypress' && event.keyCode === 13)) {
913					itemparentsubmenu = $(this).parent().next('.mobilemenuck-submenu');
914					parentitem = $(this).parents('.mobilemenuck-item')[0];
915					var parentText = $(parentitem).find('> div:first-child > * .mobilemenuck-item-text').text();
916					var level = $(parentitem).attr('data-level');
917					$(parentitem).parent().find('.mobilemenuck-submenu').hide();
918					$('.ckopen', mobilemenu).removeClass('ckopen');
919					$(itemparentsubmenu).addClass('ckopen');
920					$('.mobilemenuck-backbutton', mobilemenu).fadeIn();
921	//				$('.mobilemenuck-backbutton').after('<div class="mobilemenuck-backbutton-parent-title">' + parentText + '</div>')
922					$('.mobilemenuck-backbutton + .mobilemenuck-title').text(parentText)
923	//				$('.mobilemenuck-title:not(.mobilemenuck-backbutton)', mobilemenu).hide();
924					$('.ckopen', mobilemenu).fadeIn();
925					$('.mobilemenuck-itemwrap', mobilemenu).animate({'left': '-' + (level * 100) + '%' });
926					// go to top for submenu to avoid them to be hidden
927
928					if (opts.container === 'body') {
929						window.scrollTo({top: 0, behavior: "smooth"});
930					} else {
931						mobilemenu.animate({ scrollTop: 0 }, "fast");
932					}
933					t.storeLockedState();
934				}
935			});
936			if (! opts.merge) {
937				$('.mobilemenuck-topbar .mobilemenuck-backbutton', mobilemenu).on('click keypress', function(event) {
938					if (event.type === 'click' || (event.type === 'keypress' && event.keyCode === 13)) {
939						backbutton = this;
940						var leftpos = parseInt($('.mobilemenuck-itemwrap', mobilemenu).get(0).style.left);
941						$('.mobilemenuck-itemwrap', mobilemenu).animate({'left':  (leftpos+100) + '%'});
942						// $('.mobilemenuck-itemwrap', mobilemenu).animate({'left':  '+=100%'});
943						// $('.ckopen', mobilemenu).fadeOut(500, function() {
944							// $('.ckopen', mobilemenu).parent().parent().find('> .mobilemenuck-item > div.menuck').fadeIn();
945						oldopensubmenu = $('.ckopen', mobilemenu);
946						var parentitem = oldopensubmenu.parent().parent().prev();
947						var parentText = parentitem.find('> *:first-child .mobilemenuck-item-text').text();
948						if (! $('.ckopen', mobilemenu).parents('.mobilemenuck-submenu').length) {
949							$('.ckopen', mobilemenu).removeClass('ckopen').hide();
950							$('.mobilemenuck-backbutton + .mobilemenuck-title').text(opts.mobilemenutext)
951							$('.mobilemenuck-title', mobilemenu).fadeIn();
952							$(backbutton).hide();
953						} else {
954							$('.ckopen', mobilemenu).removeClass('ckopen').hide();
955							$(oldopensubmenu.parents('.mobilemenuck-submenu')[0]).addClass('ckopen');
956							$('.mobilemenuck-backbutton + .mobilemenuck-title').text(parentText)
957						}
958						t.storeLockedState();
959						// });
960					}
961				});
962			}
963			// open the submenu on the active item
964			if (opts.openedonactiveitem == '1') {
965				$('.maximenuck.active:not(.current) > .mobilemenuck-togglericon', t.mobilemenu).trigger('click');
966			}
967		}
968
969		t.resetFademenu = function() {
970			$('.mobilemenuck-submenu', t.mobilemenu).hide();
971			$('.mobilemenuck-item > div.menuck').show().removeClass('open');
972			$('.mobilemenuck-topbar .mobilemenuck-title').show();
973			$('.mobilemenuck-topbar .mobilemenuck-title.mobilemenuck-backbutton').hide();
974		}
975
976		t.resetPushmenu = function() {
977			$('.mobilemenuck-submenu', t.mobilemenu).hide();
978			$('.mobilemenuck-itemwrap', t.mobilemenu).css('left', '0');
979			$('.mobilemenuck-topbar .mobilemenuck-title:not(.mobilemenuck-backbutton)').show();
980			$('.mobilemenuck-topbar .mobilemenuck-title.mobilemenuck-backbutton').hide();
981		}
982
983		t.resetFlyout = function() {
984			$('.mobilemenuck-submenu', t.mobilemenu).hide();
985			$('.mobilemenuck-item > div.menuck').show().removeClass('open');
986			$('.mobilemenuck-topbar .mobilemenuck-title').show();
987			$('.mobilemenuck-topbar .mobilemenuck-title.mobilemenuck-backbutton').hide();
988		}
989
990		t.updatelevel = function() {
991			$('div.maximenuck_mod', t.menu).each(function(i, module) {
992				module = $(module);
993				liparentlevel = module.parent('li.maximenuckmodule').attr('data-level');
994				$('li.maximenuck', module).each(function(j, li) {
995					li = $(li);
996					lilevel = parseInt(li.attr('data-level')) + parseInt(liparentlevel) - 1;
997					li.attr('data-level', lilevel).addClass('level' + lilevel);
998				});
999			});
1000		}
1001
1002		t.validateitem = function(itemtmp) {
1003			if (t.menutype == 'maximenuck') {
1004				return t.validateitemMaximenuck(itemtmp);
1005			} else if (t.menutype == 'accordeonck') {
1006				return t.validateitemAccordeonck(itemtmp);
1007			} else {
1008				return t.validateitemNormal(itemtmp);
1009			}
1010		}
1011
1012		t.validateitemNormal = function(itemtmp) {
1013			if (!itemtmp || $(itemtmp).hasClass('nomobileck') || $(itemtmp).hasClass('mobilemenuck-hide'))
1014				return false;
1015
1016			if ($('> a', itemtmp).length)
1017				return $('> a', itemtmp).clone();
1018			if ($('> span.separator,> span.nav-header', itemtmp).length)
1019				return $('> span.separator,> span.nav-header', itemtmp).clone();
1020			if ($('> button', itemtmp).length) // used for collabsible layout in Cassiopeia
1021				return $('> button', itemtmp).clone();
1022
1023			return false;
1024		}
1025
1026		t.validateitemMaximenuck = function(itemtmp) {
1027			if (!itemtmp || $(itemtmp).hasClass('nomobileck') || $(itemtmp).hasClass('mobilemenuck-hide'))
1028				return false;
1029			if ($('> * > img', itemtmp).length && opts.useimages == '0' && !$('> * > span.titreck', itemtmp).length) {
1030				return false
1031			}
1032			if ($('> a.maximenuck', itemtmp).length)
1033				return $('> a.maximenuck', itemtmp).clone();
1034			if ($('> span.separator,> span.nav-header', itemtmp).length)
1035				return $('> span.separator,> span.nav-header', itemtmp).clone();
1036			if ($('> * > a.maximenuck', itemtmp).length)
1037				return $('> * > a.maximenuck', itemtmp).clone();
1038			if ($('> * > span.separator,> * > span.nav-header', itemtmp).length)
1039				return $('> * > span.separator,> * >  span.nav-header', itemtmp).clone();
1040			if ($('> div.maximenuck_mod', itemtmp).length && opts.usemodules == '1')
1041				return $('> div.maximenuck_mod', itemtmp).clone();
1042
1043			return false;
1044		}
1045
1046		t.validateitemAccordeonck = function(itemtmp) {
1047			if (!itemtmp || $(itemtmp).hasClass('nomobileck') || $(itemtmp).hasClass('mobilemenuck-hide'))
1048				return false;
1049			var outer = $('> .accordeonck_outer', itemtmp).length ? $('> .accordeonck_outer', itemtmp) : itemtmp;
1050			if (($('> div.accordeonmenuck_mod', itemtmp).length && opts.usemodules == '1')
1051			) {
1052				return $('> div.accordeonmenuck_mod', itemtmp).clone();
1053			}
1054			if (($('> a', outer).length || $('> span.separator', outer).length)
1055						&& ($('> a', outer).length || $('> span.separator', outer).length || opts.useimages == '1')
1056						|| ($('> div.accordeonckmod', outer).length && opts.usemodules == '1')
1057						|| ($('> div.accordeonmenuck_mod', outer).length && opts.usemodules == '1')
1058						|| ($('> .accordeonck_outer', outer).length)
1059						|| ($('> .accordeonmenuck_outer', outer).length)
1060						) {
1061				return $('> a', outer).length ? $('> a', outer).clone() : $('> span.separator', outer).clone();
1062			}
1063
1064			return false;
1065		}
1066
1067		t.strRepeat = function(string, count) {
1068		var s = '';
1069			if (count < 1)
1070				return '';
1071			while (count > 0) {
1072				s += string;
1073				count--;
1074			}
1075			return s;
1076		}
1077
1078		t.sortmenu = function(menu) {
1079			var items = new Array();
1080			mainitems = $('ul.maximenuck > li.maximenuck.level1', menu);
1081			j = 0;
1082			mainitems.each(function(ii, mainitem) {
1083				items.push(mainitem);
1084				if ($(mainitem).hasClass('parent')) {
1085					subitemcontainer = $('.maxipushdownck > .floatck', menu).eq(j);
1086					subitems = $('li.maximenuck', subitemcontainer);
1087					subitems.each(function(k, subitem) {
1088						items.push(subitem);
1089					});
1090					j++;
1091				}
1092			});
1093			return items;
1094		}
1095
1096		t.initCss = function() {
1097			switch (opts.displayeffect) {
1098				case 'normal':
1099				default:
1100					t.mobilemenu.css({
1101						'position': 'absolute',
1102						'z-index': '100000',
1103						'top': '0',
1104						'left': '0',
1105						'display': 'none'
1106					});
1107					break;
1108				case 'slideleft':
1109				case 'slideleftover':
1110					t.mobilemenu.css({
1111						'position': 'fixed',
1112						'overflow-y': 'auto',
1113						'overflow-x': 'hidden',
1114						'z-index': '100000',
1115						'top': '0',
1116						'left': '-' + opts.menuwidth + 'px',
1117						'width': opts.menuwidth,
1118						'height': '100%',
1119						'display': 'none'
1120					});
1121					break;
1122				case 'slideright':
1123				case 'sliderightover':
1124					t.mobilemenu.css({
1125						'position': 'fixed',
1126						'overflow-y': 'auto',
1127						'overflow-x': 'hidden',
1128						'z-index': '100000',
1129						'top': '0',
1130						'right': '-' + opts.menuwidth + 'px',
1131						'left': 'auto',
1132						'width': opts.menuwidth,
1133						'height': '100%',
1134						'display': 'none'
1135					});
1136					break;
1137				case 'topfixed':
1138					t.mobilemenu.css({
1139						'position': 'fixed',
1140						'overflow-y': 'scroll',
1141						'z-index': '100000',
1142						'top': '0',
1143						'right': '0',
1144						'left': '0',
1145						'max-height': '100%',
1146						'display': 'none'
1147					});
1148					break;
1149			}
1150		}
1151
1152		t.toggleMenu = function() {
1153			if (t.mobilemenu.css('display') == 'block') {
1154				t.closeMenu();
1155				sessionStorage.setItem('mobilemenuck-lock-hide', '1')
1156			} else {
1157				t.openMenu();
1158				sessionStorage.setItem('mobilemenuck-lock-hide', '0')
1159			}
1160		}
1161
1162		t.openMenu = function() {
1163			// mobilemenu = $('#' + menuid + '-mobile');
1164//				mobilemenu.show();
1165			if (opts.overlay === '1' && ! $('#mobilemenuck-overlay').length) {
1166				t.mobilemenu.after('<div class="mobilemenuck-overlay" data-id="' + t.mobilemenuid + '"></div>');
1167			}
1168			switch (opts.displayeffect) {
1169				case 'normal':
1170				default:
1171					t.mobilemenu.fadeOut();
1172					$('#' + opts.menuid + '-mobile').fadeIn();
1173					if (opts.container != 'body')
1174						t.mobilemenubar.css('display', 'none');
1175					break;
1176				case 'slideleft':
1177				case 'slideleftover':
1178					t.mobilemenu.css('display', 'block').css('opacity', '0').css('left', '-' + opts.menuwidth + 'px').animate({'opacity': '1', 'left': '0'});
1179					if (opts.displayeffect =='slideleft')$('body').css('position', 'relative').animate({'left': opts.menuwidth});
1180					break;
1181				case 'slideright':
1182				case 'sliderightover':
1183					t.mobilemenu.css('display', 'block').css('opacity', '0').css('right', '-' + opts.menuwidth + 'px').animate({'opacity': '1', 'right': '0'});
1184					if (opts.displayeffect =='slideright') $('body').css('position', 'relative').animate({'right': opts.menuwidth});
1185					break;
1186				case 'open':
1187					// mobilemenu..slideDown();
1188					$('#' + opts.menuid + '-mobile').slideDown('slow');
1189					if (opts.container != 'body')
1190						t.mobilemenubar.css('display', 'none');
1191					break;
1192			}
1193			t.mobilemenu.find('.mobilemenuck-button').focus();
1194			$(document).trigger('mobilemenuck_open');
1195		}
1196
1197		t.closeMenu = function(menuid) {
1198			$('.mobilemenuck-overlay[data-id="' + t.mobilemenuid + '"]').remove();
1199			sessionStorage.setItem('mobilemenuck-lock-hide', '1');
1200			if (opts.displaytype == 'fade') {
1201				t.resetFademenu();
1202			}
1203			if (opts.displaytype == 'push') {
1204				t.resetPushmenu();
1205			}
1206			if (opts.displaytype == 'flyout') {
1207				t.resetFlyout();
1208			}
1209			// mobilemenu = $('#' + menuid + '-mobile');
1210			switch (opts.displayeffect) {
1211				case 'normal':
1212				default:
1213					t.mobilemenu.fadeOut();
1214					if (opts.container != 'body')
1215						t.mobilemenubar.css('display', '');
1216					break;
1217				case 'slideleft':
1218					t.mobilemenu.animate({'opacity': '0', 'left': '-' + opts.menuwidth + 'px'}, function() {
1219						t.mobilemenu.css('display', 'none');
1220					});
1221					$('body').animate({'left': '0'}, function() {
1222						$('body').css('position', '')
1223					});
1224					break;
1225				case 'slideright':
1226					t.mobilemenu.animate({'opacity': '0', 'right': '-' + opts.menuwidth + 'px'}, function() {
1227						t.mobilemenu.css('display', 'none');
1228					});
1229					$('body').animate({'right': '0'}, function() {
1230						$('body').css('position', '')
1231					});
1232					break;
1233				case 'slideleftover':
1234					t.mobilemenu.animate({'opacity': '0', 'left': '-' + opts.menuwidth + 'px'}, function() {
1235						t.mobilemenu.css('display', 'none');
1236					});
1237					break;
1238				case 'sliderightover':
1239					t.mobilemenu.animate({'opacity': '0', 'right': '-' + opts.menuwidth + 'px'}, function() {
1240						t.mobilemenu.css('display', 'none');
1241					});
1242					break;
1243				case 'open':
1244					t.mobilemenu.slideUp('slow', function() {
1245						if (opts.container != 'body')
1246							t.mobilemenubar.css('display', '');
1247					});
1248					
1249					break;
1250			}
1251//			t.mobilemenubar.find('.mobilemenuck-bar-button').focus();
1252			$(document).trigger('mobilemenuck_close');
1253		}
1254
1255		t.getSvg = function(icon) {
1256			switch(icon) {
1257				case 'lock':
1258					return '<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M400 224h-24v-72C376 68.2 307.8 0 224 0S72 68.2 72 152v72H48c-26.5 0-48 21.5-48 48v192c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V272c0-26.5-21.5-48-48-48zm-104 0H152v-72c0-39.7 32.3-72 72-72s72 32.3 72 72v72z"></path></svg>';
1259					break;
1260				case 'unlock':
1261					return '<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M400 256H152V152.9c0-39.6 31.7-72.5 71.3-72.9 40-.4 72.7 32.1 72.7 72v16c0 13.3 10.7 24 24 24h32c13.3 0 24-10.7 24-24v-16C376 68 307.5-.3 223.5 0 139.5.3 72 69.5 72 153.5V256H48c-26.5 0-48 21.5-48 48v160c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V304c0-26.5-21.5-48-48-48z"></path></svg>';
1262					break;
1263			}
1264			return '';
1265		}
1266
1267		t.getHiddenDimensions = function(el) {
1268			let cloned = el.clone();
1269			$(document.body).append(cloned);
1270			cloned.css('visibility', 'hidden').show();
1271
1272			let dim = {width : cloned.width(), height : cloned.height()};
1273			cloned.remove();
1274
1275			return dim;
1276		}
1277
1278		t.init();
1279		t.mobilemenu.attr('data-display', opts.displaytype);
1280		t.mobilemenu.attr('data-effect', opts.displayeffect);
1281
1282		if (opts.displaytype == 'accordion')
1283			t.setAccordion();
1284		if (opts.displaytype == 'fade')
1285			t.setFade();
1286		if (opts.displaytype == 'push')
1287			t.setPush();
1288		if (opts.displaytype == 'flyout')
1289			t.setFlyout();
1290
1291		// set locked state
1292		if (sessionStorage.getItem('mobilemenuck-lock') == '1' && sessionStorage.getItem('mobilemenuck-lock-hide') !== '1') {
1293			t.openMenu();
1294			if (! sessionStorage.getItem('mobilemenuck-state')) return; // if there is no data stored
1295			let opened = sessionStorage.getItem('mobilemenuck-state').split(',');
1296			for (var i=0; i<opened.length; i++) {
1297				if (opened[i] == "true") {
1298					t.mobilemenu.find('.mobilemenuck-submenu').eq(i).parent('.mobilemenuck-item').find('> div > .mobilemenuck-togglericon').trigger('click');
1299				}
1300			}
1301		}
1302
1303		// custom target from any link
1304		$('[href*="mobilemenuck["]').each(function() {
1305			$(this).on('click', function(e) {
1306				var matches = this.href.match(/\[(.*?)\]/);
1307				if (matches[1]) {
1308					var href = $(this).attr('href');
1309					// stop propagation to other events like close on outside click
1310					e.preventDefault();
1311					// search for the menu item in the mobile menu and open its submenu
1312					if (! t.mobilemenu.find('a[href="' + href + '"]').parent().hasClass('open')
1313						&& ! t.mobilemenu.find('a[href="' + href + '"]').parent().find('+ .mobilemenuck-submenu').hasClass('ckopen')) {
1314						t.mobilemenu.find('a[href="' + href + '"] + .mobilemenuck-togglericon').trigger('click');
1315					}
1316					// show the menu after a short delay to let the submenus to be opened before
1317					if (t.mobilemenu.css('display') == 'none') {
1318						setTimeout(function() {
1319							t.openMenu();
1320						}, 200);
1321					}
1322					return false; // disable the click event feature
1323				}
1324			});
1325		});
1326
1327		if (t.mobilemenu.find('.mod-login button.input-password-toggle').length) {
1328			modLoginScript(t.mobilemenu.get(0));
1329		}
1330	}
1331	window.MobileMenuCK = MobileMenuCK;
1332
1333	// script extracted from the Joomla core, but there is no function to call it directly
1334	let modLoginScript = function(mobilemenu) {
1335		// manage the show password button
1336		[].slice.call(mobilemenu.querySelectorAll('input[type="password"]')).forEach(input => {
1337		  const toggleButton = input.parentNode.querySelector('.input-password-toggle');
1338		  input.setAttribute('data-type', input.type);
1339		  if (toggleButton) {
1340			toggleButton.addEventListener('click', () => {
1341			  const icon = toggleButton.firstElementChild;
1342			  const srText = toggleButton.lastElementChild;
1343			  if (input.type === 'password' && input.type === input.getAttribute('data-type')) {
1344				// Update the icon class
1345				icon.classList.remove('icon-eye');
1346				icon.classList.add('icon-eye-slash');
1347
1348				// Update the input type
1349				input.type = 'text';
1350
1351				// Focus the input field
1352				input.focus();
1353
1354				// Update the text for screenreaders
1355				srText.innerText = Joomla.Text._('JHIDEPASSWORD');
1356				input.setAttribute('data-type', 'text');
1357			  } else if (input.type === 'text' && input.type === input.getAttribute('data-type')) {
1358				// Update the icon class
1359				icon.classList.add('icon-eye');
1360				icon.classList.remove('icon-eye-slash');
1361
1362				// Update the input type
1363				input.type = 'password';
1364
1365				// Focus the input field
1366				input.focus();
1367
1368				// Update the text for screenreaders
1369				srText.innerText = Joomla.Text._('JSHOWPASSWORD');
1370				input.setAttribute('data-type', 'password');
1371			  } else {
1372				  input.setAttribute('data-type', input.type);
1373			  }
1374			});
1375		  }
1376		  const modifyButton = input.parentNode.querySelector('.input-password-modify');
1377		  if (modifyButton) {
1378			modifyButton.addEventListener('click', () => {
1379			  const lock = !modifyButton.classList.contains('locked');
1380			  if (lock === true) {
1381				// Add lock
1382				modifyButton.classList.add('locked');
1383
1384				// Reset value to empty string
1385				input.value = '';
1386
1387				// Disable the field
1388				input.setAttribute('disabled', '');
1389
1390				// Update the text
1391				modifyButton.innerText = Joomla.Text._('JMODIFY');
1392			  } else {
1393				// Remove lock
1394				modifyButton.classList.remove('locked');
1395
1396				// Enable the field
1397				input.removeAttribute('disabled');
1398
1399				// Focus the input field
1400				input.focus();
1401
1402				// Update the text
1403				modifyButton.innerText = Joomla.Text._('JCANCEL');
1404			  }
1405			});
1406		  }
1407		});
1408
1409		// additional script to manage the duplicate ids
1410		let loginModules = mobilemenu.querySelectorAll('form.mod-login');
1411		loginModules.forEach(function(mod) {
1412			mod.id = mod.id + '-' + mobilemenu.id;
1413			let ids = mod.querySelectorAll('[id]');
1414			ids.forEach(function(el) {
1415				el.id = el.id + '-' + mobilemenu.id;
1416			});
1417		});
1418	}
1419})(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.