Skip to content

Commit

Permalink
Fix background tappable on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
hgiesel committed Mar 6, 2025
1 parent 0250068 commit 696e904
Show file tree
Hide file tree
Showing 11 changed files with 2,409 additions and 2,468 deletions.
524 changes: 261 additions & 263 deletions src/languages/de/card/support.html

Large diffs are not rendered by default.

506 changes: 252 additions & 254 deletions src/languages/en/card/support.html

Large diffs are not rendered by default.

510 changes: 252 additions & 258 deletions src/languages/es/card/support.html

Large diffs are not rendered by default.

510 changes: 252 additions & 258 deletions src/languages/fr/card/support.html

Large diffs are not rendered by default.

560 changes: 275 additions & 285 deletions src/languages/ja/card/support.html

Large diffs are not rendered by default.

612 changes: 303 additions & 309 deletions src/languages/ko/card/support.html

Large diffs are not rendered by default.

510 changes: 252 additions & 258 deletions src/languages/pt/card/support.html

Large diffs are not rendered by default.

502 changes: 248 additions & 254 deletions src/languages/vi/card/support.html

Large diffs are not rendered by default.

577 changes: 286 additions & 291 deletions src/languages/yue/card/support.html

Large diffs are not rendered by default.

33 changes: 14 additions & 19 deletions src/languages/zh_CN/card/support.html
Original file line number Diff line number Diff line change
Expand Up @@ -533,12 +533,6 @@
}
}

function on_closeAllActiveBody(event) {
if (!event.target.closest('.word')) {
closeAllActive()
}
}

function activeEnablePopup(elem) {
const popup_elem = elem.querySelector('.popup')
if (!popup_elem) {
Expand Down Expand Up @@ -602,25 +596,26 @@
this.classList.remove('active', 'popup-active')
}

function on_activeToggle() {
if (this.classList.contains('active')) {
this.classList.remove('active', 'popup-active')
} else {
closeAllActive()
this.classList.add('active')
activeEnablePopup(this)
}
}

const word_elements = document.querySelectorAll('.word')
const is_mobile = typeof (pycmd) === typeof (undefined)

for (elem of word_elements) {
elem.addEventListener('mouseenter', on_activeEnter)
elem.addEventListener('ontouchend', on_activeEnter)
if (!is_mobile) {
elem.addEventListener('mouseleave', on_activeLeave)
}
if (is_mobile) {
elem.addEventListener('click', on_activeEnter)
elem.addEventListener('click', on_activeToggle)
elem.classList.add('tappable')
} else {
elem.addEventListener('mouseenter', on_activeEnter)
elem.addEventListener('mouseleave', on_activeLeave)
}
}

if (is_mobile) {
document.body.addEventListener('click', on_closeAllActiveBody)
document.body.classList.add('tappable')
}

}());
</script>
33 changes: 14 additions & 19 deletions src/languages/zh_TW/card/support.html
Original file line number Diff line number Diff line change
Expand Up @@ -536,12 +536,6 @@
}
}

function on_closeAllActiveBody(event) {
if (!event.target.closest('.word')) {
closeAllActive()
}
}

function activeEnablePopup(elem) {
const popup_elem = elem.querySelector('.popup')
if (!popup_elem) {
Expand Down Expand Up @@ -605,25 +599,26 @@
this.classList.remove('active', 'popup-active')
}

function on_activeToggle() {
if (this.classList.contains('active')) {
this.classList.remove('active', 'popup-active')
} else {
closeAllActive()
this.classList.add('active')
activeEnablePopup(this)
}
}

const word_elements = document.querySelectorAll('.word')
const is_mobile = typeof (pycmd) === typeof (undefined)

for (elem of word_elements) {
elem.addEventListener('mouseenter', on_activeEnter)
elem.addEventListener('ontouchend', on_activeEnter)
if (!is_mobile) {
elem.addEventListener('mouseleave', on_activeLeave)
}
if (is_mobile) {
elem.addEventListener('click', on_activeEnter)
elem.addEventListener('click', on_activeToggle)
elem.classList.add('tappable')
} else {
elem.addEventListener('mouseenter', on_activeEnter)
elem.addEventListener('mouseleave', on_activeLeave)
}
}

if (is_mobile) {
document.body.addEventListener('click', on_closeAllActiveBody)
document.body.classList.add('tappable')
}

}());
</script>

0 comments on commit 696e904

Please sign in to comment.