-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
35 lines (30 loc) · 1.04 KB
/
script.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
window.onload = function() {
addVideoHoverListener()
addVideoClickListener()
}
addVideoHoverListener = function() {
containerElements = document.getElementsByClassName("mouseover-toggle")
for (var i=0; i<containerElements.length; i++) {
containerElements[i].onmouseover = function(){showText()}
containerElements[i].onmouseout = function(){hideText()}
}
}
addVideoClickListener = function() {
container = document.getElementsByClassName("container")[0]
container.addEventListener("click", toggleAudio)
}
toggleAudio = function(e) {
// ignore link clicks so opening in new bg tab doesn't stop audio:
if (e.srcElement.nodeName !== "A") {
video = document.getElementsByClassName('video')[0]
video.muted = !video.muted
}
}
showText = function() {
toggleText = document.getElementsByClassName('toggle-text')[0]
toggleText.style.visibility = 'visible'
}
hideText = function() {
toggleText = document.getElementsByClassName('toggle-text')[0]
toggleText.style.visibility = 'hidden'
}