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

Side by Side Diff: 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
Patch Set: Created Oct. 10, 2017, 6:09 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 (function() 1 (function()
2 { 2 {
3 document.documentElement.className = "js";
4
3 var visibleTab; 5 var visibleTab;
4 var container = document.getElementById("more-container"); 6 var container = document.getElementById("more-container");
5 7
6 window.toggleMore = function() 8 window.toggleMore = function()
7 { 9 {
8 if (container.className == "hidden") 10 if (container.className == "hidden")
9 container.className = visibleTab || getDefaultTab(); 11 container.className = visibleTab || getDefaultTab();
10 else 12 else
11 container.className = "hidden"; 13 container.className = "hidden";
12 } 14 }
13 15
14 window.showTab = function(button) 16 window.showTab = function(button)
15 { 17 {
16 var id = button.id.substr(5); 18 var id = button.id.substr(5);
17 container.className = id; 19 container.className = id;
18 visibleTab = id; 20 visibleTab = id;
19 } 21 }
20 22
21 function getDefaultTab() 23 function getDefaultTab()
22 { 24 {
23 var content = document.getElementById("content"); 25 var content = document.getElementById("content");
24 var ua = content.className.match(/ua\-([^\s]+)/); 26 var ua = content.className.match(/ua\-([^\s]+)/);
25 visibleTab = ua && ua[1] || "firefox"; 27 visibleTab = ua && ua[1] || "firefox";
26 return visibleTab; 28 return visibleTab;
27 } 29 }
30
31 function changeImageToVideo(event)
32 {
33 event.preventDefault();
34
35 var image = this;
36
37 var video = document.createElement("iframe");
38 video.id = "video";
39 video.setAttribute("frameborder", "0");
40 video.setAttribute("height", "285");
41 video.setAttribute("width", "520");
42 video.setAttribute("itemprop", "video");
43 video.setAttribute("allowfullscreen", "allowfullscreen");
44 video.setAttribute("src", image.getAttribute("href"));
45
46 image.parentNode.replaceChild(video, image);
47 }
48
49 document
50 .getElementById("video")
51 .addEventListener("click", changeImageToVideo);
52
28 })(); 53 })();
OLDNEW

Powered by Google App Engine
This is Rietveld