diff options
Diffstat (limited to 'public/gallery.js')
-rw-r--r-- | public/gallery.js | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/public/gallery.js b/public/gallery.js index 19d63bb..ca1e511 100644 --- a/public/gallery.js +++ b/public/gallery.js @@ -8,6 +8,8 @@ function call(method, params) { }) } +const loading = (window.location.hostname !== 'localhost') ? 'lazy' : undefined + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - let BrowseModel = { @@ -85,18 +87,13 @@ let BrowseView = { oncreate(vnode) { vnode.dom.focus() }, view(vnode) { - const loading = undefined - if (window.location.hostname !== 'localhost') - loading = 'lazy' - 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', {src: `/thumb/${e.sha1}`, - width: e.thumbW, height: e.thumbH, title: e.name, - loading})) + m('img.thumbnail', {src: `/thumb/${e.sha1}`, + width: e.thumbW, height: e.thumbH, title: e.name, loading})) })) }, } @@ -244,8 +241,8 @@ let SimilarThumbnail = { view(vnode) { const info = vnode.attrs.info return m(m.route.Link, {href: `/view/${info.sha1}`}, - m('img', {src: `/thumb/${info.sha1}`, - width: info.thumbW, height: info.thumbH})) + m('img.thumbnail', {src: `/thumb/${info.sha1}`, + width: info.thumbW, height: info.thumbH, loading})) }, } @@ -324,22 +321,24 @@ let DuplicatesThumbnail = { const info = vnode.attrs.info return [ m(m.route.Link, {href: `/similar/${info.sha1}`}, - m('img', {src: `/thumb/${info.sha1}`, - width: info.thumbW, height: info.thumbH})), - info.occurences, + m('img.thumbnail', {src: `/thumb/${info.sha1}`, + width: info.thumbW, height: info.thumbH, loading})), + (info.occurences != 1) ? ` ×${info.occurences}` : [], ] }, } let DuplicatesList = { - view(vnode) { - if (DuplicatesModel.entries.length == 0) - return "No duplicates" + // See BrowseView. + oncreate(vnode) { vnode.dom.focus() }, - return m('.duplicates', {}, DuplicatesModel.entries.map(group => - m('.row', group.map(entry => - m(DuplicatesThumbnail, {info: entry}))), - )) + view(vnode) { + let children = (DuplicatesModel.entries.length == 0) + ? "No duplicates" + : DuplicatesModel.entries.map(group => + m('.row', group.map(entry => + m(DuplicatesThumbnail, {info: entry})))) + return m('.duplicates[tabindex=0]', {}, children) }, } |