Compare commits

..

2 Commits

4 changed files with 20 additions and 12 deletions

View File

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

View File

@ -20,16 +20,19 @@ class PanoramaViewerBlockForm extends Form
], ],
]); ]);
/*
$this->add([ $this->add([
'name' => 'o:block[__blockIndex__][o:data][width]', 'name' => 'o:block[__blockIndex__][o:data][width]',
'type' => Element\Number::class, 'type' => Element\Number::class,
'options' => [ 'options' => [
'label' => 'Width in pixels', 'label' => 'Width in percentage',
], ],
'attributes' => [ 'attributes' => [
'min' => '100', 'min' => '50',
'max' => '100',
], ],
]); ]);
*/
$this->add([ $this->add([
'name' => 'o:block[__blockIndex__][o:data][ratio]', 'name' => 'o:block[__blockIndex__][o:data][ratio]',

View File

@ -95,14 +95,10 @@ class PanoramaViewer extends AbstractBlockLayout
} }
$item_id = $attachments[0]->item()->url(); $item_id = $attachments[0]->item()->url();
//$title = $attachments[0]->item()->title(); //$title = $attachments[0]->item()->title();
$title = $block->dataValue('title');
$width = $block->dataValue('width');
$height = $width / $block->dataValue('ratio');
return $view->partial('common/block-layout/panorama-viewer', [ return $view->partial('common/block-layout/panorama-viewer', [
'panorama_type' => $panorama_type, 'panorama_type' => $panorama_type,
'title' => $title, 'title' => $block->dataValue('title'),
'width' => $width, 'ratio' => $block->dataValue('ratio'),
'height' => $height,
'autoLoad' => $block->dataValue('autoLoad'), 'autoLoad' => $block->dataValue('autoLoad'),
'renderSourceLink' => $block->dataValue('renderSourceLink'), 'renderSourceLink' => $block->dataValue('renderSourceLink'),
'urls' => $urls, 'urls' => $urls,

View File

@ -3,6 +3,8 @@
'PanoramaViewer')); 'PanoramaViewer'));
$this->headScript()->appendFile($this->assetUrl('vendor/pannellum/pannellum.js', $this->headScript()->appendFile($this->assetUrl('vendor/pannellum/pannellum.js',
'PanoramaViewer')); 'PanoramaViewer'));
$this->headScript()->appendFile($this->assetUrl('js/height_calculator.js',
'PanoramaViewer'));
if ($panorama_type == "video") { if ($panorama_type == "video") {
$this->headLink()->appendStylesheet($this->assetUrl('vendor/video.js/video-js.css', $this->headLink()->appendStylesheet($this->assetUrl('vendor/video.js/video-js.css',
@ -20,9 +22,8 @@
?> ?>
<style> <style>
#<?= $id ?> { .pannemmul-wrap {
height: <?= $height ?>px; width: 100%;
width: <?= $width ?>px;
} }
</style> </style>
@ -95,4 +96,6 @@
} }
}); });
<?php } ?> <?php } ?>
var height = get_height('#<?= $id ?>', <?= $ratio ?>)
$('#<?= $id ?>').css('height', height)
</script> </script>