PageSourceSearch

https://elarrebato.es/wp-content/themes/minisites/assets/js/events.js?v=1.0.2

js elarrebato.es collected 2026-09-26 21:00:40 UTC 7,171 bytes, 238 lines download raw bytes

1$('.menu-burger, .menu-items').on('click', function () {
2    $('.menu-bg, .menu-items, .menu-burger').toggleClass('fs');
3    $('.menu-burger').text() == "☰" ? $('.menu-burger').text('✕') : $('.menu-burger').text('☰');
4});
5
6$(".box-video:not(.box-foto)").click(function () {
7    $('iframe', this)[0].src += "&autoplay=1";
8    $(this).addClass('open');
9});
10
11$(".box-foto").click(function () {
12    var padre = $(this).parent().parent()
13    $(padre).find(".gallery_block").fadeIn(function () {
14        if (!$('.carrusel', padre).is(".slick-initialized")) {
15            $('.carrusel', padre).slick({
16                slidesToShow: 1,
17                slidesToScroll: 1,
18                arrows: true,
19                autoplay: false,
20                dots: true,
21                adaptiveHeight: true
22            });
23        }
24        $('.cerrar', padre).click(function () {
25            $('.gallery_block', padre).fadeOut()
26        })
27    })
28})
29
30
31$(document).ready(function () {
32
33    $(".navbarWhite").scroll(function () {
34
35        if ($(this).scrollTop() > 10) {
36
37            $('.navbarWhite').fadeIn();
38
39        } else {
40
41            $('.navbarWhite').fadeOut();
42
43        }
44
45    });
46
47    if ($(window).width() > 700) {
48
49        $(".bloqshop").each(function (index) {
50            bgDesk = $(this).attr('data-desk');
51            $(this).css("background-image", "url(" + bgDesk + ")");
52            //$(this).css("background-size", "cover");
53        });
54
55        // bgDesk = $('.bloqshop').attr('data-desk');
56        // $('.bloqshop').css("background-image", "url("+bgDesk+")");
57        // $('.bloqshop').css("background-size", "cover");
58
59    } else {
60
61        $(".bloqshop").each(function (index) {
62            bgMov = $(this).attr('data-mov');
63            if (bgMov != undefined && bgMov != '') {
64                $(this).css("background-image", "url(" + bgMov + ")");
65                //$(this).css("background-size", "cover");
66            } else {
67                bgDesk = $(this).attr('data-desk');
68                $(this).css("background-image", "url(" + bgDesk + ")");
69                //$(this).css("background-size", "cover"); 
70            }
71        });
72
73    }
74
75});
76
77$(document).ready(
78
79    function () {
80
81        // Comprobar si estamos, al menos, 100 px por debajo de la posición top
82        // para mostrar o esconder el botón
83        $(window).scroll(function () {
84
85            if ($(this).scrollTop() > 30) {
86
87                $('.navbarWhite').addClass("navfixed");
88                $('.contentmenu').addClass("navfixed");
89
90            } else {
91
92                $('.navbarWhite').removeClass("navfixed");
93                $('.contentmenu').removeClass("navfixed");
94            }
95
96        });
97
98        //
99        var currentBckPositionV = '';
100        if (($(window).width() < $(window).height()) &&
101            ($(window).width() <= 812)
102        ) {
103            currentBckPositionV = $('.headMobile').css('background-position');
104        }
105        $(window).on('load resize', function () {
106            if ($(window).width() > $(window).height()) {
107                // el ancho es mayor al alto entonces el dispositivo está en horizontal
108                $('.headMobile').css({ "background-image": "url('" + $('.headMobile').data('imgd') + "')" });
109                $('.headMobile').css({ 'background-position': 'center 0px' });
110            } else {
111                // el ancho no es mayor al alto entonces el dispositivo está en vertical
112                $('.headMobile').css({ "background-image": "url('" + $('.headMobile').data('imgm') + "')" });
113                if (currentBckPositionV != '') {
114                    $('.headMobile').css({ 'background-position': currentBckPositionV });
115                }
116            }
117        });
118
119
120    });
121
122//Color border form
123var color = $('.colorForm').attr('data-color');
124var fuente = $('.colorForm').attr('data-font');
125var colorBoton = $('.colorForm').attr('data-color-button');
126
127$('form input').css('border-color', color);
128$('form input').css('color', fuente);
129$('form textarea').css('border-color', color);
130$('form textarea').css('color', fuente);
131$('form label').css('color', fuente);
132$('form .btn-lg-yellow').removeAttr('style');
133$('form .btn-lg-yellow').css('background', color);
134$('form .btn-lg-yellow').css('color', '#'.colorBoton);
135$('form .btn-lg-yellow').addClass(colorBoton);
136
137var now = new Date();
138$('.datadate').each(function (index, val) {
139    isoFormatDateString = $(this).data('date');
140    var dateParts = isoFormatDateString.split("-");
141    var jsDate = new Date(dateParts[0], dateParts[1] - 1, dateParts[2].substr(0, 2));
142
143    if (jsDate < now) {
144        jQuery.ajax({
145            'type': 'POST',
146            'dataType': "json",
147            'url': ajaxurl,
148            'data': { action: "delCacheEvents" },
149            'cache': false,
150            'success': function (data) {
151                console.log('del cache');
152            }
153        });
154    }
155
156});
157
158$(document).on('click', '.imageHome', function () {
159    var ulrExterna = $(this).attr('url-externa');
160    if (ulrExterna) {
161        window.open(ulrExterna, 'FESBAL Federación Española de Bancos de Alimentos');
162    }
163
164});
165
166$(document).ready(function () {
167    if ($("#popupHome").length > 0) {
168        $('.modal-img').modal('show');
169    }
170});
171
172
173/* aplicar aspect ratio */
174$(document).ready(function () {
175    if ($(window).width() >= 768) {
176        updateBannerAspectRatio();
177    }
178
179    // Vuelve a verificar si cambia el tamaño de la pantalla
180    $(window).on("resize", function () {
181        if ($(window).width() >= 768) {
182            updateBannerAspectRatio();
183        }
184    });
185});
186
187/**
188 * Función principal que ejecuta el ajuste de aspect-ratio.
189 */
190function updateBannerAspectRatio() {
191    const $banner = $(".banner-img.imageHome");
192
193    if ($banner.length) {
194        const imageUrl = getBackgroundImageUrl($banner);
195        if (imageUrl) {
196            loadImage(imageUrl, function (img) {
197                applyAspectRatio($banner, img);
198            });
199        }
200    }
201}
202
203/**
204 * Extrae la URL de la imagen de fondo de un elemento.
205 * @param {jQuery} $element - El elemento con background-image.
206 * @returns {string|null} - La URL de la imagen o null si no se encuentra.
207 */
208function getBackgroundImageUrl($element) {
209    const backgroundImage = $element.css("background-image");
210    const urlMatch = backgroundImage.match(/url\(["']?(.*?)["']?\)/);
211    return urlMatch ? urlMatch[1] : null;
212}
213
214/**
215 * Carga una imagen y ejecuta una función de callback cuando se carga.
216 * @param {string} url - La URL de la imagen.
217 * @param {Function} callback - Función a ejecutar cuando la imagen se carga.
218 */
219function loadImage(url, callback) {
220    const img = new Image();
221    img.src = url;
222    $(img).on("load", function () {
223        callback(img);
224    });
225}
226
227/**
228 * Aplica el aspect-ratio basado en la imagen cargada.
229 * @param {jQuery} $element - El elemento al que se aplicará el aspect-ratio.
230 * @param {HTMLImageElement} img - La imagen cargada.
231 */
232function applyAspectRatio($element, img) {
233    const aspectRatio = `${img.width} / ${img.height}`;
234    $element.css({
235        "min-height": "unset",
236        "aspect-ratio": aspectRatio
237    });
238}

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.