| 1 |
/** |
| 2 |
* Prepare Numbered Lists with `start` attribute. |
| 3 |
*/ |
| 4 |
const { |
| 5 |
GHOSTKIT: { events }, |
| 6 |
} = window; |
| 7 |
|
| 8 |
events.on(document, 'init.blocks.gkt', () => { |
| 9 |
document |
| 10 |
.querySelectorAll('.is-style-styled:not(.is-style-styled-ready)') |
| 11 |
.forEach(($list) => { |
| 12 |
const start = parseInt($list.getAttribute('start'), 10); |
| 13 |
const isReversed = $list.getAttribute('reversed') !== null; |
| 14 |
const itemsCount = $list.children.length; |
| 15 |
|
| 16 |
$list.classList.add('is-style-styled-ready'); |
| 17 |
|
| 18 |
if (isReversed) { |
| 19 |
$list.style.counterReset = `li ${(start || itemsCount) + 1}`; |
| 20 |
} else if (start) { |
| 21 |
$list.style.counterReset = `li ${start - 1}`; |
| 22 |
} |
| 23 |
|
| 24 |
events.trigger($list, 'prepare.numberedList.gkt'); |
| 25 |
}); |
| 26 |
}); |
| 27 |
|