Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin video #94

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ <h2>Examples</h2>
<li><a href="#modal-slidefromtop" title="Clicking this link shows the modal">Demo slideFromTop</a></li>
<li><a href="#modal-bouncefromtop" title="Clicking this link shows the modal">Demo bounceFromTop</a></li>
<li><a href="#modal-bouncefromtopshaky" title="Clicking this link shows the modal">Demo bounceFromTopShaky</a></li>
<li><a href="#modal-html5video" title="Clicking this link shows a modal with HTML5 Video content">Demo HTML5Video</a></li>
</ul>

<!-- A modal with its content -->
Expand Down Expand Up @@ -160,6 +161,21 @@ <h2 id="label-zoomout">A zoomed out modal</h2>
data-dismiss="modal" data-close="Close">&times;</a>
</section>

<section class="modal--show" id="modal-html5video" tabindex="-1"
role="dialog" aria-labelledby="modal-label" aria-hidden="true">

<div class="modal-inner">
<div class="modal-content">
<video preload="auto" controls>
<source src="http:https://vjs.zencdn.net/v/oceans.mp4" type="video/mp4">
</video>
</div>
</div>

<a href="#!" class="modal-close" title="Close this modal" data-close="Close"
data-dismiss="modal">×</a>
</section>


<div class="content">
<p>Disrupt brunch keffiyeh chillwave Williamsburg. Excepteur food truck thundercats voluptate ethical, whatever in craft beer leggings proident Vice pour-over polaroid. Terry Richardson hoodie Truffaut Wes Anderson kale chips, synth nostrud elit sint id cillum bespoke. Semiotics synth Cosby sweater brunch beard, lo-fi esse Godard Echo Park sapiente mollit wayfarers. Cillum lomo cliche, YOLO Cosby sweater fixie tumblr eu umami Schlitz assumenda culpa. Chillwave church-key plaid, labore nulla flannel kogi Tonx single-origin coffee cred ex sustainable. Mlkshk ennui polaroid post-ironic sunt, keytar semiotics sriracha fashion axe labore church-key art party.</p>
Expand All @@ -170,5 +186,6 @@ <h2 id="label-zoomout">A zoomed out modal</h2>
</div>

<script src="modal.js"></script><!-- JS for Modal -->
<script src="plugins/html5video.js"></script>
</body>
</html>
42 changes: 42 additions & 0 deletions plugins/html5video.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* CSS Modal Plugin for HTML5 Video (play/pause)
* Author: Anselm Hannemann
* Date: 2014-02-04
*/

(function (global) {

'use strict';

var CSSModal = global.CSSModal;

// If CSS Modal is still undefined, throw an error
if (!CSSModal) {
throw new Error('Error: CSSModal is not loaded.');
}

var videos;
var i = 0;

// Enables Auto-Play when calling modal
CSSModal.on('cssmodal:show', document, function (event) {
// Fetch all video elements in active modal
videos = CSSModal.activeElement.querySelectorAll('video');

if (videos.length > 0) {
// Play first video in modal
videos[0].play();
}
});

// If modal is closed, pause all videos
CSSModal.on('cssmodal:hide', document, function (event) {
if (videos.length > 0) {
// Pause all videos in active modal
for (; i < videos.length; i++) {
videos[i].pause();
}
}
});

}(window));