Skip to content

Commit 10db53a

Browse files
committed
Adding a video modal.
1 parent cdcfb5e commit 10db53a

File tree

5 files changed

+49
-1
lines changed

5 files changed

+49
-1
lines changed

_config.yml

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ copyright: © My Company 2013
1313
# Build settings
1414
markdown: kramdown
1515

16+
# The video that plays.
17+
video: "u7deClndzQw"
18+
19+
# The navigation.
1620
navigation:
1721
left:
1822
links:
@@ -31,6 +35,7 @@ navigation:
3135
right:
3236
content: nav/right.html
3337

38+
# The footer section.
3439
footer:
3540
sections:
3641
- title: Useful Links 1

_includes/header/index.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
<h1>Hello, world!</h1>
22
<p>This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
3-
<p><a href="/about/" class="btn btn-primary btn-lg" role="button">Learn more »</a></p>
3+
<p>
4+
<a href="/about/" class="btn btn-primary btn-lg" role="button">Learn more »</a>
5+
<a class="btn btn-primary btn-lg" data-toggle="modal" data-target="#video-modal"><span class="glyphicon glyphicon-play-circle"></span> Watch Video</a>
6+
{% include modal.html id='video' title='Amazing Video' body='modals/video.html' %}
7+
</p>

_includes/modal.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<div class="modal fade" id="{{ include.id }}-modal" tabindex="-1" role="dialog" aria-labelledby="{{ include.id }}ModalLabel" aria-hidden="true">
2+
<div class="modal-dialog modal-lg">
3+
<div class="modal-content">
4+
<div class="modal-header">
5+
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
6+
<h4 class="modal-title" id="{{ include.id }}ModalLabel">{{ include.title }}</h4>
7+
</div>
8+
{% if include.body %}
9+
<div class="modal-body">
10+
{% include {{ include.body }} %}
11+
</div>
12+
{% endif %}
13+
{% if include.footer %}
14+
<div class="modal-footer">
15+
{% include {{ include.footer }} %}
16+
</div>
17+
{% endif %}
18+
</div>
19+
</div>
20+
</div>

_includes/modals/video.html

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<script type="text/template" id="video-template">
2+
<iframe src="//www.youtube.com/embed/{{ site.video }}" frameborder="0" allowfullscreen></iframe>
3+
</script>
4+
<div class="embed-responsive embed-responsive-16by9"></div>

js/app.js

+15
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
11
/** Your custom JavaScript goes here. **/
2+
(function($) {
3+
$(function() {
4+
5+
// Handle the video modal.
6+
$('#video-modal').on('shown.bs.modal', function(event) {
7+
8+
// Load the video.
9+
$('.modal-body .embed-responsive', this).append($('#video-template').html());
10+
}).on('hidden.bs.modal', function(event) {
11+
12+
// Remove the video
13+
$('.modal-body .embed-responsive iframe', this).remove();
14+
});
15+
});
16+
})(jQuery);

0 commit comments

Comments
 (0)