PageSourceSearch

https://cathoutils.be/wp-content/themes/theme-cathoutils-master/js…?ver=2a70ae37f70ab90d1b44706256a89be6

js cathoutils.be collected 2026-10-07 14:42:28 UTC 6,268 bytes, 209 lines download raw bytes

1(function($, UI) {
2
3    "use strict";
4
5    var active   = false,
6        Dropdown = function(element, options) {
7
8        var $this = this, $element = $(element);
9
10        if($element.data("dropdown")) return;
11
12        this.options  = $.extend({}, Dropdown.defaults, options);
13        this.element  = $element;
14        this.dropdown = this.element.find(".uk-dropdown");
15
16        this.centered  = this.dropdown.hasClass("uk-dropdown-center");
17        this.justified = this.options.justify ? $(this.options.justify) : false;
18
19        this.boundary  = $(this.options.boundary);
20
21        if(!this.boundary.length) {
22            this.boundary = $(window);
23        }
24
25        if (this.options.mode == "click" || UI.support.touch) {
26
27            
28            this.element.on("click", function(e) {
29                
30                var $target = $(e.target);
31                
32                // Close when user click on list item
33                if ($this.element.hasClass("uk-open") && $target.is("span[class='uk-button-term']")) {
34                    active.removeClass("uk-open");
35                    active = false;
36                    return
37                }
38
39                if (!$target.parents(".uk-dropdown").length) {
40                    
41                    if ($target.is("a[href='#']") || $target.parent().is("a[href='#']")){
42                        e.preventDefault();
43                    }
44
45                    $target.blur();
46                }
47
48                if (!$this.element.hasClass("uk-open")) {
49
50                    $this.show();
51
52                } else {
53
54                    if ($target.is("a") || !$this.element.find(".uk-dropdown").find(e.target).length) {
55                        $this.element.removeClass("uk-open");
56                        active = false;
57                    }
58                }
59            });
60
61        } else {
62
63            this.element.on("mouseenter", function(e) {
64
65                if ($this.remainIdle) {
66                    clearTimeout($this.remainIdle);
67                }
68
69                $this.show();
70
71            }).on("mouseleave", function() {
72
73                $this.remainIdle = setTimeout(function() {
74
75                    $this.element.removeClass("uk-open");
76                    $this.remainIdle = false;
77
78                    if (active && active[0] == $this.element[0]) active = false;
79
80                }, $this.options.remaintime);
81            });
82        }
83
84        this.element.data("dropdown", this);
85    };
86
87    $.extend(Dropdown.prototype, {
88
89        remainIdle: false,
90
91        show: function(){
92
93            if (active && active[0] != this.element[0]) {
94                active.removeClass("uk-open");
95            }
96
97            this.checkDimensions();
98            this.element.addClass("uk-open");
99            active = this.element;
100
101            this.registerOuterClick();
102        },
103
104        registerOuterClick: function(){
105
106            var $this = this;
107
108            $(document).off("click.outer.dropdown");
109
110            setTimeout(function() {
111                $(document).on("click.outer.dropdown", function(e) {
112
113                    if (active && active[0] == $this.element[0] && ($(e.target).is("a") || !$this.element.find(".uk-dropdown").find(e.target).length)) {
114                        active.removeClass("uk-open");
115                        $(document).off("click.outer.dropdown");
116                    }
117                });
118            }, 10);
119        },
120
121        checkDimensions: function() {
122
123            if(!this.dropdown.length) return;
124
125            var dropdown  = this.dropdown.css("margin-" + $.UIkit.langdirection, "").css("min-width", ""),
126                offset    = dropdown.show().offset(),
127                width     = dropdown.outerWidth(),
128                boundarywidth  = this.boundary.width(),
129                boundaryoffset = this.boundary.offset() ? this.boundary.offset().left:0;
130
131            // centered dropdown
132            if (this.centered) {
133                dropdown.css("margin-" + $.UIkit.langdirection, (parseFloat(width) / 2 - dropdown.parent().width() / 2) * -1);
134                offset = dropdown.offset();
135
136                // reset dropdown
137                if ((width + offset.left) > boundarywidth || offset.left < 0) {
138                    dropdown.css("margin-" + $.UIkit.langdirection, "");
139                    offset = dropdown.offset();
140                }
141            }
142
143            // justify dropdown
144            if (this.justified && this.justified.length) {
145
146                var jwidth = this.justified.outerWidth();
147
148                dropdown.css("min-width", jwidth);
149
150                if ($.UIkit.langdirection == 'right') {
151
152                    var right1   = boundarywidth - (this.justified.offset().left + jwidth),
153                        right2   = boundarywidth - (dropdown.offset().left + dropdown.outerWidth());
154
155                    dropdown.css("margin-right", right1 - right2);
156
157                } else {
158                    dropdown.css("margin-left", this.justified.offset().left - offset.left);
159                }
160
161                offset = dropdown.offset();
162
163            }
164
165            if ((width + (offset.left-boundaryoffset)) > boundarywidth) {
166                dropdown.addClass("uk-dropdown-flip");
167                offset = dropdown.offset();
168            }
169
170            if (offset.left < 0) {
171                dropdown.addClass("uk-dropdown-stack");
172            }
173
174            dropdown.css("display", "");
175        }
176
177    });
178
179    Dropdown.defaults = {
180        "mode": "hover",
181        "remaintime": 800,
182        "justify": false,
183        "boundary": $(window)
184    };
185
186    UI["dropdown"] = Dropdown;
187
188
189    var triggerevent = UI.support.touch ? "click":"mouseenter";
190
191    // init code
192    $(document).on(triggerevent+".dropdown.uikit", "[data-uk-dropdown]", function(e) {
193        var ele = $(this);
194
195        if (!ele.data("dropdown")) {
196
197            var dropdown = new Dropdown(ele, UI.Utils.options(ele.data("uk-dropdown")));
198
199            if (triggerevent=="click" || (triggerevent=="mouseenter" && dropdown.options.mode=="hover")) {
200                dropdown.show();
201            }
202
203            if(dropdown.element.find('.uk-dropdown').length) {
204                e.preventDefault();
205            }
206        }
207    });
208
209})(jQuery, jQuery.UIkit);

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.