初始化
This commit is contained in:
21
MQTTServerSideAPI/plugins/video/responsible-video.js
Normal file
21
MQTTServerSideAPI/plugins/video/responsible-video.js
Normal file
@@ -0,0 +1,21 @@
|
||||
$(function() {
|
||||
var $allVideos = $("iframe[src^='http://player.vimeo.com'], iframe[src^='http://www.youtube.com'], object, embed"),
|
||||
$fluidEl = $("figure");
|
||||
|
||||
$allVideos.each(function() {
|
||||
$(this)
|
||||
// jQuery .data does not work on object/embed elements
|
||||
.attr('data-aspectRatio', this.height / this.width)
|
||||
.removeAttr('height')
|
||||
.removeAttr('width');
|
||||
});
|
||||
$(window).resize(function() {
|
||||
var newWidth = $fluidEl.width();
|
||||
$allVideos.each(function() {
|
||||
var $el = $(this);
|
||||
$el
|
||||
.width(newWidth)
|
||||
.height(newWidth * $el.attr('data-aspectRatio'));
|
||||
});
|
||||
}).resize();
|
||||
});
|
||||
Reference in New Issue
Block a user