Sha256: 468a96ebfc751eb8364e8f8e1f9b43d13fca65bc4611576d48f946749f9b63ab

Contents?: true

Size: 902 Bytes

Versions: 4

Compression:

Stored size: 902 Bytes

Contents

jQuery(document).ready(function($) {
  // Find all YouTube videos
  var $allVideos = $("iframe[src^='http://player.vimeo.com'], iframe[src^='http://www.youtube.com']");

      // The element that is fluid width
      $fluidEl = $("#content");

  // Figure out and save aspect ratio for each video
  $allVideos.each(function() {

    $(this)
      .data('aspectRatio', this.height / this.width)

      // and remove the hard coded width/height
      .removeAttr('height')
      .removeAttr('width');

  });

  // When the window is resized
  $(window).resize(function() {

    var newWidth = $fluidEl.width();

    // Resize all videos according to their own aspect ratio
    $allVideos.each(function() {

      var $el = $(this);
      $el
        .width(newWidth)
        .height(newWidth * $el.data('aspectRatio'));

    });

  // Kick off one resize to fix all videos on page load
  }).resize();
});

Version data entries

4 entries across 2 versions & 2 rubygems

Version Path
toolkit-0.1 templates/project/embeds.respond.js
toolkit-0.1 templates/respond-to/embeds.respond.js
rwd-kickstart-1.0 templates/project/embeds.respond.js
rwd-kickstart-1.0 templates/respond-to/embeds.respond.js