yard 0.9.41 → 0.9.42

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.
@@ -1,372 +1,334 @@
1
- (function() {
2
- var clicked = null;
3
- var searchTimeout = null;
4
- var searchCache = [];
5
- var caseSensitiveMatch = false;
6
- var ignoreKeyCodeMin = 8;
7
- var ignoreKeyCodeMax = 46;
8
- var commandKey = 91;
9
-
10
- function query(selector, root) {
11
- return (root || document).querySelector(selector);
12
- }
13
-
14
- function queryAll(selector, root) {
15
- return Array.prototype.slice.call(
16
- (root || document).querySelectorAll(selector)
17
- );
18
- }
19
-
20
- function isVisible(element) {
21
- if (!element) return false;
22
- if (window.getComputedStyle(element).display === "none") return false;
23
- if (element.parentElement && element.parentElement !== document.body) {
24
- return isVisible(element.parentElement);
25
- }
26
- return true;
27
- }
28
-
29
- RegExp.escape = function(text) {
30
- return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
31
- };
32
-
33
- function ready(callback) {
34
- if (document.readyState === "loading") {
35
- document.addEventListener("DOMContentLoaded", callback, { once: true });
36
- } else {
37
- callback();
38
- }
39
- }
40
-
41
- function escapeShortcut() {
42
- document.addEventListener("keydown", function(event) {
43
- if (event.key === "Escape") {
44
- window.parent.postMessage("navEscape", "*");
45
- }
46
- });
47
- }
48
-
49
- function clearSearchTimeout() {
50
- clearTimeout(searchTimeout);
51
- searchTimeout = null;
52
- }
53
-
54
- function setClicked(item) {
55
- queryAll("#full_list li.clicked").forEach(function(node) {
56
- node.classList.remove("clicked");
57
- });
58
- clicked = item;
59
- if (clicked) clicked.classList.add("clicked");
60
- }
61
-
62
- function pathForItem(item) {
63
- if (!item || !item.id || item.id.indexOf("object_") !== 0) return null;
64
- return item.id.substring("object_".length);
65
- }
66
-
67
- function enableLinks() {
68
- queryAll("#full_list li").forEach(function(item) {
69
- var itemRow = item.querySelector(":scope > .item");
70
-
71
- if (!itemRow) return;
72
-
73
- itemRow.addEventListener("click", function(event) {
74
- var targetLink;
75
- var mouseEvent;
76
- var url;
77
-
78
- if (
79
- event.defaultPrevented ||
80
- event.button !== 0 ||
81
- event.metaKey ||
82
- event.ctrlKey ||
83
- event.shiftKey ||
84
- event.altKey
85
- ) {
86
- return true;
87
- }
88
-
89
- setClicked(item);
90
- event.stopPropagation();
91
- targetLink = event.target.closest("a");
92
-
93
- if (window.origin === "null") {
94
- if (targetLink) return true;
95
-
96
- targetLink = item.querySelector(":scope > .item .object_link a");
97
- if (!targetLink) return false;
98
- mouseEvent = new MouseEvent("click", {
99
- bubbles: true,
100
- cancelable: true,
101
- view: event.view || window,
102
- detail: event.detail,
103
- screenX: event.screenX,
104
- screenY: event.screenY,
105
- clientX: event.clientX,
106
- clientY: event.clientY,
107
- ctrlKey: event.ctrlKey,
108
- shiftKey: event.shiftKey,
109
- altKey: event.altKey,
110
- metaKey: event.metaKey,
111
- button: event.button,
112
- buttons: event.buttons,
113
- relatedTarget: event.relatedTarget
114
- });
115
- targetLink.dispatchEvent(mouseEvent);
116
- event.preventDefault();
117
- } else {
118
- if (!targetLink || !targetLink.matches(".object_link a")) {
119
- targetLink = item.querySelector(":scope > .item .object_link a");
120
- }
121
- if (!targetLink) return false;
122
-
123
- event.preventDefault();
124
- url = targetLink.getAttribute("href");
125
- try {
126
- url = new URL(url, window.location.href).href;
127
- } catch (error) {}
128
- window.top.postMessage(
129
- { action: "navigate", url: url, path: pathForItem(item) },
130
- "*"
131
- );
132
- }
133
- return false;
134
- });
135
- });
136
- }
137
-
138
- function toggleItem(toggle) {
139
- var item = toggle.parentElement.parentElement;
140
- var expanded = item.classList.contains("collapsed");
141
-
142
- item.classList.toggle("collapsed");
143
- toggle.setAttribute("aria-expanded", expanded ? "true" : "false");
144
- highlight();
145
- }
146
-
147
- function enableToggles() {
148
- queryAll("#full_list a.toggle").forEach(function(toggle) {
149
- toggle.addEventListener("click", function(event) {
150
- event.stopPropagation();
151
- event.preventDefault();
152
- toggleItem(toggle);
153
- });
154
-
155
- toggle.addEventListener("keypress", function(event) {
156
- if (event.key !== "Enter") return;
157
- event.stopPropagation();
158
- event.preventDefault();
159
- toggleItem(toggle);
160
- });
161
- });
162
- }
163
-
164
- function populateSearchCache() {
165
- queryAll("#full_list li .item").forEach(function(node) {
166
- var link = query(".object_link a", node);
167
- if (!link) return;
168
-
169
- searchCache.push({
170
- node: node,
171
- link: link,
172
- name: link.textContent,
173
- fullName: link.getAttribute("title").split(" ")[0]
174
- });
175
- });
176
- }
177
-
178
- function enableSearch() {
179
- var input = query("#search input");
180
- var fullList = query("#full_list");
181
-
182
- if (!input || !fullList) return;
183
-
184
- input.addEventListener("keyup", function(event) {
185
- if (ignoredKeyPress(event)) return;
186
- if (input.value === "") {
187
- clearSearch();
188
- } else {
189
- performSearch(input.value);
190
- }
191
- });
192
-
193
- fullList.insertAdjacentHTML(
194
- "afterend",
195
- "<div id='noresults' role='status' style='display: none'></div>"
196
- );
197
- }
198
-
199
- function ignoredKeyPress(event) {
200
- return (
201
- (event.keyCode > ignoreKeyCodeMin && event.keyCode < ignoreKeyCodeMax) ||
202
- event.keyCode === commandKey
203
- );
204
- }
205
-
206
- function clearSearch() {
207
- clearSearchTimeout();
208
- queryAll("#full_list .found").forEach(function(node) {
209
- var link = query(".object_link a", node);
210
- node.classList.remove("found");
211
- link.textContent = link.textContent;
212
- });
213
- query("#full_list").classList.remove("insearch");
214
- query("#content").classList.remove("insearch");
215
- if (clicked) {
216
- var current = clicked.parentElement;
217
- while (current) {
218
- if (current.tagName === "LI") current.classList.remove("collapsed");
219
- if (current.id === "full_list") break;
220
- current = current.parentElement;
221
- }
222
- }
223
- highlight();
224
- }
225
-
226
- function performSearch(searchString) {
227
- clearSearchTimeout();
228
- query("#full_list").classList.add("insearch");
229
- query("#content").classList.add("insearch");
230
- query("#noresults").textContent = "";
231
- query("#noresults").style.display = "none";
232
- partialSearch(searchString, 0);
233
- }
234
-
235
- function partialSearch(searchString, offset) {
236
- var lastRowClass = "";
237
- var i;
238
-
239
- for (i = offset; i < Math.min(offset + 50, searchCache.length); i += 1) {
240
- var item = searchCache[i];
241
- var searchName =
242
- searchString.indexOf("::") !== -1 ? item.fullName : item.name;
243
- var matchRegexp = new RegExp(
244
- buildMatchString(searchString),
245
- caseSensitiveMatch ? "" : "i"
246
- );
247
-
248
- if (!searchName.match(matchRegexp)) {
249
- item.node.classList.remove("found");
250
- item.link.textContent = item.link.textContent;
251
- } else {
252
- item.node.classList.add("found");
253
- if (lastRowClass) item.node.classList.remove(lastRowClass);
254
- item.node.classList.add(lastRowClass === "r1" ? "r2" : "r1");
255
- lastRowClass = item.node.classList.contains("r1") ? "r1" : "r2";
256
- item.link.innerHTML = item.name.replace(matchRegexp, "<strong>$&</strong>");
257
- }
258
- }
259
-
260
- if (i === searchCache.length) {
261
- searchDone();
262
- } else {
263
- searchTimeout = setTimeout(function() {
264
- partialSearch(searchString, i);
265
- }, 0);
266
- }
267
- }
268
-
269
- function searchDone() {
270
- var found = queryAll("#full_list li").filter(isVisible).length;
271
-
272
- searchTimeout = null;
273
- highlight();
274
-
275
- if (found === 0) {
276
- query("#noresults").textContent = "No results were found.";
277
- } else {
278
- query("#noresults").textContent = "There are " + found + " results.";
279
- }
280
- query("#noresults").style.display = "block";
281
- query("#content").classList.remove("insearch");
282
- }
283
-
284
- function buildMatchString(searchString) {
285
- var regexSearchString;
286
-
287
- caseSensitiveMatch = /[A-Z]/.test(searchString);
288
- regexSearchString = RegExp.escape(searchString);
289
- if (caseSensitiveMatch) {
290
- regexSearchString +=
291
- "|" +
292
- searchString
293
- .split("")
294
- .map(function(character) {
295
- return RegExp.escape(character);
296
- })
297
- .join(".+?");
298
- }
299
- return regexSearchString;
300
- }
301
-
302
- function highlight() {
303
- queryAll("#full_list li")
304
- .filter(isVisible)
305
- .forEach(function(item, index) {
306
- item.classList.remove("even");
307
- item.classList.remove("odd");
308
- item.classList.add(index % 2 === 0 ? "odd" : "even");
309
- });
310
- }
311
-
312
- function isInView(element) {
313
- var rect = element.getBoundingClientRect();
314
- var windowHeight =
315
- window.innerHeight || document.documentElement.clientHeight;
316
- return rect.left >= 0 && rect.bottom <= windowHeight;
317
- }
318
-
319
- function expandTo(path) {
320
- var target = document.getElementById("object_" + path);
321
-
322
- if (!target) return;
323
-
324
- setClicked(target);
325
- target.classList.remove("collapsed");
326
-
327
- var current = target.parentElement;
328
- while (current && current.id !== "full_list") {
329
- if (current.tagName === "LI") current.classList.remove("collapsed");
330
- current = current.parentElement;
331
- }
332
-
333
- queryAll("a.toggle", target).forEach(function(toggle) {
334
- toggle.setAttribute("aria-expanded", "true");
335
- });
336
-
337
- current = target.parentElement;
338
- while (current && current.id !== "full_list") {
339
- if (current.tagName === "LI") {
340
- var toggle = current.querySelector(":scope > div > a.toggle");
341
- if (toggle) toggle.setAttribute("aria-expanded", "true");
342
- }
343
- current = current.parentElement;
344
- }
345
-
346
- if (!isInView(target)) {
347
- window.scrollTo(
348
- window.scrollX,
349
- target.getBoundingClientRect().top + window.scrollY - 250
350
- );
351
- highlight();
352
- }
353
- }
354
-
355
- function windowEvents(event) {
356
- var msg = event.data;
357
- if (msg.action === "expand") {
358
- expandTo(msg.path);
359
- }
360
- return false;
361
- }
362
-
363
- window.addEventListener("message", windowEvents, false);
364
-
365
- ready(function() {
366
- escapeShortcut();
367
- enableLinks();
368
- enableToggles();
369
- populateSearchCache();
370
- enableSearch();
371
- });
1
+ (() => {
2
+ let clicked = null;
3
+ let searchTimeout = null;
4
+ const searchCache = [];
5
+ let caseSensitiveMatch = false;
6
+
7
+ function query(selector, root) {
8
+ return (root || document).querySelector(selector);
9
+ }
10
+
11
+ function queryAll(selector, root) {
12
+ return Array.prototype.slice.call(
13
+ (root || document).querySelectorAll(selector),
14
+ );
15
+ }
16
+
17
+ function isVisible(element) {
18
+ if (!element) return false;
19
+ if (window.getComputedStyle(element).display === "none") return false;
20
+ if (element.parentElement && element.parentElement !== document.body) {
21
+ return isVisible(element.parentElement);
22
+ }
23
+ return true;
24
+ }
25
+
26
+ RegExp.escape = (text) => text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
27
+
28
+ function ready(callback) {
29
+ if (document.readyState === "loading") {
30
+ document.addEventListener("DOMContentLoaded", callback, { once: true });
31
+ } else {
32
+ callback();
33
+ }
34
+ }
35
+
36
+ function escapeShortcut() {
37
+ document.addEventListener("keydown", (event) => {
38
+ if (event.key === "Escape") {
39
+ window.parent.postMessage("navEscape", "*");
40
+ }
41
+ });
42
+ }
43
+
44
+ function clearSearchTimeout() {
45
+ clearTimeout(searchTimeout);
46
+ searchTimeout = null;
47
+ }
48
+
49
+ function setClicked(item) {
50
+ queryAll("#full_list li.clicked").forEach((node) => {
51
+ node.classList.remove("clicked");
52
+ });
53
+ clicked = item;
54
+ if (clicked) clicked.classList.add("clicked");
55
+ }
56
+
57
+ function pathForItem(item) {
58
+ if (!item?.id || item.id.indexOf("object_") !== 0) return null;
59
+ return item.id.substring("object_".length);
60
+ }
61
+
62
+ function enableLinks() {
63
+ queryAll("#full_list li").forEach((item) => {
64
+ const itemRow = item.querySelector(":scope > .item");
65
+
66
+ if (!itemRow) return;
67
+
68
+ itemRow.addEventListener("click", (event) => {
69
+ let targetLink;
70
+ let url;
71
+
72
+ if (
73
+ event.defaultPrevented ||
74
+ event.button !== 0 ||
75
+ event.metaKey ||
76
+ event.ctrlKey ||
77
+ event.shiftKey ||
78
+ event.altKey
79
+ ) {
80
+ return true;
81
+ }
82
+
83
+ setClicked(item);
84
+ event.stopPropagation();
85
+ targetLink = event.target.closest("a");
86
+ if (!targetLink?.matches(".object_link a")) {
87
+ targetLink = item.querySelector(":scope > .item .object_link a");
88
+ }
89
+ if (!targetLink) return false;
90
+
91
+ event.preventDefault();
92
+ url = targetLink.getAttribute("href");
93
+ try {
94
+ url = new URL(url, window.location.href).href;
95
+ } catch (_error) {}
96
+ window.top.postMessage(
97
+ { action: "navigate", url: url, path: pathForItem(item) },
98
+ "*",
99
+ );
100
+ return false;
101
+ });
102
+ });
103
+ }
104
+
105
+ function toggleItem(toggle) {
106
+ const item = toggle.parentElement.parentElement;
107
+ const expanded = item.classList.contains("collapsed");
108
+
109
+ item.classList.toggle("collapsed");
110
+ toggle.setAttribute("aria-expanded", expanded ? "true" : "false");
111
+ highlight();
112
+ }
113
+
114
+ function enableToggles() {
115
+ queryAll("#full_list a.toggle").forEach((toggle) => {
116
+ toggle.addEventListener("click", (event) => {
117
+ event.stopPropagation();
118
+ event.preventDefault();
119
+ toggleItem(toggle);
120
+ });
121
+
122
+ toggle.addEventListener("keypress", (event) => {
123
+ if (event.key !== "Enter") return;
124
+ event.stopPropagation();
125
+ event.preventDefault();
126
+ toggleItem(toggle);
127
+ });
128
+ });
129
+ }
130
+
131
+ function populateSearchCache() {
132
+ queryAll("#full_list li .item").forEach((node) => {
133
+ const link = query(".object_link a", node);
134
+ if (!link) return;
135
+
136
+ searchCache.push({
137
+ node: node,
138
+ link: link,
139
+ name: link.textContent,
140
+ fullName: link.getAttribute("title").split(" ")[0],
141
+ });
142
+ });
143
+ }
144
+
145
+ function enableSearch() {
146
+ const input = query("#search input");
147
+ const fullList = query("#full_list");
148
+
149
+ if (!input || !fullList) return;
150
+
151
+ function updateSearchResults() {
152
+ if (input.value === "") {
153
+ clearSearch();
154
+ } else {
155
+ performSearch(input.value);
156
+ }
157
+ }
158
+
159
+ input.addEventListener("input", updateSearchResults);
160
+ input.addEventListener("change", updateSearchResults);
161
+
162
+ fullList.insertAdjacentHTML(
163
+ "afterend",
164
+ "<div id='noresults' role='status' style='display: none'></div>",
165
+ );
166
+ }
167
+
168
+ function clearSearch() {
169
+ clearSearchTimeout();
170
+ queryAll("#full_list .found").forEach((node) => {
171
+ node.classList.remove("found");
172
+ });
173
+ query("#full_list").classList.remove("insearch");
174
+ query("#content").classList.remove("insearch");
175
+ if (clicked) {
176
+ let current = clicked.parentElement;
177
+ while (current) {
178
+ if (current.tagName === "LI") current.classList.remove("collapsed");
179
+ if (current.id === "full_list") break;
180
+ current = current.parentElement;
181
+ }
182
+ }
183
+ highlight();
184
+ }
185
+
186
+ function performSearch(searchString) {
187
+ clearSearchTimeout();
188
+ query("#full_list").classList.add("insearch");
189
+ query("#content").classList.add("insearch");
190
+ query("#noresults").textContent = "";
191
+ query("#noresults").style.display = "none";
192
+ partialSearch(searchString, 0);
193
+ }
194
+
195
+ function partialSearch(searchString, offset) {
196
+ let lastRowClass = "";
197
+ let i;
198
+
199
+ for (i = offset; i < Math.min(offset + 50, searchCache.length); i += 1) {
200
+ const item = searchCache[i];
201
+ const searchName =
202
+ searchString.indexOf("::") !== -1 ? item.fullName : item.name;
203
+ const matchRegexp = new RegExp(
204
+ buildMatchString(searchString),
205
+ caseSensitiveMatch ? "" : "i",
206
+ );
207
+
208
+ if (!searchName.match(matchRegexp)) {
209
+ item.node.classList.remove("found");
210
+ } else {
211
+ item.node.classList.add("found");
212
+ if (lastRowClass) item.node.classList.remove(lastRowClass);
213
+ item.node.classList.add(lastRowClass === "r1" ? "r2" : "r1");
214
+ lastRowClass = item.node.classList.contains("r1") ? "r1" : "r2";
215
+ item.link.innerHTML = item.name.replace(
216
+ matchRegexp,
217
+ "<strong>$&</strong>",
218
+ );
219
+ }
220
+ }
221
+
222
+ if (i === searchCache.length) {
223
+ searchDone();
224
+ } else {
225
+ searchTimeout = setTimeout(() => {
226
+ partialSearch(searchString, i);
227
+ }, 0);
228
+ }
229
+ }
230
+
231
+ function searchDone() {
232
+ const found = queryAll("#full_list li").filter(isVisible).length;
233
+
234
+ searchTimeout = null;
235
+ highlight();
236
+
237
+ if (found === 0) {
238
+ query("#noresults").textContent = "No results were found.";
239
+ } else {
240
+ query("#noresults").textContent = `There are ${found} results.`;
241
+ }
242
+ query("#noresults").style.display = "block";
243
+ query("#content").classList.remove("insearch");
244
+ }
245
+
246
+ function buildMatchString(searchString) {
247
+ let regexSearchString;
248
+
249
+ caseSensitiveMatch = /[A-Z]/.test(searchString);
250
+ regexSearchString = RegExp.escape(searchString);
251
+ if (caseSensitiveMatch) {
252
+ regexSearchString +=
253
+ "|" +
254
+ searchString
255
+ .split("")
256
+ .map((character) => RegExp.escape(character))
257
+ .join(".+?");
258
+ }
259
+ return regexSearchString;
260
+ }
261
+
262
+ function highlight() {
263
+ queryAll("#full_list li")
264
+ .filter(isVisible)
265
+ .forEach((item, index) => {
266
+ item.classList.remove("even");
267
+ item.classList.remove("odd");
268
+ item.classList.add(index % 2 === 0 ? "odd" : "even");
269
+ });
270
+ }
271
+
272
+ function isInView(element) {
273
+ const rect = element.getBoundingClientRect();
274
+ const windowHeight =
275
+ window.innerHeight || document.documentElement.clientHeight;
276
+ return rect.left >= 0 && rect.bottom <= windowHeight;
277
+ }
278
+
279
+ function expandTo(path) {
280
+ const target = document.getElementById(`object_${path}`);
281
+
282
+ if (!target) return;
283
+
284
+ setClicked(target);
285
+ target.classList.remove("collapsed");
286
+
287
+ let current = target.parentElement;
288
+ while (current && current.id !== "full_list") {
289
+ if (current.tagName === "LI") current.classList.remove("collapsed");
290
+ current = current.parentElement;
291
+ }
292
+
293
+ queryAll("a.toggle", target).forEach((toggle) => {
294
+ toggle.setAttribute("aria-expanded", "true");
295
+ });
296
+
297
+ current = target.parentElement;
298
+ while (current && current.id !== "full_list") {
299
+ if (current.tagName === "LI") {
300
+ const toggle = current.querySelector(":scope > div > a.toggle");
301
+ if (toggle) toggle.setAttribute("aria-expanded", "true");
302
+ }
303
+ current = current.parentElement;
304
+ }
305
+
306
+ highlight();
307
+
308
+ if (!isInView(target)) {
309
+ window.scrollTo(
310
+ window.scrollX,
311
+ target.getBoundingClientRect().top + window.scrollY - 250,
312
+ );
313
+ }
314
+ }
315
+
316
+ function windowEvents(event) {
317
+ const msg = event.data;
318
+ if (msg.action === "expand") {
319
+ expandTo(msg.path);
320
+ }
321
+ return false;
322
+ }
323
+
324
+ window.addEventListener("message", windowEvents, false);
325
+
326
+ ready(() => {
327
+ escapeShortcut();
328
+ enableLinks();
329
+ enableToggles();
330
+ populateSearchCache();
331
+ enableSearch();
332
+ highlight();
333
+ });
372
334
  })();