@aarhus-university/au-lib-react-components 9.11.9 → 9.11.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +18 -18
- package/README.md +20 -20
- package/babel.config.js +6 -6
- package/build/dev.html +328 -328
- package/build/umd/all.css +2 -2
- package/build/umd/all.js +1 -1
- package/build/umd/alphabox.js +1 -1
- package/build/umd/auAuth.js +1 -1
- package/build/umd/databox.js +2 -2
- package/build/umd/databox.js.LICENSE.txt +5 -5
- package/build/umd/diagramme.js +1 -1
- package/build/umd/flowbox.js +1 -1
- package/build/umd/news.js +1 -1
- package/build/umd/universe.js +1 -1
- package/package.json +60 -60
- package/src/all.js +3 -3
- package/src/app.js +263 -263
- package/src/components/AUAlertComponent.js +158 -158
- package/src/components/AUAmountComponent.js +84 -84
- package/src/components/AUBannerComponent.js +99 -99
- package/src/components/AUCalendarComponent.js +393 -393
- package/src/components/AUCollapsibleComponent.js +173 -173
- package/src/components/AUDatepickerComponent.js +105 -105
- package/src/components/AUDiagrammeComponent.js +310 -310
- package/src/components/AUFilterCheckboxComponent.js +122 -122
- package/src/components/AUFocusComponent.js +55 -55
- package/src/components/AUModalComponent.js +94 -94
- package/src/components/AUPaginationComponent.js +103 -103
- package/src/components/AUSpinnerComponent.js +125 -125
- package/src/components/AutoSuggestComponent.js +132 -132
- package/src/components/alphabox/AlphaBoxComponent.js +140 -140
- package/src/components/alphabox/AlphaBoxContentComponent.js +125 -125
- package/src/components/context/AUUserContextComponent.js +91 -91
- package/src/components/context/ImpersonateComponent.js +54 -54
- package/src/components/databox/DataBoxAlphabetComponent.js +144 -144
- package/src/components/databox/DataBoxAssociationComponent.js +122 -122
- package/src/components/databox/DataBoxButtonComponent.js +153 -153
- package/src/components/databox/DataBoxComponent.js +297 -297
- package/src/components/databox/DataBoxGroupingComponent.js +62 -62
- package/src/components/databox/DataBoxSearchResultComponent.js +40 -40
- package/src/components/databox/DataBoxStackedAssociationComponent.js +58 -58
- package/src/components/databox/DataBoxSuggestionComponent.js +39 -39
- package/src/components/delphinus/AUAlertComponent.js +85 -85
- package/src/components/delphinus/AUCalendarComponent.js +487 -487
- package/src/components/delphinus/AUContentToggleComponent.js +32 -32
- package/src/components/delphinus/AUDatepickerComponent.js +164 -164
- package/src/components/delphinus/AULoginComponent.js +65 -65
- package/src/components/delphinus/AUModalComponent.js +89 -89
- package/src/components/delphinus/AUSpinnerComponent.js +74 -114
- package/src/components/delphinus/AUSubNavComponent.js +53 -53
- package/src/components/delphinus/AUTabbedContentComponent.js +150 -150
- package/src/components/delphinus/AUTableComponent.js +28 -28
- package/src/components/delphinus/AUToastComponent.js +91 -91
- package/src/components/delphinus/AUToolbarComponent.js +48 -48
- package/src/components/delphinus/hooks.js +28 -26
- package/src/components/flowbox/FlowBoxComponent.js +126 -126
- package/src/components/flowbox/FlowBoxPhoneComponent.js +106 -106
- package/src/components/form/AUMobilePrefixComponent.js +18 -18
- package/src/components/form/AUReceiptComponent.js +40 -40
- package/src/components/form/AUSubmitButtonContainerComponent.js +39 -39
- package/src/components/news/EventLayout1Component.js +94 -94
- package/src/components/news/EventLayout2Component.js +90 -90
- package/src/components/news/EventLayout3Component.js +68 -68
- package/src/components/news/NewsCategoriesComponent.js +21 -21
- package/src/components/news/NewsCollageBannerComponent.js +71 -71
- package/src/components/news/NewsCollageBannerRSSComponent.js +79 -79
- package/src/components/news/NewsColumnsComponent.js +125 -125
- package/src/components/news/NewsLanguageChangeComponent.js +74 -74
- package/src/components/news/NewsLayout1Component.js +80 -80
- package/src/components/news/NewsLayout2Component.js +80 -80
- package/src/components/news/NewsLayout3Component.js +81 -81
- package/src/components/news/NewsLayout4Component.js +80 -80
- package/src/components/news/NewsLayout5Component.js +61 -61
- package/src/components/news/NewsLayout6Component.js +55 -55
- package/src/components/news/NewsLayout7Component.js +58 -58
- package/src/components/news/NewsLayout8Component.js +57 -57
- package/src/components/news/NewsListComponent.js +291 -291
- package/src/components/news/NewsPopUpComponent.js +591 -591
- package/src/components/news/NewsRSSComponent.js +74 -74
- package/src/components/news/NewsSocialComponent.js +104 -104
- package/src/components/news/NewsSubHeaderComponent.js +19 -19
- package/src/components/password/AUChangePasswordComponent.js +177 -177
- package/src/components/password/AUCurrentPasswordComponent.js +72 -72
- package/src/components/password/AUNewPasswordComponent.js +143 -143
- package/src/components/password/AUPasswordActions.js +101 -101
- package/src/components/password/AUPasswordHooks.js +47 -47
- package/src/components/password/AUPasswordReducer.js +78 -78
- package/src/components/password/AUPasswordRequirementsComponent.js +29 -29
- package/src/components/profile/AUProfileActions.js +128 -128
- package/src/components/profile/AUProfileAvatar2016Component.js +99 -99
- package/src/components/profile/AUProfileAvatarComponent.js +83 -83
- package/src/components/profile/AUProfileAvatarV2Component.js +91 -91
- package/src/components/profile/AUProfileAvatarV3Component.js +79 -79
- package/src/components/profile/AUProfileContainerComponent.js +283 -283
- package/src/components/profile/AUProfileHooks.js +30 -30
- package/src/components/profile/AUProfileItemComponent.js +54 -54
- package/src/components/profile/AUProfileLanguageComponent.js +131 -131
- package/src/components/profile/AUProfileLoginComponent.js +41 -41
- package/src/components/profile/AUProfileMailComponent.js +307 -307
- package/src/components/profile/AUProfileMobileComponent.js +164 -164
- package/src/components/profile/AUProfileNameComponent.js +253 -253
- package/src/components/profile/AUProfileNextOfKinComponent.js +216 -216
- package/src/components/profile/AUProfileReducer.js +230 -230
- package/src/components/profile/AUProfileWidgetComponent.js +95 -95
- package/src/components/profile/AUProfileWidgetV2Component.js +116 -116
- package/src/components/profile/AUProfileWidgetV3Component.js +129 -129
- package/src/components/universe/StaffTopComponent.js +362 -362
- package/src/components/universe/StudentTopComponent.js +137 -137
- package/src/components/universe/UniverseContainerComponent.js +62 -62
- package/src/components/wrapping/AUEmbedComponent.js +47 -47
- package/src/config/webpack.dev.config.js +47 -47
- package/src/config/webpack.umd.config.js +85 -85
- package/src/index.js +6 -6
- package/src/lib/au-alphabox.js +102 -102
- package/src/lib/au-auth.js +227 -227
- package/src/lib/au-databox.js +403 -403
- package/src/lib/au-diagramme.js +87 -87
- package/src/lib/au-flowbox.js +95 -95
- package/src/lib/au-news.js +371 -371
- package/src/lib/helpers.js +216 -216
- package/src/lib/i18n.js +601 -601
- package/src/lib/menu.js +10 -10
- package/src/lib/tracking.js +65 -65
- package/src/lib/universe.js +9 -9
- package/src/lib/urlHandler.js +63 -63
- package/src/lib/validation.js +181 -181
- package/src/lib/wrapping.js +16 -16
- package/src/styles/_settings.scss +10 -10
- package/src/styles/alert.scss +39 -39
- package/src/styles/alphabox.scss +208 -208
- package/src/styles/app.scss +13 -13
- package/src/styles/autosuggest.scss +57 -57
- package/src/styles/calendar.scss +111 -111
- package/src/styles/databox.scss +563 -563
- package/src/styles/diagramme.scss +119 -119
- package/src/styles/filtercheckbox.scss +4 -4
- package/src/styles/flowbox.scss +72 -72
- package/src/styles/maps.scss +395 -395
- package/src/styles/modal.scss +34 -34
- package/src/styles/pagination.scss +10 -10
- package/src/styles/spinner.scss +30 -30
package/src/lib/au-news.js
CHANGED
|
@@ -1,371 +1,371 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
/* eslint max-classes-per-file: 0 */
|
|
3
|
-
/* eslint class-methods-use-this: 0 */
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import ReactDOM from 'react-dom';
|
|
6
|
-
import NewsListComponent from '../components/news/NewsListComponent';
|
|
7
|
-
import NewsPopUpComponent from '../components/news/NewsPopUpComponent';
|
|
8
|
-
import NewsCollageBannerComponent from '../components/news/NewsCollageBannerComponent';
|
|
9
|
-
import NewsCollageBannerRSSComponent from '../components/news/NewsCollageBannerRSSComponent';
|
|
10
|
-
import { isElementInViewport } from './helpers';
|
|
11
|
-
|
|
12
|
-
const AUNewsConfig = {
|
|
13
|
-
server: window.newsServer || '//news.au.dk',
|
|
14
|
-
newsUrl: `${window.location.href.replace(window.location.hash, '').replace('#', '')}#news-`,
|
|
15
|
-
useOverlay: !(typeof window.useOverlay !== 'undefined' && !window.useOverlay),
|
|
16
|
-
useSyndication: !(typeof window.useSyndication !== 'undefined' && !window.useSyndication),
|
|
17
|
-
tagStrip: new RegExp(/<(?!\/?sub|sup(?=>|\s.*>))\/?.*?>/ig),
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
class AUNewsHelpers {
|
|
21
|
-
static typeIdToText(_id) {
|
|
22
|
-
let id = _id;
|
|
23
|
-
id = parseInt(id, 10);
|
|
24
|
-
if (id === 0 || id === 2) {
|
|
25
|
-
return 'news';
|
|
26
|
-
}
|
|
27
|
-
if (id === 4 || id === 7) {
|
|
28
|
-
return 'event';
|
|
29
|
-
}
|
|
30
|
-
if (id === 9) {
|
|
31
|
-
return 'notice';
|
|
32
|
-
}
|
|
33
|
-
return '';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static getEventDates(item, lang) {
|
|
37
|
-
const fromDateSplit = item.event_from.date.split('.');
|
|
38
|
-
let fromDate;
|
|
39
|
-
if (lang === 'en') {
|
|
40
|
-
fromDate = new Date(
|
|
41
|
-
parseInt(fromDateSplit[0], 10),
|
|
42
|
-
parseInt(fromDateSplit[1], 10) - 1,
|
|
43
|
-
parseInt(fromDateSplit[2], 10),
|
|
44
|
-
);
|
|
45
|
-
} else {
|
|
46
|
-
fromDate = new Date(
|
|
47
|
-
parseInt(fromDateSplit[2], 10),
|
|
48
|
-
parseInt(fromDateSplit[1], 10) - 1,
|
|
49
|
-
parseInt(fromDateSplit[0], 10),
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const toDateSplit = item.event_to.date.split('.');
|
|
54
|
-
let toDate;
|
|
55
|
-
if (lang === 'en') {
|
|
56
|
-
toDate = new Date(
|
|
57
|
-
parseInt(toDateSplit[0], 10),
|
|
58
|
-
parseInt(toDateSplit[1], 10) - 1,
|
|
59
|
-
parseInt(toDateSplit[2], 10),
|
|
60
|
-
);
|
|
61
|
-
} else {
|
|
62
|
-
toDate = new Date(
|
|
63
|
-
parseInt(toDateSplit[2], 10),
|
|
64
|
-
parseInt(toDateSplit[1], 10) - 1,
|
|
65
|
-
parseInt(toDateSplit[0], 10),
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
fromDate,
|
|
71
|
-
toDate,
|
|
72
|
-
fromDateSplit,
|
|
73
|
-
toDateSplit,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
static setExternal(_item) {
|
|
78
|
-
const item = _item;
|
|
79
|
-
const ttType = parseInt(item.type, 10);
|
|
80
|
-
item.external = ttType !== 0 && ttType !== 4 && ttType !== 9;
|
|
81
|
-
// "News" eller "Event" eller "Notice"
|
|
82
|
-
item.url = !item.external
|
|
83
|
-
&& AUNewsConfig.useOverlay ? (AUNewsConfig.newsUrl + item.id) : item.permalink;
|
|
84
|
-
return item;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static getNewsID(search) {
|
|
88
|
-
const reNewsId = /^#?news-(.*)$/;
|
|
89
|
-
const match = search.match(reNewsId);
|
|
90
|
-
if (match !== null) {
|
|
91
|
-
return match[1];
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return -1;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
static isiPad() {
|
|
98
|
-
return (/iPad/i).test(navigator.userAgent);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
class AUNews {
|
|
103
|
-
constructor(lang, feeds) {
|
|
104
|
-
this.lang = lang;
|
|
105
|
-
this.feeds = feeds || [];
|
|
106
|
-
this.item = null;
|
|
107
|
-
this.setItem = this.setItem.bind(this);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
setItem(item) {
|
|
111
|
-
this.item = item;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
setPopUp() {
|
|
115
|
-
const qsNewsPrint = AU.helpers.getQuerystring('newsprint');
|
|
116
|
-
const print = qsNewsPrint !== '';
|
|
117
|
-
const openPopUp = () => {
|
|
118
|
-
const newsID = AUNewsHelpers.getNewsID(window.location.hash);
|
|
119
|
-
let mountNode = document.getElementById('au_news_popup');
|
|
120
|
-
if (print) {
|
|
121
|
-
mountNode = document.querySelector('body');
|
|
122
|
-
}
|
|
123
|
-
if (parseInt(newsID, 10) > -1) {
|
|
124
|
-
if (this.item != null) {
|
|
125
|
-
const trackerLink = `/virtual/news/${AUNewsHelpers.typeIdToText(this.item.type)}/open-list/id-${this.item.id}/${this.item.permalink}`;
|
|
126
|
-
AU.tracking.trackSingle(trackerLink);
|
|
127
|
-
}
|
|
128
|
-
// Would like to use portal here, but it won't work "standalone"
|
|
129
|
-
ReactDOM.render(
|
|
130
|
-
<NewsPopUpComponent
|
|
131
|
-
id={newsID}
|
|
132
|
-
item={this.item}
|
|
133
|
-
lang={this.lang}
|
|
134
|
-
print={print}
|
|
135
|
-
/>,
|
|
136
|
-
mountNode,
|
|
137
|
-
);
|
|
138
|
-
} else if (window.location.hash === '' || window.location.hash === '#') { // Thx IE!
|
|
139
|
-
ReactDOM.unmountComponentAtNode(mountNode);
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
openPopUp();
|
|
144
|
-
|
|
145
|
-
window.addEventListener('hashchange', () => {
|
|
146
|
-
openPopUp();
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
const fade = document.getElementById('fade');
|
|
150
|
-
fade.addEventListener('click', () => {
|
|
151
|
-
window.location.hash = '';
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
init() {
|
|
156
|
-
this.setPopUp();
|
|
157
|
-
this.feeds.forEach((f) => {
|
|
158
|
-
const list = f;
|
|
159
|
-
list.container = document.querySelector(`#au_news-list_${list.id}`);
|
|
160
|
-
list.items = [];
|
|
161
|
-
list.page = 1;
|
|
162
|
-
const elements = AUNews.getElementFormatArray(list);
|
|
163
|
-
const mountNode = list.container;
|
|
164
|
-
if (mountNode) {
|
|
165
|
-
ReactDOM.render(
|
|
166
|
-
<NewsListComponent
|
|
167
|
-
lang={this.lang}
|
|
168
|
-
list={list}
|
|
169
|
-
elements={elements}
|
|
170
|
-
setItem={this.setItem}
|
|
171
|
-
/>,
|
|
172
|
-
mountNode,
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
static getElementFormatArray(_list) {
|
|
179
|
-
const list = _list;
|
|
180
|
-
const elements = [];
|
|
181
|
-
const rowSplit = list.format.split(',');
|
|
182
|
-
let formatCount = 0;
|
|
183
|
-
for (let r = 0; r < rowSplit.length; r += 1) {
|
|
184
|
-
const element = rowSplit[r];
|
|
185
|
-
if (element !== '|') {
|
|
186
|
-
if (element.indexOf('|') > -1) {
|
|
187
|
-
const columns = [];
|
|
188
|
-
const columnSplit = element.split('|');
|
|
189
|
-
for (let c = 0; c < columnSplit.length; c += 1) {
|
|
190
|
-
const columnElements = [];
|
|
191
|
-
const columnElementsSplit = columnSplit[c].split(';');
|
|
192
|
-
for (let e = 0; e < columnElementsSplit.length; e += 1) {
|
|
193
|
-
columnElements.push(columnElementsSplit[e]);
|
|
194
|
-
list.lastelement = columnElementsSplit[e];
|
|
195
|
-
list.lastiscolumn = true;
|
|
196
|
-
formatCount += 1;
|
|
197
|
-
}
|
|
198
|
-
columns.push(columnElements);
|
|
199
|
-
}
|
|
200
|
-
elements.push(columns);
|
|
201
|
-
} else {
|
|
202
|
-
elements.push(element);
|
|
203
|
-
list.lastiscolumn = false;
|
|
204
|
-
list.lastelement = element;
|
|
205
|
-
formatCount += 1;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (list.page === 1) {
|
|
211
|
-
list.amount = formatCount;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return elements;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
class AUNewsCollage {
|
|
219
|
-
constructor(lang, element) {
|
|
220
|
-
this.element = element;
|
|
221
|
-
this.loaded = false;
|
|
222
|
-
this.lang = lang;
|
|
223
|
-
window.addEventListener('scroll', () => {
|
|
224
|
-
this.init();
|
|
225
|
-
this.initRSS();
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
loadData(key, callback) {
|
|
230
|
-
const url = `${AUNewsConfig.server}/index.php?eID=getAuNewsFeed&mode=key&key=${key}&index=0&amount=4&noPageBrowser=1&lang=${this.lang}&callback=?`;
|
|
231
|
-
$.ajax({
|
|
232
|
-
url,
|
|
233
|
-
dataType: 'json',
|
|
234
|
-
jsonpCallback: url.hashCode(),
|
|
235
|
-
jsonp: true,
|
|
236
|
-
cache: true,
|
|
237
|
-
success: (data) => {
|
|
238
|
-
if (typeof callback === 'function') {
|
|
239
|
-
callback(data);
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
loadDataRSS(url, callback) {
|
|
246
|
-
fetch(url).then((response) => response.json()).then((data) => callback(data.Items));
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
init() {
|
|
250
|
-
if (!this.loaded && isElementInViewport(this.element) && typeof window.newsCollageRSS === 'undefined') {
|
|
251
|
-
const newsElements = [
|
|
252
|
-
document.querySelector('#news1'),
|
|
253
|
-
document.querySelector('#news2'),
|
|
254
|
-
document.querySelector('#news3'),
|
|
255
|
-
document.querySelector('#news4'),
|
|
256
|
-
];
|
|
257
|
-
|
|
258
|
-
const eventElements = [
|
|
259
|
-
document.querySelector('#event1'),
|
|
260
|
-
document.querySelector('#event2'),
|
|
261
|
-
document.querySelector('#event3'),
|
|
262
|
-
];
|
|
263
|
-
|
|
264
|
-
// News
|
|
265
|
-
const newsFeedKey = this.lang === 'da' ? 'b73f5e9759ac3592043449c02dcffa56' : '400bcbb4807a5a722df5e2045fa7966f';
|
|
266
|
-
this.loadData(newsFeedKey, (data) => {
|
|
267
|
-
newsElements.forEach((e, i) => {
|
|
268
|
-
if (data[i]) {
|
|
269
|
-
ReactDOM.render(
|
|
270
|
-
<NewsCollageBannerComponent
|
|
271
|
-
type="news"
|
|
272
|
-
item={AUNewsHelpers.setExternal(data[i])}
|
|
273
|
-
title={this.lang === 'da' ? 'Nyhed' : 'News'}
|
|
274
|
-
lang={this.lang}
|
|
275
|
-
/>,
|
|
276
|
-
e,
|
|
277
|
-
);
|
|
278
|
-
} else {
|
|
279
|
-
e.style.display = 'none';
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
// Events
|
|
284
|
-
const eventFeedKey = this.lang === 'da' ? '003383f99d8ae70cde9110294ab39727' : '19a8aa9cc30143d2e41cfbdb4123541e';
|
|
285
|
-
this.loadData(eventFeedKey, (data) => {
|
|
286
|
-
eventElements.forEach((e, i) => {
|
|
287
|
-
if (data[i]) {
|
|
288
|
-
ReactDOM.render(
|
|
289
|
-
<NewsCollageBannerComponent
|
|
290
|
-
type="events"
|
|
291
|
-
item={AUNewsHelpers.setExternal(data[i])}
|
|
292
|
-
title={this.lang === 'da' ? 'Arrangement' : 'Event'}
|
|
293
|
-
lang={this.lang}
|
|
294
|
-
/>,
|
|
295
|
-
e,
|
|
296
|
-
);
|
|
297
|
-
} else {
|
|
298
|
-
e.style.display = 'none';
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
this.loaded = true;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
initRSS() {
|
|
308
|
-
if (!this.loaded && isElementInViewport(this.element) && typeof window.newsCollageRSS !== 'undefined' && window.newsCollageRSS) {
|
|
309
|
-
const newsElements = [
|
|
310
|
-
document.querySelector('#news1'),
|
|
311
|
-
document.querySelector('#news2'),
|
|
312
|
-
document.querySelector('#news3'),
|
|
313
|
-
document.querySelector('#news4'),
|
|
314
|
-
];
|
|
315
|
-
|
|
316
|
-
const eventElements = [
|
|
317
|
-
document.querySelector('#event1'),
|
|
318
|
-
document.querySelector('#event2'),
|
|
319
|
-
document.querySelector('#event3'),
|
|
320
|
-
];
|
|
321
|
-
|
|
322
|
-
// News
|
|
323
|
-
const newsFeedKey = `https://webtools.au.dk/api/news/getlist?url=${window.newsFeedRssUri}`;
|
|
324
|
-
this.loadDataRSS(newsFeedKey, (data) => {
|
|
325
|
-
newsElements.forEach((e, i) => {
|
|
326
|
-
if (data[i]) {
|
|
327
|
-
ReactDOM.render(
|
|
328
|
-
<NewsCollageBannerRSSComponent
|
|
329
|
-
type="news"
|
|
330
|
-
item={data[i]}
|
|
331
|
-
title={this.lang === 'da' ? 'Nyhed' : 'News'}
|
|
332
|
-
lang={this.lang}
|
|
333
|
-
/>,
|
|
334
|
-
e,
|
|
335
|
-
);
|
|
336
|
-
} else {
|
|
337
|
-
e.style.display = 'none';
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
});
|
|
341
|
-
// Events
|
|
342
|
-
const eventFeedKey = `https://webtools.au.dk/api/news/getlist?url=${window.eventFeedRssUri}`;
|
|
343
|
-
this.loadDataRSS(eventFeedKey, (data) => {
|
|
344
|
-
eventElements.forEach((e, i) => {
|
|
345
|
-
if (data[i]) {
|
|
346
|
-
ReactDOM.render(
|
|
347
|
-
<NewsCollageBannerRSSComponent
|
|
348
|
-
type="events"
|
|
349
|
-
item={data[i]}
|
|
350
|
-
title={this.lang === 'da' ? 'Arrangement' : 'Event'}
|
|
351
|
-
lang={this.lang}
|
|
352
|
-
/>,
|
|
353
|
-
e,
|
|
354
|
-
);
|
|
355
|
-
} else {
|
|
356
|
-
e.style.display = 'none';
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
this.loaded = true;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
window.AUNews = AUNews;
|
|
367
|
-
window.AUNewsCollage = AUNewsCollage;
|
|
368
|
-
export {
|
|
369
|
-
AUNewsConfig,
|
|
370
|
-
AUNewsHelpers,
|
|
371
|
-
};
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
/* eslint max-classes-per-file: 0 */
|
|
3
|
+
/* eslint class-methods-use-this: 0 */
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import ReactDOM from 'react-dom';
|
|
6
|
+
import NewsListComponent from '../components/news/NewsListComponent';
|
|
7
|
+
import NewsPopUpComponent from '../components/news/NewsPopUpComponent';
|
|
8
|
+
import NewsCollageBannerComponent from '../components/news/NewsCollageBannerComponent';
|
|
9
|
+
import NewsCollageBannerRSSComponent from '../components/news/NewsCollageBannerRSSComponent';
|
|
10
|
+
import { isElementInViewport } from './helpers';
|
|
11
|
+
|
|
12
|
+
const AUNewsConfig = {
|
|
13
|
+
server: window.newsServer || '//news.au.dk',
|
|
14
|
+
newsUrl: `${window.location.href.replace(window.location.hash, '').replace('#', '')}#news-`,
|
|
15
|
+
useOverlay: !(typeof window.useOverlay !== 'undefined' && !window.useOverlay),
|
|
16
|
+
useSyndication: !(typeof window.useSyndication !== 'undefined' && !window.useSyndication),
|
|
17
|
+
tagStrip: new RegExp(/<(?!\/?sub|sup(?=>|\s.*>))\/?.*?>/ig),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
class AUNewsHelpers {
|
|
21
|
+
static typeIdToText(_id) {
|
|
22
|
+
let id = _id;
|
|
23
|
+
id = parseInt(id, 10);
|
|
24
|
+
if (id === 0 || id === 2) {
|
|
25
|
+
return 'news';
|
|
26
|
+
}
|
|
27
|
+
if (id === 4 || id === 7) {
|
|
28
|
+
return 'event';
|
|
29
|
+
}
|
|
30
|
+
if (id === 9) {
|
|
31
|
+
return 'notice';
|
|
32
|
+
}
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static getEventDates(item, lang) {
|
|
37
|
+
const fromDateSplit = item.event_from.date.split('.');
|
|
38
|
+
let fromDate;
|
|
39
|
+
if (lang === 'en') {
|
|
40
|
+
fromDate = new Date(
|
|
41
|
+
parseInt(fromDateSplit[0], 10),
|
|
42
|
+
parseInt(fromDateSplit[1], 10) - 1,
|
|
43
|
+
parseInt(fromDateSplit[2], 10),
|
|
44
|
+
);
|
|
45
|
+
} else {
|
|
46
|
+
fromDate = new Date(
|
|
47
|
+
parseInt(fromDateSplit[2], 10),
|
|
48
|
+
parseInt(fromDateSplit[1], 10) - 1,
|
|
49
|
+
parseInt(fromDateSplit[0], 10),
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const toDateSplit = item.event_to.date.split('.');
|
|
54
|
+
let toDate;
|
|
55
|
+
if (lang === 'en') {
|
|
56
|
+
toDate = new Date(
|
|
57
|
+
parseInt(toDateSplit[0], 10),
|
|
58
|
+
parseInt(toDateSplit[1], 10) - 1,
|
|
59
|
+
parseInt(toDateSplit[2], 10),
|
|
60
|
+
);
|
|
61
|
+
} else {
|
|
62
|
+
toDate = new Date(
|
|
63
|
+
parseInt(toDateSplit[2], 10),
|
|
64
|
+
parseInt(toDateSplit[1], 10) - 1,
|
|
65
|
+
parseInt(toDateSplit[0], 10),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
fromDate,
|
|
71
|
+
toDate,
|
|
72
|
+
fromDateSplit,
|
|
73
|
+
toDateSplit,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static setExternal(_item) {
|
|
78
|
+
const item = _item;
|
|
79
|
+
const ttType = parseInt(item.type, 10);
|
|
80
|
+
item.external = ttType !== 0 && ttType !== 4 && ttType !== 9;
|
|
81
|
+
// "News" eller "Event" eller "Notice"
|
|
82
|
+
item.url = !item.external
|
|
83
|
+
&& AUNewsConfig.useOverlay ? (AUNewsConfig.newsUrl + item.id) : item.permalink;
|
|
84
|
+
return item;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static getNewsID(search) {
|
|
88
|
+
const reNewsId = /^#?news-(.*)$/;
|
|
89
|
+
const match = search.match(reNewsId);
|
|
90
|
+
if (match !== null) {
|
|
91
|
+
return match[1];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return -1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static isiPad() {
|
|
98
|
+
return (/iPad/i).test(navigator.userAgent);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
class AUNews {
|
|
103
|
+
constructor(lang, feeds) {
|
|
104
|
+
this.lang = lang;
|
|
105
|
+
this.feeds = feeds || [];
|
|
106
|
+
this.item = null;
|
|
107
|
+
this.setItem = this.setItem.bind(this);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
setItem(item) {
|
|
111
|
+
this.item = item;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
setPopUp() {
|
|
115
|
+
const qsNewsPrint = AU.helpers.getQuerystring('newsprint');
|
|
116
|
+
const print = qsNewsPrint !== '';
|
|
117
|
+
const openPopUp = () => {
|
|
118
|
+
const newsID = AUNewsHelpers.getNewsID(window.location.hash);
|
|
119
|
+
let mountNode = document.getElementById('au_news_popup');
|
|
120
|
+
if (print) {
|
|
121
|
+
mountNode = document.querySelector('body');
|
|
122
|
+
}
|
|
123
|
+
if (parseInt(newsID, 10) > -1) {
|
|
124
|
+
if (this.item != null) {
|
|
125
|
+
const trackerLink = `/virtual/news/${AUNewsHelpers.typeIdToText(this.item.type)}/open-list/id-${this.item.id}/${this.item.permalink}`;
|
|
126
|
+
AU.tracking.trackSingle(trackerLink);
|
|
127
|
+
}
|
|
128
|
+
// Would like to use portal here, but it won't work "standalone"
|
|
129
|
+
ReactDOM.render(
|
|
130
|
+
<NewsPopUpComponent
|
|
131
|
+
id={newsID}
|
|
132
|
+
item={this.item}
|
|
133
|
+
lang={this.lang}
|
|
134
|
+
print={print}
|
|
135
|
+
/>,
|
|
136
|
+
mountNode,
|
|
137
|
+
);
|
|
138
|
+
} else if (window.location.hash === '' || window.location.hash === '#') { // Thx IE!
|
|
139
|
+
ReactDOM.unmountComponentAtNode(mountNode);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
openPopUp();
|
|
144
|
+
|
|
145
|
+
window.addEventListener('hashchange', () => {
|
|
146
|
+
openPopUp();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const fade = document.getElementById('fade');
|
|
150
|
+
fade.addEventListener('click', () => {
|
|
151
|
+
window.location.hash = '';
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
init() {
|
|
156
|
+
this.setPopUp();
|
|
157
|
+
this.feeds.forEach((f) => {
|
|
158
|
+
const list = f;
|
|
159
|
+
list.container = document.querySelector(`#au_news-list_${list.id}`);
|
|
160
|
+
list.items = [];
|
|
161
|
+
list.page = 1;
|
|
162
|
+
const elements = AUNews.getElementFormatArray(list);
|
|
163
|
+
const mountNode = list.container;
|
|
164
|
+
if (mountNode) {
|
|
165
|
+
ReactDOM.render(
|
|
166
|
+
<NewsListComponent
|
|
167
|
+
lang={this.lang}
|
|
168
|
+
list={list}
|
|
169
|
+
elements={elements}
|
|
170
|
+
setItem={this.setItem}
|
|
171
|
+
/>,
|
|
172
|
+
mountNode,
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
static getElementFormatArray(_list) {
|
|
179
|
+
const list = _list;
|
|
180
|
+
const elements = [];
|
|
181
|
+
const rowSplit = list.format.split(',');
|
|
182
|
+
let formatCount = 0;
|
|
183
|
+
for (let r = 0; r < rowSplit.length; r += 1) {
|
|
184
|
+
const element = rowSplit[r];
|
|
185
|
+
if (element !== '|') {
|
|
186
|
+
if (element.indexOf('|') > -1) {
|
|
187
|
+
const columns = [];
|
|
188
|
+
const columnSplit = element.split('|');
|
|
189
|
+
for (let c = 0; c < columnSplit.length; c += 1) {
|
|
190
|
+
const columnElements = [];
|
|
191
|
+
const columnElementsSplit = columnSplit[c].split(';');
|
|
192
|
+
for (let e = 0; e < columnElementsSplit.length; e += 1) {
|
|
193
|
+
columnElements.push(columnElementsSplit[e]);
|
|
194
|
+
list.lastelement = columnElementsSplit[e];
|
|
195
|
+
list.lastiscolumn = true;
|
|
196
|
+
formatCount += 1;
|
|
197
|
+
}
|
|
198
|
+
columns.push(columnElements);
|
|
199
|
+
}
|
|
200
|
+
elements.push(columns);
|
|
201
|
+
} else {
|
|
202
|
+
elements.push(element);
|
|
203
|
+
list.lastiscolumn = false;
|
|
204
|
+
list.lastelement = element;
|
|
205
|
+
formatCount += 1;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (list.page === 1) {
|
|
211
|
+
list.amount = formatCount;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return elements;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
class AUNewsCollage {
|
|
219
|
+
constructor(lang, element) {
|
|
220
|
+
this.element = element;
|
|
221
|
+
this.loaded = false;
|
|
222
|
+
this.lang = lang;
|
|
223
|
+
window.addEventListener('scroll', () => {
|
|
224
|
+
this.init();
|
|
225
|
+
this.initRSS();
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
loadData(key, callback) {
|
|
230
|
+
const url = `${AUNewsConfig.server}/index.php?eID=getAuNewsFeed&mode=key&key=${key}&index=0&amount=4&noPageBrowser=1&lang=${this.lang}&callback=?`;
|
|
231
|
+
$.ajax({
|
|
232
|
+
url,
|
|
233
|
+
dataType: 'json',
|
|
234
|
+
jsonpCallback: url.hashCode(),
|
|
235
|
+
jsonp: true,
|
|
236
|
+
cache: true,
|
|
237
|
+
success: (data) => {
|
|
238
|
+
if (typeof callback === 'function') {
|
|
239
|
+
callback(data);
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
loadDataRSS(url, callback) {
|
|
246
|
+
fetch(url).then((response) => response.json()).then((data) => callback(data.Items));
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
init() {
|
|
250
|
+
if (!this.loaded && isElementInViewport(this.element) && typeof window.newsCollageRSS === 'undefined') {
|
|
251
|
+
const newsElements = [
|
|
252
|
+
document.querySelector('#news1'),
|
|
253
|
+
document.querySelector('#news2'),
|
|
254
|
+
document.querySelector('#news3'),
|
|
255
|
+
document.querySelector('#news4'),
|
|
256
|
+
];
|
|
257
|
+
|
|
258
|
+
const eventElements = [
|
|
259
|
+
document.querySelector('#event1'),
|
|
260
|
+
document.querySelector('#event2'),
|
|
261
|
+
document.querySelector('#event3'),
|
|
262
|
+
];
|
|
263
|
+
|
|
264
|
+
// News
|
|
265
|
+
const newsFeedKey = this.lang === 'da' ? 'b73f5e9759ac3592043449c02dcffa56' : '400bcbb4807a5a722df5e2045fa7966f';
|
|
266
|
+
this.loadData(newsFeedKey, (data) => {
|
|
267
|
+
newsElements.forEach((e, i) => {
|
|
268
|
+
if (data[i]) {
|
|
269
|
+
ReactDOM.render(
|
|
270
|
+
<NewsCollageBannerComponent
|
|
271
|
+
type="news"
|
|
272
|
+
item={AUNewsHelpers.setExternal(data[i])}
|
|
273
|
+
title={this.lang === 'da' ? 'Nyhed' : 'News'}
|
|
274
|
+
lang={this.lang}
|
|
275
|
+
/>,
|
|
276
|
+
e,
|
|
277
|
+
);
|
|
278
|
+
} else {
|
|
279
|
+
e.style.display = 'none';
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
// Events
|
|
284
|
+
const eventFeedKey = this.lang === 'da' ? '003383f99d8ae70cde9110294ab39727' : '19a8aa9cc30143d2e41cfbdb4123541e';
|
|
285
|
+
this.loadData(eventFeedKey, (data) => {
|
|
286
|
+
eventElements.forEach((e, i) => {
|
|
287
|
+
if (data[i]) {
|
|
288
|
+
ReactDOM.render(
|
|
289
|
+
<NewsCollageBannerComponent
|
|
290
|
+
type="events"
|
|
291
|
+
item={AUNewsHelpers.setExternal(data[i])}
|
|
292
|
+
title={this.lang === 'da' ? 'Arrangement' : 'Event'}
|
|
293
|
+
lang={this.lang}
|
|
294
|
+
/>,
|
|
295
|
+
e,
|
|
296
|
+
);
|
|
297
|
+
} else {
|
|
298
|
+
e.style.display = 'none';
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
this.loaded = true;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
initRSS() {
|
|
308
|
+
if (!this.loaded && isElementInViewport(this.element) && typeof window.newsCollageRSS !== 'undefined' && window.newsCollageRSS) {
|
|
309
|
+
const newsElements = [
|
|
310
|
+
document.querySelector('#news1'),
|
|
311
|
+
document.querySelector('#news2'),
|
|
312
|
+
document.querySelector('#news3'),
|
|
313
|
+
document.querySelector('#news4'),
|
|
314
|
+
];
|
|
315
|
+
|
|
316
|
+
const eventElements = [
|
|
317
|
+
document.querySelector('#event1'),
|
|
318
|
+
document.querySelector('#event2'),
|
|
319
|
+
document.querySelector('#event3'),
|
|
320
|
+
];
|
|
321
|
+
|
|
322
|
+
// News
|
|
323
|
+
const newsFeedKey = `https://webtools.au.dk/api/news/getlist?url=${window.newsFeedRssUri}`;
|
|
324
|
+
this.loadDataRSS(newsFeedKey, (data) => {
|
|
325
|
+
newsElements.forEach((e, i) => {
|
|
326
|
+
if (data[i]) {
|
|
327
|
+
ReactDOM.render(
|
|
328
|
+
<NewsCollageBannerRSSComponent
|
|
329
|
+
type="news"
|
|
330
|
+
item={data[i]}
|
|
331
|
+
title={this.lang === 'da' ? 'Nyhed' : 'News'}
|
|
332
|
+
lang={this.lang}
|
|
333
|
+
/>,
|
|
334
|
+
e,
|
|
335
|
+
);
|
|
336
|
+
} else {
|
|
337
|
+
e.style.display = 'none';
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
// Events
|
|
342
|
+
const eventFeedKey = `https://webtools.au.dk/api/news/getlist?url=${window.eventFeedRssUri}`;
|
|
343
|
+
this.loadDataRSS(eventFeedKey, (data) => {
|
|
344
|
+
eventElements.forEach((e, i) => {
|
|
345
|
+
if (data[i]) {
|
|
346
|
+
ReactDOM.render(
|
|
347
|
+
<NewsCollageBannerRSSComponent
|
|
348
|
+
type="events"
|
|
349
|
+
item={data[i]}
|
|
350
|
+
title={this.lang === 'da' ? 'Arrangement' : 'Event'}
|
|
351
|
+
lang={this.lang}
|
|
352
|
+
/>,
|
|
353
|
+
e,
|
|
354
|
+
);
|
|
355
|
+
} else {
|
|
356
|
+
e.style.display = 'none';
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
this.loaded = true;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
window.AUNews = AUNews;
|
|
367
|
+
window.AUNewsCollage = AUNewsCollage;
|
|
368
|
+
export {
|
|
369
|
+
AUNewsConfig,
|
|
370
|
+
AUNewsHelpers,
|
|
371
|
+
};
|