1<#compress>
2<#assign layoutAssetEntry=staticUtil['com.liferay.portal.kernel.util.WebKeys'].LAYOUT_ASSET_ENTRY>
3<#if request.getAttributeNames()?seq_contains(layoutAssetEntry)>
4 <#assign
5 parentAsset=request.getAttribute(layoutAssetEntry)
6 currentCategories=parentAsset.getCategories()
7 >
8</#if>
9
10<#assign journalArticleRetrievalService = serviceLocator.findService("com.placecube.journal.service.JournalArticleRetrievalService") />
11<#assign journalArticleService = serviceLocator.findService("com.liferay.journal.service.JournalArticleService") />
12
13<#macro getCategoryNames category>
14 <#assign allCurrentCategoryNames = allCurrentCategoryNames + [category.name]>
15 <#if category.getParentCategory()??>
16 <@getCategoryNames category.getParentCategory() />
17 </#if>
18</#macro>
19
20<#function hasCategoryName alert, pageCategoryName>
21 <#list alert.getCategories() as category>
22 <#if category.name == pageCategoryName><#return true></#if>
23 <#if allCurrentCategoryNames?seq_contains(category.name)><#return true></#if>
24 </#list>
25 <#return false>
26</#function>
27
28
29<#function normalAlert entry>
30 <#if (alertType?contains('value 1') || alertType?contains('value 2'))><#return true></#if>
31 <#return false>
32</#function>
33
34<#function isAlertHidden alertId>
35<#local cookies = request.getCookies()>
36 <#list cookies as cookie>
37 <#if cookie.getValue()?matches(alertId)>
38 <#return true>
39 </#if>
40 </#list>
41 <#return false>
42</#function>
43
44<script>
45function hideAlert(alertId) {
46 var now = new Date();
47 var time = now.getTime();
48 var expireTime = time + 1000*36000;
49 now.setTime(expireTime);
50 document.cookie = 'alertHidden=' + alertId + ';expires='+now.toUTCString()+';path=/';
51}
52</script>
53
54<#if currentCategories??>
55
56 <#assign currentCategory = currentCategories[0]>
57 <#assign serviceCategory = currentCategory.name/>
58 <#assign allCurrentCategoryNames=[]>
59
60 <@getCategoryNames currentCategory />
61
62 <#list entries as curEntry>
63
64 <#assign journalArticle = journalArticleService.getLatestArticle(curEntry.getClassPK()) />
65 <#assign alertBody = journalArticleRetrievalService.getFieldValue(journalArticle,"alertBody",locale) />
66 <#assign alertDismiss = journalArticleRetrievalService.getFieldValue(journalArticle,"select_dismiss",locale) />
67 <#assign alertType = journalArticleRetrievalService.getFieldValue(journalArticle,"select_type",locale) />
68 <#assign body = alertBody.get() />
69 <#assign categories = curEntry.getCategories()>
70 <#assign alertId = curEntry.entryId?c>
71 <#assign foundCategory = hasCategoryName(curEntry, serviceCategory)>
72
73 <#if alertType?contains('value 3')>
74 <#if !isAlertHidden(alertId)>
75 <div class="alert alert-primary <#if alertDismiss?contains('value 1')>alert-dismissible</#if> p-0" role="alert">
76 <div class="alert-body-wide d-flex justify-content-center">
77
78 <div class="alert-body">
79 <div class="alert-top alert-warning px-3">
80
81 <#if alertDismiss?contains('value 1')>
82 <button type="button" id ="alertClose" onclick="hideAlert(${alertId})" class="close text-dark mt-2" data-dismiss="alert" aria-label="Close">
83 <span aria-hidden="true">×</span>
84 </button>
85 </#if>
86
87 <h2 class="text-dark">
88 <svg class="lexicon-icon lexicon-icon-exclamation-full text-dark" id="global" viewBox="0 0 512 512">
89 <path class="lexicon-icon-outline" d="M256,0C114.6,0,0,114.6,0,256s114.6,256,256,256s256-114.6,256-256S397.4,0,256,0z M256,384c-17.7,0-32-14.3-32-32
90 s14.3-32,32-32s32,14.3,32,32S273.7,384,256,384z M272,288h-32l-16-160h64L272,288z"></path>
91 </svg>
92
93 Important
94
95 </h2>
96 </div>
97 <div class="alert-text alert-warning px-3">
98 <h3 class="mt-2">${curEntry.getTitle(locale)}</h3>
99 <p>${body}</p>
100 </div>
101 </div>
102 </div>
103 </#if>
104 </#if>
105
106 <#if normalAlert??>
107 <#if foundCategory>
108
109 <#if !isAlertHidden(alertId)>
110
111 <div class="alert alert-primary d-flex justify-content-center <#if alertDismiss?contains('value 1')>alert-dismissible</#if> p-0 mb-2" role="alert">
112 <div class="alert-body">
113 <div class="alert-top
114 <#if alertType?contains('value 1')>red-background</#if>
115 <#if alertType?contains('value 2')>bg-black</#if> px-3">
116
117 <#if alertDismiss?contains('value 1')>
118 <button type="button" id ="alertClose" onclick="hideAlert(${alertId})" class="close text-light" data-dismiss="alert" aria-label="Close">
119 <span aria-hidden="true">×</span>
120 </button>
121 </#if>
122
123 <h2 id="alert">
124 <svg class="lexicon-icon lexicon-icon-exclamation-full" viewBox="0 0 512 512">
125 <path class="lexicon-icon-outline" d="M256,0C114.6,0,0,114.6,0,256s114.6,256,256,256s256-114.6,256-256S397.4,0,256,0z M256,384c-17.7,0-32-14.3-32-32
126 s14.3-32,32-32s32,14.3,32,32S273.7,384,256,384z M272,288h-32l-16-160h64L272,288z"></path>
127 </svg>
128 <#if alertType?contains('value 1')>Warning</#if>
129 <#if alertType?contains('value 2')>Important</#if>
130
131 </h2>
132 </div>
133 <div class="
134 <#if alertType?contains('value 1')>alert-text-red</#if>
135 <#if alertType?contains('value 2')>alert-text-primary</#if> px-3">
136 <h3 class="mt-2">${curEntry.getTitle(locale)}</h3>
137 <p>${body}</p>
138 </div>
139 </div>
140 </div>
141 </#if>
142 </#if>
143 </#if>
144 </#list>
145
146<style>
147
148.portlet:first-of-type {
149margin-bottom:0px!important;
150}
151
152.alert-body {
153 max-width: 1228px;
154 width: 100%;
155 padding: 0 1rem 0 1rem;
156 margin-top: 0.8rem;
157}
158
159.alert-body-wide {
160 background-color:#fc0;
161 width: 100vw;
162 position: relative;
163 left: calc(-51vw + 50.5%);
164 margin-top: -1.1rem;
165}
166
167
168.lexicon-icon-exclamation-full {
169 height: 1.3em;
170 width: 1.3em;
171}
172
173.alert {
174 margin-bottom: -1.5rem;
175}
176
177h2#alert {
178 margin-top: 0rem;
179 margin-bottom: 0rem;
180 color:#FFFFFF;
181 font-size: 1.25rem;
182
183}
184
185.alert-primary {
186 background-color: #FFFFFF;
187 border-color: rgb(0 0 0 / 0%);
188 }
189
190.alert-top {
191 width: 100%;
192}
193
194.red-background {
195 background-color:#D4351C;
196}
197
198.bg-black {
199 background-color:#000000;
200}
201
202 .alert-primary .close {
203 color: #000000;
204 font-size: 2rem;
205 float:right;
206 position: inherit;
207 margin-top: 0.5rem;
208}
209 .alert-text-primary {
210 color: #000000!important;
211 border: 6px #000000 solid!important;
212 }
213
214 .alert-text-red {
215 color: #000000!important;
216 border: 6px #D4351C solid!important;
217 }
218
219 .alert-text-yellow {
220 color: #000000!important;
221 border: 6px #D4351C solid!important;
222 }
223
224 </style>
225
226</#if>
227</#compress>