1<#-- 03-10-2022 - JLPG: Evolutivo: 4 inserciones de codigo
2 Deteccion del site de Ucrania Urgente
3 Deteccion de enlaces externos
4 Correccion de enlaces internos dentro de Ucrania Urgente-->
5
6<#assign globalThemeSettings = serviceLocator.findService("es.gob.inclusion.settings.osgi.GlobalThemeSettings")
7 articlesGroupId = globalThemeSettings.articlesGroupId()
8 rrssArticleId = globalThemeSettings.rrssArticleId()
9
10 themeGlobalMostViewedList = [
11 {"groupId": globalThemeSettings.mostViewedGroupId1(), "articleId": globalThemeSettings.mostViewedArticleId1()},
12 {"groupId": globalThemeSettings.mostViewedGroupId2(), "articleId": globalThemeSettings.mostViewedArticleId2()},
13 {"groupId": globalThemeSettings.mostViewedGroupId3(), "articleId": globalThemeSettings.mostViewedArticleId3()},
14 {"groupId": globalThemeSettings.mostViewedGroupId4(), "articleId": globalThemeSettings.mostViewedArticleId4()},
15 {"groupId": globalThemeSettings.mostViewedGroupId5(), "articleId": globalThemeSettings.mostViewedArticleId5()},
16 {"groupId": globalThemeSettings.mostViewedGroupId6(), "articleId": globalThemeSettings.mostViewedArticleId6()},
17 {"groupId": globalThemeSettings.mostViewedGroupId7(), "articleId": globalThemeSettings.mostViewedArticleId7()}
18 ]
19/>
20
21<#assign menuJsonMap = content.getData()?eval
22 baseElementClass = "m-main-nav-desk__level"
23 maxDepth = 3
24/>
25
26<#-- 04-10-2022 - JLPG: Insercion 1:
27 Variables de site actual. Se incluye el template para detección de URLs -->
28<#include "${templatesPath}/MISSM-VALIDAURLS-JSON-TEMPLATE" >
29<#-- JLPG: Fin insercion 1 -->
30
31<nav class="navbar navbar-expand-md navbar-dark missmi-navbar" id="missm-main-navigation-desk" aria-label="">
32 <#if menuJsonMap.layouts?has_content>
33 <@drawList menuJsonMap.layouts 1/>
34 </#if>
35</nav>
36
37<#macro drawList jsonArray depth>
38 <#if jsonArray?has_content>
39 <div class="collapse navbar-collapse justify-content-md-end" id="navbarNavDropdown">
40 <ul class="navbar-nav w-100 justify-content-md-end">
41 <#list jsonArray as jsonElement>
42 <@drawElement jsonElement depth jsonElement?index/>
43 </#list>
44 </ul>
45 <#-- <#if articlesGroupId?has_content && articlesGroupId != -1 && rrssArticleId?has_content && rrssArticleId != "-1">
46 <div class="col-2 m-rrss-wrapper m-rrss-desktop-wrapper">
47 <#attempt>
48 <@liferay_journal["journal-article"]
49 articleId=rrssArticleId
50 groupId=articlesGroupId
51 wrapperCssClass="no"
52 />
53 <#recover>
54 </#attempt>
55 </div>
56 <#else>
57 <div class="col-2 m-rrss-wrapper m-rrss-desktop-wrapper">
58 <a class="m-logos-rrss__item icon-twitter text-white" href="#" target="_blank">
59 <span class="hide">twitter</span>
60 </a>
61 <a class="m-logos-rrss__item icon-instagram text-white" href="#" target="_blank">
62 <span class="hide">Instagram</span>
63 </a>
64 <a class="m-logos-rrss__item icon-youtube-play text-white" href="#" target="_blank">
65 <span class="hide">youtube</span>
66 </a>
67 <a class="m-logos-rrss__item icon-linkedin-sign text-white" href="#" target="_blank">
68 <span class="hide">linkedin</span>
69 </a>
70 </div>
71 </#if> -->
72
73 </div>
74 </#if>
75</#macro>
76
77<#macro drawElement jsonElement depth index>
78 <#if jsonElement.hidden?has_content && !jsonElement.hidden>
79 <li class="nav-item dropdown position-static nav-item__missmTopLevel ${baseElementClass}${depth}${jsonElement.layouts?has_content?then(" has-children", '')}"
80 data-missm-menuid="${jsonElement.plid}" data-missm-groupId="${jsonElement.groupId}" data-missm-isGroup="${jsonElement.isGroup?string('true', 'false')}">
81 <div class="m-main-nav-desk">
82<#-- 03-10-2022 - JLPG: Insercion 2:
83 Deteccion enlaces externos.
84 Si enlace interno y está en Ucrania Urgente, añade dominio del Ministerio. -->
85 <#assign laURL = jsonElement.url />
86 <#if (isExternalDomain && !laURL?starts_with("http"))>
87 <#assign laURL = MISSM_PRO_DOMAIN + laURL />
88 </#if>
89<#-- JLPG: Fin insercion 2 -->
90 <a class="nav-link dropdown-toggle" href="${laURL}" aria-haspopup="true" aria-expanded="false">
91 ${jsonElement.title}
92 </a>
93 <#if jsonElement.layouts?has_content>
94 <button class="m-btn-menu"><span class="sr-only"><@liferay.language key="es.gob.inclusion.menu.show-submenu" /> ${jsonElement.title}</button>
95 </#if>
96 </div>
97 <#if jsonElement.layouts?has_content && depth < maxDepth>
98 <@drawListAux jsonElement.layouts depth+1 index/>
99 </#if>
100 </li>
101 </#if>
102</#macro>
103
104<#macro drawListAux jsonArray depth index>
105 <#if jsonArray?has_content>
106 <div class="dropdown-menu w-100 missmi-submenu-container" role="menu">
107 <div class="col-8">
108 <ul class="row m-listBaseNoStyles">
109 <#list jsonArray as jsonElement>
110 <@drawElementAux jsonElement depth/>
111 </#list>
112 </ul>
113 </div>
114 <div id="missmi-destacado-page-${index}" class="col-4 separador">
115 </div>
116 </div>
117 </#if>
118</#macro>
119
120
121<#macro drawElementAux jsonElement depth>
122 <#if jsonElement.hidden?has_content && !jsonElement.hidden>
123 <li class="col-6" data-missm-menuid="${jsonElement.plid}" data-missm-groupId="${jsonElement.groupId}" data-missm-isGroup="${jsonElement.isGroup?string('true', 'false')}">
124<#-- 03-10-2022 - JLPG: Insercion 3:
125 Deteccion enlaces externos.
126 Si enlace interno y está en Ucrania Urgente, añade dominio del Ministerio. -->
127 <#assign laURL = jsonElement.url />
128 <#if (isExternalDomain && !laURL?starts_with("http"))>
129 <#assign laURL = MISSM_PRO_DOMAIN + laURL />
130 </#if>
131<#-- JLPG: Fin insercion 3 -->
132 <a class="dropdown-item" href="${laURL}">
133 ${jsonElement.title}
134 </a>
135 <#if jsonElement.layouts?has_content && depth < maxDepth>
136 <@drawListAux2 jsonElement.layouts depth+1 />
137 </#if>
138 </li>
139 </#if>
140</#macro>
141
142<#macro drawListAux2 jsonElement depth>
143 <#-- 10/04/2023 - JLPG: Inserción de macro para detectar
144 si todos los hijos del primer nivel están marcados
145 como ocultos -->
146 <#assign isVisible = false />
147 <#list jsonElement as jsonElementaux>
148 <#if jsonElementaux.hidden?has_content && !jsonElementaux.hidden>
149 <#assign isVisible = true />
150 </#if>
151 </#list>
152 <#-- Fin de inserción -->
153 <#if jsonElement?has_content && isVisible>
154 <ul class="m-listBaseWrap">
155 <#list jsonElement as jsonElementaux>
156 <@drawElementAux2 jsonElementaux depth/>
157 </#list>
158 </ul>
159 </#if>
160</#macro>
161
162<#macro drawElementAux2 jsonElement depth>
163 <#if jsonElement.hidden?has_content && !jsonElement.hidden>
164 <li data-missm-menuid="${jsonElement.plid}" data-missm-groupId="${jsonElement.groupId}" data-missm-isGroup="${jsonElement.isGroup?string('true', 'false')}">
165<#-- 03-10-2022 - JLPG: Insercion 4:
166 Deteccion enlaces externos.
167 Si enlace interno y está en Ucrania Urgente, añade dominio del Ministerio. -->
168 <#assign laURL = jsonElement.url />
169 <#if (isExternalDomain && !laURL?starts_with("http"))>
170 <#assign laURL = MISSM_PRO_DOMAIN + laURL />
171 </#if>
172<#-- JLPG: Fin insercion 4 -->
173 <a class="enlace" href="${laURL}">
174 ${jsonElement.title}
175 </a>
176 </li>
177 </#if>
178</#macro>
179
180<div id="themeGlobalMostViewedContents" class="d-none">
181 <#list themeGlobalMostViewedList as cur_item>
182 <#if cur_item?has_content && cur_item.articleId?has_content && cur_item.articleId != "-1" && cur_item.groupId?has_content && cur_item.groupId != -1>
183 <div id="missmi-destacado-menu-${cur_item?index + 1}" class="missmi-destacado-menu">
184 <#attempt>
185 <@liferay_journal["journal-article"]
186 articleId=cur_item.articleId
187 groupId=cur_item.groupId
188 wrapperCssClass="no"
189 />
190 <#recover>
191 </#attempt>
192 </div>
193 </#if>
194 </#list>
195</div>
196
197 <script>
198 $( document ).ready(function() {
199 var menuItems = document.querySelectorAll('#missm-main-navigation-desk li.has-children');
200
201 for (var i = 0; i < menuItems.length; i++) {
202 menuItems[i].querySelector('.m-btn-menu').addEventListener("click",function(event){
203 var aux = this.parentNode.parentNode;
204 if(aux.querySelector('.nav-link').classList.contains('show')){
205 aux.querySelector('.dropdown-menu').classList.remove('show');
206 aux.querySelector('.nav-link').classList.remove('show');
207 aux.querySelector('a').setAttribute('aria-expanded', "false");
208 aux.querySelector('button').setAttribute('aria-expanded', "false");
209 aux.querySelector('button').classList.remove('active');
210 aux.classList.remove('active');
211 } else{
212 document.querySelectorAll('.dropdown-menu.show').forEach(function(element){
213 element.classList.remove('show');
214 element.parentNode.querySelector('a').setAttribute('aria-expanded', "false");
215 element.parentNode.querySelector('button').setAttribute('aria-expanded', "false");
216 element.parentNode.querySelector('button').classList.remove('active');
217 element.parentNode.classList.remove('active');
218 });
219 aux.querySelector('.dropdown-menu').classList.add('show');
220 aux.querySelector('.nav-link').classList.add('show');
221 aux.querySelector('a').setAttribute('aria-expanded', "true");
222 aux.querySelector('button').setAttribute('aria-expanded', "true");
223 aux.querySelector('button').classList.add('active');
224 aux.classList.add('active');
225 }
226 event.preventDefault();
227 });
228 }
229 $('.nav-link').click(function () {
230 location.href = this.href;
231 });
232
233 document.querySelectorAll('[id^="missmi-destacado-page-"]').forEach(function(element) {
234 let index = element.id.split("missmi-destacado-page-")[1];
235 if (document.getElementById("missmi-destacado-menu-" + index)) {
236 element.appendChild(document.getElementById("missmi-destacado-menu-" + index));
237 }
238 });
239
240 /*var menus = document.querySelectorAll('.nav-item');
241 menus.forEach(menu => {
242 menu.addEventListener( 'mouseover', function(e) {
243 this.querySelector('.nav-link').classList.add('show');
244 this.lastElementChild.classList.add('show');
245 // this..setAttribute('aria-expanded', 'true');
246 });
247 menu.addEventListener( 'mouseout', function(e) {
248 this.querySelector('.nav-link').classList.remove('show');
249 this.lastElementChild.classList.remove('show');
250 // this..setAttribute('aria-expanded', 'false');
251 });
252 });*/
253
254 $(".m-main-nav-desk__level1.has-children").hover(
255 function () {
256 if ($(this).find(".m-btn-menu").attr("aria-expanded") != "true"){
257 $(this).find(".m-btn-menu").trigger("click");
258 };
259 },
260 function () {
261 if ($(this).find(".m-btn-menu").attr("aria-expanded") == "true"){
262 $(this).find(".m-btn-menu").trigger("click");
263 };
264 }
265 );
266
267 Liferay.on('allPortletsReady',
268 function() {
269 var forcedNameId=$('[data-missm-force-menuid]').first().data("missm-force-menuid");
270
271 var _checkAlreadyClass = function (){
272 return ($(".nav-item__missmTopLevel.nav-item__missmUnderlined").length>0);
273 }
274 var _checkUnderlineMenu = function(el){
275 if (typeof el != "undefined" && el.length>0 && !_checkAlreadyClass()){
276 if (el.hasClass("nav-item__missmTopLevel")){
277 el.addClass("nav-item__missmUnderlined");
278 }else {
279 el.parents(".nav-item__missmTopLevel").addClass("nav-item__missmUnderlined");
280 }
281 }
282 }
283 if (typeof forcedNameId != "undefined") {
284 $("li[data-missm-menuid='"+forcedNameId+"']").each(function(){
285 _checkUnderlineMenu($("li[data-missm-menuid='"+forcedNameId+"']"));
286 });
287 }
288 _checkUnderlineMenu($("li[data-missm-menuid='"+Liferay.ThemeDisplay.getLayoutId()+"']"));
289 _checkUnderlineMenu($("li[data-missm-menuid='"+Liferay.ThemeDisplay.getParentLayoutId()+"']"));
290 _checkUnderlineMenu($("li[data-missm-groupid='"+Liferay.ThemeDisplay.getScopeGroupId()+"'][data-missm-isgroup='true']"));
291 }
292 );
293
294 });
295
296</script>