OLD | NEW |
1 (function() | 1 (function() |
2 { | 2 { |
3 document.documentElement.className = "js"; | |
4 | |
5 var visibleTab; | 3 var visibleTab; |
6 var container = document.getElementById("more-container"); | 4 var container = document.getElementById("more-container"); |
7 | 5 |
8 window.toggleMore = function() | 6 window.toggleMore = function() |
9 { | 7 { |
10 if (container.className == "hidden") | 8 if (container.className == "hidden") |
11 container.className = visibleTab || getDefaultTab(); | 9 container.className = visibleTab || getDefaultTab(); |
12 else | 10 else |
13 container.className = "hidden"; | 11 container.className = "hidden"; |
14 } | 12 } |
15 | 13 |
16 window.showTab = function(button) | 14 window.showTab = function(button) |
17 { | 15 { |
18 var id = button.id.substr(5); | 16 var id = button.id.substr(5); |
19 container.className = id; | 17 container.className = id; |
20 visibleTab = id; | 18 visibleTab = id; |
21 } | 19 } |
22 | 20 |
23 function getDefaultTab() | 21 function getDefaultTab() |
24 { | 22 { |
25 var content = document.getElementById("content"); | 23 var content = document.getElementById("content"); |
26 var ua = content.className.match(/ua\-([^\s]+)/); | 24 var ua = content.className.match(/ua\-([^\s]+)/); |
27 visibleTab = ua && ua[1] || "firefox"; | 25 visibleTab = ua && ua[1] || "firefox"; |
28 return visibleTab; | 26 return visibleTab; |
29 } | 27 } |
30 | 28 |
31 // Change overlay icon on #video to play icon | |
32 document | |
33 .getElementById("video-play") | |
34 .setAttribute("src", "/img/video-play.png"); | |
35 | |
36 // Save time user clicked to show video disclaimer | |
37 var timeClickedVideo; | |
38 | |
39 function changeImageToVideo(event) | |
40 { | |
41 event.preventDefault(); | |
42 | |
43 var videoContainer = document.getElementById("video-container"); | |
44 | |
45 if (videoContainer.className == "show-disclaimer") | |
46 { | |
47 // Enfore 600ms delay | |
48 var currentTime = new Date().getTime(); | |
49 if (currentTime - timeClickedVideo < 600) return; | |
50 | |
51 var image = this; | |
52 | |
53 var video = document.createElement("iframe"); | |
54 video.id = "video"; | |
55 video.setAttribute("frameborder", "0"); | |
56 video.setAttribute("height", "285"); | |
57 video.setAttribute("width", "520"); | |
58 video.setAttribute("itemprop", "video"); | |
59 video.setAttribute("allowfullscreen", "allowfullscreen"); | |
60 video.setAttribute("src", image.getAttribute("href")); | |
61 | |
62 image.parentNode.replaceChild(video, image); | |
63 | |
64 videoContainer.className = ""; | |
65 } | |
66 else | |
67 { | |
68 videoContainer.className = "show-disclaimer"; | |
69 timeClickedVideo = new Date().getTime(); | |
70 } | |
71 } | |
72 | |
73 document | |
74 .getElementById("video") | |
75 .addEventListener("click", changeImageToVideo); | |
76 | |
77 })(); | 29 })(); |
OLD | NEW |