musora-content-services 1.0.9 → 1.0.11
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/CHANGELOG.md +4 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/global.html +947 -933
- package/docs/index.html +27 -9
- package/docs/index.js.html +147 -51
- package/docs/scripts/collapse.js +39 -0
- package/docs/scripts/commonNav.js +28 -0
- package/docs/scripts/nav.js +12 -0
- package/docs/scripts/polyfill.js +4 -0
- package/docs/scripts/search.js +99 -265
- package/docs/styles/jsdoc.css +776 -0
- package/docs/styles/prettify.css +80 -0
- package/jsdoc.json +1 -1
- package/package.json +5 -4
- package/src/index.js +127 -43
package/docs/scripts/search.js
CHANGED
|
@@ -1,265 +1,99 @@
|
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
bringElementIntoView(element); // defined in core.js
|
|
101
|
-
}, 100);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function buildSearchResult(result) {
|
|
107
|
-
let output = '';
|
|
108
|
-
const removeHTMLTagsRegExp = /(<([^>]+)>)/ig;
|
|
109
|
-
|
|
110
|
-
for (const res of result) {
|
|
111
|
-
const { title = '', description = '' } = res.item;
|
|
112
|
-
|
|
113
|
-
const _link = res.item.link.replace('<a href="', '').replace(/">.*/, '');
|
|
114
|
-
const _title = title.replace(removeHTMLTagsRegExp, "");
|
|
115
|
-
const _description = description.replace(removeHTMLTagsRegExp, "");
|
|
116
|
-
|
|
117
|
-
output += `
|
|
118
|
-
<a onclick="onClickSearchItem(event)" href="${_link}" class="search-result-item">
|
|
119
|
-
<div class="search-result-item-title">${_title}</div>
|
|
120
|
-
<div class="search-result-item-p">${_description || 'No description available.'}</div>
|
|
121
|
-
</a>
|
|
122
|
-
`;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return output;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function getSearchResult(list, keys, searchKey) {
|
|
129
|
-
const defaultOptions = {
|
|
130
|
-
shouldSort: true,
|
|
131
|
-
threshold: 0.4,
|
|
132
|
-
location: 0,
|
|
133
|
-
distance: 100,
|
|
134
|
-
maxPatternLength: 32,
|
|
135
|
-
minMatchCharLength: 1,
|
|
136
|
-
keys: keys
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const options = { ...defaultOptions };
|
|
140
|
-
|
|
141
|
-
// eslint-disable-next-line no-undef
|
|
142
|
-
const searchIndex = Fuse.createIndex(options.keys, list);
|
|
143
|
-
|
|
144
|
-
// eslint-disable-next-line no-undef
|
|
145
|
-
const fuse = new Fuse(list, options, searchIndex);
|
|
146
|
-
|
|
147
|
-
const result = fuse.search(searchKey);
|
|
148
|
-
|
|
149
|
-
if (result.length > 20) {
|
|
150
|
-
return result.slice(0, 20);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return result;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function debounce(func, wait, immediate) {
|
|
157
|
-
let timeout;
|
|
158
|
-
|
|
159
|
-
return function() {
|
|
160
|
-
const args = arguments;
|
|
161
|
-
|
|
162
|
-
clearTimeout(timeout);
|
|
163
|
-
timeout = setTimeout(() => {
|
|
164
|
-
timeout = null;
|
|
165
|
-
if (!immediate) {
|
|
166
|
-
// eslint-disable-next-line consistent-this, no-invalid-this
|
|
167
|
-
func.apply(this, args);
|
|
168
|
-
}
|
|
169
|
-
}, wait);
|
|
170
|
-
|
|
171
|
-
if (immediate && !timeout) {
|
|
172
|
-
// eslint-disable-next-line consistent-this, no-invalid-this
|
|
173
|
-
func.apply(this, args);
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
let searchData;
|
|
179
|
-
|
|
180
|
-
async function search(event) {
|
|
181
|
-
const value = event.target.value;
|
|
182
|
-
const keys = ['title', 'description'];
|
|
183
|
-
|
|
184
|
-
if (!resultBox) {
|
|
185
|
-
console.error('Search result container not found');
|
|
186
|
-
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (!value) {
|
|
191
|
-
showResultText('Type anything to view search result');
|
|
192
|
-
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (!searchData) {
|
|
197
|
-
showResultText('Loading...');
|
|
198
|
-
|
|
199
|
-
try {
|
|
200
|
-
// eslint-disable-next-line require-atomic-updates
|
|
201
|
-
searchData = await fetchAllData();
|
|
202
|
-
} catch (e) {
|
|
203
|
-
console.log(e);
|
|
204
|
-
showResultText('Failed to load result.');
|
|
205
|
-
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const result = getSearchResult(searchData, keys, value);
|
|
211
|
-
|
|
212
|
-
if (!result.length) {
|
|
213
|
-
showResultText('No result found! Try some different combination.');
|
|
214
|
-
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// eslint-disable-next-line require-atomic-updates
|
|
219
|
-
resultBox.innerHTML = buildSearchResult(result);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function onDomContentLoaded() {
|
|
223
|
-
const searchButton = document.querySelectorAll('.search-button');
|
|
224
|
-
const debouncedSearch = debounce(search, 300);
|
|
225
|
-
|
|
226
|
-
if (searchCloseButton) {
|
|
227
|
-
searchCloseButton.addEventListener('click', hideSearch);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (searchButton) {
|
|
231
|
-
searchButton.forEach(function(item) {
|
|
232
|
-
item.addEventListener('click', showSearch);
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (searchContainer) {
|
|
237
|
-
searchContainer.addEventListener('click', hideSearch);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
if (searchWrapper) {
|
|
241
|
-
searchWrapper.addEventListener('click', function(event) {
|
|
242
|
-
event.stopPropagation();
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (searchInput) {
|
|
247
|
-
searchInput.addEventListener('keyup', debouncedSearch);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// eslint-disable-next-line no-undef
|
|
251
|
-
if (window.location.hash === searchHash) {
|
|
252
|
-
showSearch();
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// eslint-disable-next-line no-undef
|
|
257
|
-
window.addEventListener('DOMContentLoaded', onDomContentLoaded);
|
|
258
|
-
|
|
259
|
-
// eslint-disable-next-line no-undef
|
|
260
|
-
window.addEventListener('hashchange', function() {
|
|
261
|
-
// eslint-disable-next-line no-undef
|
|
262
|
-
if (window.location.hash === searchHash) {
|
|
263
|
-
showSearch();
|
|
264
|
-
}
|
|
265
|
-
});
|
|
1
|
+
|
|
2
|
+
var searchAttr = 'data-search-mode';
|
|
3
|
+
function contains(a,m){
|
|
4
|
+
return (a.textContent || a.innerText || "").toUpperCase().indexOf(m) !== -1;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
//on search
|
|
8
|
+
document.getElementById("nav-search").addEventListener("keyup", function(event) {
|
|
9
|
+
var search = this.value.toUpperCase();
|
|
10
|
+
|
|
11
|
+
if (!search) {
|
|
12
|
+
//no search, show all results
|
|
13
|
+
document.documentElement.removeAttribute(searchAttr);
|
|
14
|
+
|
|
15
|
+
document.querySelectorAll("nav > ul > li:not(.level-hide)").forEach(function(elem) {
|
|
16
|
+
elem.style.display = "block";
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (typeof hideAllButCurrent === "function"){
|
|
20
|
+
//let's do what ever collapse wants to do
|
|
21
|
+
hideAllButCurrent();
|
|
22
|
+
} else {
|
|
23
|
+
//menu by default should be opened
|
|
24
|
+
document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) {
|
|
25
|
+
elem.style.display = "block";
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
//we are searching
|
|
30
|
+
document.documentElement.setAttribute(searchAttr, '');
|
|
31
|
+
|
|
32
|
+
//show all parents
|
|
33
|
+
document.querySelectorAll("nav > ul > li").forEach(function(elem) {
|
|
34
|
+
elem.style.display = "block";
|
|
35
|
+
});
|
|
36
|
+
document.querySelectorAll("nav > ul").forEach(function(elem) {
|
|
37
|
+
elem.style.display = "block";
|
|
38
|
+
});
|
|
39
|
+
//hide all results
|
|
40
|
+
document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) {
|
|
41
|
+
elem.style.display = "none";
|
|
42
|
+
});
|
|
43
|
+
//show results matching filter
|
|
44
|
+
document.querySelectorAll("nav > ul > li > ul a").forEach(function(elem) {
|
|
45
|
+
if (!contains(elem.parentNode, search)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
elem.parentNode.style.display = "block";
|
|
49
|
+
});
|
|
50
|
+
//hide parents without children
|
|
51
|
+
document.querySelectorAll("nav > ul > li").forEach(function(parent) {
|
|
52
|
+
var countSearchA = 0;
|
|
53
|
+
parent.querySelectorAll("a").forEach(function(elem) {
|
|
54
|
+
if (contains(elem, search)) {
|
|
55
|
+
countSearchA++;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
var countUl = 0;
|
|
60
|
+
var countUlVisible = 0;
|
|
61
|
+
parent.querySelectorAll("ul").forEach(function(ulP) {
|
|
62
|
+
// count all elements that match the search
|
|
63
|
+
if (contains(ulP, search)) {
|
|
64
|
+
countUl++;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// count all visible elements
|
|
68
|
+
var children = ulP.children
|
|
69
|
+
for (i=0; i<children.length; i++) {
|
|
70
|
+
var elem = children[i];
|
|
71
|
+
if (elem.style.display != "none") {
|
|
72
|
+
countUlVisible++;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
if (countSearchA == 0 && countUl === 0){
|
|
78
|
+
//has no child at all and does not contain text
|
|
79
|
+
parent.style.display = "none";
|
|
80
|
+
} else if(countSearchA == 0 && countUlVisible == 0){
|
|
81
|
+
//has no visible child and does not contain text
|
|
82
|
+
parent.style.display = "none";
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
document.querySelectorAll("nav > ul.collapse_top").forEach(function(parent) {
|
|
86
|
+
var countVisible = 0;
|
|
87
|
+
parent.querySelectorAll("li").forEach(function(elem) {
|
|
88
|
+
if (elem.style.display !== "none") {
|
|
89
|
+
countVisible++;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (countVisible == 0) {
|
|
94
|
+
//has no child at all and does not contain text
|
|
95
|
+
parent.style.display = "none";
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|