Initial commit
This commit is contained in:
commit
28e6ddf404
1083 changed files with 191734 additions and 0 deletions
|
@ -0,0 +1,10 @@
|
|||
.jetpack-video-wrapper {
|
||||
margin-bottom: 1.6em;
|
||||
}
|
||||
|
||||
.jetpack-video-wrapper > embed,
|
||||
.jetpack-video-wrapper > iframe,
|
||||
.jetpack-video-wrapper > object,
|
||||
.jetpack-video-wrapper > .wp-video {
|
||||
margin-bottom: 0;
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
( function( $ ) {
|
||||
|
||||
/**
|
||||
* A function to help debouncing.
|
||||
*/
|
||||
var debounce = function( func, wait ) {
|
||||
|
||||
var timeout, args, context, timestamp;
|
||||
|
||||
return function() {
|
||||
|
||||
context = this;
|
||||
args = [].slice.call( arguments, 0 );
|
||||
timestamp = new Date();
|
||||
|
||||
var later = function() {
|
||||
|
||||
var last = ( new Date() ) - timestamp;
|
||||
|
||||
if ( last < wait ) {
|
||||
timeout = setTimeout( later, wait - last );
|
||||
} else {
|
||||
timeout = null;
|
||||
func.apply( context, args );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
if ( ! timeout ) {
|
||||
timeout = setTimeout( later, wait );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* A function to resize videos.
|
||||
*/
|
||||
function responsive_videos() {
|
||||
|
||||
$( '.jetpack-video-wrapper' ).find( 'embed, iframe, object' ).each( function() {
|
||||
var video_element, video_width, video_height, video_ratio, video_wrapper, video_margin, container_width;
|
||||
|
||||
video_element = $( this );
|
||||
video_margin = 0;
|
||||
|
||||
if ( video_element.parents( '.jetpack-video-wrapper' ).prev( 'p' ).css( 'text-align' ) === 'center' ) {
|
||||
video_margin = '0 auto';
|
||||
}
|
||||
|
||||
if ( ! video_element.attr( 'data-ratio' ) ) {
|
||||
video_element
|
||||
.attr( 'data-ratio', this.height / this.width )
|
||||
.attr( 'data-width', this.width )
|
||||
.attr( 'data-height', this.height )
|
||||
.css( {
|
||||
'display' : 'block',
|
||||
'margin' : video_margin
|
||||
} );
|
||||
}
|
||||
|
||||
video_width = video_element.attr( 'data-width' );
|
||||
video_height = video_element.attr( 'data-height' );
|
||||
video_ratio = video_element.attr( 'data-ratio' );
|
||||
video_wrapper = video_element.parent();
|
||||
container_width = video_wrapper.width();
|
||||
|
||||
if ( video_ratio === 'Infinity' ) {
|
||||
video_width = '100%';
|
||||
}
|
||||
|
||||
video_element
|
||||
.removeAttr( 'height' )
|
||||
.removeAttr( 'width' );
|
||||
|
||||
if ( video_width > container_width ) {
|
||||
video_element
|
||||
.width( container_width )
|
||||
.height( container_width * video_ratio );
|
||||
} else {
|
||||
video_element
|
||||
.width( video_width )
|
||||
.height( video_height );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load responsive_videos().
|
||||
* Trigger resize to make sure responsive_videos() is loaded after IS.
|
||||
*/
|
||||
$( window ).load( responsive_videos ).resize( debounce( responsive_videos, 100 ) ).trigger( 'resize' );
|
||||
$( document ).on( 'post-load', responsive_videos );
|
||||
|
||||
} )( jQuery );
|
1
plugins/jetpack/modules/theme-tools/responsive-videos/responsive-videos.min.js
vendored
Normal file
1
plugins/jetpack/modules/theme-tools/responsive-videos/responsive-videos.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
!function(t){function a(){t(".jetpack-video-wrapper").find("embed, iframe, object").each(function(){var a,e,i,r,h,n,d;a=t(this),n=0,"center"===a.parents(".jetpack-video-wrapper").prev("p").css("text-align")&&(n="0 auto"),a.attr("data-ratio")||a.attr("data-ratio",this.height/this.width).attr("data-width",this.width).attr("data-height",this.height).css({display:"block",margin:n}),e=a.attr("data-width"),i=a.attr("data-height"),r=a.attr("data-ratio"),h=a.parent(),d=h.width(),"Infinity"===r&&(e="100%"),a.removeAttr("height").removeAttr("width"),e>d?a.width(d).height(d*r):a.width(e).height(i)})}var e=function(t,a){var e,i,r,h;return function(){r=this,i=[].slice.call(arguments,0),h=new Date;var n=function(){var d=new Date-h;a>d?e=setTimeout(n,a-d):(e=null,t.apply(r,i))};e||(e=setTimeout(n,a))}};t(window).load(a).resize(e(a,100)).trigger("resize"),t(document).on("post-load",a)}(jQuery);
|
Reference in a new issue