PageSourceSearch

https://abilitynet.org.uk/sites/abilitynet.org.uk/modules/contrib/tb_megamenu/js/tb-megamenu-touch.js?tlp6ul

js abilitynet.org.uk collected 2026-09-24 07:29:59 UTC 2,046 bytes, 61 lines download raw bytes

1Drupal.TBMegaMenu = Drupal.TBMegaMenu || {};
2
3(function ($) {
4  Drupal.TBMegaMenu.createTouchMenu = function(items) {
5    items.children('a, .tb_nolink').each( function() {
6      var $item = $(this);
7      var tbitem = $(this).parent();
8
9      $item.click( function(event){
10        if ($item.hasClass('tb-megamenu-clicked')) {
11          var $uri = $item.attr('href');
12          if ($uri && $uri !== '#') {
13            window.location.href = $uri;
14          }
15        }
16        else {
17          event.preventDefault();
18          $item.addClass('tb-megamenu-clicked');
19          if(!tbitem.hasClass('open')){	
20            tbitem.addClass('open');
21          }
22
23          // Find any parent siblings that are open and close them.
24          tbitem.siblings('.open').find('.tb-megamenu-clicked').removeClass('tb-megamenu-clicked');
25          tbitem.siblings('.open').removeClass('open');
26
27          $('body').addClass('tb-megamenu-open');
28        }
29      });
30    });
31  }
32  
33  Drupal.TBMegaMenu.eventStopPropagation = function(event) {
34    if (event.stopPropagation) {
35      event.stopPropagation();
36    }
37    else if (window.event) {
38      window.event.cancelBubble = true;
39    }
40  }
41
42  Drupal.behaviors.tbMegaMenuTouchAction = {
43    attach: function(context) {
44      var isTouch = window.matchMedia('(pointer: coarse)').matches;
45      if(isTouch){
46        $('html').addClass('touch');
47        Drupal.TBMegaMenu.createTouchMenu($('.tb-megamenu ul.nav li.mega').has('.dropdown-menu'));
48
49        // When the user touches anywhere outside of the open menu item, close
50        // the open menu item.
51        $(document).on('touchstart', function(event) {
52          if ($('body').hasClass('tb-megamenu-open') && !$(event.target).closest('.mega.open').length) {
53            $('.tb-megamenu ul.nav li.mega a, .tb-megamenu ul.nav li.mega .tb_nolink').removeClass('tb-megamenu-clicked');
54            $('.tb-megamenu ul.nav li.mega').removeClass('open');
55            $('body').removeClass('tb-megamenu-open');
56         }
57       });
58      }
59    }
60  }
61})(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.