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