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