PageSourceSearch

https://www.cuevadecastilla.be/wp-content/plugins/sticky-header-ef…/assets/js/she-header.js?ver=2.2.3

js cuevadecastilla.be collected 2026-09-26 19:51:30 UTC 23,188 bytes, 575 lines download raw bytes

1var $j = jQuery.noConflict();
2
3$j(document).ready(function () {
4    "use strict";
5    // She header
6    sheHeader();
7
8    // Anchor scroll offset — keep in-page links clear of the sticky header.
9    sheAnchorOffset();
10
11    // Back to Top button — inject + wire its own scroll/click handlers.
12    sheBackToTop();
13
14    // Debounce resize: sheHeader() re-runs the full per-header setup and
15    // rebinds every scroll listener, so firing it on every resize pixel is
16    // wasteful (and janky on devices that stream resize events). Run it once
17    // the resize settles instead.
18    var sheResizeTimer;
19    $j(window).on('resize', function (e) {
20        clearTimeout(sheResizeTimer);
21        sheResizeTimer = setTimeout(function () {
22            sheHeader(e);
23            sheAnchorOffset();
24        }, 150);
25    });
26
27    // The header height changes as it shrinks / becomes sticky, so keep the
28    // anchor offset in sync on scroll. rAF-throttled and cheap: it reads one
29    // height and sets one CSS property.
30    var sheAnchorTicking = false;
31    $j(window).on('scroll', function () {
32        if (!sheAnchorTicking) {
33            sheAnchorTicking = true;
34            window.requestAnimationFrame(function () {
35                sheAnchorOffset();
36                sheAnchorTicking = false;
37            });
38        }
39    });
40});
41
42
43/* ==============================================
44HEADER EFFECTS
45============================================== */
46
47
48function sheHeader(e) {
49
50    // Iterate each sticky header independently so that multiple sticky headers
51    // each use their OWN settings/scroll-distance instead of all sharing the
52    // first matched header's settings (the "sticks too early" group bug).
53    $j('.elementor-element.she-header-yes').each(function (sheIndex) {
54
55    var header = $j(this),
56        container = header.find('.elementor-container').add(header.filter('.e-con')),
57        header_elementor = header.closest('.elementor-edit-mode').length ? header : $j(),
58        header_logo = header.find('.elementor-widget-theme-site-logo img:not(.elementor-widget-n-menu img), .elementor-widget-image img:not(.elementor-widget-n-menu img)'),
59        header_logo_div = header.find('.elementor-widget-theme-site-logo a, .elementor-widget-image a'),
60        data_settings = header.data('settings');
61
62    if (typeof data_settings != 'undefined') {
63        var responsive_settings = data_settings["transparent_on"];
64        var width = $j(window).width(),
65            header_height = header.height(),
66            logo_width = header_logo.width(),
67            logo_height = header_logo.height();
68    }
69
70    // Check responsive is enabled
71    if (typeof width != 'undefined' && width) {
72        if (width >= 1025) {
73            var enabled = "desktop";
74        } else if (width > 767 && width < 1025) {
75            var enabled = "tablet";
76        } else if (width <= 767) {
77            var enabled = "mobile";
78        }
79    }
80
81    if ($j.inArray(enabled, responsive_settings) !== -1) {
82
83        var scroll_distance = data_settings["scroll_distance"];
84        var she_offset = data_settings["she_offset_top"];
85        var she_padding = data_settings["she_padding"];
86        var she_width = data_settings["she_width"];
87        var transparent_header = data_settings["transparent_header_show"];
88        var background = data_settings["background"];
89        var bottom_border_color = data_settings["custom_bottom_border_color"],
90            bottom_border_view = data_settings["bottom_border"],
91            bottom_border_width = data_settings["custom_bottom_border_width"];
92
93        var shrink_header = data_settings["shrink_header"],
94            data_height = data_settings["custom_height_header"],
95            data_height_tablet = data_settings["custom_height_header_tablet"],
96            data_height_mobile = data_settings["custom_height_header_mobile"];
97
98        var shrink_logo = data_settings["shrink_header_logo"],
99            data_logo_height = data_settings["custom_height_header_logo"],
100            data_logo_height_tablet = data_settings["custom_height_header_logo_tablet"],
101            data_logo_height_mobile = data_settings["custom_height_header_logo_mobile"];
102
103        var change_logo_color = data_settings["change_logo_color"];
104
105        var blur_bg = data_settings["blur_bg"];
106
107        var scroll_distance_hide_header = data_settings["scroll_distance_hide_header"];
108
109        // offset
110        if (width >= 1025) {
111            she_offset = data_settings["she_offset_top"];
112            she_padding = data_settings["she_padding"];
113            she_width = data_settings["she_width"];
114        } else if (width > 767 && width < 1025) {
115            she_offset = data_settings["she_offset_top_tablet"];
116            she_padding = data_settings["she_padding_tablet"];
117            she_width = data_settings["she_width_tablet"];
118        } else if (width <= 767) {
119            she_offset = data_settings["she_offset_top_mobile"];
120            she_padding = data_settings["she_padding_mobile"];
121            she_width = data_settings["she_width_mobile"];
122        }
123
124        if (header.hasClass("she-header")) {
125            if( e?.type === 'resize' ){
126                header.css("width", she_width.size + she_width.unit);
127                header.css("padding-top", she_padding.top + she_padding.unit);
128                header.css("padding-bottom", she_padding.bottom + she_padding.unit);
129                header.css("padding-left", she_padding.left + she_padding.unit);
130                header.css("padding-right", she_padding.right + she_padding.unit);
131            }
132        }
133
134        // add transparent class
135        if (transparent_header == "yes") {
136            header.addClass('she-header-transparent-yes');
137        }
138
139        // header height shrink
140        if (typeof data_height != "undefined" && data_height) {
141            if (width >= 1025) {
142                var shrink_height = data_height["size"];
143            } else if (width > 767 && width < 1025) {
144                var shrink_height = data_height_tablet["size"];
145                if (shrink_height == "") {
146                    shrink_height = data_height["size"];
147                }
148            } else if (width <= 767) {
149                var shrink_height = data_height_mobile["size"];
150                if (shrink_height == "") {
151                    shrink_height = data_height["size"];
152                }
153            }
154        }
155
156        // Logo height shrink
157        if (
158            typeof data_logo_height != "undefined" &&
159            data_logo_height
160        ) {
161            if (width >= 1025) {
162                var shrink_logo_height = data_logo_height["size"];
163            } else if (width > 767 && width < 1025) {
164                var shrink_logo_height =
165                    data_logo_height_tablet["size"];
166            } else if (width <= 767) {
167                var shrink_logo_height =
168                    data_logo_height_mobile["size"];
169            }
170
171            //Calc New width and height
172            if (shrink_logo_height == "") {
173                //Get logo shrink settings from desktop
174                shrink_logo_height = data_logo_height["size"];
175
176                if (shrink_logo_height == "") {
177                    // Shrink same settings from height shrink option
178                    shrink_logo_height = shrink_height;
179
180                    var percent =
181                        parseInt(shrink_logo_height) /
182                        parseInt(header_height),
183                        width_l = logo_width * percent,
184                        height_l = logo_height * percent;
185                } else {
186                    var width_l =
187                        (logo_width * shrink_logo_height) / 100,
188                        height_l =
189                            (logo_height * shrink_logo_height) / 100;
190                }
191            } else {
192                //Get logo shrink settings from the responsive option
193                var width_l = (logo_width * shrink_logo_height) / 100,
194                    height_l = (logo_height * shrink_logo_height) / 100;
195            }
196        }
197
198        // border bottom
199        if (typeof bottom_border_width != 'undefined' && bottom_border_width) {
200            var bottom_border = bottom_border_width["size"] + "px solid " + bottom_border_color;
201        }
202
203        // hide header on scroll
204        if (
205            typeof scroll_distance_hide_header != "undefined" &&
206            scroll_distance_hide_header
207        ) {
208            var mywindow = $j(window),
209                mypos = mywindow.scrollTop();
210
211            mywindow.off('scroll.sheHide' + sheIndex).on('scroll.sheHide' + sheIndex, function () {
212                var sd_hh_s = scroll_distance_hide_header["size"],
213                    sd_hh_u = scroll_distance_hide_header["unit"],
214                    sd_hh_tablet =
215                        data_settings[
216                        "scroll_distance_hide_header_tablet"
217                        ],
218                    sd_hh_tablet_s = sd_hh_tablet["size"],
219                    sd_hh_tablet_u = sd_hh_tablet["unit"],
220                    sd_hh_mobile =
221                        data_settings[
222                        "scroll_distance_hide_header_mobile"
223                        ],
224                    sd_hh_mobile_s = sd_hh_mobile["size"],
225                    sd_hh_mobile_u = sd_hh_mobile["unit"];
226
227                // get responsive view
228                if (
229                    typeof scroll_distance_hide_header != "undefined" &&
230                    scroll_distance_hide_header
231                ) {
232                    if (width >= 1025) {
233                        var sd_hh = sd_hh_s,
234                            sd_hh_u = sd_hh_u;
235                        // calc sise for vh unit
236                        if (sd_hh_u == "vh") {
237                            sd_hh = window.innerHeight * (sd_hh / 100);
238                        }
239                    } else if (width > 767 && width < 1025) {
240                        var sd_hh = sd_hh_tablet_s,
241                            sd_hh_u = sd_hh_tablet_u;
242
243                        if (sd_hh == "") {
244                            sd_hh = sd_hh_s;
245                        }
246                        // calc sise for vh unit
247                        if (sd_hh_u == "vh") {
248                            sd_hh = window.innerHeight * (sd_hh / 100);
249                        }
250                    } else if (width <= 767) {
251                        var sd_hh = sd_hh_mobile_s,
252                            sd_hh_u = sd_hh_mobile_u;
253
254                        if (sd_hh == "") {
255                            sd_hh = sd_hh_s;
256                        }
257                        // calc sise for vh unit
258                        if (sd_hh_u == "vh") {
259                            sd_hh = window.innerHeight * (sd_hh / 100);
260                        }
261                    }
262                }
263
264                if (mypos > sd_hh) {
265                    if (mywindow.scrollTop() > mypos) {
266                        header.addClass("headerup");
267                    } else {
268                        header.removeClass("headerup");
269                    }
270                }
271                mypos = mywindow.scrollTop();
272            });
273        }
274
275        // scroll function — throttled with requestAnimationFrame so the
276        // heavy per-property style writes below run at most once per frame.
277        var she_scroll_ticking = false;
278        $j(window).off("load.sheScroll" + sheIndex + " scroll.sheScroll" + sheIndex).on("load.sheScroll" + sheIndex + " scroll.sheScroll" + sheIndex, function (e) {
279            if (she_scroll_ticking) {
280                return;
281            }
282            she_scroll_ticking = true;
283            requestAnimationFrame(function () {
284                she_scroll_ticking = false;
285            var scroll = $j(window).scrollTop();
286
287            if (header_elementor.length) {
288                header_elementor.css("position", "relative");
289            }
290
291            var sd_s = scroll_distance["size"],
292                sd_u = scroll_distance["unit"],
293                sd_tablet = data_settings["scroll_distance_tablet"],
294                sd_tablet_s = sd_tablet["size"],
295                sd_tablet_u = sd_tablet["unit"],
296                sd_mobile = data_settings["scroll_distance_mobile"],
297                sd_mobile_s = sd_mobile["size"],
298                sd_mobile_u = sd_mobile["unit"];
299
300            // get responsive view
301            if (
302                typeof scroll_distance != "undefined" &&
303                scroll_distance
304            ) {
305                if (width >= 1025) {
306                    var sd = sd_s,
307                        sd_u = sd_u;
308                    // calc sise for vh unit
309                    if (sd_u == "vh") {
310                        sd = window.innerHeight * (sd / 100);
311                    }
312                } else if (width > 767 && width < 1025) {
313                    var sd = sd_tablet_s,
314                        sd_u = sd_tablet_u;
315
316                    if (sd == "") {
317                        sd = sd_s;
318                    }
319                    // calc sise for vh unit
320                    if (sd_u == "vh") {
321                        sd = window.innerHeight * (sd / 100);
322                    }
323                } else if (width <= 767) {
324                    var sd = sd_mobile_s,
325                        sd_u = sd_mobile_u;
326
327                    if (sd == "") {
328                        sd = sd_s;
329                    }
330                    // calc sise for vh unit
331                    if (sd_u == "vh") {
332                        sd = window.innerHeight * (sd / 100);
333                    }
334                }
335            }
336
337            if (scroll >= sd) {
338                header.removeClass('header').addClass("she-header");
339                header.css("background-color", background);
340                header.css("border-bottom", bottom_border);
341
342                // Multi-Sticky (Pro) manages its own top / width / padding via a
343                // placeholder spacer. Skip Free's geometry writes for those
344                // containers so the two don't fight (cosmetic background/border
345                // above still apply). Pure-Free headers have no
346                // data-she-multi-mode attribute and get the full treatment.
347                if (!header.attr("data-she-multi-mode")) {
348                    header.css("top", she_offset.size + she_offset.unit);
349
350                    if (width >= 783 && document.body.classList.contains('admin-bar')) {
351                        if (she_offset.unit === 'px') {
352                            header.css("top", (32 + she_offset.size) + "px");
353                        } else {
354                            header.css("top", "calc(32px + " + she_offset.size + she_offset.unit + ")");
355                        }
356                    }
357
358                    header.css("padding-top", she_padding.top + she_padding.unit);
359                    header.css("padding-bottom", she_padding.bottom + she_padding.unit);
360                    header.css("padding-left", she_padding.left + she_padding.unit);
361                    header.css("padding-right", she_padding.right + she_padding.unit);
362                    header.css("width", she_width.size + she_width.unit);
363                }
364
365                header.removeClass('she-header-transparent-yes');
366
367                if (shrink_header == "yes") {
368                    header.css({ "padding-top": "0", "padding-bottom": "0", "margin-top": "0", "margin-bottom": "0" });
369                    container.css({ "min-height": shrink_height, "transition": "all 0.4s ease-in-out", "
369-webkit-transition": "all 0.4s ease-in-out", "-moz-transition": "all 0.4s ease-in-out" });
370                }
371
372                if (change_logo_color == "yes") {
373                    header_logo.addClass("change-logo-color");
374                }
375
376                // ---------------------------------- SHRINK LOGO
377                if (shrink_logo == "yes") {
378                    header_logo.css({
379                        width: width_l,
380                        transition: "all 0.4s ease-in-out",
381                        "-webkit-transition": "all 0.4s ease-in-out",
382                        "-moz-transition": "all 0.4s ease-in-out",
383                    });
384                }
385
386            } else {
387                header.removeClass("she-header").addClass('header');
388                header.css("background-color", "");
389                header.css("border-bottom", "");
390                if (!header.attr("data-she-multi-mode")) {
391                    header.css("top", "");
392                    header.css("padding-top", "");
393                    header.css("padding-bottom", "");
394                    header.css("padding-left", "");
395                    header.css("padding-right", "");
396                    header.css("width", "");
397                }
398
399                if (transparent_header == "yes") {
400                    header.addClass('she-header-transparent-yes');
401                }
402                if (shrink_header == "yes") {
403                    header.css({ "padding-top": "", "padding-bottom": "", "margin-top": "", "margin-bottom": "" });
404                    container.css("min-height", "");
405                }
406
407                // ---------------------------------- SHRINK LOGO
408                if (shrink_logo == "yes") {
409                    header_logo.css({ height: "", width: "" });
410                }
411
412                if (change_logo_color == "yes") {
413                    header_logo.removeClass("change-logo-color");
414
415                }
416
417            }
418
419
420            }); // end requestAnimationFrame
421        });
422    }
423
424    }); // end .each — per sticky-header iteration
425
426};
427
428
429/* ==============================================
430ANCHOR SCROLL OFFSET
431Keeps in-page anchor links (and keyboard focus) clear of the sticky header by
432setting scroll-padding-top on <html> to the live header height. Using the CSS
433scroll-padding mechanism means native #anchor jumps, scrollIntoView() and
434focus scrolling all respect the offset — no click interception needed.
435============================================== */
436function sheAnchorOffset() {
437    var html = document.documentElement;
438
439    // First sticky header that has the anchor-offset option enabled.
440    var $header = $j('.elementor-element.she-header-yes').filter(function () {
441        var s = $j(this).data('settings') || {};
442        return s.she_anchor_offset === 'yes';
443    }).first();
444
445    if (!$header.length) {
446        // Feature off (or no such header) — clear anything we may have set.
447        html.style.scrollPaddingTop = '';
448        html.style.scrollBehavior = '';
449        return;
450    }
451
452    var s = $header.data('settings') || {};
453
454    // Extra offset (SLIDER → { size, unit }).
455    var extra = 0;
456    if (s.she_anchor_offset_extra && s.she_anchor_offset_extra.size !== '' && typeof s.she_anchor_offset_extra.size !== 'undefined') {
457        extra = parseFloat(s.she_anchor_offset_extra.size) || 0;
458    }
459
460    var headerHeight = $header.outerHeight() || 0;
461    html.style.scrollPaddingTop = (headerHeight + extra) + 'px';
462
463    // Smooth scroll — honour the visitor's reduced-motion preference.
464    var prefersReduced = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
465    if (s.she_anchor_smooth === 'yes' && !prefersReduced) {
466        html.style.scrollBehavior = 'smooth';
467    } else {
468        html.style.scrollBehavior = '';
469    }
470}
471
472
473/* ==============================================
474BACK TO TOP BUTTON
475Injects a floating button into <body> (NOT the header) that appears after a
476configurable scroll distance and scrolls back to the top on click. It must live
477in <body>, not inside the header: a position:fixed element is positioned
478relative to any ancestor that has a transform, and the header frequently gets
479one (e.g. .headerup's translateY when Hide-on-scroll-down is active), which
480would drag the button off-screen. Styling is read from the element settings and
481applied inline, since the button is outside the Elementor wrapper.
482============================================== */
483function sheBackToTop() {
484    if (document.querySelector('.she-totop-btn')) {
485        return; // already injected.
486    }
487
488    // First sticky header that has the Back to Top option enabled.
489    var $header = $j('.elementor-element.she-header-yes').filter(function () {
490        var s = $j(this).data('settings') || {};
491        return s.she_totop_enable === 'yes';
492    }).first();
493
494    if (!$header.length) {
495        return;
496    }
497
498    var s = $header.data('settings') || {};
499
500    // Scroll distance before the button appears (SLIDER → { size, unit }).
501    var threshold = sheSliderNum(s.she_totop_display_after, 300);
502
503    var btn = document.createElement('button');
504    btn.type = 'button';
505    btn.className = 'she-totop-btn';
506    btn.setAttribute('aria-label', 'Back to top');
507    btn.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
507<path d="M12 8.29l-6.29 6.3 1.41 1.41L12 11.12l4.88 4.88 1.41-1.41z"></path></svg>';
508
509    // Inline styling (button lives in <body>, so Elementor selectors can't
510    // reach it — mirror the announcement bar's approach).
511    var offset = sheSliderNum(s.she_totop_offset, 24);
512    btn.style.bottom = offset + 'px';
513    if (s.she_totop_position === 'left') {
514        btn.style.left = offset + 'px';
515        btn.style.right = 'auto';
516    } else {
517        btn.style.right = offset + 'px';
518        btn.style.left = 'auto';
519    }
520
521    var size = sheSliderNum(s.she_totop_size, 44);
522    btn.style.width = size + 'px';
523    btn.style.height = size + 'px';
524
525    if (s.she_totop_radius && s.she_totop_radius.size !== '' && typeof s.she_totop_radius.size !== 'undefined') {
526        btn.style.borderRadius = s.she_totop_radius.size + ( s.she_totop_radius.unit || 'px' );
527    }
528    if (s.she_totop_bg) {
529        btn.style.backgroundColor = s.she_totop_bg;
530    }
531    if (s.she_totop_icon_color) {
532        btn.style.color = s.she_totop_icon_color;
533    }
534    if (s.she_totop_bg_hover) {
535        btn.style.setProperty('--she-totop-hover', s.she_totop_bg_hover);
536    }
537
538    document.body.appendChild(btn);
539
540    btn.addEventListener('click', function () {
541        var prefersReduced = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
542        window.scrollTo({ top: 0, behavior: prefersReduced ? 'auto' : 'smooth' });
543    });
544
545    var ticking = false;
546    function toggle() {
547        var y = window.pageYOffset || document.documentElement.scrollTop;
548        if (y > threshold) {
549            btn.classList.add('she-totop-visible');
550        } else {
551            btn.classList.remove('she-totop-visible');
552        }
553        ticking = false;
554    }
555
556    $j(window).on('scroll', function () {
557        if (!ticking) {
558            ticking = true;
559            window.requestAnimationFrame(toggle);
560        }
561    });
562
563    toggle(); // set initial state (e.g. page loaded already scrolled down).
564}
565
566// Read an Elementor SLIDER value ({ size, unit }) as a number, with a fallback.
567function sheSliderNum(ctrl, fallback) {
568    if (ctrl && ctrl.size !== '' && typeof ctrl.size !== 'undefined') {
569        var n = parseFloat(ctrl.size);
570        if (!isNaN(n)) {
571            return n;
572        }
573    }
574    return fallback;
575}

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.