diff --git a/asset/js/height_calculator.js b/asset/js/height_calculator.js deleted file mode 100644 index 1411939..0000000 --- a/asset/js/height_calculator.js +++ /dev/null @@ -1,4 +0,0 @@ -function get_height(container, ratio) { - var height = $(container).width() / ratio - return height -} diff --git a/asset/js/media_dimensions.js b/asset/js/media_dimensions.js new file mode 100644 index 0000000..48793d2 --- /dev/null +++ b/asset/js/media_dimensions.js @@ -0,0 +1,20 @@ +function get_height(container, ratio) { + var height = $(container).width() / ratio + return height +} + +function adjust_height() { + $(".embeded-vimeo-wrapper").each(function() { + var iframe = $(this).find('iframe') + var ratio = $(iframe).attr('ratio') + $(iframe).prop("height", get_height(iframe, ratio)) + }); +} + +jQuery(document).ready(function() { + adjust_height(); +}); + +$(window).resize(function() { + adjust_height(); +}); diff --git a/view/common/block-layout/vimeo.phtml b/view/common/block-layout/vimeo.phtml index 369f5ee..d7de0d4 100644 --- a/view/common/block-layout/vimeo.phtml +++ b/view/common/block-layout/vimeo.phtml @@ -1,9 +1,9 @@ headScript()->appendFile($this->assetUrl('js/height_calculator.js', +$this->headScript()->appendFile($this->assetUrl('js/media_dimensions.js', 'Vimeo')); ?> -
@@ -23,17 +23,5 @@ $this->headScript()->appendFile($this->assetUrl('js/height_calculator.js',