jellyfish-web/dashboard-ui/bower_components/emby-webcomponents/itemcontextmenu.js

1 line
11 KiB
JavaScript
Raw Normal View History

2018-09-12 19:26:21 +02:00
define(["apphost","globalize","connectionManager","itemHelper","appRouter","playbackManager","loading","appSettings","browser","actionsheet"],function(appHost,globalize,connectionManager,itemHelper,appRouter,playbackManager,loading,appSettings,browser,actionsheet){"use strict";function getCommands(options){var item=options.item,canPlay=playbackManager.canPlay(item),commands=[],user=options.user,restrictOptions=(browser.operaTv||browser.web0s)&&!user.Policy.IsAdministrator;canPlay&&"Photo"!==item.MediaType&&(!1!==options.play&&commands.push({name:globalize.translate("sharedcomponents#Play"),id:"resume"}),options.playAllFromHere&&"Program"!==item.Type&&"TvChannel"!==item.Type&&commands.push({name:globalize.translate("sharedcomponents#PlayAllFromHere"),id:"playallfromhere"})),playbackManager.canQueue(item)&&(!1!==options.queue&&commands.push({name:globalize.translate("sharedcomponents#AddToPlayQueue"),id:"queue"}),!1!==options.queue&&commands.push({name:globalize.translate("sharedcomponents#PlayNext"),id:"queuenext"})),(item.IsFolder||"MusicArtist"===item.Type||"MusicGenre"===item.Type)&&"livetv"!==item.CollectionType&&!1!==options.shuffle&&commands.push({name:globalize.translate("sharedcomponents#Shuffle"),id:"shuffle"}),"Audio"!==item.MediaType&&"MusicAlbum"!==item.Type&&"MusicArtist"!==item.Type&&"MusicGenre"!==item.Type||!1===options.instantMix||itemHelper.isLocalItem(item)||commands.push({name:globalize.translate("sharedcomponents#InstantMix"),id:"instantmix"}),commands.length&&commands.push({divider:!0}),restrictOptions||(itemHelper.supportsAddingToCollection(item)&&commands.push({name:globalize.translate("sharedcomponents#AddToCollection"),id:"addtocollection"}),itemHelper.supportsAddingToPlaylist(item)&&commands.push({name:globalize.translate("sharedcomponents#AddToPlaylist"),id:"addtoplaylist"})),"Timer"===item.Type&&user.Policy.EnableLiveTvManagement&&!1!==options.cancelTimer&&commands.push({name:globalize.translate("sharedcomponents#CancelRecording"),id:"canceltimer"}),"Recording"===item.Type&&"InProgress"===item.Status&&user.Policy.EnableLiveTvManagement&&!1!==options.cancelTimer&&commands.push({name:globalize.translate("sharedcomponents#CancelRecording"),id:"canceltimer"}),"SeriesTimer"===item.Type&&user.Policy.EnableLiveTvManagement&&!1!==options.cancelTimer&&commands.push({name:globalize.translate("sharedcomponents#CancelSeries"),id:"cancelseriestimer"}),itemHelper.canConvert(item,user,connectionManager.getApiClient(item))&&commands.push({name:globalize.translate("sharedcomponents#Convert"),id:"convert"}),item.CanDelete&&!1!==options.deleteItem&&("Playlist"===item.Type||"BoxSet"===item.Type?commands.push({name:globalize.translate("sharedcomponents#Delete"),id:"delete"}):commands.push({name:globalize.translate("sharedcomponents#DeleteMedia"),id:"delete"})),item.CanDownload&&appHost.supports("filedownload")&&commands.push({name:globalize.translate("sharedcomponents#Download"),id:"download"}),appHost.supports("sync")&&!1!==options.syncLocal&&itemHelper.canSync(user,item)&&commands.push({name:globalize.translate("sharedcomponents#Download"),id:"synclocal"});var canEdit=itemHelper.canEdit(user,item);if(canEdit&&!1!==options.edit&&"SeriesTimer"!==item.Type){var text="Timer"===item.Type||"SeriesTimer"===item.Type?globalize.translate("sharedcomponents#Edit"):globalize.translate("sharedcomponents#EditMetadata");commands.push({name:text,id:"edit"})}return itemHelper.canEditImages(user,item)&&!1!==options.editImages&&commands.push({name:globalize.translate("sharedcomponents#EditImages"),id:"editimages"}),canEdit&&("Video"!==item.MediaType||"TvChannel"===item.Type||"Program"===item.Type||"Virtual"===item.LocationType||"Recording"===item.Type&&"Completed"!==item.Status||!1!==options.editSubtitles&&commands.push({name:globalize.translate("sharedcomponents#EditSubtitles"),id:"editsubtitles"})),!1!==options.identify&&itemHelper.canIdentify(user,item)&&commands.push({name:globalize.translate("sharedcomponents#Identify"),id:"identify"}),"Program"===item.Type&&!1!==options.record&&item.TimerId&&commands.push({name:Globalize.tr