Skip to content

Commit

Permalink
Load Youtube iframe on click only
Browse files Browse the repository at this point in the history
(Increases performances and offers better privacy)
  • Loading branch information
saivann committed Jun 26, 2015
1 parent 098fcf1 commit 007d453
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 5 deletions.
37 changes: 34 additions & 3 deletions _less/screen.less
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,39 @@ table td,table th{
color:#7b7c7c;
margin:20px auto 45px auto;
}
.mainvideo iframe{
.mainvideo{
position:relative;
margin:auto;
max-width:640px;
max-height:360px;
}
.mainvideo iframe,
.mainvideo img{
width:640px;
height:360px;
}
.mainvideo div div{
cursor:pointer;
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
}
.mainvideo .mainvideoicon{
display:block;
background:url(/img/icons/video_play.svg) center center no-repeat;
}
.mainvideo .mainvideoiconhover{
display:none;
background:url(/img/icons/video_play_hover.svg) center center no-repeat;
}
.mainvideo:hover .mainvideoicon{
display:none;
}
.mainvideo:hover .mainvideoiconhover{
display:block;
}
.mainlist{
font-size:125%;
width:760px;
Expand Down Expand Up @@ -2327,10 +2356,9 @@ h2 .rssicon{
.press-quotes p{
width:auto;
}
.mainvideo{
.mainvideo>div{
position:relative;
padding-bottom:56.25%;
padding-top:30px;
height:0;
overflow:hidden;
}
Expand All @@ -2341,6 +2369,9 @@ h2 .rssicon{
width:100%;
height:100%;
}
.mainvideo img{
height:auto;
}
.mainlist,
.mainlist>div{
width:auto;
Expand Down
20 changes: 19 additions & 1 deletion _templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,26 @@
layout: base
id: index
---
<script>
function loadMainVideo(e) {
var p = document.getElementById('mainvideo'),
t = p.getElementsByTagName('DIV')[0],
nd = document.createElement('IFRAME');
nd.src = '//www.youtube.com/embed/Gc2en3nHxA4?rel=0&amp;showinfo=0&amp;wmode=opaque&amp;autoplay=1{% if page.lang != 'en' %}&amp;cc_load_policy=1&amp;hl={{ page.lang }}&amp;cc_lang_pref={{ page.lang }}{% endif %}';
nd.setAttribute('frameborder', 0);
nd.setAttribute('allowfullscreen', true);
t.innerHTML = '';
t.appendChild(nd);
removeEvent(p, loadMainVideo);
cancelEvent(e);
}
</script>
<p class="mainsummary">{% translate listintro %}</p>
<div class="mainvideo"><iframe src="//www.youtube.com/embed/Gc2en3nHxA4?rel=0&amp;showinfo=0&amp;wmode=opaque&amp;{% if page.lang != 'en' %}cc_load_policy=1&amp;hl={{ page.lang }}&amp;cc_lang_pref={{ page.lang }}{% endif %}" frameborder="0" allowfullscreen></iframe></div>
<div class="mainvideo" id="mainvideo" onclick="loadMainVideo(event);"><div>
<img src="/img/video/video_wuc.jpg" alt="Youtube video">
<div class="mainvideoicon"></div>
<div class="mainvideoiconhover"></div>
</div></div>
<div class="mainlist">
<div><div><img src="/img/icons/main_ico_instant.svg" alt="Icon"><div>{% translate list1 %}</div></div></div>
<div><div><img src="/img/icons/main_ico_worldwide.svg" alt="Icon"><div>{% translate list2 %}</div></div></div>
Expand Down
Binary file added img/icons/video_play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions img/icons/video_play.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icons/video_play_hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions img/icons/video_play_hover.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions img/video/COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The files inside this folder may be subjected to copyright restrictions. The
use of these materials is not permitted unless otherwise specified by their
copyright owner.
Binary file added img/video/video_wuc.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 19 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,26 @@
id: index
title: Bitcoin
---
<script>
function loadMainVideo(e) {
var p = document.getElementById('mainvideo'),
t = p.getElementsByTagName('DIV')[0],
nd = document.createElement('IFRAME');
nd.src = '//www.youtube.com/embed/Gc2en3nHxA4?rel=0&amp;showinfo=0&amp;wmode=opaque&amp;autoplay=1{% if page.lang != 'en' %}&amp;cc_load_policy=1&amp;hl={{ page.lang }}&amp;cc_lang_pref={{ page.lang }}{% endif %}';
nd.setAttribute('frameborder', 0);
nd.setAttribute('allowfullscreen', true);
t.innerHTML = '';
t.appendChild(nd);
removeEvent(p, loadMainVideo);
cancelEvent(e);
}
</script>
<p class="mainsummary">{% translate listintro %}</p>
<div class="mainvideo"><iframe src="//www.youtube.com/embed/Gc2en3nHxA4?rel=0&amp;showinfo=0&amp;wmode=opaque{% if page.lang != 'en' %}&amp;cc_load_policy=1&amp;hl={{ page.lang }}&amp;cc_lang_pref={{ page.lang }}{% endif %}" frameborder="0" allowfullscreen></iframe></div>
<div class="mainvideo" id="mainvideo" onclick="loadMainVideo(event);"><div>
<img src="/img/video/video_wuc.jpg" alt="Youtube video">
<div class="mainvideoicon"></div>
<div class="mainvideoiconhover"></div>
</div></div>
<div class="mainlist">
<div><div><img src="/img/icons/main_ico_instant.svg" alt="Icon"><div>{% translate list1 %}</div></div></div>
<div><div><img src="/img/icons/main_ico_worldwide.svg" alt="Icon"><div>{% translate list2 %}</div></div></div>
Expand Down

0 comments on commit 007d453

Please sign in to comment.