|
51 | 51 | let clearSelectionLabel = $state('Clear selection'); |
52 | 52 |
|
53 | 53 | let emptySelection = $derived(range == 'selected-pages' && selection.pages.length == 0); |
| 54 | + let emptySelectionTIFF = $derived(emptySelection && format == 'image-tiff'); |
54 | 55 | let tooManyTiffs = $derived(range == 'selected-pages' && format == 'image-tiff' && selection.pages.length > 10); |
55 | | - let largeTiffVolume = $derived(range == 'volume' && format == 'image-tiff' && totalSeq > 10); |
56 | | -
|
57 | | - let buttonDisabled = $derived(emptySelection || tooManyTiffs || largeTiffVolume); |
| 56 | + let buttonDisabled = $derived(emptySelection || emptySelectionTIFF || tooManyTiffs ); |
58 | 57 | let errorMessage = $derived( |
59 | | - emptySelection ? `You haven't selected any pages to download. |
60 | | - To select pages, use the selection checkbox in the page toolbar.` : |
61 | | - tooManyTiffs ? `You have selected ${ |
62 | | - selection.pages.length |
63 | | - } page scans. Please update range to 10 page scans or fewer to proceed with a TIFF download.` : |
64 | | - largeTiffVolume ? `This volume has more than 10 pages. Please choose 10 page scans or fewer to proceed with a TIFF download.` : |
| 58 | + emptySelectionTIFF ? `<p>No pages selected. |
| 59 | + Use the toolbar to select up to <span class="fw-bold">10 pages</span> to continue your TIFF download.</p>` : |
| 60 | + emptySelection ? `<p>No pages selected. |
| 61 | + Use the toolbar to select pages.</p>` : |
| 62 | + tooManyTiffs ? `<p>Your selection exceeds the TIFF download limit. Select 10 pages or fewer to continue.</p>` : |
65 | 63 | null |
66 | 64 | ); |
67 | | -
|
| 65 | + let errorCount = 0; |
68 | 66 |
|
69 | 67 | const _mtm = (window._mtm = window._mtm || []); |
70 | 68 |
|
|
264 | 262 | scriptEl.onerror = () => { |
265 | 263 | document.body.removeChild(scriptEl); |
266 | 264 | errorMessage = 'Failed to start download. Please try again.'; |
267 | | - HT.live.announce(errorMessage); |
| 265 | + HT.live.announce(errorMessage.replace(/<\/?[^>]+(>|$)/g, "")); |
268 | 266 | downloadInProgress = false; |
269 | 267 | _mtm.push({'event': 'pt-large-download-error', 'downloadUrl': `${requestUrl.toString()}`}); |
270 | 268 | }; |
|
425 | 423 | |
426 | 424 | $effect(() => { |
427 | 425 | if (errorMessage) { |
428 | | - HT.live.announce(errorMessage); |
| 426 | + errorCount++; |
| 427 | + // this is a hacky workaround for aria-live announcements |
| 428 | + // chrome does not re-announce the last message it announced, even if it left the DOM and re-entered the DOM |
| 429 | + // this adds a space to the end of the message before sending it to our announcement library |
| 430 | + HT.live.announce(`${errorMessage.replace(/<\/?[^>]+(>|$)/g, "")}${' '.repeat(errorCount)}`); |
429 | 431 | } |
430 | 432 | }); |
431 | 433 |
|
|
568 | 570 | <!-- svelte-ignore a11y_no_noninteractive_tabindex --> |
569 | 571 | <fieldset class="mb-3" id="download-range"> |
570 | 572 | <legend class="fs-5">Range</legend> |
571 | | - <div aria-live="polite" aria-atomic="true"> |
572 | | - {#if format == 'image-tiff' && (range == 'selected-pages' || range == 'volume')} |
573 | | - <p class="fs-7 mb-3 mt-2 text-cyan-700" tabindex="0" id="tiff-note"> |
574 | | - Note: TIFF downloads are limited to <span class="fw-bold">10 page scans</span> at a time, as it is resource-intensive. |
575 | | - </p> |
576 | | - {/if} |
577 | | - </div> |
578 | | - |
579 | 573 | {#if $currentView == '1up'} |
580 | 574 | <div class="form-check"> |
581 | 575 | <input |
|
687 | 681 | </button> |
688 | 682 | </p> |
689 | 683 | {#if errorMessage} |
690 | | - <div class="alert alert-warning fs-7 d-flex justify-content-between gap-2 pe-2"> |
691 | | - <i class="alert-icon fa-solid fa-triangle-exclamation"></i> |
692 | | - <p class="py-3">{errorMessage}</p> |
| 684 | + <div class="alert inline-alert alert-warning fs-7 d-flex gap-2"> |
| 685 | + <div class="icon-wrapper d-flex"> |
| 686 | + <i class="alert-icon fa-solid fa-triangle-exclamation" aria-hidden="true"></i> |
| 687 | + </div> |
| 688 | + {@html errorMessage} |
693 | 689 | </div> |
694 | 690 | {/if} |
695 | 691 | <p class="fs-7 mb-1"> |
|
798 | 794 |
|
799 | 795 | <style lang="scss"> |
800 | 796 | .alert-warning { |
801 | | - --bs-alert-color: var(--color-neutral-800); |
802 | | - --bs-alert-border-color: #997404; |
| 797 | + --alert-warning-color: #664D03; |
| 798 | + --alert-warning-base: #FFF3CD; |
| 799 | + --alert-warning-border-color: #FFECB5; |
| 800 | + --bs-alert-color: var(--alert-warning-color); |
| 801 | + --bs-alert-bg: var(--alert-warning-base); |
| 802 | + --bs-alert-border-color: var(--alert-warning-border-color); |
803 | 803 | } |
804 | | - .alert { |
805 | | - border: none; |
806 | | - border-inline-start: 0.25rem solid var(--bs-alert-border-color); |
807 | | - padding: 0; |
808 | | - border-radius: 0.25rem; |
| 804 | + .alert.inline-alert { |
| 805 | + border: 1px solid var(--bs-alert-border-color); |
| 806 | + padding-block: 0.75rem; |
| 807 | + padding-inline: 0.5rem 0.75rem; |
| 808 | + border-radius: 0.375rem; |
809 | 809 | box-shadow: 0px 4px 8px 0px rgba(25, 11, 1, 0.04); |
| 810 | + line-height: 1.3125rem; |
| 811 | + letter-spacing: -0.00875rem; |
| 812 | + color: var(--bs-alert-color); |
| 813 | + .icon-wrapper { |
| 814 | + width: 1.5rem; |
| 815 | + height: 1.5rem; |
| 816 | + justify-content: center; |
| 817 | + align-items: center; |
| 818 | + gap: 0.625rem; |
| 819 | + } |
810 | 820 | i.alert-icon { |
811 | | - color: var(--bs-alert-border-color); |
| 821 | + font-size: 1rem; |
812 | 822 | display: flex; |
813 | 823 | width: 1.5rem; |
814 | | - padding-block-start: 1rem; |
815 | 824 | flex-direction: column; |
816 | 825 | align-items: center; |
817 | | - gap: 0.5rem; |
818 | | - align-self: stretch; |
819 | | - margin-inline-start: 0.5rem; |
820 | | - line-height: 1.3125rem; |
821 | | - } |
822 | | - p { |
823 | | - line-height: 1.3125rem; |
824 | | - letter-spacing: -0.01rem; |
825 | | - margin-block-end: 0; |
| 826 | + opacity: 0.8; |
826 | 827 | } |
827 | 828 | } |
828 | 829 | </style> |
0 commit comments