diff --git a/Module.php b/Module.php index 07310a0..bcb048d 100644 --- a/Module.php +++ b/Module.php @@ -16,6 +16,12 @@ class Module extends AbstractModule '100' => '100 %', ]; + const ZOOM_TYPE = [ + '' => '', + 'zoom' => 'Touch / grab', + 'wheelzoom' => 'Deep zooming', + ]; + public function getConfig() { return include __DIR__ . '/config/module.config.php'; diff --git a/config/module.config.php b/config/module.config.php index 853110f..63f5f66 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -21,7 +21,7 @@ return [ 'ImageViewerBlockForm' => [ 'title' => '', 'width' => 600, - 'zoom' => false, + 'zoom_type' => '', 'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;', ] ] diff --git a/src/Form/ImageViewerBlockForm.php b/src/Form/ImageViewerBlockForm.php index 1708ccb..53d45ca 100644 --- a/src/Form/ImageViewerBlockForm.php +++ b/src/Form/ImageViewerBlockForm.php @@ -28,6 +28,16 @@ class ImageViewerBlockForm extends Form ], ]); + $this->add([ + 'name' => 'o:block[__blockIndex__][o:data][zoom_type]', + 'type' => Element\Select::class, + 'options' => [ + 'label' => 'Zooming', + 'value_options' => Module::ZOOM_TYPE, + ], + ]); + + /* $this->add([ 'type' => Element\Checkbox::class, 'name' => 'o:block[__blockIndex__][o:data][zoom]', @@ -38,6 +48,6 @@ class ImageViewerBlockForm extends Form 'unchecked_value' => false, ], ]); - + */ } } diff --git a/src/Site/BlockLayout/ImageViewer.php b/src/Site/BlockLayout/ImageViewer.php index 816a300..0bca3b6 100644 --- a/src/Site/BlockLayout/ImageViewer.php +++ b/src/Site/BlockLayout/ImageViewer.php @@ -49,7 +49,8 @@ class ImageViewer extends AbstractBlockLayout $form->setData([ 'o:block[__blockIndex__][o:data][title]' => $data['title'], 'o:block[__blockIndex__][o:data][width]' => $data['width'], - 'o:block[__blockIndex__][o:data][zoom]' => $data['zoom'], + 'o:block[__blockIndex__][o:data][zoom_type]' => $data['zoom_type'], + //'o:block[__blockIndex__][o:data][zoom]' => $data['zoom'], ]); $form->prepare(); @@ -75,7 +76,7 @@ class ImageViewer extends AbstractBlockLayout $media = $attachments[0]->item()->media()[0]; return $view->partial('common/block-layout/imageViewer', [ - 'zoom' => $block->dataValue('zoom'), + 'zoom_type' => $block->dataValue('zoom_type'), 'title' => $block->dataValue('title'), 'width' => $block->dataValue('width'), 'image' => $media->primaryMedia()->thumbnailUrl('large'), diff --git a/view/common/block-layout/imageViewer.phtml b/view/common/block-layout/imageViewer.phtml index cf7b4bb..1a719b4 100644 --- a/view/common/block-layout/imageViewer.phtml +++ b/view/common/block-layout/imageViewer.phtml @@ -1,15 +1,18 @@ -headScript()->appendFile($this->assetUrl('vendor/wheelzoom/wheelzoom.js', - // 'ImageViewer')); +headScript()->appendFile($this->assetUrl('vendor/wheelzoom/wheelzoom.js', + 'ImageViewer')); + } + if ($zoom_type == "zoom") { $this->headScript()->appendFile($this->assetUrl('vendor/zoom/jquery.zoom.min.js', 'ImageViewer')); $this->headLink()->appendStylesheet($this->assetUrl('css/zoom.css', 'ImageViewer')); -} ?> + } +?> -