Compare commits

..

No commits in common. "415df49b47165c419064551fe607e477f3d23cc8" and "9e9a5829f7872fc3e913ab7031acf25c0a26c747" have entirely different histories.

6 changed files with 16 additions and 37 deletions

View File

@ -9,19 +9,12 @@ class Module extends AbstractModule
{ {
const NAMESPACE = __NAMESPACE__; const NAMESPACE = __NAMESPACE__;
const IMAGE_WIDTH = [
'25' => '25 %',
'50' => '50 %',
'75' => '75 %',
'100' => '100 %',
];
/*
const RATIOS = [ const RATIOS = [
'1.777' => '16:9', '1.777' => '16:9',
'1.333' => '4:3', '1.333' => '4:3',
'2' => '2:1', '2' => '2:1',
]; ];
*/
public function getConfig() public function getConfig()
{ {
return include __DIR__ . '/config/module.config.php'; return include __DIR__ . '/config/module.config.php';

View File

@ -1,4 +0,0 @@
function get_height(container, ratio) {
var height = $(container).width() / ratio
return height
}

View File

@ -31,7 +31,7 @@ return [
'VimeoBlockForm' => [ 'VimeoBlockForm' => [
'title' => '', 'title' => '',
'renderSourceLink' => true, 'renderSourceLink' => true,
'width' => 100, 'width' => 600,
'ratio' => '2', 'ratio' => '2',
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;', 'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;',
] ]

View File

@ -12,16 +12,13 @@ class VimeoBlockForm extends Form
$this->add([ $this->add([
'name' => 'o:block[__blockIndex__][o:data][width]', 'name' => 'o:block[__blockIndex__][o:data][width]',
'type' => Element\Select::class, 'type' => Element\Number::class,
'options' => [ 'options' => [
'label' => 'Width', 'label' => 'Width in pixels',
'value_options' => Module::IMAGE_WIDTH, ],
],
/*
'attributes' => [ 'attributes' => [
'min' => '100', 'min' => '100',
], ],
*/
]); ]);
$this->add([ $this->add([

View File

@ -75,17 +75,15 @@ class Vimeo extends AbstractBlockLayout
static $id = 0; static $id = 0;
$media = $attachments[0]->item()->media()[0]; $media = $attachments[0]->item()->media()[0];
$vimeo_width = $media->mediaData()['width']; $width = 900;
$vimeo_height = $media->mediaData()['height']; //$height = $width / $block->dataValue('ratio');
$ratio = $vimeo_width / $vimeo_height; $height = $width / 1.333;
return $view->partial('common/block-layout/vimeo', [ return $view->partial('common/block-layout/vimeo', [
'title' => $block->dataValue('title'), 'title' => $block->dataValue('title'),
'renderSourceLink' => $block->dataValue('renderSourceLink'), 'renderSourceLink' => $block->dataValue('renderSourceLink'),
'item_url' => $attachments[0]->item()->url(), 'item_url' => $attachments[0]->item()->url(),
'width' => $block->dataValue('width'), 'width' => $width,
'video_id' => $media->mediaData()['video_id'], 'height' => $height,
'ratio' => $ratio,
'vimeo_iframe' => $media->mediaData()['html'], 'vimeo_iframe' => $media->mediaData()['html'],
]); ]);
} }

View File

@ -1,9 +1,4 @@
<?php <div class="vimeo-wrap" style="position:relative;">
$this->headScript()->appendFile($this->assetUrl('js/height_calculator.js',
'Vimeo'));
?>
<div id="vimeo_<?= $video_id ?>" class="vimeo-wrap" style="position:relative;">
<?php if ($renderSourceLink) { ?> <?php if ($renderSourceLink) { ?>
<div class="source-link"> <div class="source-link">
@ -21,11 +16,11 @@ $this->headScript()->appendFile($this->assetUrl('js/height_calculator.js',
</div> </div>
<script> <script>
jQuery(document).ready(function() { jQuery(document).ready(function() {
var vimeo = $("#vimeo_<?= $video_id ?>").find('iframe'); var vimeo = $(".vimeo-wrap").find('iframe');
$(vimeo).prop("width", "<?= $width ?>%") //$(vimeo).prop('width', <?= $width ?>);
var height = get_height(vimeo, <?= $ratio ?>) //$(vimeo).prop('height', <?= $height ?>);
$(vimeo).prop("height", height)
}); });
</script> </script>