Add hotpot navigation and slideshow

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2024-10-28 13:51:46 -07:00
parent 2163f9158a
commit 6b3e1f4e19
6 changed files with 85 additions and 4 deletions

View File

@@ -2,6 +2,8 @@
namespace MediaWiki\Extension\GlModelViewer;
use MediaTransformOutput;
use ConfigFactory;
use OutputPage;
use Html;
class GlModelTransformOutput extends MediaTransformOutput {
@@ -157,8 +159,40 @@ class GlModelTransformOutput extends MediaTransformOutput {
$attrMenu = array(
'class' => 'glmv-menu'
);
$mainConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
$menuUrl = $mainConfig->get( 'ExtensionAssetsPath' ) . '/GlModelViewer/resources/menu_arrow.svg';
$attrMenuImg = array (
'class' => 'glmv-menu-image',
'src' => $menuUrl
);
$menuImg = Html::rawElement('img', $attrMenuImg, '');
return Html::rawElement('div', $attrMenu, '>');
$gotoUrl = $mainConfig->get( 'ExtensionAssetsPath' ) . '/GlModelViewer/resources/goto_hs.svg';
$attrMenuButtonPrev = array (
'class' => 'glmv-menu-button prev-hs',
'onclick' => 'prevAnnotation(event.target.closest(".glmv-container").querySelector("model-viewer"))',
'onmousedown' => 'event.stopPropagation()',
'ontouchstart' => 'event.stopPropagation()'
);
$attrMenuButtonNext = array (
'class' => 'glmv-menu-button next-hs',
'onclick' => 'nextAnnotation(event.target.closest(".glmv-container").querySelector("model-viewer"))',
'onmousedown' => 'event.stopPropagation()',
'ontouchstart' => 'event.stopPropagation()'
);
$slideUrl = $mainConfig->get( 'ExtensionAssetsPath' ) . '/GlModelViewer/resources/hs_slideshow.svg';
$attrMenuButtonSlides = array (
'class' => 'glmv-menu-button',
'onclick' => 'event.target.toggleAttribute("toggled"); slideshowAnnotations(event.target.closest(".glmv-container").querySelector("model-viewer"))',
'onmousedown' => 'event.stopPropagation()',
'ontouchstart' => 'event.stopPropagation()'
);
$buttonPrev = Html::rawElement('div', $attrMenuButtonPrev, '<img src="' . $gotoUrl . '"></image>');
$buttonNext = Html::rawElement('div', $attrMenuButtonNext, '<img src="' . $gotoUrl . '"></image>');
$buttonSlides = Html::rawElement('div', $attrMenuButtonSlides, '<img src="' . $slideUrl . '"></image>');
return Html::rawElement('div', $attrMenu, $menuImg . $buttonPrev . $buttonSlides . $buttonNext);
}
/**