WordPress.org

Make WordPress Core

Ticket #21480: fitvids.diff

File fitvids.diff, 3.7 KB (added by andyadams, 3 years ago)

Howabout a version that includes FitVids?

  • wp-content/themes/twentytwelve/functions.php

     
    101101                wp_enqueue_script( 'comment-reply' ); 
    102102 
    103103        /** 
     104         * FitVids adds responsiveness for videos. 
     105         */ 
     106        wp_enqueue_script( 'twentytwelve-fitvids', get_template_directory_uri() . '/js/fitvids.js', array( 'jquery' ), '20120802', true ); 
     107 
     108        /** 
    104109         * JavaScript for handling navigation menus and the resized 
    105110         * styles for small screen sizes. 
    106111         */ 
    107         wp_enqueue_script( 'twentytwelve-navigation', get_template_directory_uri() . '/js/theme.js', array( 'jquery' ), '20120802', true ); 
     112        wp_enqueue_script( 'twentytwelve-navigation', get_template_directory_uri() . '/js/theme.js', array( 'jquery', 'twentytwelve-fitvids' ), '20120802', true ); 
    108113 
    109114        /** 
    110115         * Load special font CSS file. 
  • wp-content/themes/twentytwelve/js/fitvids.js

     
     1/*global jQuery */ 
     2/*! 
     3* FitVids 1.0 
     4* 
     5* Copyright 2011, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com 
     6* Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/ 
     7* Released under the WTFPL license - http://sam.zoy.org/wtfpl/ 
     8* 
     9* Date: Thu Sept 01 18:00:00 2011 -0500 
     10*/ 
     11(function(a){a.fn.fitVids=function(b){var c={customSelector:null};var d=document.createElement("div"),e=document.getElementsByTagName("base")[0]||document.getElementsByTagName("script")[0];d.className="fit-vids-style";d.innerHTML="­<style>               .fluid-width-video-wrapper {                 width: 100%;                              position: relative;                       padding: 0;                            }                                                                                   .fluid-width-video-wrapper iframe,        .fluid-width-video-wrapper object,        .fluid-width-video-wrapper embed {           position: absolute;                       top: 0;                                   left: 0;                                  width: 100%;                              height: 100%;                          }                                       </style>";e.parentNode.insertBefore(d,e);if(b){a.extend(c,b)}return this.each(function(){var b=["iframe[src*='player.vimeo.com']","iframe[src*='www.youtube.com']","iframe[src*='www.kickstarter.com']","object","embed"];if(c.customSelector){b.push(c.customSelector)}var d=a(this).find(b.join(","));d.each(function(){var b=a(this);if(this.tagName.toLowerCase()=="embed"&&b.parent("object").length||b.parent(".fluid-width-video-wrapper").length){return}var c=this.tagName.toLowerCase()=="object"?b.attr("height"):b.height(),d=c/b.width();if(!b.attr("id")){var e="fitvid"+Math.floor(Math.random()*999999);b.attr("id",e)}b.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top",d*100+"%");b.removeAttr("height").removeAttr("width")})})}})(jQuery) 
     12 No newline at end of file 
  • wp-content/themes/twentytwelve/js/theme.js

    Property changes on: wp-content/themes/twentytwelve/js/fitvids.js
    ___________________________________________________________________
    Added: svn:eol-style
       + native
    
     
    3838                        } 
    3939                }, 200 ); 
    4040        } ); 
     41 
     42        $('#main').fitVids(); 
    4143} ); 
     44 No newline at end of file