use amendments to render throbber/grayscale
This commit is contained in:
@@ -62,6 +62,11 @@ function DrawImg()
|
|||||||
if( im.width == 0 )
|
if( im.width == 0 )
|
||||||
return
|
return
|
||||||
|
|
||||||
|
// find any matching ammendment
|
||||||
|
am=document.amendments.filter(obj => obj.eid === document.viewing.id)
|
||||||
|
if( am.length )
|
||||||
|
am=am[0]
|
||||||
|
|
||||||
canvas.width=NewWidth(im)
|
canvas.width=NewWidth(im)
|
||||||
canvas.height=NewHeight(im)
|
canvas.height=NewHeight(im)
|
||||||
|
|
||||||
@@ -69,14 +74,29 @@ function DrawImg()
|
|||||||
$('#img-cap').width(canvas.width)
|
$('#img-cap').width(canvas.width)
|
||||||
|
|
||||||
// actually draw the pixel images to the canvas at the right size
|
// actually draw the pixel images to the canvas at the right size
|
||||||
if( grayscale )
|
if (!Array.isArray(am))
|
||||||
context.filter='grayscale(1)'
|
context.filter='grayscale(1)'
|
||||||
context.drawImage(im, 0, 0, canvas.width, canvas.height )
|
context.drawImage(im, 0, 0, canvas.width, canvas.height )
|
||||||
// -50 is a straight up hack, no idea why this works, but its good enough for me
|
// -50 is a straight up hack, no idea why this works, but its good enough for me
|
||||||
if( throbber )
|
if (!Array.isArray(am))
|
||||||
$('#throbber').attr('style', 'display:show; position:absolute; left:'+canvas.width/2+'px; top:'+(canvas.height/2-50)+'px' )
|
{
|
||||||
|
const style = 'position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);';
|
||||||
|
$('#throbber').attr('style', style + ' height: 96px;');
|
||||||
|
$('#white-circle').attr('style', style + ' height: 72px;');
|
||||||
|
if(am.type.which == 'img' )
|
||||||
|
$('#inside-img').attr('style', style + ' height: 64px;').attr('src', '/internal/'+am.type.what );
|
||||||
else
|
else
|
||||||
$('#throbber').hide();
|
{
|
||||||
|
$('#inside-icon').attr('style', `${style} color:${am.type.colour}; height: 64px;`)
|
||||||
|
$('#inside-icon').attr('fill', am.type.colour )
|
||||||
|
$('#inside-icon use').attr('xlink:href', `/internal/icons.svg#${am.type.what}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$('#throbber').hide()
|
||||||
|
$('#white-circle').hide()
|
||||||
|
$('#inside-img').hide()
|
||||||
|
$('#inside-icon').hide()
|
||||||
|
}
|
||||||
|
|
||||||
// show (or not) the whole figcaption with fname in it - based on state of fname_toggle
|
// show (or not) the whole figcaption with fname in it - based on state of fname_toggle
|
||||||
if( $('#fname_toggle').prop('checked' ) )
|
if( $('#fname_toggle').prop('checked' ) )
|
||||||
@@ -678,12 +698,10 @@ function addViewerKeyHandler() {
|
|||||||
{
|
{
|
||||||
case "Left": // IE/Edge specific value
|
case "Left": // IE/Edge specific value
|
||||||
case "ArrowLeft":
|
case "ArrowLeft":
|
||||||
if( $('#la').prop('disabled') == false )
|
|
||||||
$('#la').click()
|
$('#la').click()
|
||||||
break;
|
break;
|
||||||
case "Right": // IE/Edge specific value
|
case "Right": // IE/Edge specific value
|
||||||
case "ArrowRight":
|
case "ArrowRight":
|
||||||
if( $('#ra').prop('disabled') == false )
|
|
||||||
$('#ra').click()
|
$('#ra').click()
|
||||||
break;
|
break;
|
||||||
case "d":
|
case "d":
|
||||||
@@ -724,7 +742,6 @@ function nextImageInViewer()
|
|||||||
getNextEntry()
|
getNextEntry()
|
||||||
setDisabledForViewingNextPrevBttons()
|
setDisabledForViewingNextPrevBttons()
|
||||||
ViewImageOrVideo()
|
ViewImageOrVideo()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// wrapper func to start the viewer - needed as we have a dbl-click & View file
|
// wrapper func to start the viewer - needed as we have a dbl-click & View file
|
||||||
|
|||||||
Reference in New Issue
Block a user