PageSourceSearch

https://www.druni.pt/blog/wp-content/plugins/colabwp/assets/js/colabwp-filters.js?ver=2.3

js druni.pt collected 2026-10-04 10:47:38 UTC 3,501 bytes, 111 lines download raw bytes

1// Archivo: assets/js/colabwp-filters.js
2jQuery(document).ready(function($) {
3    // Solo ejecutar si existen los elementos del filtro
4    if (!$('.colabwp-filter-container').length) {
5        return;
6    }
7    
8    // Obtener traducciones
9    var i18n = window.colabwp_filters_i18n || {
10        show_less: 'Show less',
11        plus: '+'
12    };
13    
14    var $filterTags = $(".colabwp-filter-tag");
15    var $cards = $(".colabwp-card");
16    var $noResults = $(".colabwp-no-results");
17    var $resetBtn = $(".colabwp-filter-reset");
18    var $moreBtn = $(".colabwp-filter-more");
19    var $hiddenTags = $(".colabwp-filter-hidden");
20    
21    // Mostrar/ocultar filtros extras
22    $moreBtn.on("click", function() {
23        if ($hiddenTags.is(":visible")) {
24            $hiddenTags.hide();
25            var count = $hiddenTags.length;
26            $(this).text(i18n.plus + count);
27        } else {
28            $hiddenTags.show();
29            $(this).text(i18n.show_less);
30        }
31    });
32    
33    // Click en filtros
34    $filterTags.on("click", function() {
35        var $this = $(this);
36        var category = $this.data("category");
37        
38        // Toggle active class
39        if (category === "all") {
40            $filterTags.removeClass("active");
41            $this.addClass("active");
42            $resetBtn.hide();
43        } else {
44            $filterTags.filter('[data-category="all"]').removeClass("active");
45            $this.toggleClass("active");
46            
47            // Mostrar/ocultar botón reset
48            if ($filterTags.filter(".active:not([data-category='all'])").length > 0) {
49                $resetBtn.show();
50            } else {
51                $resetBtn.hide();
52                $filterTags.filter('[data-category="all"]').addClass("active");
53            }
54        }
55        
56        // Filtrar cards
57        filterCards();
58    });
59    
60    // Botón reset
61    $resetBtn.on("click", function() {
62        $filterTags.removeClass("active");
63        $filterTags.filter('[data-category="all"]').addClass("active");
64        $(this).hide();
65        filterCards();
66    });
67    
68    // Función para filtrar cards
69    function filterCards() {
70        var activeFilters = [];
71        $filterTags.filter(".active:not([data-category='all'])").each(function() {
72            activeFilters.push($(this).data("category"));
73        });
74        
75        var visibleCount = 0;
76        
77        $cards.each(function() {
78            var $card = $(this);
79            var cardCategories = $card.data("categories").toString().split(",");
80            var shouldShow = false;
81            
82            if (activeFilters.length === 0) {
83                shouldShow = true;
84            } else {
85                // Verificar si la card tiene alguna de las categorías activas
86                for (var i = 0; i < activeFilters.length; i++) {
87                    if (cardCategories.indexOf(activeFilters[i].toString()) !== -1) {
88                        shouldShow = true;
89                        break;
90                    }
91                }
92            }
93            
94            if (shouldShow) {
95                $card.fadeIn(300);
96                visibleCount++;
97            } else {
98                $card.fadeOut(300);
99            }
100        });
101        
102        // Mostrar mensaje si no hay resultados
103        if (visibleCount === 0) {
104            setTimeout(function() {
105                $noResults.fadeIn(300);
106            }, 300);
107        } else {
108            $noResults.fadeOut(300);
109        }
110    }
111});

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.