@aarhus-university/au-lib-react-components 9.11.2 → 9.11.6
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 +88 -87
- package/src/components/delphinus/AUSpinnerComponent.js +114 -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 +25 -25
- 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 -302
- 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 +120 -116
- 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 -599
- 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
|
@@ -1,291 +1,291 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import ReactDOM from 'react-dom';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import EventLayout1Component from './EventLayout1Component';
|
|
6
|
-
import EventLayout2Component from './EventLayout2Component';
|
|
7
|
-
import EventLayout3Component from './EventLayout3Component';
|
|
8
|
-
import NewsLayout1Component from './NewsLayout1Component';
|
|
9
|
-
import NewsLayout2Component from './NewsLayout2Component';
|
|
10
|
-
import NewsLayout3Component from './NewsLayout3Component';
|
|
11
|
-
import NewsLayout4Component from './NewsLayout4Component';
|
|
12
|
-
import NewsLayout5Component from './NewsLayout5Component';
|
|
13
|
-
import NewsLayout6Component from './NewsLayout6Component';
|
|
14
|
-
import NewsLayout7Component from './NewsLayout7Component';
|
|
15
|
-
import NewsLayout8Component from './NewsLayout8Component';
|
|
16
|
-
import NewsColumnsComponent from './NewsColumnsComponent';
|
|
17
|
-
import NewsRSSComponent from './NewsRSSComponent';
|
|
18
|
-
import AUSpinnerComponent from '../AUSpinnerComponent';
|
|
19
|
-
import { newsLabels as labels } from '../../lib/i18n';
|
|
20
|
-
import { AUNewsConfig } from '../../lib/au-news';
|
|
21
|
-
|
|
22
|
-
class NewsListComponent extends React.Component {
|
|
23
|
-
constructor(props) {
|
|
24
|
-
super(props);
|
|
25
|
-
|
|
26
|
-
this.pointer = -1;
|
|
27
|
-
this.layouts = [
|
|
28
|
-
<NewsLayout1Component />,
|
|
29
|
-
<NewsLayout2Component />,
|
|
30
|
-
<NewsLayout3Component />,
|
|
31
|
-
<NewsLayout4Component />,
|
|
32
|
-
<NewsLayout5Component />,
|
|
33
|
-
<NewsLayout6Component />,
|
|
34
|
-
<NewsLayout7Component />,
|
|
35
|
-
<NewsLayout8Component />,
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
this.layoutsEvents = [
|
|
39
|
-
<EventLayout1Component />,
|
|
40
|
-
<EventLayout2Component />,
|
|
41
|
-
<EventLayout3Component />,
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
const { list, elements } = props;
|
|
45
|
-
|
|
46
|
-
this.state = {
|
|
47
|
-
loading: true,
|
|
48
|
-
more: !list.noPageBrowser,
|
|
49
|
-
items: [],
|
|
50
|
-
elements,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
this.handleLoadMore = this.handleLoadMore.bind(this);
|
|
54
|
-
this.incrementPointer = this.incrementPointer.bind(this);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
componentDidMount() {
|
|
58
|
-
this.setHeader();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
getItems(index, amount, callback) {
|
|
62
|
-
const { list, lang } = this.props;
|
|
63
|
-
const url = `${AUNewsConfig.server}/index.php?eID=getAuNewsFeed&mode=key&key=${list.feed_key}&index=${index}&amount=${(amount + (list.noPageBrowser === 0 ? 1 : 0))}&lang=${lang}${list.extra_param}&callback=?`;
|
|
64
|
-
|
|
65
|
-
// Axios does not support JSONP requests!
|
|
66
|
-
$.ajax({
|
|
67
|
-
url,
|
|
68
|
-
dataType: 'json',
|
|
69
|
-
jsonpCallback: url.hashCode(),
|
|
70
|
-
jsonp: true,
|
|
71
|
-
cache: true,
|
|
72
|
-
success: (items) => {
|
|
73
|
-
callback(items, items.length > amount && list.noPageBrowser === 0);
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
setHeader() {
|
|
79
|
-
const { list } = this.props;
|
|
80
|
-
list.header = document.querySelector(`#c${list.id} .csc-header h1`);
|
|
81
|
-
if (!list.header) {
|
|
82
|
-
list.header = document.querySelector(`#c${list.id} .csc-header h2`);
|
|
83
|
-
}
|
|
84
|
-
if (list.header) {
|
|
85
|
-
list.header.parentNode.classList.add('relative');
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
incrementPointer() {
|
|
90
|
-
// "Global" pointer til at holde styr på, hvor langt vi er nået igennem data
|
|
91
|
-
// til de forskellige elementer
|
|
92
|
-
this.pointer += 1;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
handleLoadMore(e) {
|
|
96
|
-
e.preventDefault();
|
|
97
|
-
this.setState({
|
|
98
|
-
loading: true,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
const { elements } = this.props;
|
|
102
|
-
let lastElement = elements[elements.length - 1];
|
|
103
|
-
if (Array.isArray(lastElement)) {
|
|
104
|
-
const temp = lastElement[lastElement.length - 1];
|
|
105
|
-
if (Array.isArray(temp)) {
|
|
106
|
-
lastElement = temp[temp.length - 1];
|
|
107
|
-
} else {
|
|
108
|
-
lastElement = temp;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const amount = 10;
|
|
113
|
-
const newElements = [];
|
|
114
|
-
for (let i = 0; i < amount; i += 1) {
|
|
115
|
-
newElements.push(lastElement);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const { items, elements: sElements } = this.state;
|
|
119
|
-
this.getItems(items.length - 1, amount, (_items, more) => {
|
|
120
|
-
this.setState({
|
|
121
|
-
items: items.slice(0, items.length - 1).concat(_items),
|
|
122
|
-
elements: sElements.concat(newElements),
|
|
123
|
-
loading: false,
|
|
124
|
-
more,
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
render() {
|
|
130
|
-
this.pointer = -1;
|
|
131
|
-
const {
|
|
132
|
-
list,
|
|
133
|
-
elements: pElements,
|
|
134
|
-
lang,
|
|
135
|
-
setItem,
|
|
136
|
-
} = this.props;
|
|
137
|
-
const {
|
|
138
|
-
items,
|
|
139
|
-
elements,
|
|
140
|
-
loading,
|
|
141
|
-
more,
|
|
142
|
-
} = this.state;
|
|
143
|
-
let isHeader = false;
|
|
144
|
-
const headerElementValue = list.feed_type === 'events' ? 3 : 6;
|
|
145
|
-
const renderElements = elements.map((e, j) => {
|
|
146
|
-
const key = j;
|
|
147
|
-
// Kolonne
|
|
148
|
-
if (Array.isArray(e)) {
|
|
149
|
-
let length = 0;
|
|
150
|
-
for (let i = 0; i < e.length; i += 1) {
|
|
151
|
-
for (let n = 0; n < e[i].length; n += 1) {
|
|
152
|
-
this.incrementPointer();
|
|
153
|
-
length += 1;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<NewsColumnsComponent
|
|
159
|
-
key={key}
|
|
160
|
-
type={list.feed_type}
|
|
161
|
-
listid={list.id}
|
|
162
|
-
cols={e}
|
|
163
|
-
items={items.slice(j, j + length)}
|
|
164
|
-
setPopupItem={setItem}
|
|
165
|
-
incrementPointer={this.incrementPointer}
|
|
166
|
-
lang={lang}
|
|
167
|
-
/>
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Ikke-kolonne
|
|
172
|
-
const element = parseInt(e, 10);
|
|
173
|
-
if (element === headerElementValue && !isHeader) {
|
|
174
|
-
isHeader = true;
|
|
175
|
-
const hItems = [];
|
|
176
|
-
for (let x = j; x < items.length; x += 1) {
|
|
177
|
-
// Høker-hack-fix af load more ved listevisning
|
|
178
|
-
// jf. FB84396 - der er givetvis stadig et issue, hvis listerne ligger i en kolonne...
|
|
179
|
-
if (parseInt(pElements[x], 10) === headerElementValue
|
|
180
|
-
|| (!Number.isNaN(pElements[x]) && items.length - pElements.length > 2)) {
|
|
181
|
-
this.incrementPointer();
|
|
182
|
-
hItems.push(items[this.pointer]);
|
|
183
|
-
} else {
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (list.feed_type === 'events') {
|
|
189
|
-
return (
|
|
190
|
-
<EventLayout3Component
|
|
191
|
-
key={key}
|
|
192
|
-
listid={list.id}
|
|
193
|
-
items={hItems}
|
|
194
|
-
setPopupItem={setItem}
|
|
195
|
-
lang={lang}
|
|
196
|
-
/>
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return (
|
|
201
|
-
<NewsLayout6Component
|
|
202
|
-
key={key}
|
|
203
|
-
listid={list.id}
|
|
204
|
-
items={hItems}
|
|
205
|
-
setPopupItem={setItem}
|
|
206
|
-
lang={lang}
|
|
207
|
-
/>
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (element !== headerElementValue) {
|
|
212
|
-
this.incrementPointer();
|
|
213
|
-
isHeader = false;
|
|
214
|
-
const layoutsArray = list.feed_type === 'events' ? this.layoutsEvents : this.layouts;
|
|
215
|
-
return React.cloneElement(layoutsArray[element - 1], {
|
|
216
|
-
key,
|
|
217
|
-
item: items[this.pointer],
|
|
218
|
-
listid: list.id,
|
|
219
|
-
setPopupItem: setItem,
|
|
220
|
-
lang,
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return null;
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
let syndication = null;
|
|
228
|
-
const syndicationNode = document.querySelector(`#c${list.id} .csc-header`);
|
|
229
|
-
if (syndicationNode && AUNewsConfig.useSyndication && list.feed_type !== 'events') {
|
|
230
|
-
syndication = ReactDOM.createPortal(
|
|
231
|
-
<NewsRSSComponent
|
|
232
|
-
url={`http:${AUNewsConfig.server}/index.php?eID=getAuNewsFeed&mode=xml&key=${list.feed_key}&lang=${lang}`}
|
|
233
|
-
lang={lang}
|
|
234
|
-
/>,
|
|
235
|
-
syndicationNode,
|
|
236
|
-
'2',
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return [
|
|
241
|
-
<div key={0}>
|
|
242
|
-
{renderElements}
|
|
243
|
-
{(() => {
|
|
244
|
-
if (more) {
|
|
245
|
-
return (
|
|
246
|
-
<button
|
|
247
|
-
type="button"
|
|
248
|
-
onClick={this.handleLoadMore}
|
|
249
|
-
className="button small"
|
|
250
|
-
>
|
|
251
|
-
{labels[lang].news.listLoadMore}
|
|
252
|
-
</button>
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
return null;
|
|
256
|
-
})()}
|
|
257
|
-
</div>,
|
|
258
|
-
<AUSpinnerComponent
|
|
259
|
-
key={1}
|
|
260
|
-
domID={`news-spinner-${list.id}`}
|
|
261
|
-
loaded={!loading}
|
|
262
|
-
loadingCondition={loading}
|
|
263
|
-
onLoad={() => {
|
|
264
|
-
this.getItems(0, list.amount, (_items, _more) => {
|
|
265
|
-
this.setState({ items: _items, loading: false, more: _more });
|
|
266
|
-
});
|
|
267
|
-
}}
|
|
268
|
-
content={<div />}
|
|
269
|
-
/>,
|
|
270
|
-
syndication,
|
|
271
|
-
];
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
NewsListComponent.propTypes = {
|
|
276
|
-
lang: PropTypes.string.isRequired,
|
|
277
|
-
list: PropTypes.shape({
|
|
278
|
-
feed_key: PropTypes.string.isRequired,
|
|
279
|
-
noPageBrowser: PropTypes.bool.isRequired,
|
|
280
|
-
id: PropTypes.number.isRequired,
|
|
281
|
-
amount: PropTypes.number.isRequired,
|
|
282
|
-
extra_param: PropTypes.string.isRequired,
|
|
283
|
-
header: PropTypes.instanceOf(Element).isRequired,
|
|
284
|
-
feed_type: PropTypes.string.isRequired,
|
|
285
|
-
}).isRequired,
|
|
286
|
-
elements: PropTypes.arrayOf(PropTypes.number).isRequired,
|
|
287
|
-
setItem: PropTypes.func.isRequired,
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
NewsListComponent.displayName = 'NewsListComponent';
|
|
291
|
-
export default NewsListComponent;
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import EventLayout1Component from './EventLayout1Component';
|
|
6
|
+
import EventLayout2Component from './EventLayout2Component';
|
|
7
|
+
import EventLayout3Component from './EventLayout3Component';
|
|
8
|
+
import NewsLayout1Component from './NewsLayout1Component';
|
|
9
|
+
import NewsLayout2Component from './NewsLayout2Component';
|
|
10
|
+
import NewsLayout3Component from './NewsLayout3Component';
|
|
11
|
+
import NewsLayout4Component from './NewsLayout4Component';
|
|
12
|
+
import NewsLayout5Component from './NewsLayout5Component';
|
|
13
|
+
import NewsLayout6Component from './NewsLayout6Component';
|
|
14
|
+
import NewsLayout7Component from './NewsLayout7Component';
|
|
15
|
+
import NewsLayout8Component from './NewsLayout8Component';
|
|
16
|
+
import NewsColumnsComponent from './NewsColumnsComponent';
|
|
17
|
+
import NewsRSSComponent from './NewsRSSComponent';
|
|
18
|
+
import AUSpinnerComponent from '../AUSpinnerComponent';
|
|
19
|
+
import { newsLabels as labels } from '../../lib/i18n';
|
|
20
|
+
import { AUNewsConfig } from '../../lib/au-news';
|
|
21
|
+
|
|
22
|
+
class NewsListComponent extends React.Component {
|
|
23
|
+
constructor(props) {
|
|
24
|
+
super(props);
|
|
25
|
+
|
|
26
|
+
this.pointer = -1;
|
|
27
|
+
this.layouts = [
|
|
28
|
+
<NewsLayout1Component />,
|
|
29
|
+
<NewsLayout2Component />,
|
|
30
|
+
<NewsLayout3Component />,
|
|
31
|
+
<NewsLayout4Component />,
|
|
32
|
+
<NewsLayout5Component />,
|
|
33
|
+
<NewsLayout6Component />,
|
|
34
|
+
<NewsLayout7Component />,
|
|
35
|
+
<NewsLayout8Component />,
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
this.layoutsEvents = [
|
|
39
|
+
<EventLayout1Component />,
|
|
40
|
+
<EventLayout2Component />,
|
|
41
|
+
<EventLayout3Component />,
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
const { list, elements } = props;
|
|
45
|
+
|
|
46
|
+
this.state = {
|
|
47
|
+
loading: true,
|
|
48
|
+
more: !list.noPageBrowser,
|
|
49
|
+
items: [],
|
|
50
|
+
elements,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
this.handleLoadMore = this.handleLoadMore.bind(this);
|
|
54
|
+
this.incrementPointer = this.incrementPointer.bind(this);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
componentDidMount() {
|
|
58
|
+
this.setHeader();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
getItems(index, amount, callback) {
|
|
62
|
+
const { list, lang } = this.props;
|
|
63
|
+
const url = `${AUNewsConfig.server}/index.php?eID=getAuNewsFeed&mode=key&key=${list.feed_key}&index=${index}&amount=${(amount + (list.noPageBrowser === 0 ? 1 : 0))}&lang=${lang}${list.extra_param}&callback=?`;
|
|
64
|
+
|
|
65
|
+
// Axios does not support JSONP requests!
|
|
66
|
+
$.ajax({
|
|
67
|
+
url,
|
|
68
|
+
dataType: 'json',
|
|
69
|
+
jsonpCallback: url.hashCode(),
|
|
70
|
+
jsonp: true,
|
|
71
|
+
cache: true,
|
|
72
|
+
success: (items) => {
|
|
73
|
+
callback(items, items.length > amount && list.noPageBrowser === 0);
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
setHeader() {
|
|
79
|
+
const { list } = this.props;
|
|
80
|
+
list.header = document.querySelector(`#c${list.id} .csc-header h1`);
|
|
81
|
+
if (!list.header) {
|
|
82
|
+
list.header = document.querySelector(`#c${list.id} .csc-header h2`);
|
|
83
|
+
}
|
|
84
|
+
if (list.header) {
|
|
85
|
+
list.header.parentNode.classList.add('relative');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
incrementPointer() {
|
|
90
|
+
// "Global" pointer til at holde styr på, hvor langt vi er nået igennem data
|
|
91
|
+
// til de forskellige elementer
|
|
92
|
+
this.pointer += 1;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
handleLoadMore(e) {
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
this.setState({
|
|
98
|
+
loading: true,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const { elements } = this.props;
|
|
102
|
+
let lastElement = elements[elements.length - 1];
|
|
103
|
+
if (Array.isArray(lastElement)) {
|
|
104
|
+
const temp = lastElement[lastElement.length - 1];
|
|
105
|
+
if (Array.isArray(temp)) {
|
|
106
|
+
lastElement = temp[temp.length - 1];
|
|
107
|
+
} else {
|
|
108
|
+
lastElement = temp;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const amount = 10;
|
|
113
|
+
const newElements = [];
|
|
114
|
+
for (let i = 0; i < amount; i += 1) {
|
|
115
|
+
newElements.push(lastElement);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const { items, elements: sElements } = this.state;
|
|
119
|
+
this.getItems(items.length - 1, amount, (_items, more) => {
|
|
120
|
+
this.setState({
|
|
121
|
+
items: items.slice(0, items.length - 1).concat(_items),
|
|
122
|
+
elements: sElements.concat(newElements),
|
|
123
|
+
loading: false,
|
|
124
|
+
more,
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
render() {
|
|
130
|
+
this.pointer = -1;
|
|
131
|
+
const {
|
|
132
|
+
list,
|
|
133
|
+
elements: pElements,
|
|
134
|
+
lang,
|
|
135
|
+
setItem,
|
|
136
|
+
} = this.props;
|
|
137
|
+
const {
|
|
138
|
+
items,
|
|
139
|
+
elements,
|
|
140
|
+
loading,
|
|
141
|
+
more,
|
|
142
|
+
} = this.state;
|
|
143
|
+
let isHeader = false;
|
|
144
|
+
const headerElementValue = list.feed_type === 'events' ? 3 : 6;
|
|
145
|
+
const renderElements = elements.map((e, j) => {
|
|
146
|
+
const key = j;
|
|
147
|
+
// Kolonne
|
|
148
|
+
if (Array.isArray(e)) {
|
|
149
|
+
let length = 0;
|
|
150
|
+
for (let i = 0; i < e.length; i += 1) {
|
|
151
|
+
for (let n = 0; n < e[i].length; n += 1) {
|
|
152
|
+
this.incrementPointer();
|
|
153
|
+
length += 1;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<NewsColumnsComponent
|
|
159
|
+
key={key}
|
|
160
|
+
type={list.feed_type}
|
|
161
|
+
listid={list.id}
|
|
162
|
+
cols={e}
|
|
163
|
+
items={items.slice(j, j + length)}
|
|
164
|
+
setPopupItem={setItem}
|
|
165
|
+
incrementPointer={this.incrementPointer}
|
|
166
|
+
lang={lang}
|
|
167
|
+
/>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Ikke-kolonne
|
|
172
|
+
const element = parseInt(e, 10);
|
|
173
|
+
if (element === headerElementValue && !isHeader) {
|
|
174
|
+
isHeader = true;
|
|
175
|
+
const hItems = [];
|
|
176
|
+
for (let x = j; x < items.length; x += 1) {
|
|
177
|
+
// Høker-hack-fix af load more ved listevisning
|
|
178
|
+
// jf. FB84396 - der er givetvis stadig et issue, hvis listerne ligger i en kolonne...
|
|
179
|
+
if (parseInt(pElements[x], 10) === headerElementValue
|
|
180
|
+
|| (!Number.isNaN(pElements[x]) && items.length - pElements.length > 2)) {
|
|
181
|
+
this.incrementPointer();
|
|
182
|
+
hItems.push(items[this.pointer]);
|
|
183
|
+
} else {
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (list.feed_type === 'events') {
|
|
189
|
+
return (
|
|
190
|
+
<EventLayout3Component
|
|
191
|
+
key={key}
|
|
192
|
+
listid={list.id}
|
|
193
|
+
items={hItems}
|
|
194
|
+
setPopupItem={setItem}
|
|
195
|
+
lang={lang}
|
|
196
|
+
/>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
<NewsLayout6Component
|
|
202
|
+
key={key}
|
|
203
|
+
listid={list.id}
|
|
204
|
+
items={hItems}
|
|
205
|
+
setPopupItem={setItem}
|
|
206
|
+
lang={lang}
|
|
207
|
+
/>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (element !== headerElementValue) {
|
|
212
|
+
this.incrementPointer();
|
|
213
|
+
isHeader = false;
|
|
214
|
+
const layoutsArray = list.feed_type === 'events' ? this.layoutsEvents : this.layouts;
|
|
215
|
+
return React.cloneElement(layoutsArray[element - 1], {
|
|
216
|
+
key,
|
|
217
|
+
item: items[this.pointer],
|
|
218
|
+
listid: list.id,
|
|
219
|
+
setPopupItem: setItem,
|
|
220
|
+
lang,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return null;
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
let syndication = null;
|
|
228
|
+
const syndicationNode = document.querySelector(`#c${list.id} .csc-header`);
|
|
229
|
+
if (syndicationNode && AUNewsConfig.useSyndication && list.feed_type !== 'events') {
|
|
230
|
+
syndication = ReactDOM.createPortal(
|
|
231
|
+
<NewsRSSComponent
|
|
232
|
+
url={`http:${AUNewsConfig.server}/index.php?eID=getAuNewsFeed&mode=xml&key=${list.feed_key}&lang=${lang}`}
|
|
233
|
+
lang={lang}
|
|
234
|
+
/>,
|
|
235
|
+
syndicationNode,
|
|
236
|
+
'2',
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return [
|
|
241
|
+
<div key={0}>
|
|
242
|
+
{renderElements}
|
|
243
|
+
{(() => {
|
|
244
|
+
if (more) {
|
|
245
|
+
return (
|
|
246
|
+
<button
|
|
247
|
+
type="button"
|
|
248
|
+
onClick={this.handleLoadMore}
|
|
249
|
+
className="button small"
|
|
250
|
+
>
|
|
251
|
+
{labels[lang].news.listLoadMore}
|
|
252
|
+
</button>
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
return null;
|
|
256
|
+
})()}
|
|
257
|
+
</div>,
|
|
258
|
+
<AUSpinnerComponent
|
|
259
|
+
key={1}
|
|
260
|
+
domID={`news-spinner-${list.id}`}
|
|
261
|
+
loaded={!loading}
|
|
262
|
+
loadingCondition={loading}
|
|
263
|
+
onLoad={() => {
|
|
264
|
+
this.getItems(0, list.amount, (_items, _more) => {
|
|
265
|
+
this.setState({ items: _items, loading: false, more: _more });
|
|
266
|
+
});
|
|
267
|
+
}}
|
|
268
|
+
content={<div />}
|
|
269
|
+
/>,
|
|
270
|
+
syndication,
|
|
271
|
+
];
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
NewsListComponent.propTypes = {
|
|
276
|
+
lang: PropTypes.string.isRequired,
|
|
277
|
+
list: PropTypes.shape({
|
|
278
|
+
feed_key: PropTypes.string.isRequired,
|
|
279
|
+
noPageBrowser: PropTypes.bool.isRequired,
|
|
280
|
+
id: PropTypes.number.isRequired,
|
|
281
|
+
amount: PropTypes.number.isRequired,
|
|
282
|
+
extra_param: PropTypes.string.isRequired,
|
|
283
|
+
header: PropTypes.instanceOf(Element).isRequired,
|
|
284
|
+
feed_type: PropTypes.string.isRequired,
|
|
285
|
+
}).isRequired,
|
|
286
|
+
elements: PropTypes.arrayOf(PropTypes.number).isRequired,
|
|
287
|
+
setItem: PropTypes.func.isRequired,
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
NewsListComponent.displayName = 'NewsListComponent';
|
|
291
|
+
export default NewsListComponent;
|