PageSourceSearch

https://somoscooperativismo-ba.coop.br/assets/js/somoscoop/noticias.js

js somoscooperativismo-ba.coop.br collected 2026-10-08 11:00:57 UTC 7,181 bytes, 214 lines download raw bytes

1$ = jQuery.noConflict();
2
3$(document).ready(function () {
4
5    chamarCSS();
6    reposicionarItemsArtigo();
7    reposicionarItensMeta();
8    //removerPontosFinalTexto();
9    //incluirTagPublicacoes();
10    incluirImagemPadrao();
11    limitarSubtitulosNoticias();
12
13    function chamarCSS() {
14        var protocolo = window.location.protocol;
15        var host = window.location.host;
16
17        var linkCss = protocolo + '//' + host + '/assets/css/somoscoop/noticias.css';
18
19        $('head').append('<link rel="stylesheet" type="text/css" href="' + linkCss + '">');
20    }
21
22    function reposicionarItemsArtigo() {
23        $('.sppb-addon-article').each(function () {
24            var titulo = $(this).children('.sppb-article-info-wrap').children('h3');
25            var metaInfo = $(this).children('.sppb-article-info-wrap').children('.sppb-article-meta');
26            var texto = $(this).children('.sppb-article-info-wrap').children('.sppb-article-introtext');
27            var botaoLeiaMais = $(this).children('.sppb-article-info-wrap').children('.sppb-readmore');
28
29            $(this).children('.sppb-article-info-wrap').append(metaInfo, titulo, texto, botaoLeiaMais)
30
31        })
32    }
33
34    function reposicionarItensMeta() {
35        $('.sppb-article-meta').each(function () {
36            let dataPublicacao = $(this).children('.sppb-meta-date');
37            let categoriaArtigo = $(this).children('.sppb-meta-category');
38            $(this).append(categoriaArtigo, dataPublicacao);
39        })
40    }
41
42
43    /*function removerPontosFinalTexto(){
44        $('.sppb-article-introtext').each(function(){
45            let text = $(this).text()
46            let newText = text.replace('...','')
47            $(this).text(newText)
48        })
49    }*/
50
51    /*function incluirTagPublicacoes(){
52        $('.sppb-article-meta').each(function(){
53            var data = $(this).children('.sppb-meta-date[itemprop="datePublished"]').text();
54            
55            $(this).children('.sppb-meta-date[itemprop="datePublished"]').text('Publicações '+data)
56        })
57    }*/
58
59    function incluirImagemPadrao() {
60
61        $('.sppb-addon-article').each(function () {
62            var imagem = $(this).children('.sppb-article-img-wrap');
63
64            if (imagem.length == 0) {
65                $('<a class="default-imagem-link" href="#" ><div class="default-imagem"></div></a>')
66                    .insertBefore($(this).children('.sppb-article-info-wrap'))
67
68            }
69        })
70    }
71
72    function limitarSubtitulosNoticias() {
73        $('.sppb-article-info-wrap')
74            .each(function () {
75                let titulo = $(this)
76                    .children('h3')
77                    .children('a')
78                    .text();
79
80                let texto = $(this)
81                    .children('.sppb-article-introtext')
82                    .text();
83
84                var ultimaPalavra = titulo.split(' ').reverse();
85
86                if (titulo.length <= 25) {
87
88                    $(this)
89                        .children('.sppb-article-introtext')
90                        .text(limitarTextoNoticia(texto, 150));
91
92                    $(this)
93                        .children('h3')
94                        .css('height', '1.5rem');
95
96                    $(this)
97                        .children('.sppb-article-introtext')
98                        .css('height', '7rem');
99
100                    if (titulo.length >= 20 && ultimaPalavra[0].length >= 7) {
101
102                        $(this)
103                            .children('.sppb-article-introtext')
104                            .text(limitarTextoNoticia(texto, 110));
105
106                        $(this)
107                            .children('h3')
108                            .css('height', '3rem');
109
110                        $(this)
111                            .children('.sppb-article-introtext')
112                            .css('height', '5.5rem');
113                    }
114                }
115
116                if (titulo.length > 20 && titulo.length <= 45) {
117                    $(this)
118                        .children('.sppb-article-introtext')
119                        .text(limitarTextoNoticia(texto, 110));
120
121                    $(this)
122                        .children('h3')
123                        .css('height', '3rem');
124
125                    $(this)
126                        .children('.sppb-article-introtext')
127                        .css('height', '5.5rem');
128
129                    if (titulo.length > 30 && ultimaPalavra[0].length >= 7) {
130
131                        $(this)
132                            .children('.sppb-article-introtext')
133                            .text(limitarTextoNoticia(texto, 85));
134
135                        $(this)
136                            .children('h3')
137                            .css('height', '3rem');
138
139                        $(this)
140                            .children('.sppb-article-introtext')
141                            .css('height', '5.5rem');
142                    }
143                }
144
145                if (titulo.length > 45 && titulo.length <= 60) {
146                    $(this)
147                        .children('.sppb-article-introtext')
148                        .text(limitarTextoNoticia(texto, 85));
149
150                    $(this)
151                        .children('h3')
152                        .css('height', '4rem');
153
154                    $(this)
155                        .children('.sppb-article-introtext')
156                        .css('height', '4.5rem');
157
158                    if (titulo.length >= 48 && ultimaPalavra[0].length >= 7) {
159
160                        $(this)
161                            .children('.sppb-article-introtext')
162                            .text(limitarTextoNoticia(texto, 60));
163
164                        $(this)
165                            .children('h3')
166                            .css('height', '4rem');
167
168                        $(this)
169                            .children('.sppb-article-introtext')
170                            .css('height', '4.5rem');
171                    }
172                }
173
174                if (titulo.length > 60 && titulo.length < 75) {
175                    $(this)
176                        .children('.sppb-article-introtext')
177                        .text(limitarTextoNoticia(texto, 60));
178
179                    $(this)
180                        .children('h3')
181                        .css('height', '4.5rem');
182
183                    $(this)
184                        .children('.sppb-article-introtext')
185                        .css('height', '4rem');
186                }
187
188                if (titulo.length > 75) {
189                    $(this)
190                        .children('.sppb-article-introtext')
191                        .text(limitarTextoNoticia(texto, 0));
192                    $(this)
193                        .children('h3')
194                        .css('height', '3.3rem');
195                }
196
197            });
198    
199    }
200
201    function limitarTextoNoticia(texto, tamanhoTexto) {
202
203        var continuacaoTexto = '...';
204      
205        var textoReduzido = texto.slice(0, tamanhoTexto);
206      
207      	if(textoReduzido == 0 || texto.length <= 5){
208           continuacaoTexto = '';
209        }
210      
211        return textoReduzido + continuacaoTexto;
212    }
213
214});

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.