PageSourceSearch

https://www.landschloss-korntal.de/fileadmin/templates/landschloss…/Public/js/core/dropdown.js?1611314253

js landschloss-korntal.de collected 2026-10-09 03:28:20 UTC 16,606 bytes, 497 lines download raw bytes

1/*! UIkit 2.23.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
2(function(UI) {
3
4    "use strict";
5
6    var active = false, hoverIdle, flips = {
7        'x': {
8            "bottom-left"   : 'bottom-right',
9            "bottom-right"  : 'bottom-left',
10            "bottom-center" : 'bottom-right',
11            "top-left"      : 'top-right',
12            "top-right"     : 'top-left',
13            "top-center"    : 'top-right',
14            "left-top"      : 'right',
15            "left-bottom"   : 'right-bottom',
16            "left-center"   : 'right-center',
17            "right-top"     : 'left',
18            "right-bottom"  : 'left-bottom',
19            "right-center"  : 'left-center'
20        },
21        'y': {
22            "bottom-left"   : 'top-left',
23            "bottom-right"  : 'top-right',
24            "bottom-center" : 'top-center',
25            "top-left"      : 'bottom-left',
26            "top-right"     : 'bottom-right',
27            "top-center"    : 'bottom-center',
28            "left-top"      : 'top-left',
29            "left-bottom"   : 'left-bottom',
30            "left-center"   : 'top-left',
31            "right-top"     : 'top-left',
32            "right-bottom"  : 'bottom-left',
33            "right-center"  : 'top-left'
34        },
35        'xy': {
36
37        }
38    };
39
40    UI.component('dropdown', {
41
42        defaults: {
43           'mode'            : 'hover',
44           'pos'             : 'bottom-left',
45           'offset'          : 0,
46           'remaintime'      : 800,
47           'justify'         : false,
48           'boundary'        : UI.$win,
49           'delay'           : 0,
50           'dropdownSelector': '.uk-dropdown,.uk-dropdown-blank',
51           'hoverDelayIdle'  : 250
52        },
53
54        remainIdle: false,
55
56        boot: function() {
57
58            var triggerevent = UI.support.touch ? "click" : "mouseenter";
59
60            // init code
61            UI.$html.on(triggerevent+".dropdown.uikit", "[data-uk-dropdown]", function(e) {
62
63                var ele = UI.$(this);
64
65                if (!ele.data("dropdown")) {
66
67                    var dropdown = UI.dropdown(ele, UI.Utils.options(ele.attr("data-uk-dropdown")));
68
69                    if (triggerevent=="click" || (triggerevent=="mouseenter" && dropdown.options.mode=="hover")) {
70                        dropdown.element.trigger(triggerevent);
71                    }
72
73                    if (dropdown.element.find(dropdown.options.dropdownSelector).length) {
74                        e.preventDefault();
75                    }
76                }
77            });
78        },
79
80        init: function() {
81
82            var $this = this;
83
84            this.dropdown     = this.find(this.options.dropdownSelector);
85            this.offsetParent = this.dropdown.parents().filter(function() {
86                return UI.$.inArray(UI.$(this).css('position'), ['relative', 'fixed', 'absolute']) !== -1;
87            }).slice(0,1);
88
89            this.centered  = this.dropdown.hasClass('uk-dropdown-center');
90            this.justified = this.options.justify ? UI.$(this.options.justify) : false;
91
92            this.boundary  = UI.$(this.options.boundary);
93
94            if (!this.boundary.length) {
95                this.boundary = UI.$win;
96            }
97
98            // legacy DEPRECATED!
99            if (this.dropdown.hasClass('uk-dropdown-up')) {
100                this.options.pos = 'top-left';
101            }
102            if (this.dropdown.hasClass('uk-dropdown-flip')) {
103                this.options.pos = this.options.pos.replace('left','right');
104            }
105            if (this.dropdown.hasClass('uk-dropdown-center')) {
106                this.options.pos = this.options.pos.replace(/(left|right)/,'center');
107            }
108            //-- end legacy
109
110            // Init ARIA
111            this.element.attr('aria-haspopup', 'true');
112            this.element.attr('aria-expanded', this.element.hasClass("uk-open"));
113
114            if (this.options.mode == "click" || UI.support.touch) {
115
116                this.on("click.uikit.dropdown", function(e) {
117
118                    var $target = UI.$(e.target);
119
120                    if (!$target.parents($this.options.dropdownSelector).length) {
121
122                        if ($target.is("a[href='#']") || $target.parent().is("a[href='#']") || ($this.dropdown.length && !$this.dropdown.is(":visible")) ){
123                            e.preventDefault();
124                        }
125
126                        $target.blur();
127                    }
128
129                    if (!$this.element.hasClass('uk-open')) {
130
131                        $this.show();
132
133                    } else {
134
135                        if (!$this.dropdown.find(e.target).length || $target.is(".uk-dropdown-close") || $target.parents(".uk-dropdown-close").length) {
136                            $this.hide();
137                        }
138                    }
139                });
140
141            } else {
142
143                this.on("mouseenter", function(e) {
144
145                    $this.trigger('pointerenter.uk.dropdown', [$this]);
146
147                    if ($this.remainIdle) {
148                        clearTimeout($this.remainIdle);
149                    }
150
151                    if (hoverIdle) {
152                        clearTimeout(hoverIdle);
153                    }
154
155                    if (active && active == $this) {
156                        return;
157                    }
158
159                    // pseudo manuAim
160                    if (active && active != $this) {
161
162                        hoverIdle = setTimeout(function() {
163                            hoverIdle = setTimeout($this.show.bind($this), $this.options.delay);
164                        }, $this.options.hoverDelayIdle);
165
166                    } else {
167
168                        hoverIdle = setTimeout($this.show.bind($this), $this.options.delay);
169                    }
170
171                }).on("mouseleave", function() {
172
173                    if (hoverIdle) {
174                        clearTimeout(hoverIdle);
175                    }
176
177                    $this.remainIdle = setTimeout(function() {
178                        if (active && active == $this) $this.hide();
179                    }, $this.options.remaintime);
180
181                    $this.trigger('pointerleave.uk.dropdown', [$this]);
182
183                }).on("click", function(e){
184
185                    var $target = UI.$(e.target);
186
187                    if ($this.remainIdle) {
188                        clearTimeout($this.remainIdle);
189                    }
190
191                    if (active && active == $this) {
192                        return;
193                    }
194
195                    if ($target.is("a[href='#']") || $target.parent().is("a[href='#']")){
196                        e.preventDefault();
197                    }
198
199                    $this.show();
200                });
201            }
202        },
203
204        show: function(){
205
206            UI.$html.off("click.outer.dropdown");
207
208            if (active && active != this) {
209                active.hide(true);
210            }
211
212            if (hoverIdle) {
213                clearTimeout(hoverIdle);
214            }
215
216            this.trigger('beforeshow.uk.dropdown', [this]);
217
218            this.checkDimensions();
219            this.element.addClass('uk-open');
220
221            // Update ARIA
222            this.element.attr('aria-expanded', 'true');
223
224            this.trigger('show.uk.dropdown', [this]);
225
226            UI.Utils.checkDisplay(this.dropdown, true);
227            active = this;
228
229            this.registerOuterClick();
230        },
231
232        hide: function(force) {
233
234            this.trigger('beforehide.uk.dropdown', [this, force]);
235
236            this.element.removeClass('uk-open');
237
238            if (this.remainIdle) {
239                clearTimeout(this.remainIdle);
240            }
241
242            this.remainIdle = false;
243
244            // Update ARIA
245            this.element.attr('aria-expanded', 'false');
246
247            this.trigger('hide.uk.dropdown', [this, force]);
248
249            if (active == this) active = false;
250        },
251
252        registerOuterClick: function(){
253
254            var $this = this;
255
256            UI.$html.off("click.outer.dropdown");
257
258            setTimeout(function() {
259
260                UI.$html.on("click.outer.dropdown", function(e) {
261
262                    if (hoverIdle) {
263                        clearTimeout(hoverIdle);
264                    }
265
266                    var $target = UI.$(e.target);
267
268                    if (active == $this && !$this.element.find(e.target).length) {
269                        $this.hide(true);
270                        UI.$html.off("click.outer.dropdown");
271                    }
272                });
273            }, 10);
274        },
275
276        checkDimensions: function() {
277
278            if (!this.dropdown.length) return;
279
280            // reset
281            this.dropdown.removeClass('uk-dropdown-top uk-dropdown-bottom uk-dropdown-left uk-dropdown-right uk-dropdown-stack').css({
282                'top-left':'',
283                'left':'',
284                'margin-left' :'',
285                'margin-right':''
286            });
287
288            if (this.justified && this.justified.length) {
289                this.dropdown.css("min-width", "");
290            }
291
292            var $this          = this,
293                pos            = UI.$.extend({}, this.offsetParent.offset(), {width: this.offsetParent[0].offsetWidth, height: this.offsetParent[0].offsetHeight}),
294                posoffset      = this.options.offset,
295                dropdown       = this.dropdown,
296                offset         = dropdown.show().offset(),
297                width          = dropdown.outerWidth(),
298                height         = dropdown.outerHeight(),
299                boundarywidth  = this.boundary.width(),
300                boundaryoffset = this.boundary.offset() ? this.boundary.offset(): {top:0, left:0},
301                dpos           = this.options.pos;
302
303            var variants =  {
304                    "bottom-left"   : {top: 0 + pos.height + posoffset, left: 0},
305                    "bottom-right"  : {top: 0 + pos.height + posoffset, left: 0 + pos.width - width},
306                    "bottom-center" : {top: 0 + pos.height + posoffset, left: 0 + pos.width / 2 - width / 2},
307                    "top-left"      : {top: 0 - height - posoffset, left: 0},
308                    "top-right"     : {top: 0 - height - posoffset, left: 0 + pos.width - width},
309                    "top-center"    : {top: 0 - height - posoffset, left: 0 + pos.width / 2 - width / 2},
310                    "left-top"      : {top: 0, left: 0 - width - posoffset},
311                    "left-bottom"   : {top: 0 + pos.height - height, left: 0 - width - posoffset},
312                    "left-center"   : {top: 0 + pos.height / 2 - height / 2, left: 0 - width - posoffset},
313                    "right-top"     : {top: 0, left: 0 + pos.width + posoffset},
314                    "right-bottom"  : {top: 0 + pos.height - height, left: 0 + pos.width + posoffset},
315                    "right-center"  : {top: 0 + pos.height / 2 - height / 2, left: 0 + pos.width + posoffset}
316                },
317                css = {},
318                pp;
319
320            pp = dpos.split('-');
321            css = variants[dpos] ? variants[dpos] : variants['bottom-left'];
322
323            // justify dropdown
324            if (this.justified && this.justified.length) {
325                justify(dropdown.css({left:0}), this.justified, boundarywidth);
326            } else {
327
328                switch(this.checkBoundary(pos.left + css.left, pos.top + css.top, width, height, boundarywidth)) {
329
330                    case "x":
331                        dpos = flips['x'][dpos] || 'right-top';
332                        break;
333                    case "y":
334                        dpos = flips['y'][dpos] || 'top-left';
335                        break;
336                    case "xy":
337                        dpos = flips['xy'][dpos] || 'right-bottom';
338                        break;
339                }
340
341                pp = dpos.split('-');
342                css = variants[dpos] ? variants[dpos] : variants['bottom-left'];
343            }
344
345            if (width > boundarywidth) {
346                dropdown.addClass("uk-dropdown-stack");
347                this.trigger('stack.uk.dropdown', [this]);
348            }
349
350            dropdown.css(css).css("display", "").addClass('uk-dropdown-'+pp[0]);
351        },
352
353        checkBoundary: function(left, top, width, height, boundarywidth) {
354
355            var axis = "";
356
357            if (left < 0 || ((left - UI.$win.scrollLeft())+width) > boundarywidth) {
358               axis += "x";
359            }
360
361            if (top < 0 || ((top - UI.$win.scrollTop())+height) > window.innerHeight) {
362               axis += "y";
363            }
364
365            return axis;
366        }
367    });
368
369
370    UI.component('dropdownOverlay', {
371
372        defaults: {
373           'justify' : false,
374           'cls'     : '',
375           'duration': 200
376        },
377
378        boot: function() {
379
380            // init code
381            UI.ready(function(context) {
382
383                UI.$("[data-uk-dropdown-overlay]", context).each(function() {
384                    var ele = UI.$(this);
385
386                    if (!ele.data("dropdownOverlay")) {
387                        UI.dropdownOverlay(ele, UI.Utils.options(ele.attr("data-uk-dropdown-overlay")));
388                    }
389                });
390            });
391        },
392
393        init: function() {
394
395            var $this = this;
396
397            this.justified = this.options.justify ? UI.$(this.options.justify) : false;
398            this.overlay   = this.element.find('uk-dropdown-overlay');
399
400            if (!this.overlay.length) {
401                this.overlay = UI.$('<div class="uk-dropdown-overlay"></div>').appendTo(this.element);
402            }
403
404            this.overlay.addClass(this.options.cls);
405
406            this.on({
407
408                'beforeshow.uk.dropdown': function(e, dropdown) {
409                    $this.dropdown = dropdown;
410
411                    if ($this.justified && $this.justified.length) {
412                        justify($this.overlay.css({'display':'block', 'margin-left':'','margin-right':''}), $this.justified, $this.justified.outerWidth());
413                    }
414                },
415
416                'show.uk.dropdown': function(e, dropdown) {
417
418                    var h = $this.dropdown.dropdown.outerHeight(true);
419
420                    $this.dropdown.element.removeClass('uk-open');
421
422                    $this.overlay.stop().css('display', 'block').animate({height: h}, $this.options.duration, function() {
423
424                       $this.dropdown.dropdown.css('visibility', '');
425                       $this.dropdown.element.addClass('uk-open');
426
427                       UI.Utils.checkDisplay($this.dropdown.dropdown, true);
428                    });
429
430                    $this.pointerleave = false;
431                },
432
433                'hide.uk.dropdown': function() {
434                    $this.overlay.stop().animate({height: 0}, $this.options.duration);
435                },
436
437                'pointerenter.uk.dropdown': function(e, dropdown) {
438                    clearTimeout($this.remainIdle);
439                },
440
441                'pointerleave.uk.dropdown': function(e, dropdown) {
442                    $this.pointerleave = true;
443                }
444            });
445
446
447            this.overlay.on({
448
449                'mouseenter': function() {
450                    if ($this.remainIdle) {
451                        clearTimeout($this.dropdown.remainIdle);
452                        clearTimeout($this.remainIdle);
453                    }
454                },
455
456                'mouseleave': function(){
457
458                    if ($this.pointerleave && active) {
459
460                        $this.remainIdle = setTimeout(function() {
461                           if(active) active.hide();
462                        }, active.options.remaintime);
463                    }
464                }
465            })
466        }
467
468    });
469
470
471    function justify(ele, justifyTo, boundarywidth, offset) {
472
473        ele           = UI.$(ele);
474        justifyTo     = UI.$(justifyTo);
475        boundarywidth = boundarywidth || window.innerWidth;
476        offset        = offset || ele.offset();
477
478        if (justifyTo.length) {
479
480            var jwidth = justifyTo.outerWidth();
481
482            ele.css("min-width", jwidth);
483
484            if (UI.langdirection == 'right') {
485
486                var right1   = boundarywidth - (justifyTo.offset().left + jwidth),
487                    right2   = boundarywidth - (ele.offset().left + ele.outerWidth());
488
489                ele.css("margin-right", right1 - right2);
490
491            } else {
492                ele.css("margin-left", justifyTo.offset().left - offset.left);
493            }
494        }
495    }
496
497})(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.