Add disable hs buttons when 0 annotations
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -183,10 +183,10 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
|||||||
$attrModelView = array_merge(['src' => $srcUrl, 'class' => 'mv-model', 'interpolation-decay' => '100', 'interaction-prompt' => 'none'], $attrModelView);
|
$attrModelView = array_merge(['src' => $srcUrl, 'class' => 'mv-model', 'interpolation-decay' => '100', 'interaction-prompt' => 'none'], $attrModelView);
|
||||||
$attrModelView['style'] = 'width: 100%; height: 100%;';
|
$attrModelView['style'] = 'width: 100%; height: 100%;';
|
||||||
$attrModelView['onload'] = 'modelLoaded(event)';
|
$attrModelView['onload'] = 'modelLoaded(event)';
|
||||||
$hotspotHtml = (isset($hotspots)) ? implode($hotspots) : '';
|
$hotspotHtml = (!empty($hotspots)) ? implode($hotspots) : '';
|
||||||
|
|
||||||
$elModel = Html::rawElement('model-viewer', $attrModelView, $hotspotHtml);
|
$elModel = Html::rawElement('model-viewer', $attrModelView, $hotspotHtml);
|
||||||
$elMenu = self::buildViewMenu();
|
$elMenu = self::buildViewMenu(!empty($hotspots));
|
||||||
|
|
||||||
$elFileLink = '';
|
$elFileLink = '';
|
||||||
if (!isset($viewParams['preview']) && $context->getTitle() != $this->file->getTitle()) {
|
if (!isset($viewParams['preview']) && $context->getTitle() != $this->file->getTitle()) {
|
||||||
@@ -213,9 +213,10 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
|||||||
/**
|
/**
|
||||||
* Build the button menu used for viewer actions
|
* Build the button menu used for viewer actions
|
||||||
*
|
*
|
||||||
|
* @param bool $annotsDrawn true to enable the annotation buttons
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function buildViewMenu() {
|
private static function buildViewMenu($annotsDrawn) {
|
||||||
$attrMenu = array(
|
$attrMenu = array(
|
||||||
'class' => 'glmv-menu awaiting-model',
|
'class' => 'glmv-menu awaiting-model',
|
||||||
'style' => 'display: none;'
|
'style' => 'display: none;'
|
||||||
@@ -230,13 +231,15 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
|||||||
|
|
||||||
$gotoUrl = $mainConfig->get( 'ExtensionAssetsPath' ) . '/GlModelViewer/resources/goto_hs.svg';
|
$gotoUrl = $mainConfig->get( 'ExtensionAssetsPath' ) . '/GlModelViewer/resources/goto_hs.svg';
|
||||||
$attrMenuButtonPrev = array (
|
$attrMenuButtonPrev = array (
|
||||||
'class' => 'glmv-menu-button prev-hs disable-on-hide',
|
'class' => 'glmv-menu-button prev-hs disable-on-hide disable-on-none',
|
||||||
|
'disabled' => !$annotsDrawn,
|
||||||
'onclick' => 'prevAnnotation(event.target.closest(".glmv-container").querySelector("model-viewer"))',
|
'onclick' => 'prevAnnotation(event.target.closest(".glmv-container").querySelector("model-viewer"))',
|
||||||
'onmousedown' => 'event.stopPropagation()',
|
'onmousedown' => 'event.stopPropagation()',
|
||||||
'ontouchstart' => 'event.stopPropagation()'
|
'ontouchstart' => 'event.stopPropagation()'
|
||||||
);
|
);
|
||||||
$attrMenuButtonNext = array (
|
$attrMenuButtonNext = array (
|
||||||
'class' => 'glmv-menu-button next-hs disable-on-hide',
|
'class' => 'glmv-menu-button next-hs disable-on-hide disable-on-none',
|
||||||
|
'disabled' => !$annotsDrawn,
|
||||||
'onclick' => 'nextAnnotation(event.target.closest(".glmv-container").querySelector("model-viewer"))',
|
'onclick' => 'nextAnnotation(event.target.closest(".glmv-container").querySelector("model-viewer"))',
|
||||||
'onmousedown' => 'event.stopPropagation()',
|
'onmousedown' => 'event.stopPropagation()',
|
||||||
'ontouchstart' => 'event.stopPropagation()'
|
'ontouchstart' => 'event.stopPropagation()'
|
||||||
@@ -244,7 +247,8 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
|||||||
|
|
||||||
$slideUrl = $mainConfig->get( 'ExtensionAssetsPath' ) . '/GlModelViewer/resources/hs_slideshow.svg';
|
$slideUrl = $mainConfig->get( 'ExtensionAssetsPath' ) . '/GlModelViewer/resources/hs_slideshow.svg';
|
||||||
$attrMenuButtonSlides = array (
|
$attrMenuButtonSlides = array (
|
||||||
'class' => 'glmv-menu-button disable-on-hide',
|
'class' => 'glmv-menu-button disable-on-hide disable-on-none',
|
||||||
|
'disabled' => !$annotsDrawn,
|
||||||
'onclick' => 'event.target.toggleAttribute("toggled"); slideshowAnnotations(event.target.closest(".glmv-container").querySelector("model-viewer"))',
|
'onclick' => 'event.target.toggleAttribute("toggled"); slideshowAnnotations(event.target.closest(".glmv-container").querySelector("model-viewer"))',
|
||||||
'onmousedown' => 'event.stopPropagation()',
|
'onmousedown' => 'event.stopPropagation()',
|
||||||
'ontouchstart' => 'event.stopPropagation()'
|
'ontouchstart' => 'event.stopPropagation()'
|
||||||
@@ -252,7 +256,8 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
|||||||
|
|
||||||
$hideUrl = $mainConfig->get( 'ExtensionAssetsPath' ) . '/GlModelViewer/resources/hs_hide.svg';
|
$hideUrl = $mainConfig->get( 'ExtensionAssetsPath' ) . '/GlModelViewer/resources/hs_hide.svg';
|
||||||
$attrMenuButtonHide = array (
|
$attrMenuButtonHide = array (
|
||||||
'class' => 'glmv-menu-button',
|
'class' => 'glmv-menu-button disable-on-none',
|
||||||
|
'disabled' => !$annotsDrawn,
|
||||||
'onclick' => 'event.target.toggleAttribute("toggled"); toggleAnnotations(event.target.closest(".glmv-container").querySelector("model-viewer"))',
|
'onclick' => 'event.target.toggleAttribute("toggled"); toggleAnnotations(event.target.closest(".glmv-container").querySelector("model-viewer"))',
|
||||||
'onmousedown' => 'event.stopPropagation()',
|
'onmousedown' => 'event.stopPropagation()',
|
||||||
'ontouchstart' => 'event.stopPropagation()'
|
'ontouchstart' => 'event.stopPropagation()'
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ extractMvconfig = function() {
|
|||||||
if (mvconfig.annotations === undefined) {
|
if (mvconfig.annotations === undefined) {
|
||||||
mvconfig.annotations = {}
|
mvconfig.annotations = {}
|
||||||
}
|
}
|
||||||
|
const mView = $('model-viewer')[0]
|
||||||
|
const hsButtons = [...mView.parentElement.querySelectorAll('.disable-on-none')]
|
||||||
|
hsButtons.forEach( mb => {
|
||||||
|
mb.toggleAttribute('disabled',$.isEmptyObject(mvconfig.annotations))
|
||||||
|
})
|
||||||
|
|
||||||
if (mvconfig.annotationSets === undefined) {
|
if (mvconfig.annotationSets === undefined) {
|
||||||
mvconfig.annotationSets = {}
|
mvconfig.annotationSets = {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user