Merge pull request #100 from GouthamShiv/patch-1
update to feedback selection logic
This commit is contained in:
commit
cd228d507d
@ -5,15 +5,18 @@ const panel = document.querySelector('#panel')
|
|||||||
let selectedRating = 'Satisfied'
|
let selectedRating = 'Satisfied'
|
||||||
|
|
||||||
ratingsContainer.addEventListener('click', (e) => {
|
ratingsContainer.addEventListener('click', (e) => {
|
||||||
if(e.target.parentNode.classList.contains('rating')) {
|
if(e.target.parentNode.classList.contains('rating') && e.target.nextElementSibling) {
|
||||||
removeActive()
|
removeActive()
|
||||||
e.target.parentNode.classList.add('active')
|
e.target.parentNode.classList.add('active')
|
||||||
selectedRating = e.target.nextElementSibling.innerHTML
|
selectedRating = e.target.nextElementSibling.innerHTML
|
||||||
}
|
} else if(
|
||||||
if(e.target.classList.contains('rating')) {
|
e.target.parentNode.classList.contains('rating') &&
|
||||||
|
e.target.previousSibling &&
|
||||||
|
e.target.previousElementSibling.nodeName === 'IMG'
|
||||||
|
) {
|
||||||
removeActive()
|
removeActive()
|
||||||
e.target.classList.add('active')
|
e.target.parentNode.classList.add('active')
|
||||||
selectedRating = e.target.nextElementSibling.innerHTML
|
selectedRating = e.target.innerHTML
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
@ -32,4 +35,4 @@ function removeActive() {
|
|||||||
for(let i = 0; i < ratings.length; i++) {
|
for(let i = 0; i < ratings.length; i++) {
|
||||||
ratings[i].classList.remove('active')
|
ratings[i].classList.remove('active')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user