renders source link and subtitle

This commit is contained in:
buttle 2021-05-31 19:29:45 +02:00
parent d88f3edc0c
commit 2882f5c115
4 changed files with 43 additions and 31 deletions

View File

@ -20,6 +20,7 @@ return [
'DefaultSettings' => [ 'DefaultSettings' => [
'ImageViewerBlockForm' => [ 'ImageViewerBlockForm' => [
'title' => '', 'title' => '',
'renderSourceLink' => true,
'width' => 600, 'width' => 600,
'zoom_type' => '', 'zoom_type' => '',
'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

@ -10,15 +10,6 @@ class ImageViewerBlockForm extends Form
public function init() public function init()
{ {
$this->add([
'name' => 'o:block[__blockIndex__][o:data][title]',
'type' => Element\Text::class,
'options' => [
'label' => 'Title (option)',
]
]);
$this->add([ $this->add([
'name' => 'o:block[__blockIndex__][o:data][width]', 'name' => 'o:block[__blockIndex__][o:data][width]',
'type' => Element\Select::class, 'type' => Element\Select::class,
@ -37,17 +28,23 @@ class ImageViewerBlockForm extends Form
], ],
]); ]);
/*
$this->add([ $this->add([
'type' => Element\Checkbox::class, 'type' => Element\Checkbox::class,
'name' => 'o:block[__blockIndex__][o:data][zoom]', 'name' => 'o:block[__blockIndex__][o:data][renderSourceLink]',
'options' => [ 'options' => [
'label' => 'Zoom', 'label' => 'Display a link to the item',
//'use_hidden_element' => true, //'use_hidden_element' => true,
'checked_value' => true, 'checked_value' => true,
'unchecked_value' => false, 'unchecked_value' => false,
], ],
]); ]);
*/
$this->add([
'name' => 'o:block[__blockIndex__][o:data][title]',
'type' => Element\Text::class,
'options' => [
'label' => 'Sub-title',
]
]);
} }
} }

View File

@ -50,7 +50,7 @@ class ImageViewer extends AbstractBlockLayout
'o:block[__blockIndex__][o:data][title]' => $data['title'], 'o:block[__blockIndex__][o:data][title]' => $data['title'],
'o:block[__blockIndex__][o:data][width]' => $data['width'], 'o:block[__blockIndex__][o:data][width]' => $data['width'],
'o:block[__blockIndex__][o:data][zoom_type]' => $data['zoom_type'], 'o:block[__blockIndex__][o:data][zoom_type]' => $data['zoom_type'],
//'o:block[__blockIndex__][o:data][zoom]' => $data['zoom'], 'o:block[__blockIndex__][o:data][renderSourceLink]' => $data['renderSourceLink'],
]); ]);
$form->prepare(); $form->prepare();
@ -78,6 +78,8 @@ class ImageViewer extends AbstractBlockLayout
return $view->partial('common/block-layout/imageViewer', [ return $view->partial('common/block-layout/imageViewer', [
'zoom_type' => $block->dataValue('zoom_type'), 'zoom_type' => $block->dataValue('zoom_type'),
'title' => $block->dataValue('title'), 'title' => $block->dataValue('title'),
'item_url' => $attachments[0]->item()->url(),
'renderSourceLink' => $block->dataValue('renderSourceLink'),
'width' => $block->dataValue('width'), 'width' => $block->dataValue('width'),
'image' => $media->primaryMedia()->thumbnailUrl('large'), 'image' => $media->primaryMedia()->thumbnailUrl('large'),
'id' => 'iv-' . ++$id, 'id' => 'iv-' . ++$id,

View File

@ -15,35 +15,23 @@
} }
?> ?>
<?php <?php if ($renderSourceLink) { ?>
if ($title !== false && $title !== "") { <div class="source-link">
$title = sprintf('<p id="wheelzoom-title">%s</p>', $title); <a href="<?= $item_url ?>">Source</a>
} else { </div>
$title = false; <?php } ?>
}
?>
<?php if ($zoom_type == "zoom") { ?> <?php if ($zoom_type == "zoom") { ?>
<div id='<?= $id ?>' class='zoom' style='width:<?= $width ?>%; cursor:grab'> <div id='<?= $id ?>' class='zoom' style='width:<?= $width ?>%; cursor:grab'>
<img src='<?= $image ?>' alt='<?= $title ?>'/> <img src='<?= $image ?>' alt='<?= $title ?>'/>
</div> </div>
<script>
$(document).ready(function(){
$('#<?= $id ?>').zoom({on:'grab', 'duration': 200, 'magnify': 1.5});
});
</script>
<?php } ?> <?php } ?>
<?php if ($zoom_type == "wheelzoom") { ?> <?php if ($zoom_type == "wheelzoom") { ?>
<div class='zoom' style='display:block; width:<?= $width ?>%; cursor:crosshair'> <div class='zoom' style='display:block; width:<?= $width ?>%; cursor:crosshair'>
<img id="<?= $id ?>" src="<?= $image ?>" /> <img id="<?= $id ?>" src="<?= $image ?>" />
</div> </div>
<script>
$(document).ready(function(){
wheelzoom(document.querySelector('#<?= $id ?>'));
});
</script>
<?php } ?> <?php } ?>
<?php if ($zoom_type == "") { ?> <?php if ($zoom_type == "") { ?>
@ -54,3 +42,27 @@
/> />
</div> </div>
<?php } ?> <?php } ?>
<?php if ($title) { ?>
<div class="item_title">
<?= $title ?>
</div>
<?php } ?>
<?php if ($zoom_type == "zoom") { ?>
<script>
$(document).ready(function(){
$('#<?= $id ?>').zoom({on:'grab', 'duration': 200, 'magnify': 1.5});
});
</script>
<?php } ?>
<?php if ($zoom_type == "wheelzoom") { ?>
<script>
$(document).ready(function(){
wheelzoom(document.querySelector('#<?= $id ?>'));
});
</script>
<?php } ?>