|
13 | 13 | customElements.define( |
14 | 14 | 'prpl-badge-progress-bar', |
15 | 15 | class extends HTMLElement { |
16 | | - constructor( badgeId, points, maxPoints ) { |
| 16 | + constructor( badgeId, points, maxPoints, brandingId = 0 ) { |
17 | 17 | // Get parent class properties |
18 | 18 | super(); |
19 | 19 | badgeId = badgeId || this.getAttribute( 'data-badge-id' ); |
20 | 20 | points = points || this.getAttribute( 'data-points' ); |
21 | 21 | maxPoints = maxPoints || this.getAttribute( 'data-max-points' ); |
| 22 | + brandingId = brandingId || this.getAttribute( 'data-branding-id' ); |
22 | 23 | const progress = ( points / maxPoints ) * 100; |
23 | 24 |
|
24 | 25 | this.innerHTML = ` |
@@ -49,6 +50,7 @@ customElements.define( |
49 | 50 | position: absolute; |
50 | 51 | left: calc(${ progress }% - 3.75rem); |
51 | 52 | top: -2.5rem;" |
| 53 | + branding-id="${ brandingId }" |
52 | 54 | ></prpl-badge> |
53 | 55 | </div> |
54 | 56 | </div> |
@@ -93,16 +95,19 @@ const prplUpdatePreviousMonthBadgeProgressBar = ( pointsDiff ) => { |
93 | 95 | const badgeMaxPoints = progressBar.getAttribute( 'data-max-points' ); |
94 | 96 | const badgeProgress = customElements.get( 'prpl-badge-progress-bar' ); |
95 | 97 | const badgeNewPoints = parseInt( badgePoints ) + pointsDiff; |
| 98 | + const brandingId = progressBar.getAttribute( 'data-branding-id' ); |
96 | 99 |
|
97 | 100 | // Create a new badge progress bar. |
98 | 101 | const newProgressBar = new badgeProgress( |
99 | 102 | badgeId, |
100 | 103 | badgeNewPoints, |
101 | | - badgeMaxPoints |
| 104 | + badgeMaxPoints, |
| 105 | + brandingId |
102 | 106 | ); |
103 | 107 | newProgressBar.setAttribute( 'data-badge-id', badgeId ); |
104 | 108 | newProgressBar.setAttribute( 'data-points', badgeNewPoints ); |
105 | 109 | newProgressBar.setAttribute( 'data-max-points', badgeMaxPoints ); |
| 110 | + newProgressBar.setAttribute( 'data-branding-id', brandingId ); |
106 | 111 |
|
107 | 112 | // Replace the old badge progress bar with the new one. |
108 | 113 | progressBar.replaceWith( newProgressBar ); |
|
0 commit comments