-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcartao.js
45 lines (33 loc) · 1.19 KB
/
cartao.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
;(function(){
const cartoes = document.querySelectorAll(".cartao")
for(let j = 0; j < cartoes.length; j++){
const cartao = cartoes[j]
cartao.addEventListener('click', function(event) {
const elementoSelecionado = event.target
if (elementoSelecionado.classList.contains('opcoesDoCartao-remove')){
cartao.classList.add("cartao--some")
cartao.addEventListener('transitionend', function(){
cartao.remove()
})
}
})
cartao.addEventListener("focusin", function(){
cartao.classList.add("cartao--focado")
})
cartao.addEventListener("focusout", function(){
cartao.classList.remove("cartao--focado")
cartao.addEventListener("change", function mudaCor(event){
const elementoSelecionado = event.target
const isRadioTipo = elementoSelecionado.classList.contains('opcoesDoCartao-radioTipo')
if (isRadioTipo){
cartao.style.backgroundColor = elementoSelecionado.value
}
})
})
cartao.addEventListener("keydown", function deixaClickarComEnter(event){
if(event.target.classList.contains("opcoesDoCartao-opcao") && (event.key === 'Enter' || event.key === '')){
event.target.click()
}
})
}
})()