Skip to content

Commit 4043d67

Browse files
authored
Merge pull request #8942 from jimchamp/8906/bug/fix-work-cover-carousel
Fix work's `add-cover` carousel
2 parents 74f6870 + 136727a commit 4043d67

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

openlibrary/plugins/openlibrary/js/carousel/Carousel.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,18 @@ export class Carousel {
4242
this.$container = $container;
4343

4444
//This loads in i18n strings from a hidden input element, generated in the books/custom_carousel.html template.
45-
this.i18n = JSON.parse($('input[name="carousel-i18n-strings"]').attr('value'));
46-
this.availabilityStatuses = {
47-
open: {cls: 'cta-btn--available', cta: this.i18n['open']},
48-
borrow_available: {cls: 'cta-btn--available', cta: this.i18n['borrow_available']},
49-
borrow_unavailable: {cls: 'cta-btn--unavailable', cta: this.i18n['borrow_unavailable']},
50-
error: {cls: 'cta-btn--missing', cta: this.i18n['error']},
51-
// private: {cls: 'cta-btn--available', cta: 'Preview'}
52-
};
45+
const i18nInput = document.querySelector('input[name="carousel-i18n-strings"]')
46+
if (i18nInput) {
47+
this.i18n = JSON.parse(i18nInput.value);
48+
49+
this.availabilityStatuses = {
50+
open: {cls: 'cta-btn--available', cta: this.i18n['open']},
51+
borrow_available: {cls: 'cta-btn--available', cta: this.i18n['borrow_available']},
52+
borrow_unavailable: {cls: 'cta-btn--unavailable', cta: this.i18n['borrow_unavailable']},
53+
error: {cls: 'cta-btn--missing', cta: this.i18n['error']},
54+
// private: {cls: 'cta-btn--available', cta: 'Preview'}
55+
};
56+
}
5357
}
5458

5559
get slick() {

0 commit comments

Comments
 (0)