PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.2
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.2
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / blocks / changelog / frontend.js

frontend.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.2, at gutenberg/blocks/changelog/frontend.js

58 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Block Changelog
3 */
4 const {
5 GHOSTKIT: { events },
6 } = window;
7
8 /**
9 * Prepare Changelogs.
10 */
11 events.on(document, 'init.blocks.gkt', () => {
12 document
13 .querySelectorAll('.ghostkit-changelog:not(.ghostkit-changelog-ready)')
14 .forEach(($this) => {
15 events.trigger($this, 'prepare.changelog.gkt');
16
17 $this.classList.add('ghostkit-changelog-ready');
18
19 // Add badges.
20 $this
21 .querySelector(':scope > .ghostkit-changelog-more')
22 .querySelectorAll(':scope > ul li, :scope > ol li')
23 .forEach(($li) => {
24 const text = $li.innerHTML.trim();
25 const typeMatches = text.match(
26 /^\[(new|added|fixed|improved|updated|removed|changed)\]\s(.*)/i
27 );
28
29 if (typeMatches) {
30 const changeType = typeMatches[1];
31 const changeDescription = typeMatches[2];
32
33 let className = 'ghostkit-badge';
34
35 switch (changeType.toLowerCase()) {
36 case 'added':
37 case 'new':
38 className += ' ghostkit-badge-success';
39 break;
40 case 'fixed':
41 case 'improved':
42 case 'updated':
43 className += ' ghostkit-badge-primary';
44 break;
45 case 'removed':
46 className += ' ghostkit-badge-danger';
47 break;
48 // no default
49 }
50
51 $li.innerHTML = `<span class="${className}">${changeType}</span> ${changeDescription}`;
52 }
53 });
54
55 events.trigger($this, 'prepared.changelog.gkt');
56 });
57 });
58