aboutsummaryrefslogtreecommitdiff
path: root/public/gallery.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/gallery.js')
-rw-r--r--public/gallery.js30
1 files changed, 18 insertions, 12 deletions
diff --git a/public/gallery.js b/public/gallery.js
index c7d21a1..5df58e6 100644
--- a/public/gallery.js
+++ b/public/gallery.js
@@ -64,6 +64,17 @@ let Header = {
},
}
+let Thumbnail = {
+ view(vnode) {
+ const e = vnode.attrs.info
+ if (!e.thumbW || !e.thumbH)
+ return m('.thumbnail.missing', {...vnode.attrs, info: null})
+ return m('img.thumbnail', {...vnode.attrs, info: null,
+ src: `/thumb/${e.sha1}`, width: e.thumbW, height: e.thumbH,
+ loading})
+ },
+}
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
let BrowseModel = {
@@ -144,10 +155,9 @@ let BrowseView = {
return m('.browser[tabindex=0]', {
// Trying to force the oncreate on path changes.
key: BrowseModel.path,
- }, BrowseModel.entries.map(e => {
- return m(m.route.Link, {href: `/view/${e.sha1}`},
- m('img.thumbnail', {src: `/thumb/${e.sha1}`,
- width: e.thumbW, height: e.thumbH, title: e.name, loading}))
+ }, BrowseModel.entries.map(info => {
+ return m(m.route.Link, {href: `/view/${info.sha1}`},
+ m(Thumbnail, {info, title: info.name}))
}))
},
}
@@ -289,8 +299,7 @@ let SimilarThumbnail = {
view(vnode) {
const info = vnode.attrs.info
return m(m.route.Link, {href: `/view/${info.sha1}`},
- m('img.thumbnail', {src: `/thumb/${info.sha1}`,
- width: info.thumbW, height: info.thumbH, loading}))
+ m(Thumbnail, {info}))
},
}
@@ -363,8 +372,7 @@ let DuplicatesThumbnail = {
const info = vnode.attrs.info
return [
m(m.route.Link, {href: `/similar/${info.sha1}`},
- m('img.thumbnail', {src: `/thumb/${info.sha1}`,
- width: info.thumbW, height: info.thumbH, loading})),
+ m(Thumbnail, {info})),
(info.occurences != 1) ? ` ×${info.occurences}` : [],
]
},
@@ -416,8 +424,7 @@ let OrphansReplacement = {
return [
` → `,
m(m.route.Link, {href: `/view/${info.sha1}`},
- m('img.thumbnail', {src: `/thumb/${info.sha1}`,
- width: info.thumbW, height: info.thumbH, loading})),
+ m(Thumbnail, {info})),
`${info.tags} tags`,
]
},
@@ -429,8 +436,7 @@ let OrphansRow = {
return m('.row', [
// It might not load, but still allow tag viewing.
m(m.route.Link, {href: `/view/${info.sha1}`},
- m('img.thumbnail', {src: `/thumb/${info.sha1}`,
- width: info.thumbW, height: info.thumbH, loading})),
+ m(Thumbnail, {info})),
`${info.tags} tags`,
m(OrphansReplacement, {info: info.replacement}),
])