PageSourceSearch

https://permafrost.su/profiles/dkan/themes/contrib/radix/assets/js/radix.script.js?pfnoqa

js permafrost.su collected 2026-10-02 11:42:02 UTC 4,207 bytes, 121 lines download raw bytes

1/**
2 * @file
3 * JS for Radix.
4 */
5(function ($, Drupal, window, document, undefined) {
6  // Allow dropdown links to be clickable by showing dropdowns on hover/focus.
7  Drupal.behaviors.radix_dropdown = {
8    attach: function(context, setting) {
9      $('.dropdown').once('radix-dropdown', function(){
10        var dropdown = this;
11
12        // Helper function to show the dropdown.
13        function show() {
14          if (!$(dropdown).hasClass('open')) {
15            $('>[data-toggle="dropdown"]', dropdown).trigger('click.bs.dropdown');
16          }
17        }
18
19        // Helper function to hide the dropdown.
20        function hide() {
21          if ($(dropdown).hasClass('open')) {
22            $('>[data-toggle="dropdown"]', dropdown).trigger('click.bs.dropdown');
23          }
24        }
25
26        // Show dropdown on hover and focus.
27        $(this).on('mouseenter.radix.dropdown', function(e) {
28          show();
29        });
30        $(this).on('mouseleave.radix.dropdown', function() {
31          hide();
32        });
33        $(this).on('focusin.radix.dropdown', function() {
34          show();
35        });
36        $('body').once('radix-dropdown').on('focusout.radix.dropdown', function(e) {
37          var parent = $(e.target).closest('li.radix-dropdown-processed.open').get(0);
38          if (parent) {
39            // Defer to after all handlers so we can see where focus landed.
40            setTimeout(function () {
41              // Don't do anything if no element is focused - that can only
42              // happen with the mouse and this is meant to close the menu
43              // when the keyboard is used to change focus.
44              if (!document.activeElement || document.activeElement === document.body) {
45                return;
46              }
47              // Hide the parent if it doesn't contain the now focused element
48              // and is still open.
49              if (!parent.contains(document.activeElement) && $(parent).hasClass('open')) {
50                $(parent).trigger('click.bs.dropdown');
51              }
52            }, 0);
53          }
54        });
55
56        $(this).on('keydown.radix.dropdown', function(e) {
57          // Prevent up/down arrow from doing anything -- they conflict with
58          // using focus to show the dropdown, and the default Bootstrap keydown
59          // handler will trigger our click handler to visit the link.
60          if (e.keyCode == 38 || e.keyCode == 40) {
61            return false;
62          }
63          // Show/hide dropdown with spacebar.
64          if (e.keyCode == 32) {
65            $('>[data-toggle="dropdown"]', dropdown).trigger('click.bs.dropdown');
66            return false;
67          }
68          // Hide the dropdown with the escape hey.
69          if (e.keyCode == 27) {
70            // Leave focus on the parent after it's hidden.
71            $('>[data-toggle="dropdown"]', dropdown).focus();
72            hide();
73            return false;
74          }
75        });
76
77        // Allow a.dropdown-toggle to be clickable.
78        if ($(this).has('> a.dropdown-toggle')) {
79          $(this).on('click.radix.dropdown', function(e) {
80            var $target = $(e.target);
81            if ($target.parent().get(0) == dropdown && $target.is('a.dropdown-toggle') && $target.attr('href')) {
82              e.preventDefault();
83              window.location.href = $target.attr('href');
84            }
85          });
86        }
87      });
88    }
89  }
90
91  // Bootstrap tooltip.
92  Drupal.behaviors.radix_tooltip = {
93    attach: function(context, setting) {
94      if ($.fn.tooltip) {
95        $("[data-toggle='tooltip']").tooltip();
96      }
97    }
98  }
99
100  // Bootstrap popover.
101  Drupal.behaviors.radix_popover = {
102    attach: function(context, setting) {
103      if ($.fn.popover) {
104        $("[data-toggle='popover']").popover();
105      }
106    }
107  }
108
109  $(document).ready(function() {
110    // Show first tab by default.
111    // Ignore the "primary" tabs on the node edit page.
112    if ($.fn.tab) {
113      var tabs = $('.nav-tabs').not('.primary');
114      tabs.children('li').first().find('a').tab('show');
115
116      if (hash = window.location.hash) {
117        $('.nav-tabs > li > a[href$="' + hash + '"]').tab('show');
118      }
119    }
120  });
121})(jQuery, Drupal, this, this.document);

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.