1/*jshint browser:true */ 2/*! 3 * FitVids 1.1 4 * 5 * Copyright 2013, 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 */ 10 11; 12( function ( $ ) { 13 14 'use strict'; 15 16 $.fn.fitVids = function ( options ) { 17 var settings = { 18 customSelector: null, 19 ignore: null 20 }; 21 22 if ( !document.getElementById( 'fit-vids-style' ) ) { 23 // appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js 24 var head = document.head || document.getElementsByTagName( 'head' )[0]; 25 var css = '.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%;}'; 26 var div = document.createElement( "div" ); 27 div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>'; 28 head.appendChild( div.childNodes[1] ); 29 } 30 31 if ( options ) { 32 $.extend( settings, options ); 33 } 34 35 return this.each( function () { 36 var selectors = [ 37 'iframe[src*="player.vimeo.com"]', 38 'iframe[src*="youtube.com"]', 39 'iframe[src*="youtube-nocookie.com"]', 40 'iframe[src*="kickstarter.com"][src*="video.html"]', 41 'object', 42 'embed' 43 ]; 44 45 if ( settings.customSelector ) { 46 selectors.push( settings.customSelector ); 47 } 48 49 var ignoreList = '.fitvidsignore'; 50 51 if ( settings.ignore ) { 52 ignoreList = ignoreList + ', ' + settings.ignore; 53 } 54 55 var $allVideos = $( this ).find( selectors.join( ',' ) ); 56 $allVideos = $allVideos.not( 'object object' ); // SwfObj conflict patch 57 $allVideos = $allVideos.not( ignoreList ); // Disable FitVids on this video. 58 59 $allVideos.each( function () { 60 var $this = $( this ); 61 if ( $this.parents( ignoreList ).length > 0 ) { 62 return; // Disable FitVids on this video. 63 } 64 if ( this.tagName.toLowerCase() === 'embed' && $this.parent( 'object' ).length || $this.parent( '.fluid-width-video-wrapper' ).length ) { 65 return; 66 } 67 if ( ( !$this.css( 'height' ) && !$this.css( 'width' ) ) && ( isNaN( $this.attr( 'height' ) ) || isNaN( $this.attr( 'width' ) ) ) ) 68 { 69 $this.attr( 'height', 9 ); 70 $this.attr( 'width', 16 ); 71 } 72 var height = ( this.tagName.toLowerCase() === 'object' || ( $this.attr( 'height' ) && !isNaN( parseInt( $this.attr( 'height' ), 10 ) ) ) ) ? parseInt( $this.attr( 'height' ), 10 ) : $this.height(), 73 width = !isNaN( parseInt( $this.attr( 'width' ), 10 ) ) ? parseInt( $this.attr( 'width' ), 10 ) : $this.width(), 74 aspectRatio = height / width; 75 if ( !$this.attr( 'name' ) ) { 76 var videoName = 'fitvid' + $.fn.fitVids._count; 77 $this.attr( 'name', videoName ); 78 $.fn.fitVids._count++; 79 } 80 if ( typeof BBTHEME_LEARNDASH_FRONT_VIDEO !== 'undefined' && typeof BBTHEME_LEARNDASH_FRONT_VIDEO.hide_wrapper !== 'undefined' && 'hide' === BBTHEME_LEARNDASH_FRONT_VIDEO.hide_wrapper ) { 81 if ( typeof BBTHEME_LEARNDASH_FRONT_VIDEO !== 'undefined' && typeof BBTHEME_LEARNDASH_FRONT_VIDEO.video_progression_enabled !== 'undefined' && 'on' === BBTHEME_LEARNDASH_FRONT_VIDEO.video_progression_enabled ) { 82 if ( typeof BBTHEME_LEARNDASH_FRONT_VIDEO !== 'undefined' && typeof BBTHEME_LEARNDASH_FRONT_VIDEO.video_type !== 'undefined' && 'vimeo' === BBTHEME_LEARNDASH_FRONT_VIDEO.video_type ) { 83 $this.closest('div').addClass("fluid-width-video-wrapper").css('padding-top', (aspectRatio * 100) + '%'); 84 } else { 85 $this.wrap( '<div class="fluid-width-video-wrapper"></div>' ).parent( '.fluid-width-video-wrapper' ).css( 'padding-top', ( aspectRatio * 100 ) + '%' ); 86 } 87 } else { 88 $this.wrap( '<div class="fluid-width-video-wrapper"></div>' ).parent( '.fluid-width-video-wrapper' ).css( 'padding-top', ( aspectRatio * 100 ) + '%' ); 89 } 90 } else { 91 $this.wrap( '<div class="fluid-width-video-wrapper"></div>' ).parent( '.fluid-width-video-wrapper' ).css( 'padding-top', ( aspectRatio * 100 ) + '%' ); 92 $this.closest( 'div' ).addClass( "fluid-width-video-wrapper" ).css( 'padding-top', ( aspectRatio * 100 ) + '%' ); 93 } 94 if( $this.closest( '.ld-video' ).length ){ 95 $this.closest( '.ld-video' ).css( 'padding-bottom', ( aspectRatio * 100 ) + '%' ); 96 } 97 $this.closest( '.fluid-width-video-wrapper' ).parent( 'p' ).addClass('bb-video-wrapper'); 98 $this.removeAttr( 'height' ).removeAttr( 'width' ); 99 } ); 100 } ); 101 }; 102
103 // Internal counter for unique video names. 104 $.fn.fitVids._count = 0; 105 106// Works with either jQuery or Zepto 107} )( window.jQuery || window.Zepto );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.