* Class that represents a box inside a card.
| 2 | * Class that represents a box inside a card. |
| 3 | */ |
| 4 | class CardBox { |
| 5 | |
| 6 | // Define properties related to the DOM elements and their styles. |
| 7 | DOM = { |
| 8 | el: null, // The main container of the box |
| 9 | number: null, // The number inside the box |
| 10 | numberChars: null, // Individual characters of the number (after using Splitting.js) |
| 11 | tags: null, // The tags associated with this box |
| 12 | category: null, // The category of the box |
| 13 | categoryChars: null, // Individual characters of the category (after using Splitting.js) |
| 14 | }; |
| 15 | |
| 16 | /** |
| 17 | * Constructor: Initializes the properties with the actual DOM elements. |
| 18 | * @param {HTMLElement} DOM_el - The main container of the box. |
| 19 | */ |
| 20 | constructor(DOM_el) { |
| 21 | // Associate the provided element with the main container |
| 22 | this.DOM.el = DOM_el; |
| 23 | // Fetch various child elements |
| 24 | this.DOM.number = this.DOM.el.querySelector('.card__box-number'); |
| 25 | this.DOM.tags = this.DOM.el.querySelector('.card__box-tags'); |
| 26 | this.DOM.category = this.DOM.el.querySelector('.card__box-category'); |
| 27 | |
| 28 | // Prepare the number and category elements for splitting using Splitting.js |
| 29 | if ( this.DOM.number ) { |
| 30 | this.DOM.number.dataset.splitting = ''; |
| 31 | } |
| 32 | if ( this.DOM.category ) { |
| 33 | this.DOM.category.dataset.splitting = ''; |
| 34 | } |
| 35 | |
| 36 | // Use Splitting.js to split the text content into individual characters for animation/effects. |
| 37 | Splitting(); |
| 38 | |
| 39 | // Store references to the individual characters after the split. |
| 40 | if (this.DOM.number) { |
| 41 | this.DOM.numberChars = this.DOM.number.querySelectorAll('.char'); |
| 42 | } |
| 43 | if (this.DOM.category) { |
| 44 | this.DOM.categoryChars = this.DOM.category.querySelectorAll('.char'); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Class representing Card1. |
nothing calls this directly
no outgoing calls
no test coverage detected