PageSourceSearch

https://cm-gaviao.pt/wp-content/plugins/events-horizontal-scroll/js/events-script.js?ver=1.0.0

js cm-gaviao.pt collected 2026-10-02 12:11:09 UTC 3,338 bytes, 101 lines download raw bytes

1// events-script.js
2jQuery(document).ready(function($) {
3    'use strict';
4    
5    function initializeEventsScroll() {
6        const container = $('#eventsScrollContainer');
7        const scrollLeftBtn = $('.scroll-left');
8        const scrollRightBtn = $('.scroll-right');
9        
10        if (!container.length) return;
11        
12        // Configuração do scroll
13        let isDown = false;
14        let startX;
15        let scrollLeft;
16        
17        // Eventos para drag com mouse
18        container.on('mousedown', function(e) {
19            isDown = true;
20            container.addClass('active');
21            startX = e.pageX - container.offset().left;
22            scrollLeft = container.scrollLeft();
23        });
24        
25        container.on('mouseleave', function() {
26            isDown = false;
27            container.removeClass('active');
28        });
29        
30        container.on('mouseup', function() {
31            isDown = false;
32            container.removeClass('active');
33        });
34        
35        container.on('mousemove', function(e) {
36            if (!isDown) return;
37            e.preventDefault();
38            const x = e.pageX - container.offset().left;
39            const walk = (x - startX) * 2;
40            container.scrollLeft(scrollLeft - walk);
41        });
42        
43        // Eventos para touch (mobile)
44        container.on('touchstart', function(e) {
45            isDown = true;
46            startX = e.originalEvent.touches[0].pageX - container.offset().left;
47            scrollLeft = container.scrollLeft();
48        });
49        
50        container.on('touchmove', function(e) {
51            if (!isDown) return;
52            e.preventDefault();
53            const x = e.originalEvent.touches[0].pageX - container.offset().left;
54            const walk = (x - startX) * 2;
55            container.scrollLeft(scrollLeft - walk);
56        });
57        
58        container.on('touchend', function() {
59            isDown = false;
60        });
61        
62        // Botões de navegação
63        scrollLeftBtn.on('click', function() {
64            container.animate({
65                scrollLeft: container.scrollLeft() - 350
66            }, 300);
67        });
68        
69        scrollRightBtn.on('click', function() {
70            container.animate({
71                scrollLeft: container.scrollLeft() + 350
72            }, 300);
73        });
74        
75        // Mostrar/ocultar botões baseado na posição do scroll
76        function updateScrollButtons() {
77            const scrollLeft = container.scrollLeft();
78            const maxScrollLeft = container[0].scrollWidth - container[0].clientWidth;
79            
80            scrollLeftBtn.toggle(scrollLeft > 0);
81            scrollRightBtn.toggle(scrollLeft < maxScrollLeft - 5); // Margem de erro
82        }
83        
84        // Atualizar botões no scroll
85        container.on('scroll', updateScrollButtons);
86        
87        // Atualizar botões no resize da janela
88        $(window).on('resize', updateScrollButtons);
89        
90        // Inicializar visibilidade dos botões
91        updateScrollButtons();
92    }
93    
94    // Inicializar quando o documento estiver pronto
95    initializeEventsScroll();
96    
97    // Re-inicializar se houver conteúdo carregado via AJAX
98    $(document).on('ajaxComplete', function() {
99        setTimeout(initializeEventsScroll, 100);
100    });
101});

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.