generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 174
/
utils.js
84 lines (75 loc) · 2.19 KB
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { stub } from 'sinon';
export const getConfig = () => ({});
export const loadStyle = stub();
export const loadScript = stub();
export const localizeLink = (e) => e;
export const utf8ToB64 = (str) => window.btoa(unescape(encodeURIComponent(str)));
export const b64ToUtf8 = (str) => decodeURIComponent(escape(window.atob(str)));
export function getMetadata(name, doc = document) {
const attr = name && name.includes(':') ? 'property' : 'name';
const meta = doc.head.querySelector(`meta[${attr}="${name}"]`);
return meta && meta.content;
}
export function createIntersectionObserver({ el, callback /* , once = true, options = {} */ }) {
// fire immediately
callback(el, { target: el });
}
export const parseEncodedConfig = stub().returns({
analyticsTrackImpression: false,
analyticsCollectionName: '',
andLogicTags: [],
autoCountryLang: false,
bookmarkIconSelect: '',
bookmarkIconUnselect: '',
cardStyle: 'half-height',
collectionBtnStyle: 'primary',
collectionButtonStyle: 'primary',
container: '1200MaxWidth',
country: 'caas:country/us',
contentTypeTags: [],
disableBanners: false,
draftDb: false,
environment: '',
endpoint: 'www.adobe.com/chimera-api/collection',
excludedCards: [],
fallbackEndpoint: '',
featuredCards: [],
gutter: '4x',
headers: [],
hideCtaIds: [],
language: 'caas:language/en',
layoutType: '4up',
loadMoreBtnStyle: 'primary',
onlyShowBookmarkedCards: false,
orLogicTags: [],
paginationAnimationStyle: 'paged',
paginationEnabled: false,
paginationQuantityShown: false,
paginationUseTheme3: false,
paginationType: '',
placeholderUrl: '/my/placeholder.json',
resultsPerPage: 5,
searchFields: [],
setCardBorders: false,
showBookmarksFilter: false,
showBookmarksOnCards: false,
showFilters: false,
filters: [],
secondarySource: '',
secondaryTags: [],
showSearch: false,
showTotalResults: false,
sortDefault: 'dateDesc',
sortEnablePopup: false,
sortEnableRandomSampling: false,
sortReservoirSample: 3,
sortReservoirPool: 1000,
source: ['hawks'],
targetActivity: '',
targetEnabled: false,
theme: 'lightest',
totalCardsToShow: 10,
useLightText: false,
useOverlayLinks: false,
userInfo: [],
});