blackhydrogen / noop-sewi

Sana Encounter Web Interface (SEWI)
0 stars 1 forks source link

RESOURCE_GALLERY_* constants should reference sewi.staticPath #137

Closed blackhydrogen closed 9 years ago

blackhydrogen commented 9 years ago

Found them by chance. The two constants are: RESOURCE_GALLERY_DEFAULT_THUMBNAIL RESOURCE_GALLERY_RESOURCE_THUMBNAIL_DOM

blackhydrogen commented 9 years ago

I did something like that. Not 100% sure if this is the way to go though. @TheFuzzy can confirm if we should do the below format or use hard-coded paths.

'<img src="' + sewi.staticPath +'images/image_tooltip_grayscale.png">'

TheFuzzy commented 9 years ago

Alternatively, do something like the following:

RESOURCE_GALLERY_RESOURCE_THUMBNAIL_CONTAINER_DOM: '<div class="resource-thumbnail-container"></div>',
RESOURCE_GALLERY_RESOURCE_THUMBNAIL_DOM: '<div class="resource-thumbnail-container"><img class="resource-thumbnail"></div>',
RESOURCE_GALLERY_LOADING_THUMBNAIL: 'images/loading.gif',
RESOURCE_GALLERY_DEFAULT_THUMBNAIL: 'images/default_thumbnail.png',

Then later in code you could do something like:

var loadingThumbnailPath = sewi.staticPath + sewi.constants.RESOURCE_GALLERY_LOADING_THUMBNAIL;
var defaultThumbnailPath = sewi.staticPath + sewi.constants.RESOURCE_GALLERY_DEFAULT_THUMBNAIL;
...
var thumbnailContainer = $(sewi.constants.RESOURCE_GALLERY_RESOURCE_THUMBNAIL_CONTAINER_DOM);
var thumbnail = $(sewi.constants.RESOURCE_GALLERY_RESOURCE_THUMBNAIL_DOM).attr('src', loadingThumbnailPath);
...
if (failedToLoad) {
    thumbnail.attr('src', defaultThumbnailPath);
}