PageSourceSearch

https://www.mineduc.gob.gt/mineduc/templates/mineduc/js/category_template.js?v-1

js mineduc.gob.gt collected 2026-09-24 09:01:49 UTC 5,723 bytes, 168 lines download raw bytes

1window.addEventListener('load', function () {
2    insertFinderCategoria();
3    init();
4    document.querySelectorAll('.content-menu').forEach(menu => {
5        menu.addEventListener('click', function(event) {
6            // Verificar si se hizo clic en un `li` que contiene un `ul`
7            const clickedLi = event.target.closest('li');
8            if (clickedLi && clickedLi.querySelector('ul')) {
9                // Alternar la clase `activa` del elemento clicado
10                clickedLi.querySelector('ul').classList.toggle('activo');
11            }
12        });
13    });
14});
15
16function init() {
17    let toolTimeline = new TimelineMax();
18    let duration = .9;
19    toolTimeline.from('h1', duration, {
20        opacity: 0,
21        // scale:10,
22        ease: Linear.easeIn
23    }, .8)
24    toolTimeline.staggerFrom('.boxes__box', duration, {
25        opacity: 0,
26        scale: 0,
27        ease: Back.easeInOut
28    }, .1, .2);
29
30    toolTimeline.to('.boxes img', duration, {
31        opacity: 1,
32        right: 0,
33        ease: Back.easeOut
34    }, .4);
35
36    toolTimeline.staggerTo('li', duration, {
37        top: 0,
38        ease: Back.easeOut
39    }, .1, .9);
40
41};
42
43function insertFinderCategoria() {
44    const finder = document.querySelector('#categoryFinder');
45    if (!finder) return;
46    // Limpia el texto del encabezado y compara en minúsculas sin espacios
47    const blog = document.querySelector(".com-content-category-blog");
48    if (blog) {     
49        blog.parentNode.className += " gridBlog";         
50        blog.parentNode.insertBefore(finder, blog.parentNode.firstChild);
51        finder.style.display= "flex"
52    }
53
54}
55
56function insertBannerIncategoria() {
57    // Detecta si estamos en un artículo
58    const categoryRaw = localStorage.getItem("currentCategory");
59    if (!categoryRaw) return;
60
61    const categoryContent = JSON.parse(categoryRaw);
62
63    if (!categoryContent.View || categoryContent.View !== "article") return;
64
65    // Obtiene la imagen del artículo
66    const params = JSON.parse(categoryContent.params || "{}");
67    const imageUrl = params.image || params.image_fulltext || params.image_intro;
68    if (!imageUrl) return; // No hace nada si no hay imagen
69
70    // Selecciona el banner original del template
71    const originalBanner = document.querySelector(".hero");
72    if (!originalBanner) return;
73
74    // Crea el nuevo banner usando htmlBanner
75    const newBanner = htmlBanner(categoryContent.Category, [imageUrl]);
76
77    // Copia las clases del banner original para mantener estilos y ancho
78    newBanner.className = originalBanner.className;
79
80    // Reemplaza el banner original por el nuevo
81    originalBanner.parentNode.replaceChild(newBanner, originalBanner);
82
83    // Opcional: fuerza que la imagen ocupe todo el ancho
84    const img = newBanner.querySelector("img");
85    if (img) {
86        img.style.width = "100%";
87        img.style.height = "auto";
88        img.style.objectFit = "cover";
89    }
90}
91
92const htmlBanner = (header, imagenes) => {
93    const banner = document.createElement("div");
94    banner.className = "hero";
95    banner.innerHTML = `<div class="hero__item">
96      <h1 class="title">${header}</h1>
97    </div>
98    <div class="hero__item">
99      <div class="boxes">
100        <div>${imagenes ? imagenes.map(image => `<img src="${image}" alt="encabezado de pagina">`).join() : ""}</div>
101        <div class="boxes__box"></div>
102        <div class="boxes__box"></div>
103        <div class="boxes__box"></div>
104        <div class="boxes__box"></div>
105        <div class="boxes__box"></div>
106        <div class="boxes__box"></div>
107      </div>
108    </div>`;
109    return banner;
110}
111
112const PageType = {
113    A4: "A4",
114    A4_HORIZONTAL: "A4-horizontal",
115    CARTA: "carta",
116    CARTA_HORIZONTAL: "carta-horizontal",
117    OFICIO: "oficio",
118    OFICIO_HORIZONTAL: "oficio-horizontal"
119}
120const printA4Template = ()=>{
121    const template = document.querySelector("#a4template");
122    ExportPdf(template, PageType.A4_HORIZONTAL);
123
124}
125const ExportPdf = (body, pagetype = PageType.A4) => {
126    const options = {
127        margin: 0,
128        filename: `filename_${new Date()}.pdf`,
129        image: { type: 'jpeg', quality: 1.0 },
130        html2canvas: {
131            scrollX: 0,
132            scrollY: 0, scale: 4, logging: true, dpi: 192, letterRendering: true
133        },
134        jsPDF: { unit: 'cm', format: 'a4', orientation: 'portrait' }
135    };
136    // Cambiar las configuraciones según el tipo de página
137    switch (pagetype) {
138        case PageType.A4:
139            options.jsPDF.format = 'a4';
140            options.jsPDF.orientation = 'portrait';  // A4 en orientación vertical
141            break;
142        case PageType.A4_HORIZONTAL:
143            options.jsPDF.format = 'a4';
144            options.jsPDF.orientation = 'landscape';  // A4 en orientación horizontal
145            break;
146        case PageType.CARTA:
147            options.jsPDF.format = 'letter'; // Carta en formato vertical
148            options.jsPDF.orientation = 'portrait';
149            break;
150        case PageType.CARTA_HORIZONTAL:
151            options.jsPDF.format = 'letter';
152            options.jsPDF.orientation = 'landscape'; // Carta en formato horizontal
153            break;
154        case PageType.OFICIO:
155            options.jsPDF.format = 'legal'; // Oficio en formato vertical
156            options.jsPDF.orientation = 'portrait';
157            break;
158        case PageType.OFICIO_HORIZONTAL:
159            options.jsPDF.format = 'legal';
160            options.jsPDF.orientation = 'landscape'; // Oficio en formato horizontal
161            break;
162        default:
163            options.jsPDF.format = 'a4'; // Por defecto usar A4
164            options.jsPDF.orientation = 'portrait';
165    }
166    // @ts-ignore
167    html2pdf().set(options).from(body).save();
168}

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.