Use ooui for edit action buttons (#32)

This PR converts the original basic preview edit actions buttons to MediaWiki's ooui to better match the style of the edit page.

Reviewed-on: #32
This commit is contained in:
2024-11-08 15:27:14 +00:00
parent 109cc08b90
commit 5a2f8819e3
4 changed files with 91 additions and 39 deletions

View File

@@ -44,11 +44,15 @@ class GlModelHooks {
public static function onBeforePageDisplay($out) {
preg_match('/(<model-viewer src="\S*?\.(glb|gltf"))/',$out->getHTML(),$findGltf);
if ($findGltf[0]) {
$mvScriptAttr = array(
'src' => 'https://ajax.googleapis.com/ajax/libs/model-viewer/3.5.0/model-viewer.min.js',
'type' => 'module'
$out->addHeadItems(
Html::rawElement(
'script',
array(
'src' => 'https://ajax.googleapis.com/ajax/libs/model-viewer/3.5.0/model-viewer.min.js',
'type' => 'module'
)
)
);
$out->addHeadItems(Html::rawElement('script',$mvScriptAttr));
$out->addModules('ext.glmv');
}
}
@@ -72,45 +76,12 @@ class GlModelHooks {
}
$out = $editor->getContext()->getOutput();
$out->addModules('ext.glmv');
$out->addModules('ext.glmv.prev');
$mvTransform = $file->transform([ 'width' => '800', 'hight' => '600', 'view' => 'test']);
$previewViewer = $mvTransform->toHtml([ 'preview' => true]);
$addButtonAttr = array(
'class' => 'preview-button AddHotspot',
'onclick' => 'readyAddHotspot()'
);
$readButtonAttr = array(
'class' => 'preview-button ReadHotspots',
'onclick' => 'readMetadata()'
);
$delButtonAttr = array(
'class' => 'preview-button DeleteHotspots',
'onclick' => 'readyDelHotspot()'
);
$dldButtonAttr = array(
'class' => 'preview-button MakeImage',
'onclick' => 'downloadImage("' . $title . '")'
);
$orbButtonAttr = array(
'class' => 'preview-button SetOrbit',
'onclick' => 'writeCameraOrbit()'
);
$addHsButton = array(
Html::rawElement('button',$addButtonAttr,'Add a new hotspot'),
Html::rawElement('button',$readButtonAttr,'Update hotspots'),
Html::rawElement('button',$delButtonAttr,'Delete hotspot'),
Html::rawElement('button',$dldButtonAttr,'Download image'),
Html::rawElement('button',$orbButtonAttr,'Set start view')
);
$previewHTML = Html::rawElement('div',NULL,$previewViewer.implode($addHsButton));
$previewHTML = Html::rawElement('div',NULL,$previewViewer);
return false;
}