blacklight-frontend 8.11.0 → 9.0.0-beta2

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.
Files changed (37) hide show
  1. package/README.md +30 -8
  2. package/app/assets/builds/blacklight.css +452 -0
  3. package/app/assets/javascripts/blacklight/blacklight.esm.js +6 -76
  4. package/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
  5. package/app/assets/javascripts/blacklight/blacklight.js +6 -76
  6. package/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
  7. package/app/assets/stylesheets/blacklight/_balanced_list.scss +1 -4
  8. package/app/assets/stylesheets/blacklight/_blacklight_base.scss +1 -3
  9. package/app/assets/stylesheets/blacklight/_bookmark.scss +44 -41
  10. package/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +0 -25
  11. package/app/assets/stylesheets/blacklight/_constraints.scss +15 -24
  12. package/app/assets/stylesheets/blacklight/_controls.scss +2 -18
  13. package/app/assets/stylesheets/blacklight/_facets.scss +17 -84
  14. package/app/assets/stylesheets/blacklight/_group.scss +2 -5
  15. package/app/assets/stylesheets/blacklight/_header.scss +8 -11
  16. package/app/assets/stylesheets/blacklight/_icons.scss +0 -8
  17. package/app/assets/stylesheets/blacklight/_modal.scss +1 -1
  18. package/app/assets/stylesheets/blacklight/_pagination.scss +0 -4
  19. package/app/assets/stylesheets/blacklight/_search_form.scss +0 -1
  20. package/app/assets/stylesheets/blacklight/_search_history.scss +0 -8
  21. package/app/assets/stylesheets/blacklight/_search_results.scss +1 -15
  22. package/app/assets/stylesheets/blacklight/blacklight_defaults.scss +9 -14
  23. package/app/assets/stylesheets/blacklight/build.scss +4 -0
  24. package/app/javascript/{blacklight → blacklight-frontend}/bookmark_toggle.js +1 -1
  25. package/app/javascript/{blacklight → blacklight-frontend}/checkbox_submit.js +3 -0
  26. package/app/javascript/{blacklight → blacklight-frontend}/core.js +2 -10
  27. package/app/javascript/{blacklight → blacklight-frontend}/facet_suggest.js +1 -3
  28. package/app/javascript/blacklight-frontend/index.js +16 -0
  29. package/app/javascript/{blacklight → blacklight-frontend}/modal.js +1 -5
  30. package/package.json +15 -5
  31. package/app/assets/stylesheets/blacklight/_autocomplete.scss +0 -25
  32. package/app/assets/stylesheets/blacklight/_mixins.scss +0 -20
  33. package/app/javascript/blacklight/index.js +0 -18
  34. package/app/javascript/blacklight/modalForm.js +0 -60
  35. /package/app/javascript/{blacklight → blacklight-frontend}/button_focus.js +0 -0
  36. /package/app/javascript/{blacklight → blacklight-frontend}/debounce.js +0 -0
  37. /package/app/javascript/{blacklight → blacklight-frontend}/search_context.js +0 -0
package/README.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ![CI Workflow](https://github.com/projectblacklight/blacklight/actions/workflows/ruby.yml/badge.svg)
4
4
 
5
+ ## Branches
6
+
7
+ * The `main` branch is currently where we do new development for the upcoming 9.0 release.
8
+ * The `8.x` series is on the [release-8.x](https://github.com/projectblacklight/blacklight/tree/release-8.x) branch
9
+ * The `7.x` series is on the [release-7.x](https://github.com/projectblacklight/blacklight/tree/release-7.x) branch
10
+ * The `6.x` series is on the [release-6.x](https://github.com/projectblacklight/blacklight/tree/release-6.x) branch
11
+
12
+ ## Description
5
13
 
6
14
  Blacklight is an open source Solr user interface discovery platform.
7
15
  You can use Blacklight to enable searching and browsing of your collections.
@@ -53,15 +61,29 @@ Code contributions are always welcome, instructions for contributing can be foun
53
61
  You'll also want some information about how Blacklight expects [Apache Solr](http://lucene.apache.org/solr ) to run, which you can find in [Solr Configuration](https://github.com/projectblacklight/blacklight/wiki/Solr-Configuration#solr-configuration)
54
62
 
55
63
  ## Building the javascript
56
- The javascript is built by npm from sources in `app/javascript` into a bundle
57
- in `app/assets/javascripts/blacklight/blacklight.js`. This file should not be edited
58
- by hand as any changes would be overwritten. When any of the javascript
59
- components in the gem are changed, this bundle should be rebuild with the
60
- following steps:
64
+ The javascript includes some derivative combination files that are built at release time, that can be used by some javascript pipelines. The derivatives are placed at `app/assets/javascripts/blacklight`, and files there should not be edited by hand.
65
+
66
+ When any of the javascript components in the gem are changed, you may have to rebuild these derivative files.
67
+
68
+
61
69
  1. [Install npm](https://www.npmjs.com/get-npm)
62
- 1. run `npm install` to download dependencies
63
- 1. run `npm run prepare` to build the bundle
64
- 1. run `npm publish` to push the javascript package to https://npmjs.org/package/blacklight-frontend
70
+ 1. run `bundle exec rake build:npm`
71
+ (just runs `npm install` to download dependencies and `npm run prepare` to build the bundle)
72
+
73
+
74
+ ## Releasing versions
75
+
76
+ You always need to release both the rubygem and npm package simultaneously. For more information, see [wiki](https://github.com/projectblacklight/blacklight/wiki/How-to-release-a-version)
77
+
78
+ Summary of technical steps:
79
+
80
+ 1. Make sure `./package.json` and `./VERSION` files have correct and matching versions.
81
+ 1. Release ruby gem with `bundle exec rake release`
82
+ 1. Release npm package
83
+ 1. Build derivative products included in release with `bundle exec rake build:npm`
84
+ 1. Publish with `npm publish`.
85
+
86
+
65
87
 
66
88
  ## Using the javascript
67
89
  Blacklight ships with Javascript that can be compiled either by Webpacker or by
@@ -0,0 +1,452 @@
1
+ /* This is the default blacklight theme. */
2
+ /* This file is generated by Blacklight. You probably don't want to edit
3
+ this file directly, or you'll have to manually merge your changes if later
4
+ versions of Blacklight change this file. Instead, use your own CSS file
5
+ which over-rides things in this file. Or of course you can choose
6
+ not to use the Blacklight CSS file at all in your local app. */
7
+ :root {
8
+ --bl-logo-image: url("blacklight/logo.png");
9
+ --bl-logo-width: 150px;
10
+ --bl-logo-height: 50px;
11
+ --bs-secondary-color: rgba(
12
+ 33,
13
+ 37,
14
+ 41,
15
+ 0.75
16
+ ); /* for compatability with BS < 5.3 */
17
+ --bl-main-padding-y: 0.5rem;
18
+ --bl-constraint-remove-hover-bg: #bb2d3b;
19
+ --bl-constraint-remove-hover-border-color: #bb2d3b;
20
+ --bl-field-name-color: var(--bs-secondary-color);
21
+ /* emulate Bootstrap backdrop bg & opacity */
22
+ --bl-modal-backdrop-bg: rgba(0, 0, 0, 0.5);
23
+ }
24
+
25
+ .page-link {
26
+ white-space: nowrap;
27
+ }
28
+
29
+ dialog.modal[open] {
30
+ display: block;
31
+ background: none;
32
+ border: none;
33
+ max-height: unset;
34
+ max-width: unset;
35
+ }
36
+ dialog.modal[open]::backdrop {
37
+ background-color: var(--bl-modal-backdrop-bg);
38
+ }
39
+
40
+ /* Generic layout stuff */
41
+ main {
42
+ padding-block: var(--bl-main-padding-y);
43
+ }
44
+
45
+ /*
46
+ Header bar at top (Bootstrap nav-bar)
47
+ */
48
+ .navbar.bg-dark {
49
+ --bs-emphasis-color-rgb: 255, 255, 255;
50
+ }
51
+
52
+ .navbar-logo {
53
+ /* The main logo image for the Blacklight instance */
54
+ background: transparent var(--bl-logo-image) no-repeat top left;
55
+ background-size: var(--bl-logo-width) var(--bl-logo-height);
56
+ height: var(--bl-logo-height);
57
+ overflow: hidden;
58
+ text-indent: 100%;
59
+ white-space: nowrap;
60
+ width: var(--bl-logo-width);
61
+ }
62
+
63
+ .navbar-search {
64
+ z-index: 1;
65
+ }
66
+ .navbar-search search {
67
+ display: contents;
68
+ }
69
+ .navbar-search .search-field {
70
+ min-width: 7em;
71
+ }
72
+
73
+ .constraints-container {
74
+ display: flex;
75
+ flex-wrap: wrap;
76
+ gap: 0.5rem 0.25rem;
77
+ }
78
+
79
+ .applied-filter {
80
+ --separator-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='currentColor'%3e%3cpath fill-rule='evenodd' d='M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708'/%3e%3c/svg%3e");
81
+ }
82
+ .applied-filter .constraint-value {
83
+ cursor: default;
84
+ text-overflow: ellipsis;
85
+ overflow: hidden;
86
+ white-space: nowrap;
87
+ max-width: clamp(288px, 30vw, 500px);
88
+ }
89
+ .applied-filter .constraint-value .filter-name:after {
90
+ background-color: var(--bs-btn-color);
91
+ content: "";
92
+ mask: var(--separator-icon);
93
+ mask-repeat: no-repeat;
94
+ display: inline-block;
95
+ height: 1.1rem;
96
+ width: 1.25rem;
97
+ vertical-align: text-bottom;
98
+ margin-right: -0.2rem;
99
+ margin-left: 0.25rem;
100
+ transition: background-color 0.15s ease-in-out;
101
+ }
102
+ .applied-filter .remove {
103
+ --bs-btn-hover-bg: var(--bl-constraint-remove-hover-bg);
104
+ --bs-btn-hover-border-color: var(--bl-constraint-remove-hover-border-color);
105
+ --bs-btn-active-bg: var(--bl-constraint-remove-hover-bg);
106
+ --bs-btn-active-border-color: var(
107
+ --bl-constraint-remove-hover-border-color
108
+ );
109
+ }
110
+
111
+ .search-widgets {
112
+ display: flex;
113
+ }
114
+
115
+ .sort-pagination,
116
+ .pagination-search-widgets {
117
+ border-bottom: var(--bs-border-width) solid var(--bs-border-color);
118
+ }
119
+
120
+ .sort-pagination .dropdown-toggle {
121
+ cursor: pointer;
122
+ }
123
+
124
+ .no-js .btn-group:focus-within .dropdown-menu {
125
+ display: block; /* show menu when tabbing to it, without Javascript */
126
+ }
127
+
128
+ .view-type {
129
+ display: inline-block;
130
+ }
131
+
132
+ .modal_form {
133
+ margin-bottom: 0;
134
+ }
135
+
136
+ .input-group > .search-q {
137
+ flex-grow: 4;
138
+ }
139
+
140
+ .input-group > .search-autocomplete-wrapper {
141
+ display: inline-block;
142
+ flex-grow: 4;
143
+ padding: 0;
144
+ position: relative;
145
+ }
146
+ .input-group > .search-autocomplete-wrapper .search-q {
147
+ border: 0;
148
+ height: 100%;
149
+ width: 100%;
150
+ }
151
+ .input-group > .search-autocomplete-wrapper ul {
152
+ display: block;
153
+ }
154
+
155
+ .search-btn {
156
+ border-top-left-radius: 0;
157
+ border-bottom-left-radius: 0;
158
+ display: flex;
159
+ }
160
+
161
+ .search-field,
162
+ .search-q {
163
+ scroll-margin: 5rem;
164
+ }
165
+
166
+ .documents-list {
167
+ --bl-results-document-margin-top: 1rem;
168
+ --bl-results-document-padding-top: 1rem;
169
+ }
170
+ .documents-list .document {
171
+ display: flex;
172
+ border-bottom: 1px dotted var(--bs-border-color);
173
+ margin-top: var(--bl-results-document-margin-top);
174
+ padding-top: var(--bl-results-document-padding-top);
175
+ }
176
+ .documents-list .document .document-main-section {
177
+ flex-grow: 1;
178
+ }
179
+ .documents-list .document .document-thumbnail {
180
+ flex-grow: 0;
181
+ margin-bottom: 3rem;
182
+ padding-left: 3rem;
183
+ }
184
+
185
+ .page-links {
186
+ display: inline-block;
187
+ border: 1px solid transparent;
188
+ padding: 0.375rem 0.75rem;
189
+ padding-left: 0;
190
+ }
191
+
192
+ .pagination {
193
+ flex-wrap: wrap;
194
+ }
195
+
196
+ .group-key {
197
+ --bl-border-color: var(--bs-gray-600);
198
+ border-bottom: 1px solid var(--bl-border-color);
199
+ clear: right;
200
+ }
201
+
202
+ .grouped-documents .document {
203
+ border-bottom: 0;
204
+ }
205
+
206
+ .bookmark-toggle {
207
+ --bl-icon-color: var(--bs-primary);
208
+ /* override for line 21.
209
+ Creates weird spacing in toolbar when min-width is set to 8rem */
210
+ }
211
+ .no-js .bookmark-toggle input[type=submit] {
212
+ display: inline;
213
+ }
214
+ .no-js .bookmark-toggle .toggle-bookmark {
215
+ display: none;
216
+ }
217
+ .bookmark-toggle input[type=submit] {
218
+ display: none;
219
+ }
220
+ .bookmark-toggle .toggle-bookmark {
221
+ cursor: pointer;
222
+ }
223
+ .bookmark-toggle .toggle-bookmark .toggle-bookmark-label {
224
+ font-weight: inherit;
225
+ min-width: 8.5em;
226
+ }
227
+ .bookmark-toggle .toggle-bookmark .toggle-bookmark-label .blacklight-icons svg {
228
+ height: 1.25rem;
229
+ width: 1.25rem;
230
+ overflow: visible;
231
+ fill: var(--bl-icon-color);
232
+ }
233
+ .bookmark-toggle .toggle-bookmark .toggle-bookmark-label .blacklight-icons svg.bookmark-checked {
234
+ display: none;
235
+ }
236
+ .bookmark-toggle .toggle-bookmark .toggle-bookmark-input:checked + span svg.bookmark-checked {
237
+ display: inherit;
238
+ }
239
+ .bookmark-toggle .toggle-bookmark .toggle-bookmark-input:checked + span svg.bookmark-unchecked {
240
+ display: none;
241
+ }
242
+ .bookmark-toggle .header-tools .toggle-bookmark-label {
243
+ min-width: 2rem;
244
+ }
245
+
246
+ .dl-invert dt {
247
+ font-weight: normal;
248
+ color: var(--bl-field-name-color);
249
+ }
250
+ @media (min-width: 768px) {
251
+ .dl-invert dt {
252
+ text-align: end;
253
+ }
254
+ }
255
+
256
+ .sidenav {
257
+ --bl-facet-active-bg: var(--bs-success);
258
+ --bl-facet-active-item-color: var(--bs-success);
259
+ --bl-facet-remove-color: var(--bs-secondary-color);
260
+ --bl-facet-remove-hover-color: var(--bs-danger);
261
+ --bl-facet-label-indent: -15px;
262
+ --bl-facet-label-padding-left: 15px;
263
+ --bl-facet-header-padding-y: 0.5rem;
264
+ --bl-facet-value-padding-y: 0.2rem;
265
+ }
266
+ .sidenav .facet-toggle-button [data-hide-label] {
267
+ display: inline;
268
+ }
269
+ .sidenav .facet-toggle-button [data-show-label] {
270
+ display: none;
271
+ }
272
+ .sidenav .facet-toggle-button[aria-expanded=false] [data-hide-label] {
273
+ display: none;
274
+ }
275
+ .sidenav .facet-toggle-button[aria-expanded=false] [data-show-label] {
276
+ display: inline;
277
+ }
278
+
279
+ @media (max-width: 991.98px) {
280
+ .no-js #sidebar {
281
+ order: 6 !important;
282
+ }
283
+ }
284
+ .no-js .facet-content.collapse {
285
+ display: block;
286
+ }
287
+ .no-js .facet-toggle-handle {
288
+ display: none;
289
+ }
290
+ .no-js .pivot-facet.collapse {
291
+ display: block;
292
+ }
293
+ .no-js .facets-collapse.collapse {
294
+ display: block;
295
+ }
296
+
297
+ .facets-header {
298
+ display: flex;
299
+ justify-content: space-between;
300
+ padding-block: var(--bl-facet-header-padding-y);
301
+ }
302
+
303
+ .facets-heading {
304
+ line-height: inherit;
305
+ }
306
+
307
+ .facet-limit {
308
+ --bs-accordion-btn-bg: var(--bs-gray-100);
309
+ --bs-btn-hover-bg: var(--bs-gray-200);
310
+ --bs-accordion-active-bg: var(--bs-accordion-btn-bg);
311
+ }
312
+
313
+ .facet-limit-active {
314
+ --bs-accordion-btn-bg: var(--bl-facet-active-bg);
315
+ --bs-btn-hover-bg: var(--bs-accordion-btn-bg);
316
+ --bs-accordion-btn-color: var(--bs-light);
317
+ --bs-btn-hover-color: var(--bs-accordion-btn-color);
318
+ --bs-accordion-active-color: var(--bs-accordion-btn-color);
319
+ }
320
+
321
+ .facet-values {
322
+ margin-bottom: 0;
323
+ }
324
+ .facet-values a {
325
+ text-decoration: none;
326
+ }
327
+ .facet-values li {
328
+ display: flex;
329
+ align-items: flex-start;
330
+ padding-block: var(--bl-facet-value-padding-y);
331
+ }
332
+ .facet-values li.treeitem {
333
+ display: block;
334
+ }
335
+ .facet-values li .selected {
336
+ color: var(--bl-facet-active-item-color);
337
+ }
338
+ .facet-values .remove {
339
+ color: var(--bl-facet-remove-color);
340
+ font-weight: bold;
341
+ text-decoration: none;
342
+ }
343
+ .facet-values .remove:hover {
344
+ color: var(--bl-facet-remove-hover-color);
345
+ text-decoration: none;
346
+ }
347
+ .facet-values .facet-label {
348
+ hyphens: auto;
349
+ overflow-wrap: break-word;
350
+ padding-left: var(--bl-facet-label-padding-left);
351
+ padding-right: 1em;
352
+ text-indent: var(--bl-facet-label-indent);
353
+ }
354
+ .facet-values .facet-count {
355
+ margin-left: auto;
356
+ }
357
+ .facet-values .facet-checkbox {
358
+ width: 1.25rem;
359
+ }
360
+
361
+ .facet-extended-list .sort-options {
362
+ text-align: right;
363
+ }
364
+ .facet-extended-list .prev-next-links {
365
+ float: left;
366
+ }
367
+
368
+ .facet-field-heading {
369
+ /* This prevents the contained stretch link from covering the panel body */
370
+ position: relative;
371
+ }
372
+ .facet-field-heading a {
373
+ color: inherit;
374
+ }
375
+
376
+ /* Sidenav
377
+ -------------------------------------------------- */
378
+ .pivot-facet.show {
379
+ display: flex;
380
+ }
381
+
382
+ .facet-toggle-handle {
383
+ margin-block: 0;
384
+ padding-block: 0;
385
+ padding-inline: 0.5rem;
386
+ margin-inline-start: -0.75rem;
387
+ }
388
+ .pivot-facet .facet-toggle-handle {
389
+ margin-inline-start: -1.5rem;
390
+ }
391
+ .facet-toggle-handle.collapsed .show {
392
+ display: flex;
393
+ }
394
+ .facet-toggle-handle.collapsed .hide {
395
+ display: none;
396
+ }
397
+ .facet-toggle-handle .show {
398
+ display: none;
399
+ }
400
+ .facet-toggle-handle .hide {
401
+ display: flex;
402
+ }
403
+ .facet-toggle-handle .show .icon,
404
+ .facet-toggle-handle .hide .icon {
405
+ width: 1em;
406
+ height: 1em;
407
+ padding: 0.375rem 0.75rem;
408
+ }
409
+ .facet-toggle-handle .show .icon {
410
+ background: transparent url('data:image/svg+xml,%3csvg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-square" viewBox="0 0 16 16"%3e%3cpath d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z" /%3e%3cpath d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z" /%3e%3c/svg%3e') center/1em auto no-repeat;
411
+ }
412
+ .facet-toggle-handle .hide .icon {
413
+ background: transparent url('data:image/svg+xml,%3csvg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-dash-square" viewBox="0 0 16 16"%3e%3cpath d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z" /%3e%3cpath d="M4 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 4 8z" /%3e%3c/svg%3e') center/1em auto no-repeat;
414
+ }
415
+
416
+ /* Search History */
417
+ .search-history {
418
+ --bl-history-filter-name-color: var(--bs-secondary-color);
419
+ }
420
+ .search-history .constraint {
421
+ padding-inline-end: 1rem;
422
+ display: block;
423
+ }
424
+ .search-history .filter-name {
425
+ color: var(--bl-history-filter-name-color);
426
+ }
427
+
428
+ .modal-dialog {
429
+ border-radius: 5px;
430
+ }
431
+
432
+ .modal-content .page-sidebar {
433
+ display: none;
434
+ }
435
+ .modal-content .blacklight-modal-close {
436
+ display: block;
437
+ }
438
+
439
+ .blacklight-modal-close {
440
+ display: none;
441
+ }
442
+
443
+ .modal-footer:not(.modal .modal-footer) {
444
+ border-top: var(--bs-border-width) solid var(--bs-border-color);
445
+ padding-top: 1rem;
446
+ margin-top: 1rem;
447
+ }
448
+
449
+ .remove .bi {
450
+ height: 1em;
451
+ width: 1em;
452
+ }
@@ -36,6 +36,9 @@ class CheckboxSubmit {
36
36
  }).then((json) => {
37
37
  this.labelTarget.removeAttribute('disabled');
38
38
  this.checkboxTarget.removeAttribute('disabled');
39
+ // For accessibility return keyboard focus
40
+ // back to the checkbox after form submission
41
+ this.checkboxTarget.focus();
39
42
  this.updateStateFor(!this.checked);
40
43
  this.bookmarksCounter().forEach(counter => {
41
44
  counter.innerHTML = json.bookmarks.count;
@@ -151,8 +154,6 @@ const FacetSuggest = async (e) => {
151
154
  const blob = await response.blob();
152
155
  const text = await blob.text();
153
156
 
154
- const facetArea = document.querySelector('.facet-extended-list');
155
-
156
157
  if (text && facetArea) {
157
158
  facetArea.innerHTML = text;
158
159
  }
@@ -283,7 +284,7 @@ const Modal = (() => {
283
284
  }
284
285
  elements.forEach((el) => frag.appendChild(el));
285
286
  modal.activateScripts(frag);
286
-
287
+
287
288
  modal.target().querySelector('.modal-content').replaceChildren(frag);
288
289
 
289
290
  // send custom event with the modal dialog div as the target
@@ -292,7 +293,6 @@ const Modal = (() => {
292
293
 
293
294
  // if they did preventDefault, don't show the dialog
294
295
  if (e.defaultPrevented) return;
295
-
296
296
  modal.show();
297
297
  };
298
298
 
@@ -377,67 +377,6 @@ const Modal = (() => {
377
377
  return modal;
378
378
  })();
379
379
 
380
- // The email and sms forms are displayed inside a modal. When the form is submitted,
381
- // this script closes the modal and puts the output on the main part of the page.
382
- // By default it is rendering catalog/sms_success and catalog/email_succcess.
383
- // These templates deliver a payload of the format used by turbo-streams.
384
- // See https://turbo.hotwired.dev/handbook/streams
385
- // That format allows a downstream application to override the template to define
386
- // multiple customizable areas of the page to get updated.
387
- class ModalForm {
388
- constructor(errorHandler, badRequestHandler, hideModal) {
389
- this.errorHandler = errorHandler;
390
- this.badRequestHandler = badRequestHandler;
391
- this.hideModal = hideModal;
392
- }
393
-
394
- get triggerFormSelector() {
395
- return 'form[data-blacklight-modal~=trigger]'
396
- }
397
-
398
- bind() {
399
- document.addEventListener('submit', (e) => {
400
- if (e.target.matches(this.triggerFormSelector))
401
- this.onSubmit(e);
402
- });
403
- }
404
-
405
- // This is like a light-weight version of turbo that only supports append presently.
406
- updateTurboStream(data) {
407
- this.hideModal();
408
- const domparser = new DOMParser();
409
- const dom = domparser.parseFromString(data, "text/html");
410
- dom.querySelectorAll("turbo-stream[action='append']").forEach((node) => {
411
- const target = node.getAttribute('target');
412
- const element = document.getElementById(target);
413
- if (element)
414
- element.append(node.querySelector('template').content.cloneNode(true));
415
- else
416
- console.error(`Unable to find an element on the page with and ID of "${target}""`);
417
- });
418
- }
419
-
420
- onSubmit(e) {
421
- e.preventDefault();
422
- const form = e.target;
423
- fetch(form.action, {
424
- body: new FormData(form),
425
- headers: { "X-Requested-With": "XMLHttpRequest" }, // Ensures rails will return true when checking request.xhr?
426
- method: form.method,
427
- })
428
- .then(response => {
429
- if (response.status === 422) {
430
- return response.text().then(content => this.badRequestHandler(content) )
431
- }
432
- if (!response.ok) {
433
- throw new TypeError("Request failed");
434
- }
435
- response.text().then(content => this.updateTurboStream(content));
436
- })
437
- .catch(error => this.errorHandler(error));
438
- }
439
- }
440
-
441
380
  const SearchContext = (e) => {
442
381
  const contextLink = e.target.closest('[data-context-href]');
443
382
  if (contextLink) {
@@ -509,14 +448,6 @@ const Core = function() {
509
448
  const listeners = [];
510
449
  if (typeof Turbo !== 'undefined') {
511
450
  listeners.push('turbo:load', 'turbo:frame-load');
512
- } else if (typeof Turbolinks !== 'undefined' && Turbolinks.supported) {
513
- // Turbolinks 5
514
- if (Turbolinks.BrowserAdapter) {
515
- listeners.push('turbolinks:load');
516
- } else {
517
- // Turbolinks < 5
518
- listeners.push('page:load', 'DOMContentLoaded');
519
- }
520
451
  } else {
521
452
  listeners.push('DOMContentLoaded');
522
453
  }
@@ -526,8 +457,8 @@ const Core = function() {
526
457
  };
527
458
  }();
528
459
 
529
- // turbolinks triggers page:load events on page transition
530
- // If app isn't using turbolinks, this event will never be triggered, no prob.
460
+ // turbo triggers turbo:load events on page transition
461
+ // If app isn't using turbo, this event will never be triggered, no prob.
531
462
  Core.listeners().forEach(function(listener) {
532
463
  document.addEventListener(listener, function() {
533
464
  Core.activate();
@@ -550,7 +481,6 @@ const index = {
550
481
  ButtonFocus,
551
482
  FacetSuggest,
552
483
  Modal,
553
- ModalForm,
554
484
  SearchContext,
555
485
  Core,
556
486
  onLoad: Core.onLoad