From 2da195f925df0272f27158a7a66bce7e3486915f Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Sun, 31 Jul 2016 16:03:08 +0200 Subject: [PATCH] Use disabled functionality of basicContext --- src/scripts/contextMenu.js | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/scripts/contextMenu.js b/src/scripts/contextMenu.js index 66e09e1..54576f8 100644 --- a/src/scripts/contextMenu.js +++ b/src/scripts/contextMenu.js @@ -7,34 +7,27 @@ function buildAlbumList(albums, exclude, action, parent = 0, layer = 0) { let items = [] for (i in albums) { - if ((layer == 0 && !albums[i].parent) || albums[i].parent == parent) { + if ((layer==0 && !albums[i].parent) || albums[i].parent==parent) { + let album = albums[i] let thumb = 'src/images/no_cover.svg' - if (album.thumbs && album.thumbs[0]) - thumb = album.thumbs[0] - else if(album.thumbUrl) - thumb = album.thumbUrl + if (album.thumbs && album.thumbs[0]) thumb = album.thumbs[0] + else if (album.thumbUrl) thumb = album.thumbUrl + if (album.title==='') album.title = 'Untitled' let prefix = layer > 0 ? "  ".repeat(layer - 1) + "└ " : "" - let html = prefix + lychee.html`
$${ album.title }
` + let html = prefix + lychee.html`
$${ album.title }
` - if (exclude.indexOf(album.id) == -1) { - items.push({ - title: html, - fn: () => action(album) - }) - } - else { - html = "
" + html + "
" - items.push({ - title: html, - fn: () => {} - }) - } + items.push({ + title: html, + disabled: (exclude.indexOf(album.id)!==-1), + fn: () => action(album) + }) items = items.concat(buildAlbumList(albums, exclude, action, album.id, layer + 1)) + } }