PageSourceSearch

https://perspective.brussels/_integration/assets/js/script-menu.js?v=2026100405119

js perspective.brussels collected 2026-10-03 22:59:23 UTC 22,765 bytes, 601 lines download raw bytes

1window.onresize = init;
2window.onload = init;
3init;
4
5// Mediaqueries
6
7function init() {
8    console.log('fenêtre redimensionnée');
9        if (window.matchMedia("(max-width:991px)").matches) {
10            // $(".language-switcher-locale-url").appendTo("#primary-nav");
11            $(".nav--menu-block-13 > li > a.is-active-trail").removeClass("maintainHover").next().css({
12              "display": "none",
13            });;
14
15        }
16
17        else {
18                // $(".language-switcher-locale-url").appendTo(".breadcrumb .region-utility");
19                $(".nav--menu-block-13 > li > a.is-active-trail").addClass("maintainHover").next().css({
20                  "display": "flex",
21                });;
22            }
23
24            if (window.matchMedia("(max-width:808px)").matches) {
25              $('#block-views-exp-recherche-perspective-page').insertBefore('.cd-main-header');
26                $('.secondary-navigation .nav--menu-top-menu > li').addClass('secondary-li').appendTo('.nav--main-menu');
27				$('.nav--menu-eu2024be > li').addClass('eu24').addClass('secondary-li').appendTo('.nav--main-menu');
28            }  else {
29                    $('.secondary-li').appendTo('.secondary-navigation .nav--menu-top-menu');
30                    $('#block-views-exp-recherche-perspective-page').appendTo('.region-header');
31                }
32}
33
34
35// Block search toggle on mobile
36
37$('#search-toggle').on('click', function(e) {
38        $(this).toggleClass('is-open');
39        $("#block-views-exp-recherche-perspective-page").toggleClass('is-open');
40        $(".cd-main-header").toggleClass('search-is-open');
41        e.preventDefault();
42});
43
44
45
46
47// End Megamenu
48
49// Mega Menu Mobile
50jQuery(document).ready(function($){
51    //if you change this breakpoint in the style.css file (or _layout.scss if you use SASS), don't forget to update this value as well
52    var MqL = 808;
53    //move nav element position according to window width
54    moveNavigation();
55    $(window).on('resize', function(){
56        (!window.requestAnimationFrame) ? setTimeout(moveNavigation, 300) : window.requestAnimationFrame(moveNavigation);
57    });
58
59    //mobile - open lateral menu clicking on the menu icon
60    $('.cd-nav-trigger').on('click', function(event){
61        event.preventDefault();
62        if( $('.cd-main-content').hasClass('nav-is-visible') ) {
63            closeNav();
64            $('.cd-overlay').removeClass('is-visible');
65        } else {
66            $(this).addClass('nav-is-visible');
67            $('.cd-primary-nav').addClass('nav-is-visible');
68            $('.cd-main-header').addClass('nav-is-visible');
69            $('.cd-main-content').addClass('nav-is-visible').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
70                $('body').addClass('overflow-hidden');
71            });
72            toggleSearch('close');
73            $('.cd-overlay').addClass('is-visible');
74        }
75    });
76
77    //open search form
78    $('.cd-search-trigger').on('click', function(event){
79        event.preventDefault();
80        toggleSearch();
81        closeNav();
82    });
83
84    //close lateral menu on mobile
85    $('.cd-overlay').on('swiperight', function(){
86        if($('.cd-primary-nav').hasClass('nav-is-visible')) {
87            closeNav();
88            $('.cd-overlay').removeClass('is-visible');
89        }
90    });
91    $('.nav-on-left .cd-overlay').on('swipeleft', function(){
92        if($('.cd-primary-nav').hasClass('nav-is-visible')) {
93            closeNav();
94            $('.cd-overlay').removeClass('is-visible');
95        }
96    });
97    $('.cd-overlay').on('click', function(){
98        closeNav();
99        toggleSearch('close')
100        $('.cd-overlay').removeClass('is-visible');
101    });
102
103
104    //prevent default clicking on direct children of .cd-primary-nav
105    $('.cd-primary-nav').children('.has-children-2').children('a').on('click', function(event){
106        if ($(window).width() < MqL) {
107        event.preventDefault();
108        }
109    });
110
111    // Add go back button
112
113    $('.has-children-2').each(function() {
114        var $mylocation = $(this).find(".cd-secondary-nav");
115        $(this).children('a').clone().prependTo($mylocation).wrap('<li class="see-all"></li>');
116    });
117
118
119
120
121    // $('.has-children-2 > a' ).each(function() {
122    //   $(this).clone().siblings('div').prependTo('.cd-secondary-nav').wrap('<li class="see-all"></li>');
123    // });
124
125    $('.cd-secondary-nav').prepend('<li class="go-back"><a href="#0">Menu</a></li>');
126
127    //open submenu
128    $('.has-children-2').children('a').on('click', function(event){
129        if( !checkWindowWidth() );
130        var selected = $(this);
131        if( selected.next('.menu-attach-block-wrapper').find('.cd-secondary-nav').hasClass('is-hidden') ) {
132            //desktop version only
133            selected.addClass('selected').next('.menu-attach-block-wrapper').find('.cd-secondary-nav').removeClass('is-hidden').end().closest('.cd-primary-nav').addClass('moves-out');
134            selected.parent('.has-children-2').siblings('.has-children-2').find('.cd-secondary-nav').addClass('is-hidden').end().children('a').removeClass('selected');
135            $('.cd-overlay').addClass('is-visible');
136        } else {
137            selected.removeClass('selected').next('.menu-attach-block-wrapper').find('.cd-secondary-nav').addClass('is-hidden').end().closest('.cd-primary-nav').removeClass('moves-out');
138            $('.cd-overlay').removeClass('is-visible');
139        }
140        toggleSearch('close');
141    });
142
143    //submenu items - go back link
144    $('.go-back').on('click', function(event){
145        $(this).closest('.cd-secondary-nav').addClass('is-hidden').closest('.cd-primary-nav').removeClass('moves-out');
146        event.preventDefault();
147    });
148
149    function closeNav() {
150        $('.cd-nav-trigger').removeClass('nav-is-visible');
151        $('.cd-main-header').removeClass('nav-is-visible');
152        $('.cd-primary-nav').removeClass('nav-is-visible');
153        $('.cd-secondary-nav').addClass('is-hidden');
154        $('.has-children-2 a').removeClass('selected');
155        $('.cd-overlay').removeClass('is-visible');
156        $('.moves-out').removeClass('moves-out');
157        $('.cd-main-content').removeClass('nav-is-visible').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
158            $('body').removeClass('overflow-hidden');
159        });
160    }
161
162    function toggleSearch(type) {
163        if(type=="close") {
164            //close serach
165            $("#block-views-exp-recherche-perspective-page").removeClass('is-open');
166            $('.cd-search').removeClass('is-visible');
167            $('.cd-search-trigger').removeClass('search-is-visible');
168            $('.cd-overlay').removeClass('search-is-visible');
169            $(".cd-main-header").removeClass('search-is-open');
170        } else {
171            //toggle search visibility
172            $("#block-views-exp-recherche-perspective-page").toggleClass('is-open');
173            $('.cd-search').toggleClass('is-visible');
174            $('.cd-search-trigger').toggleClass('search-is-visible');
175            $('.cd-overlay').toggleClass('search-is-visible');
176            $(".cd-main-header").toggleClass('search-is-open');
177            if($(window).width() > MqL && $('.cd-search').hasClass('is-visible')) $('.cd-search').find('input[type="search"]').focus();
178            ($('.cd-search').hasClass('is-visible')) ? $('.cd-overlay').addClass('is-visible') : $('.cd-overlay').removeClass('is-visible') ;
179        }
180    }
181
182    function checkWindowWidth() {
183        //check window width (scrollbar included)
184        var e = window,
185            a = 'inner';
186        if (!('innerWidth' in window )) {
187            a = 'client';
188            e = document.documentElement || document.body;
189        }
190        if ( e[ a+'Width' ] <= MqL ) {
191            return true;
192        } else {
193            return false;
194        }
195    }
196
197    function moveNavigation(){
198        var navigation = $('#primary-nav');
199        var desktop = checkWindowWidth();
200        if ( desktop ) {
201
202            // Vue mobile
203             closeNav();
204            navigation.detach();
205            navigation.insertAfter('.cd-main-content');
206            $(".language-switcher-locale-url").appendTo("#primary-nav .nav--main-menu").wrap('<div class="lg-wrapper"></div>');
207            $(".language-switcher-locale-url").appendTo("#primary-nav .nav--main-menu").wrap('<div class="lg-wrapper"></div>');
208
209
210
211        } else {
212
213            // vue desktop
214
215            closeNav();
216            navigation.detach();
217            navigation.appendTo('#block-menu-block-2');
218            $(".language-switcher-locale-url").appendTo(".breadcrumb .region-utility");
219
220            // Initialize Megamenu
221
222        if (jQuery) {
223            (function ($) {
224                'use strict';
225                $(document).ready(function () {
226                  $("#primary-nav").accessibleMegaMenu({
227
228                    /* prefix for generated unique id attributes, which are required
229                       to indicate aria-owns, aria-controls and aria-labelledby */
230                    uuidPrefix: 'accessible-megamenu',
231
232                    /* css class used to define the megamenu styling */
233                    menuClass: 'nav--main-menu',
234
235                    /* css class for a top-level navigation item in the megamenu */
236                    topNavItemClass: 'nav-item',
237
238                    /* css class for a megamenu panel */
239                    panelClass: 'menu-attach-block-wrapper',
240
241                    /* css class for a group of items within a megamenu panel */
242                    panelGroupClass: 'sub-nav-group',
243
244                    /* css class for the hover state */
245                    hoverClass: 'hover',
246
247                    /* css class for the focus state */
248                    focusClass: 'focus',
249
250                    /* css class for the open state */
251                    openClass: 'open'
252                });
253                });
254            }(jQuery));
255        }
256        }
257    }
258
259
260    //chosen
261
262    $(".actu-filters select").chosen({
263        disable_search_threshold: 20
264     });
265});
266
267
268
269// megamenu toggle overlay
270
271// Initialize Megamenu
272
273if (jQuery) {
274    (function ($) {
275        'use strict';
276
277        // Overlay menu mobile
278
279        $('.nav--menu-block-13 > li').each(function() {
280            var $cloneLi = $(this).children("ul");
281            $(this).children('a').clone().prependTo($cloneLi).wrap('<li class="see-all"></li>');
282        });
283
284        $('.nav--menu-block-13 > .nav__item.has-subnav > a').click(function(e) {
285
286
287            var $this = $(this);
288
289            if (window.matchMedia("(max-width:991px)").matches) {
290              if ($this.next().hasClass('show')) {
291                  $this.next().removeClass('show');
292                  $this.next().slideUp(350);
293                  $this.removeClass('is-open');
294                  $this.parent().removeClass('is-highlighted');
295              } else {
296                  $this.parent().parent().children('li.has-subnav').children('ul').removeClass('show');
297                  $this.parent().parent().children('li.has-subnav').children('ul').slideUp(350);
298                  $this.parent().parent().children('li.has-subnav').children("a").removeClass('is-open');
299                  $this.parent().parent().find('li').removeClass('is-highlighted');
300                  $this.toggleClass('is-open');
301                  $this.parent().toggleClass('is-highlighted');
302                  $this.next().toggleClass('show');
303                  $this.next().slideToggle(350);
304              }
305              return false;
306              e.preventDefault();
307          } else {
308            $this.next().removeClass('show');
309            $this.next().show();
310          }
311
312
313      });
314
315      // Init accesible menu
316
317        $('.nav--menu-block-13').setup_navigation();
318
319
320        // Init menu aim
321
322
323        var $menu = $(".nav--menu-block-13");
324
325        // jQuery-menu-aim: <meaningful part of the example>
326        // Hook up events to be fired on menu row activation.
327        $menu.menuAim({
328            activate: activateSubmenu,
329            deactivate: deactivateSubmenu
330        });
331        // jQuery-menu-aim: </meaningful part of the example>
332
333        // jQuery-menu-aim: the following JS is used to show and hide the submenu
334        // contents. Again, this can be done in any number of ways. jQuery-menu-aim
335        // doesn't care how you do this, it just fires the activate and deactivate
336        // events at the right times so you know when to show and hide your submenus.
337        function activateSubmenu(row) {
338          if (window.matchMedia("(min-width:992px)").matches) {
339            var $row = $(row),
340            $submenu = $row.children('ul');
341
342              // Keep the currently activated row's highlighted look
343              $row.find("a").addClass("maintainHover");
344              $submenu.css({
345                "display": "flex",
346              });
347
348              if ($row.hasClass("is-active-trail")) {
349                // Keep the currently activated row's highlighted look
350
351                $row.find("a").addClass("maintainHover");
352                $submenu.css({
353                  "display": "flex",
354                });
355              } else {
356                $row.find("a").addClass("maintainHover");
357                $submenu.css({
358                  "display": "flex",
359                });
360
361                $row.parent().children('li.is-active-trail').children('a').removeClass("maintainHover").next().css({
362                  "display": "none",
363                });;
364              }
365            }
366        }
367
368        function deactivateSubmenu(row) {
369          if (window.matchMedia("(min-width:992px)").matches) {
370            var $row = $(row),
371  		        $submenu = $row.children('ul');
372
373              // Hide the submenu and remove the row's highlighted look
374              $row.find("a").removeClass("maintainHover");
375
376
377              $submenu.css({
378                "display": "none",
379              });
380          }
381        }
382
383        // Bootstrap's dropdown menus immediately close on document click.
384        // Don't let this event close the menu if a submenu is being clicked.
385        // This event propagation control doesn't belong in the menu-aim plugin
386        // itself because the plugin is agnostic to bootstrap.
387        $(".nav--menu-block-13 li").click(function(e) {
388            e.stopPropagation();
389        });
390
391        // $(document).click(function() {
392        //     // Simply hide the submenu on any click. Again, this is just a hacked
393        //     // together menu/submenu structure to show the use of jQuery-menu-aim.
394
395        //     $("a.maintainHover").removeClass("maintainHover");
396        // });
397
398        $( ".nav--menu-block-13" ).mouseleave(function() {
399          if (window.matchMedia("(min-width:992px)").matches) {
400            $("a.maintainHover:not('is-active-trail')").removeClass("maintainHover");
401
402            $(".nav--menu-block-13 > li > a.is-active-trail").addClass("maintainHover").next().css({
403              "display": "flex",
404            });;
405          }
406        });
407
408        if ($('.nav--menu-block-13 > li > a.is-active-trail').length == 0) {
409          $('.nav--menu-block-13 > li:first-child').children('a').addClass("maintainHover").next().css({
410            "display": "flex",
411          });
412        }
413
414        // timeline
415		$('#timeline a[href$="be-ecole"]').click(function(e) {
416          return false;
417        });
418		$('#timeline a[href$="be-school"]').click(function(e) {
419          return false;
420        });
421        $('.nav--menu-timeline-toolbox > li > ul > li > a[href*=dummy]').click(function(e) {
422          $(this).closest('ul').prev().trigger( "click" );
423        });
424
425
426        $('.nav--menu-timeline-toolbox > li > ul > li > a').each(function(index) {
427            var $clone = $(this).text();
428            var $title = $(this).attr("title");
429            $(this).attr('data-tooltip', $clone).text(index + 1);
430            $(this).closest('li').attr('data-tooltip', $clone);
431            $(this).closest('li').attr('data-title', $title);
432        });
433
434        $('.nav--menu-timeline-toolbox > li > ul > li > ul > li > a').each(function(index) {
435            var $clone = $(this).text();
436            $(this).attr('data-tooltip', $clone).text(index + 1);
437        });
438
439        $( ".nav--menu-timeline-toolbox > li > ul > li > ul > li > a" ).hover(
440
441            function() {
442              var $dataClone = $(this).attr("data-tooltip");
443              var $datatitle = $(this).attr("title");
444
445              if ( $(this).attr("title") !== "" ) {
446                $(this).closest('ul').prev().addClass('is-hover');
447                $(this).closest('li').addClass('have-tooltip');
448                $(this).attr("title",'');
449              }
450
451              $(this).closest('ul').addClass('is-hover').attr('data-tooltip', $dataClone);
452              $(this).closest('li').addClass('is-hover').attr('data-title', $datatitle).siblings().removeClass('is-hover');
453
454
455            }, function() {
456              var $datatitle = $(this).closest('li').attr("data-title");
457              var $activeClone = $(this).closest('ul').find('a.is-active-trail').attr("data-tooltip");
458
459              if ($(this).parent().hasClass('is-active-trail')) {
460
461              } else {
462
463                if ($('.nav--menu-timeline-toolbox > li > ul > li > ul > li.is-active-trail').length) {
464                  $(this).closest('ul').children('li:not(.is-active-trail)').removeClass('is-hover');
465                  $(this).closest('ul').attr('data-tooltip', $activeClone).addClass('is-hover').children('li.is-active-trail').addClass('is-hover');
466                } else {
467                  $(this).closest('li').parent().removeClass('is-hover').attr('data-tooltip', '');
468                  $(this).closest('li').removeClass('is-hover');
469                }
470
471              }
472
473            $(this).attr("title",$datatitle);
474            $(this).closest('li').removeClass('have-tooltip').attr('data-title', '');
475            }
476
477        );
478
479
480        $( ".nav--menu-timeline-toolbox > li > ul > li > a" ).hover(
481
482            function() {
483              var $dataClone = $(this).attr("data-tooltip");
484
485
486              if ( $(this).attr("title") !== "" ) {
487                $(this).closest('ul').prev().addClass('is-hover');
488                $(this).closest('li').addClass('have-tooltip');
489                $(this).attr('title', "");
490              }
491
492
493
494              $(this).closest('li').addClass('is-hover').siblings().removeClass('is-hover');
495              $(this).closest('ul').prev().attr('data-tooltip', $dataClone);
496
497            }, function() {
498                var $contenttitle = $(this).closest('li').attr("data-title");
499
500                $(this).closest('ul').prev().removeClass('is-hover');
501                $(this).closest('li').removeClass('have-tooltip');
502
503                $(this).attr('title', $contenttitle);
504
505              if ($(this).parent().hasClass('is-active-trail')) {
506
507              } else {
508                $(this).closest('ul').children('li.is-active-trail').addClass('is-hover');
509                $(this).closest('li').removeClass('is-hover');
510              }
511
512              $(this).closest('ul').prev().attr('data-tooltip', "");
513
514            }
515
516        );
517
518        $( ".nav--menu-timeline-toolbox > li > a" ).hover(
519            function() {
520              $(this).parent().addClass('hover-main-link');
521            }, function() {
522              $(this).parent().removeClass('hover-main-link');
523            }
524        );
525
526
527        if ($('.nav--menu-timeline-toolbox > li.is-active-trail').length) {
528            $('.nav--menu-timeline-toolbox > li:not(.is-active-trail)').addClass('is-close');
529            $('.nav--menu-timeline-toolbox > li.is-active-trail').addClass('is-highlighted').addClass('hoverable').children("a").addClass('is-open').next().addClass('show');
530        }
531
532        if ($('.nav--menu-timeline-toolbox > li > ul > li.is-active-trail').length) {
533            $('.nav--menu-timeline-toolbox > li > ul > li.is-active-trail').addClass('is-hover');
534        }
535
536
537        if ($('.nav--menu-timeline-toolbox > li > ul > li > ul > li.is-active-trail').length) {
538            var $activeData = $('.nav--menu-timeline-toolbox > li > ul > li > ul > li > a.is-active-trail').attr("data-tooltip");
539
540            $('.nav--menu-timeline-toolbox > li > ul > li > ul > li.is-active-trail').addClass('is-hover').parent().addClass('is-hover');
541            $('.nav--menu-timeline-toolbox > li > ul > li > ul > li.is-active-trail').parent().attr('data-tooltip', $activeData);
542
543        }
544
545        $('.nav--menu-timeline-toolbox > li > a').click(function(e) {
546        e.preventDefault();
547
548            var $this = $(this);
549
550            if ($this.next().hasClass('show')) {
551                  $this.next().removeClass('show');
552                  $this.removeClass('is-open');
553                  $this.parent().removeClass('is-highlighted');
554                  $this.closest('.nav--menu-timeline-toolbox').children().removeClass('is-close').removeClass('hoverable').children('a').css("opacity", "0").delay(200).animate({
555  opacity: 1
556});
557
558            } else {
559
560                  $this.parent().parent().children('li.has-subnav').children('ul').removeClass('show');
561                  $this.parent().parent().children('li.has-subnav').children("a").removeClass('is-open');
562                  $this.parent().parent().children('li').removeClass('is-highlighted').removeClass('hoverable').addClass('is-close');
563
564                  if ($this.parent().hasClass('is-close')) {
565                    $this.hide().delay(400).fadeIn(400);
566                    $this.toggleClass('is-open');
567                    $this.parent().toggleClass('is-highlighted').toggleClass('is-close').stop().delay(1000).queue(function(){
568                      $(this).toggleClass('hoverable');
569                    });
570                    $this.next().toggleClass('show');
571                  } else {
572                    $this.toggleClass('is-open');
573                    $this.parent().toggleClass('is-highlighted').stop().delay(1000).queue(function(){
574                      $(this).toggleClass('hoverable');
575                    });
576                    $this.next().toggleClass('show');
577                  }
578            }
579
580
581
582
583           return false;
584      });
585
586      $('.timeline-anchor').click(function(e) {
587          e.preventDefault();
588
589          if ($(this).parent().prev().hasClass('menu-is-open')) {
590            $('.toolbox-toggle').removeClass("is-on");
591            $('.toolbox-toggle').parent().next('.toolbox-overlay-nav').removeClass('is-active');
592            $('.toolbox-toggle').parent().parent().removeClass('menu-is-open');
593            e.preventDefault();
594          }
595
596          return false;
597     });
598
599
600    }(jQuery));
601}

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.