PageSourceSearch

https://www.embrapa.br/o/embrapa-portal-theme/js/main.js?browserId…=js&languageId=pt_BR&t=1790027522000

js embrapa.br collected 2026-09-24 08:39:20 UTC 9,827 bytes, 310 lines download raw bytes

1/*1790028008000*/
2// Espera que o DOM esteja completamente carregado
3document.addEventListener("DOMContentLoaded", function() {
4
5  (function () {
6    const $header = document.querySelector(".embrapa__header");
7    const menuMobile = document.querySelector(".embrapa__menu_mobile");
8    const linksWithChildren = document.querySelectorAll(
9      "[data-item-menu-children]"
10    );
11    const searchBtn = document.querySelector(
12      ".embp_header_accessibility_list_item_search_btn"
13    );
14    const searchBarForm = document.querySelector(
15      ".embp_header_accessibility_list_item_searchbar form"
16    );
17
18    linksWithChildren.forEach((link) => {
19      link.addEventListener("click", function () {
20        link.classList.toggle("active");
21        link.nextElementSibling.classList.toggle("active");
22      });
23    });
24
25    searchBtn.addEventListener("click", () => {
26      searchBtn.nextElementSibling.classList.toggle("show");
27    });
28
29    searchBarForm.addEventListener("submit", (e) => {
30      e.preventDefault();
31    const inputValue = searchBarForm.querySelector("input").value;
32    window.location.href = `/busca-geral/-/busca/${inputValue}?buscaPortal=${inputValue}`;
33    });
34  })();
35
36
37  // Código JavaScript de acessibilidade
38
39  function toggleAcessibilidade() {
40    var bodyElement = document.body;
41
42    if (bodyElement.classList.contains('acessibilidade')) {
43        bodyElement.classList.remove('acessibilidade');
44        localStorage.removeItem('acessibilidadeAtivada');
45    } else {
46        bodyElement.classList.add('acessibilidade');
47        localStorage.setItem('acessibilidadeAtivada', 'true');
48    }
49  }
50
51  function verificarAcessibilidade() {
52    if (localStorage.getItem('acessibilidadeAtivada') === 'true') {
53        document.body.classList.add('acessibilidade');
54    }
55  }
56
57  verificarAcessibilidade();
58
59  var botaoAcessibilidade = document.querySelector('.icon-acessibilidade');
60    if (botaoAcessibilidade) {
61      botaoAcessibilidade.addEventListener('click', function(e) {
62          e.preventDefault();
63          toggleAcessibilidade();
64      });
65  }
66
67
68  // Seleciona todos os elementos com a classe lfr-icon-menu-arrow e caret
69  var icons = document.querySelectorAll('i.lfr-icon-menu-arrow.caret');
70  
71  // Substitui cada ícone encontrado
72  icons.forEach(function(icon) {
73      // Remove as classes existentes
74      icon.classList.remove('lfr-icon-menu-arrow', 'caret');
75      // Adiciona a classe do Font Awesome para substituir
76      icon.classList.add('fas', 'fa-chevron-down');  // Exemplo com chevron-down
77  });
78
79});
80
81window.onload = function() {
82  const containers = document.querySelectorAll(".listador-ativo-parceria-portlet");
83
84  containers.forEach(function(container) {
85      const firstColumns = container.querySelectorAll(".portlet-column-first.col-md-6");
86      const lastColumns = container.querySelectorAll(".portlet-column-last.col-md-6");
87
88      firstColumns.forEach(function(firstColumn, index) {
89          const lastColumn = lastColumns[index];
90
91          if (firstColumn && lastColumn && firstColumn.innerHTML.trim() === "") {
92              // Oculta a primeira coluna se estiver vazia
93              firstColumn.style.display = "none";
94
95              // Ajusta a última coluna para ocupar o espaço completo
96              lastColumn.classList.remove("col-md-6");
97              lastColumn.classList.add("col-md-12");
98          }
99      });
100  });
101};
102
103
104// Cria uma região aria-live para feedback de acessibilidade
105(function createAriaLiveRegion() {
106  const liveRegion = document.createElement('div');
107  liveRegion.setAttribute('id', 'accessibility-feedback');
108  liveRegion.setAttribute('aria-live', 'polite');
109  liveRegion.setAttribute('role', 'status');
110  liveRegion.setAttribute('style', 'position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden;');
111  document.body.appendChild(liveRegion);
112})();
113
114// Função genérica para focar elementos
115function focusElement(selector, description) {
116  const tryFocus = () => {
117    const element = document.querySelector(selector);
118    if (element) {
119      element.setAttribute('tabindex', '-1');
120      element.focus();
121
122      const liveRegion = document.getElementById('accessibility-feedback');
123      if (liveRegion) {
124        liveRegion.textContent = description;
125      }
126    } else {
127      // Se não encontrar de imediato, tenta de novo em 100ms até 10 vezes
128      if (focusElement.attempts < 10) {
129        focusElement.attempts++;
130        setTimeout(() => focusElement(selector, description), 100);
131      }
132    }
133  };
134
135  focusElement.attempts = 0;
136  tryFocus();
137}
138
139// Escuta os atalhos Alt+1, Alt+2 e Alt+3
140document.addEventListener('keydown', function (event) {
141  if (event.altKey && !event.ctrlKey && !event.shiftKey && !event.metaKey) {
142    switch (event.key) {
143      case '1':
144        event.preventDefault();
145        focusElement('#main-content', 'Conteúdo principal focado');
146        break;
147      case '2':
148        event.preventDefault();
149        focusElement('.embp_header_container_top', 'Menu principal focado');
150        break;
151      case '3':
152        event.preventDefault();
153        focusElement('.embp_header_accessibility_list_item_searchbar input[type="text"]', 'Campo de busca focado');
154        break;
155    }
156  }
157});
158
159// Altera o breadcrumb para remover o último item se for igual ao penúltimo
160(function () {
161  const observer = new MutationObserver((mutations, obs) => {
162    const breadcrumb = document.querySelector("ol.breadcrumb");
163
164    if (breadcrumb) {
165      obs.disconnect(); // Parar de observar
166
167      // Esconde inicialmente
168      breadcrumb.style.visibility = "hidden";
169
170      const breadcrumbItems = breadcrumb.querySelectorAll("li");
171
172      if (breadcrumbItems.length >= 2) {
173        const lastItem = breadcrumbItems[breadcrumbItems.length - 1];
174        const secondLastItem = breadcrumbItems[breadcrumbItems.length - 2];
175
176        const lastSpan = lastItem.querySelector("span");
177        const secondLastSpan = secondLastItem.querySelector("span");
178
179        if (
180          lastSpan &&
181          secondLastSpan &&
182          lastSpan.textContent.trim() === secondLastSpan.textContent.trim()
183        ) {
184          secondLastItem.remove();
185        }
186      }
187
188      // Mostra novamente o breadcrumb após a manipulação
189      breadcrumb.style.visibility = "visible";
190    }
191  });
192
193  observer.observe(document.body, {
194    childList: true,
195    subtree: true,
196  });
197})();
198
199AUI().ready(
200  /*
201	This function gets loaded when all the HTML, not including the portlets, is
202	loaded.
203	*/
204  "aui-base",
205  function (A) {
206    //meus dados
207    var lnkMeusDados =
208      '<div class="collapse nav-collapse" id="_145_navMeusDadosControlsNavbarCollapse"><ul aria-label="Controles de layout" class="nav nav-add-controls" id="_145_navMeusDadosControls" role="menubar"><li class="dockbar-item"><a class="editar_meus_dados" href="/group/intranet/meus-dados" title="Meus dados"><i class="icon-user"></i><span>Meus dados</span></a></li><li class="dockbar-item"></li></ul></div>';
209    $("#_145_dockbarbodyContent").append(lnkMeusDados);
210
211    //submit dos formulários de busca
212    $(".busca-conteudo").submit(function () {
213      var action = $(this).attr("action");
214
215      var palavrasChave = $("#palavrasChave", this).val();
216      if (palavrasChave) {
217        action += "busca/" + encodeURIComponent(palavrasChave);
218      } else {
219        action += "todos";
220      }
221      $(this).attr("action", action);
222
223      return true;
224    });
225
226    //submit dos formulários de busca
227    $(".busca-rapida").submit(function () {
228      var palavrasChave = $("#palavrasChave", this).val();
229      var area = $("#areaBusca", this).val();
230
231      if (area != "" || palavrasChave != "") {
232        var action = $(this).attr("action");
233
234        action += "busca-intranet/";
235        if (area) {
236          action += "area/" + encodeURIComponent(area);
237        }
238        if (palavrasChave) {
239          action += "/" + encodeURIComponent(palavrasChave);
240        }
241
242        $(this).attr("action", action);
243
244        return true;
245      } else {
246        return false;
247      }
248    });
249
250    //submit dos formulários de busca geral de intranet
251    $("#form-busca-intranet").submit(function () {
252      var palavrasChave = $("#palavrasChave", this).val();
253      if (palavrasChave != "") {
254        var action = $(this).attr("action");
255        action += "busca-intranet/" + encodeURIComponent(palavrasChave);
256        $(this).attr("action", action);
257        return true;
258      } else {
259        return false;
260      }
261    });
262
263    $(".user-portrait.use-dialog img").unwrap();
264    $(".user-fullname.use-dialog").wrapInner(
265      "<span class='user-fullname user-fullname-embrapa' style='font-weight: bold; color: #2C2F34;'></span>"
266    );
267    $("span.user-fullname.user-fullname-embrapa").unwrap();
268
269    //Adiciona ancora para paginacao em publicador de conteudo web
270    A.all(".portlet-boundary_101_").each(function (e) {
271      var anchor = e.attr("id");
272      //Links
273      e.all('ul.pager.lfr-pagination-buttons li a[href^="http"]').each(
274        function (paginationLink) {
275          var oldLink = paginationLink.attr("href");
276          paginationLink.attr("href", oldLink + "#" + anchor);
277        }
278      );
279      //Menu
280      e.all('ul.dropdown-menu.lfr-menu-list li a[href^="http"]').each(function (
281        paginationLink
282      ) {
283        var oldLink = paginationLink.attr("href");
284        paginationLink.attr("href", oldLink + "#" + anchor);
285      });
286    });
287  }
288);
289
290Liferay.Portlet.ready(
291  /*
292	This function gets loaded after each and every portlet on the page.
293
294	portletId: the current portlet's id
295	node: the Alloy Node object of the current portlet
296	*/
297
298  function (portletId, node) {}
299);
300
301Liferay.on(
302  "allPortletsReady",
303
304  /*
305	This function gets loaded when everything, including the portlets, is on
306	the page.
307	*/
308
309  function () {}
310);

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.