1.0.10 • Published 6 years ago

youtube-iframe-assistant v1.0.10

Weekly downloads
15
License
ISC
Repository
github
Last release
6 years ago

YouTube Iframe Assistant

Make all Iframe videos fully responsive and scale with the screen.

This project began as a YouTube centered helper, but does support the following video embeds:

  • YouTube
  • Vimeo
  • Potentially others, no more tested

If you have embed types that you would like to request be tested, please submit an issue here

Requirements

  • jQuery - v1.12.4 ^
  • jQuery.actual - latest

If using webpack

require('jquery.actual');
require('youtube-iframe-assistant');

If using separated scripts

<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.actual/1.0.19/jquery.actual.min.js"></script>
<script src="/path/to/youtube-iframe-assistant.js"></script>

Getting Started

Simply call the youtubeIframeAssistant function and all iframes will be automatically set to scale responsively

$(function () {
 
    youtubeIframeAssistant();
 
});

You can pass in different settings to tweak your criterea and functionality

$(function () {
 
    youtubeIframeAssistant({
        useBootstrapModal: true
    });
 
});

You can either surround your iframe with a figure tag, or allow the plugin to automatically wrap the iframe if it is not already the parent element.

<iframe width="560" height="315" src="https://www.youtube.com/embed/RQ2BHsL4C0I?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
 
---- OR ----
 
<figure>
    <iframe width="560" height="315" src="https://www.youtube.com/embed/RQ2BHsL4C0I?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
</figure>

Bootstrap Modals

This plugin can be used along side Bootstrap's Modals with no adjustments, and default styles can be toggled on/off.

<div class="btn btn-primary video-toggle" data-toggle="modal" data-target="#target-modal">Open Video</div>
 
<div id="target-modal" class="modal fade video-modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-body">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>

                <iframe width="560" height="315" src="http://youtube.videosrc" frameborder="0" allowfullscreen></iframe>
            </div>
        </div>
    </div>
</div>

Settings

SettingTypeDefaultDescription
useBootstrapModalbooleanfalseSet this to true if using Bootstraps modals as video popups
startVideoOnModalOpenbooleantrueIf using Bootstrap Modals, start the video when the modal opens, based on videoTogglesClass
stopVideoOnModalClosebooleantrueIf using Bootstrap Modals, stop the video when the modal closes, based on the videoModalsClass
useIframeClassbooleanfalseChange the scope of the iframes effected down to a class
iframeClassstring".iframe-video"Class of the iframes to be scoped to
videoTogglesClassstring".video-toggle"The class that will be watched in order to trigger the video play
videoModalsClassstring".video-modal"The class that will be used to watch for modal closes to stop the video contained
1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago