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

68
modules/glmv-prev.js Normal file
View File

@@ -0,0 +1,68 @@
const addHS = new OO.ui.ButtonWidget({
icon: 'mapPinAdd',
label: 'Add annotation',
invisibleLabel: true,
class: 'edit-button'
})
addHS.on('click', readyAddHotspot)
addHS.setDisabled(true)
console.log(addHS)
const updateHS = new OO.ui.ButtonWidget({
icon: 'reload',
label: 'Update annotations',
invisibleLabel: true
})
updateHS.on('click', readMetadata)
updateHS.setDisabled(true)
const deleteHS = new OO.ui.ButtonWidget({
icon: 'cancel',
label: 'Delete annotation',
invisibleLabel: true
})
deleteHS.on('click', readyDelHotspot)
deleteHS.setDisabled(true)
const hotspotButtons = new OO.ui.ButtonGroupWidget( {
items: [ addHS, updateHS, deleteHS ]
} );
console.log(hotspotButtons)
const downloadViewerImage = new OO.ui.ButtonWidget({
icon: 'imageAdd',
label: 'Download current image',
invisibleLabel: true
})
downloadViewerImage.on('click', () => {
downloadImage("TempTitle.glb")
})
downloadViewerImage.setDisabled(true)
const setView = new OO.ui.ButtonWidget({
icon: 'camera',
label: 'Set Initial View',
invisibleLabel: true
})
setView.on('click', writeCameraOrbit)
setView.setDisabled(true)
const cameraButtons = new OO.ui.ButtonGroupWidget( {
items: [ downloadViewerImage, setView ]
} );
const modelMenu = new OO.ui.HorizontalLayout( {
items: [
hotspotButtons,
cameraButtons
],
id: 'edit-model-menu'
});
$('#wikiPreview').after(modelMenu.$element);
enableMenu = function() {
modelMenu.items.forEach(group => {
group.items.forEach(el => el.setDisabled(false))
});
}

View File

@@ -8,6 +8,7 @@ let deleteHotspot = null
*/
modelLoaded = function() {
$('.awaiting-model').css('display', 'flex').removeClass('awaiting-model')
enableMenu()
}
/**