PageSourceSearch

https://www.bnlsis.org/themes/base_theme/js/components/off-canvas.js?tlefoz

js bnlsis.org collected 2026-09-25 02:44:27 UTC 3,060 bytes, 95 lines download raw bytes

1(function ($, Drupal, once) {
2  Drupal.behaviors.btOffCanvas = {
3    attach: function (context, settings) {
4
5      // offcavnas event.
6      $(document).on('click', '.off-canvas .close-button', function (e) {
7        const toggle_mobile = $('.secondary-toggle-mobile');
8
9        setTimeout(function () {
10          toggle_mobile.trigger('focus');
11        }, 0);
12      });
13
14      // admin toolbar.
15      const toolbar = once('js_admin-toolbar', '.toolbar', context);
16
17      toolbar.forEach(function () {
18        const body = $('body');
19
20        if (!body.hasClass('user-logged-in') && $('.toolbar').length === 0) {
21          return;
22        }
23
24        $.initialize('.toolbar', function () {
25          const tray = $(this).find('.toolbar-tray');
26          const toolbar = $(this).find('.toolbar-bar');
27
28          var height = toolbar.height();
29          var tray_height = tray.height();
30
31          body.css('padding-top', height + 'px');
32
33          if ($('body').hasClass('toolbar-tray-open')) {
34            body.css('padding-top', tray_height + 'px');
35          }
36        });
37
38      });
39
40      // layout builder categories summary icon.
41      const layout_builder_categories = once('js_layout-builder-category', '.js-layout-builder-categories', context);
42
43      layout_builder_categories.forEach(function (el) {
44        const summary = $(el).find('summary');
45
46        summary.append('<i class="icon-chevron-up-regular"></i>');
47
48        summary.click(function () {
49
50          const carret_up = $(this).children('.icon-chevron-up-regular');
51          const carret_down = $(this).children('.icon-chevron-down-regular');
52
53          if (carret_up.length > 0) {
54            carret_up.attr('class', carret_up.attr('class').replace('up', 'down'));
55          }
56          if (carret_down.length > 0) {
57            carret_down.attr('class', carret_down.attr('class').replace('down', 'up'));
58          }
59        });
60      });
61
62      /**
63       * Detect when the Off-Canvas closes and focus on the toggle button.
64       */ 
65      once('off-canvas-toggle', $('#mobile-menu-canvas'), context).forEach(function (el) {
66        const $offCanvasElem = $(el);
67        let lastState = null;
68      
69        if ($offCanvasElem.length !== 0) {
70          // Set up a MutationObserver to detect class changes
71          const observer = new MutationObserver((mutations) => {
72            mutations.forEach((mutation) => {
73              if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
74                const isOpen = mutation.target.classList.contains('is-open');
75                if (isOpen !== lastState) {
76                  lastState = isOpen;
77
78                  // Detect if closes.
79                  if (!isOpen) {
80                    $('.toggle-mobile').trigger('focus');
81                  }
82                }
83              }
84            });
85          });
86
87          // Start observing the Off-Canvas element
88          observer.observe($offCanvasElem[0], { 
89            attributes: true,
90          });
91        }
92      });
93    }
94  };
95})(jQuery, Drupal, once);

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.