PageSourceSearch

https://www.restaurantpertinence.com/wp-content/themes/h-code/assets/js/bootstrap-hover-dropdown.js?ver=1.8.2

js restaurantpertinence.com collected 2026-10-07 02:26:20 UTC 4,960 bytes, 118 lines download raw bytes

1/**
2 * Project: Bootstrap Hover Dropdown
3 * Author: Cameron Spear
4 * Contributors: Mattia Larentis
5 *
6 * Dependencies: Bootstrap's Dropdown plugin, jQuery
7 *
8 * A simple plugin to enable Bootstrap dropdowns to active on hover and provide a nice user experience.
9 *
10 * License: MIT
11 *
12 * http://cameronspear.com/blog/bootstrap-dropdown-on-hover-plugin/
13 */
14"use strict";
15var isTouchDevice = "ontouchstart" in window || navigator.msMaxTouchPoints;
16if (!isTouchDevice) {
17    ; (function ($, window, undefined) {
18        // outside the scope of the jQuery plugin to
19        // keep track of all dropdowns
20        var $allDropdowns = $();
21
22        // if instantlyCloseOthers is true, then it will instantly
23        // shut other nav items when a new one is hovered over
24        $.fn.dropdownHover = function (options) {
25            // don't do anything if touch is supported
26            // (plugin causes some issues on mobile)
27            if ('ontouchstart' in document) return this; // don't want to affect chaining
28
29            // the element we really care about
30            // is the dropdown-toggle's parent
31            $allDropdowns = $allDropdowns.add(this.parent());
32
33            // H-Code V1.8
34            var hcodeDelay = ( $('nav').attr('data-menu-hover-delay') ) ? $('nav').attr('data-menu-hover-delay') : "100";
35
36            return this.each(function () {
37                var $this = $(this),
38                    $parent = $this.parent(),
39                    defaults = {
40                        delay: hcodeDelay,
41                        instantlyCloseOthers: true
42                    },
43                    data = {
44                        delay: $(this).data('delay'),
45                        instantlyCloseOthers: $(this).data('close-others')
46                    },
47                    showEvent = 'show.bs.dropdown',
48                    hideEvent = 'hide.bs.dropdown',
49                    // shownEvent  = 'shown.bs.dropdown',
50                    // hiddenEvent = 'hidden.bs.dropdown',
51                    settings = $.extend(true, {}, defaults, options, data),
52                    timeout;
53
54                $parent.hover(function (event) {
55                    // so a neighbor can't open the dropdown
56                    /*if (!$parent.hasClass('open') && !$this.is(event.target)) {
57                        // stop this event, stop executing any code
58                        // in this callback but continue to propagate
59                        return true;
60                    }*/
61
62                    openDropdown(event);
63                }, function () {
64                    timeout = window.setTimeout(function () {
65                        $parent.removeClass('open');
66                        $this.trigger(hideEvent);
67                    }, settings.delay);
68                });
69
70                // this helps with button groups!
71                $this.hover(function (event) {
72                    // this helps prevent a double event from firing.
73                    // see https://github.com/CWSpear/bootstrap-hover-dropdown/issues/55
74                    if (!$parent.hasClass('open') && !$parent.is(event.target)) {
75                        // stop this event, stop executing any code
76                        // in this callback but continue to propagate
77                        return true;
78                    }
79
80                    openDropdown(event);
81                });
82
83                // handle submenus
84                $parent.find('.dropdown-submenu').each(function () {
85                    var $this = $(this);
86                    var subTimeout;
87                    $this.hover(function () {
88                        window.clearTimeout(subTimeout);
89                        $this.children('.dropdown-menu').show();
90                        // always close submenu siblings instantly
91                        $this.siblings().children('.dropdown-menu').hide();
92                    }, function () {
93                        var $submenu = $this.children('.dropdown-menu');
94                        subTimeout = window.setTimeout(function () {
95                            $submenu.hide();
96                        }, settings.delay);
97                    });
98                });
99
100                function openDropdown(event) {
101                    $allDropdowns.find(':focus').blur();
102
103                    if (settings.instantlyCloseOthers === true)
104                        $allDropdowns.removeClass('open');
105
106                    window.clearTimeout(timeout);
107                    $parent.addClass('open');
108                    $this.trigger(showEvent);
109                }
110            });
111        };
112
113        $(document).ready(function () {
114            // apply dropdownHover to all elements with the data-hover="dropdown" attribute
115            $('[data-hover="dropdown"]').dropdownHover();
116        });
117    })(jQuery, this);
118}

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.