Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: static/js/index.js

Issue 29572820: Issue 5727 - Implement non-embedded homepage video on abp.org (Closed) Base URL: https://hg.adblockplus.org/web.adblockplus.org
Left Patch Set: Created Oct. 10, 2017, 6:09 p.m.
Right Patch Set: Addressed NITs Created Oct. 16, 2017, 8:27 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « static/img/video-thumbnail.jpg ('k') | templates/default.tmpl » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 (function() 1 (function()
2 { 2 {
3 document.documentElement.className = "js"; 3 document.documentElement.className = "js";
4 4
5 var visibleTab; 5 var visibleTab;
6 var container = document.getElementById("more-container"); 6 var container = document.getElementById("more-container");
7 7
8 window.toggleMore = function() 8 window.toggleMore = function()
9 { 9 {
10 if (container.className == "hidden") 10 if (container.className == "hidden")
(...skipping 10 matching lines...) Expand all
21 } 21 }
22 22
23 function getDefaultTab() 23 function getDefaultTab()
24 { 24 {
25 var content = document.getElementById("content"); 25 var content = document.getElementById("content");
26 var ua = content.className.match(/ua\-([^\s]+)/); 26 var ua = content.className.match(/ua\-([^\s]+)/);
27 visibleTab = ua && ua[1] || "firefox"; 27 visibleTab = ua && ua[1] || "firefox";
28 return visibleTab; 28 return visibleTab;
29 } 29 }
30 30
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
31 function changeImageToVideo(event) 39 function changeImageToVideo(event)
32 { 40 {
33 event.preventDefault(); 41 event.preventDefault();
42
43 var videoContainer = document.getElementById("video-container");
34 44
35 var image = this; 45 if (videoContainer.className == "show-disclaimer")
46 {
47 // Enfore 600ms delay
48 var currentTime = new Date().getTime();
49 if (currentTime - timeClickedVideo < 600) return;
36 50
37 var video = document.createElement("iframe"); 51 var image = this;
38 video.id = "video"; 52
39 video.setAttribute("frameborder", "0"); 53 var video = document.createElement("iframe");
40 video.setAttribute("height", "285"); 54 video.id = "video";
41 video.setAttribute("width", "520"); 55 video.setAttribute("frameborder", "0");
42 video.setAttribute("itemprop", "video"); 56 video.setAttribute("height", "285");
43 video.setAttribute("allowfullscreen", "allowfullscreen"); 57 video.setAttribute("width", "520");
44 video.setAttribute("src", image.getAttribute("href")); 58 video.setAttribute("itemprop", "video");
45 59 video.setAttribute("allowfullscreen", "allowfullscreen");
46 image.parentNode.replaceChild(video, image); 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 }
47 } 71 }
48 72
49 document 73 document
50 .getElementById("video") 74 .getElementById("video")
51 .addEventListener("click", changeImageToVideo); 75 .addEventListener("click", changeImageToVideo);
52 76
53 })(); 77 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld