PageSourceSearch

https://nationaltrailraceway.com/modules/contrib/responsive_menu/js/responsive_menu.config.js?v=8.9.11

js nationaltrailraceway.com collected 2026-10-02 05:50:45 UTC 5,065 bytes, 171 lines download raw bytes

1(function ($) {
2
3  'use strict';
4
5  /**
6   * Provides the off-canvas menu.
7   *
8   * @type {Drupal~behavior}
9   *
10   * @prop {Drupal~behaviorAttach} attach
11   *   Attaches the behavior for the off-canvas menu.
12   */
13  Drupal.behaviors.responsive_menu_mmenu = {
14    attach: function (context) {
15      $(context).find('body').once('responsive-menu-mmenu').each(function() {
16
17        if (typeof($.mmenu) !== 'undefined') {
18
19          // Get the position and theme options from Drupal settings.
20          var position = drupalSettings.responsive_menu.position,
21            theme = drupalSettings.responsive_menu.theme,
22            pagedim = drupalSettings.responsive_menu.pagedim,
23            extension_keyboard = drupalSettings.responsive_menu.extension_keyboard;
24
25          var settings = {
26            extensions: [
27              theme,
28              'effect-slide-menu',
29              position === 'left' ? 'position-left' : 'position-right'
30            ],
31            offCanvas: {
32              zposition: 'next',
33              position: position
34            },
35            screenReader: {
36              aria: true,
37              text: true
38            }
39          };
40
41          var options = {
42            clone: false,
43            classNames: {
44              selected: "menu__item--active-trail"
45            }
46          };
47
48          if (extension_keyboard) {
49            settings.keyboardNavigation = {
50              enable: true,
51              enhance: true
52            }
53          }
54
55          if (pagedim !== 'none') {
56            settings.extensions.push(pagedim);
57          }
58
59          // Set up the off canvas menu.
60          $('#off-canvas').mmenu(settings, options);
61
62          // Fix some quirks with Firefox rendering the toolbar in an odd position.
63          if ($('#toolbar-administration').length > 0) {
64            var api = $('#off-canvas').data('mmenu');
65            api.bind("opened", function ($panel) {
66              $('.toolbar-tray-vertical').css('overflow-x', 'auto');
67            });
68            api.bind("closed", function ($panel) {
69              $('.toolbar-tray-vertical').css('overflow-x', 'hidden');
70            });
71          }
72        }
73      });
74    }
75  };
76
77  /**
78   * Provides additional but optional functionality.
79   *
80   * @type {Drupal~behavior}
81   *
82   * @prop {Drupal~behaviorAttach} attach
83   *   Attaches the behavior for superfish and hammerjs.
84   */
85  Drupal.behaviors.responsive_menu_optional = {
86    attach: function (context, settings) {
87
88      $(context).find('body').once('responsive-menu-optional').each(function () {
89
90        // Apply the superfish library to the menu.
91        if ($.fn.superfish && drupalSettings.responsive_menu.superfish.active) {
92          // Get the superfish settings.
93          var superfishDelay = drupalSettings.responsive_menu.superfish.delay,
94            superfishSpeed = drupalSettings.responsive_menu.superfish.speed,
95            superfishSpeedOut = drupalSettings.responsive_menu.superfish.speedOut;
96          // Attach superfish to the responsive menu.
97          $('#horizontal-menu').superfish({
98            delay: parseInt(superfishDelay, 10),
99            speed: parseInt(superfishSpeed, 10),
100            speedOut: parseInt(superfishSpeedOut, 10)
101          }).addClass('sf-menu');
102        }
103
104        // Add the Hammer config if needed.
105        if (typeof(Hammer) !== 'undefined') {
106
107          var mc = new Hammer($('body').get(0), {
108            cssProps: {
109              userSelect: true
110            },
111            // Reset the touchAction to auto as this allows pinch zooming.
112            // mmenu handles the scrolling once open.
113            touchAction: 'auto'
114          });
115          mc.get('swipe').set({
116            velocity: 0.3,
117            threshold: 5
118          });
119
120          mc.on("swipeleft swiperight", function(e) {
121            // Only do something if we're below our breakpoint. The simplest
122            // method is to check whether the horizontal desktop sized
123            // responsive menu is hidden.
124            if ($('.responsive-menu-block-wrapper').is(':hidden')) {
125              hammerswipe(mc, e);
126            }
127          });
128
129        }
130
131      });
132    }
133  };
134
135  /**
136   * Opens or closes the mmenu based on swipe direction.
137   *
138   * @param mc
139   *   Hammer object instance.
140   * @param e
141   *   Swipe event.
142   */
143  function hammerswipe(mc, e) {
144    var position = drupalSettings.responsive_menu.position;
145    var api = $('#off-canvas').data('mmenu'),
146      $html = $('html');
147
148    if (e.type == 'swiperight') {
149      if (position == 'right' && $html.hasClass('mm-opened')) {
150        // Close the menu.
151        api.close();
152      }
153      if (position == 'left' && !$html.hasClass('mm-opened')) {
154        // Open the menu.
155        api.open();
156      }
157    }
158
159    if (e.type == 'swipeleft') {
160      if (position == 'right' && !$html.hasClass('mm-opened')) {
161        // Open the menu.
162        api.open();
163      }
164      if (position == 'left' && $html.hasClass('mm-opened')) {
165        // Close the menu.
166        api.close();
167      }
168    }
169  }
170
171})(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.