PageSourceSearch

https://www.greenarrowtv.com/wp-content/themes/goliath/theme/asset…/bootstrap-hover-dropdown.js?ver=1740279383

js greenarrowtv.com collected 2026-10-02 06:52:30 UTC 4,758 bytes, 120 lines download raw bytes

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

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.