2017-06-23 21:00:42 +00:00
|
|
|
<template>
|
2020-05-15 12:12:36 +00:00
|
|
|
<span :title="title" :class="['ui', {'tiny': discrete}, {'icon': !discrete}, {'buttons': !dropdownOnly && !iconOnly}, 'play-button component-play-button']">
|
2018-03-05 20:51:40 +00:00
|
|
|
<button
|
2018-07-17 11:09:13 +00:00
|
|
|
v-if="!dropdownOnly"
|
2020-07-18 14:50:40 +00:00
|
|
|
@click.stop.prevent="replacePlay"
|
2018-05-10 15:52:13 +00:00
|
|
|
:disabled="!playable"
|
2020-08-01 09:11:51 +00:00
|
|
|
:aria-label="labels.replacePlay"
|
2018-07-17 11:09:13 +00:00
|
|
|
:class="buttonClasses.concat(['ui', {loading: isLoading}, {'mini': discrete}, {disabled: !playable}])">
|
2021-10-21 17:26:18 +00:00
|
|
|
<i v-if="playing" class="pause icon"></i>
|
|
|
|
<i v-else :class="[playIconClass, 'icon']"></i>
|
2020-03-26 15:18:37 +00:00
|
|
|
<template v-if="!discrete && !iconOnly"> <slot><translate translate-context="*/Queue/Button.Label/Short, Verb">Play</translate></slot></template>
|
2017-06-23 21:00:42 +00:00
|
|
|
</button>
|
2020-08-04 11:22:31 +00:00
|
|
|
<button
|
2019-12-26 10:38:26 +00:00
|
|
|
v-if="!discrete && !iconOnly"
|
2021-02-24 08:03:14 +00:00
|
|
|
@click.stop.prevent="clicked = true"
|
2019-12-26 10:38:26 +00:00
|
|
|
:class="['ui', {disabled: !playable && !filterableArtist}, 'floating', 'dropdown', {'icon': !dropdownOnly}, {'button': !dropdownOnly}]">
|
2019-02-14 09:49:06 +00:00
|
|
|
<i :class="dropdownIconClasses.concat(['icon'])" :title="title" ></i>
|
2019-12-26 10:38:26 +00:00
|
|
|
<div class="menu" v-if="clicked">
|
2019-02-05 16:59:22 +00:00
|
|
|
<button class="item basic" ref="add" data-ref="add" :disabled="!playable" @click.stop.prevent="add" :title="labels.addToQueue">
|
2019-03-08 11:37:02 +00:00
|
|
|
<i class="plus icon"></i><translate translate-context="*/Queue/Dropdown/Button/Label/Short">Add to queue</translate>
|
2019-02-05 16:59:22 +00:00
|
|
|
</button>
|
|
|
|
<button class="item basic" ref="addNext" data-ref="addNext" :disabled="!playable" @click.stop.prevent="addNext()" :title="labels.playNext">
|
2019-03-18 09:07:58 +00:00
|
|
|
<i class="step forward icon"></i>{{ labels.playNext }}
|
2019-02-05 16:59:22 +00:00
|
|
|
</button>
|
|
|
|
<button class="item basic" ref="playNow" data-ref="playNow" :disabled="!playable" @click.stop.prevent="addNext(true)" :title="labels.playNow">
|
2019-07-05 07:47:37 +00:00
|
|
|
<i class="play icon"></i>{{ labels.playNow }}
|
|
|
|
</button>
|
2019-02-05 16:59:22 +00:00
|
|
|
<button v-if="track" class="item basic" :disabled="!playable" @click.stop.prevent="$store.dispatch('radios/start', {type: 'similar', objectId: track.id})" :title="labels.startRadio">
|
2021-04-10 14:08:35 +00:00
|
|
|
<i class="feed icon"></i><translate translate-context="*/Queue/Button.Label/Short, Verb">Play radio</translate>
|
2019-02-05 16:59:22 +00:00
|
|
|
</button>
|
2021-10-21 17:26:18 +00:00
|
|
|
<button v-if="track" class="item basic" :disabled="!playable" @click.stop="$store.commit('playlists/chooseTrack', track)">
|
|
|
|
<i class="list icon"></i>
|
|
|
|
<translate translate-context="Sidebar/Player/Icon.Tooltip/Verb">Add to playlist…</translate>
|
|
|
|
</button>
|
2021-02-24 08:03:14 +00:00
|
|
|
<button v-if="track" class="item basic" @click.stop.prevent="$router.push(`/library/tracks/${track.id}/`)">
|
2021-10-21 17:26:18 +00:00
|
|
|
<i class="info icon"></i>
|
|
|
|
<translate v-if="track.artist.content_category === 'podcast'" translate-context="*/Queue/Dropdown/Button/Label/Short">Episode details</translate>
|
|
|
|
<translate v-else translate-context="*/Queue/Dropdown/Button/Label/Short">Track details</translate>
|
2021-02-24 08:03:14 +00:00
|
|
|
</button>
|
2019-09-09 09:10:25 +00:00
|
|
|
<div class="divider"></div>
|
2020-08-04 11:22:31 +00:00
|
|
|
<button v-if="filterableArtist" ref="filterArtist" data-ref="filterArtist" class="item basic" :disabled="!filterableArtist" @click.stop.prevent="filterArtist" :title="labels.hideArtist">
|
2019-03-08 11:37:02 +00:00
|
|
|
<i class="eye slash outline icon"></i><translate translate-context="*/Queue/Dropdown/Button/Label/Short">Hide content from this artist</translate>
|
2019-02-14 09:49:06 +00:00
|
|
|
</button>
|
2019-09-09 09:10:25 +00:00
|
|
|
<button
|
2020-03-31 08:45:41 +00:00
|
|
|
v-for="obj in getReportableObjs({track, album, artist, playlist, account, channel})"
|
2019-09-09 09:10:25 +00:00
|
|
|
:key="obj.target.type + obj.target.id"
|
|
|
|
class="item basic"
|
2021-02-24 08:03:14 +00:00
|
|
|
:ref="`report${obj.target.type}${obj.target.id}`" :data-ref="`report${obj.target.type}${obj.target.id}`"
|
2019-09-09 09:10:25 +00:00
|
|
|
@click.stop.prevent="$store.dispatch('moderation/report', obj.target)">
|
|
|
|
<i class="share icon" /> {{ obj.label }}
|
|
|
|
</button>
|
2017-06-23 21:00:42 +00:00
|
|
|
</div>
|
2020-08-04 11:22:31 +00:00
|
|
|
</button>
|
2018-07-17 11:09:13 +00:00
|
|
|
</span>
|
2017-06-23 21:00:42 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-03-21 10:58:26 +00:00
|
|
|
import axios from 'axios'
|
2017-06-23 21:00:42 +00:00
|
|
|
import jQuery from 'jquery'
|
|
|
|
|
2019-09-09 09:10:25 +00:00
|
|
|
import ReportMixin from '@/components/mixins/Report'
|
2021-10-21 17:26:18 +00:00
|
|
|
import PlayOptionsMixin from '@/components/mixins/PlayOptions'
|
2019-09-09 09:10:25 +00:00
|
|
|
|
2017-06-23 21:00:42 +00:00
|
|
|
export default {
|
2021-10-21 17:26:18 +00:00
|
|
|
mixins: [ReportMixin, PlayOptionsMixin],
|
2017-06-23 21:00:42 +00:00
|
|
|
props: {
|
|
|
|
// we can either have a single or multiple tracks to play when clicked
|
|
|
|
tracks: {type: Array, required: false},
|
|
|
|
track: {type: Object, required: false},
|
2019-09-09 09:10:25 +00:00
|
|
|
account: {type: Object, required: false},
|
2018-07-17 11:09:13 +00:00
|
|
|
dropdownIconClasses: {type: Array, required: false, default: () => { return ['dropdown'] }},
|
|
|
|
playIconClass: {type: String, required: false, default: 'play icon'},
|
|
|
|
buttonClasses: {type: Array, required: false, default: () => { return ['button'] }},
|
2018-03-21 10:58:26 +00:00
|
|
|
playlist: {type: Object, required: false},
|
2018-05-22 20:22:53 +00:00
|
|
|
discrete: {type: Boolean, default: false},
|
2018-07-17 11:09:13 +00:00
|
|
|
dropdownOnly: {type: Boolean, default: false},
|
|
|
|
iconOnly: {type: Boolean, default: false},
|
2019-02-14 09:49:06 +00:00
|
|
|
artist: {type: Object, required: false},
|
|
|
|
album: {type: Object, required: false},
|
2020-03-04 21:18:28 +00:00
|
|
|
library: {type: Object, required: false},
|
2020-03-31 08:45:41 +00:00
|
|
|
channel: {type: Object, required: false},
|
2021-10-21 17:26:18 +00:00
|
|
|
isPlayable: {type: Boolean, required: false, default: null},
|
|
|
|
playing: {type: Boolean, required: false, default: false},
|
|
|
|
paused: {type: Boolean, required: false, default: false}
|
2017-06-23 21:00:42 +00:00
|
|
|
},
|
2018-03-05 20:51:40 +00:00
|
|
|
data () {
|
|
|
|
return {
|
2019-02-14 09:49:06 +00:00
|
|
|
isLoading: false,
|
2019-12-26 10:38:26 +00:00
|
|
|
clicked: false
|
2018-03-05 20:51:40 +00:00
|
|
|
}
|
|
|
|
},
|
2018-02-19 19:14:39 +00:00
|
|
|
computed: {
|
2018-07-01 19:50:50 +00:00
|
|
|
labels () {
|
2020-08-04 09:27:06 +00:00
|
|
|
let replacePlay
|
|
|
|
if (this.track) {
|
|
|
|
replacePlay = this.$pgettext('*/Queue/Dropdown/Button/Title', 'Play track')
|
|
|
|
} else if (this.album) {
|
|
|
|
replacePlay = this.$pgettext('*/Queue/Dropdown/Button/Title', 'Play album')
|
|
|
|
} else if (this.artist) {
|
|
|
|
replacePlay = this.$pgettext('*/Queue/Dropdown/Button/Title', 'Play artist')
|
|
|
|
} else if (this.playlist) {
|
|
|
|
replacePlay = this.$pgettext('*/Queue/Dropdown/Button/Title', 'Play playlist')
|
|
|
|
} else {
|
|
|
|
replacePlay = this.$pgettext('*/Queue/Dropdown/Button/Title', 'Play tracks')
|
|
|
|
}
|
2021-02-24 08:03:14 +00:00
|
|
|
|
2018-07-01 19:50:50 +00:00
|
|
|
return {
|
2019-02-05 16:59:22 +00:00
|
|
|
playNow: this.$pgettext('*/Queue/Dropdown/Button/Title', 'Play now'),
|
|
|
|
addToQueue: this.$pgettext('*/Queue/Dropdown/Button/Title', 'Add to current queue'),
|
|
|
|
playNext: this.$pgettext('*/Queue/Dropdown/Button/Title', 'Play next'),
|
2019-07-05 07:47:37 +00:00
|
|
|
startRadio: this.$pgettext('*/Queue/Dropdown/Button/Title', 'Play similar songs'),
|
2019-09-09 09:10:25 +00:00
|
|
|
report: this.$pgettext('*/Moderation/*/Button/Label,Verb', 'Report…'),
|
2021-10-21 17:26:18 +00:00
|
|
|
addToPlaylist: this.$pgettext('Sidebar/Player/Icon.Tooltip/Verb', 'Add to playlist…'),
|
2020-08-04 09:27:06 +00:00
|
|
|
replacePlay,
|
2018-07-01 19:50:50 +00:00
|
|
|
}
|
|
|
|
},
|
2018-05-10 15:52:13 +00:00
|
|
|
title () {
|
|
|
|
if (this.playable) {
|
2019-10-01 13:19:55 +00:00
|
|
|
return this.$pgettext('*/*/Button.Label/Noun', 'More…')
|
2018-05-10 15:52:13 +00:00
|
|
|
} else {
|
|
|
|
if (this.track) {
|
2019-02-05 16:59:22 +00:00
|
|
|
return this.$pgettext('*/Queue/Button/Title', 'This track is not available in any library you have access to')
|
2018-05-10 15:52:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-12-26 10:38:26 +00:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
clicked () {
|
|
|
|
let self = this
|
|
|
|
this.$nextTick(() => {
|
|
|
|
jQuery(this.$el).find('.ui.dropdown').dropdown({
|
|
|
|
selectOnKeydown: false,
|
|
|
|
action: function (text, value, $el) {
|
2020-08-04 11:22:31 +00:00
|
|
|
// used to ensure focusing the dropdown and clicking via keyboard
|
2019-12-26 10:38:26 +00:00
|
|
|
// works as expected
|
2020-08-04 11:22:31 +00:00
|
|
|
let button = self.$refs[$el.data('ref')]
|
|
|
|
if (Array.isArray(button)) {
|
|
|
|
button[0].click()
|
|
|
|
} else {
|
|
|
|
button.click()
|
|
|
|
}
|
2019-12-26 10:38:26 +00:00
|
|
|
jQuery(self.$el).find('.ui.dropdown').dropdown('hide')
|
2020-02-23 14:31:03 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
jQuery(this.$el).find('.ui.dropdown').dropdown('show', function () {
|
|
|
|
// little magic to ensure the menu is always visible in the viewport
|
|
|
|
// By default, try to diplay it on the right if there is enough room
|
|
|
|
let menu = jQuery(self.$el).find('.ui.dropdown').find(".menu")
|
|
|
|
let viewportOffset = menu.get(0).getBoundingClientRect();
|
|
|
|
let left = viewportOffset.left;
|
|
|
|
let viewportWidth = document.documentElement.clientWidth
|
|
|
|
let rightOverflow = viewportOffset.right - viewportWidth
|
|
|
|
let leftOverflow = -viewportOffset.left
|
|
|
|
let offset = 0
|
|
|
|
if (rightOverflow > 0) {
|
|
|
|
offset = -rightOverflow - 5
|
|
|
|
menu.css({cssText: `left: ${offset}px !important;`});
|
|
|
|
}
|
|
|
|
else if (leftOverflow > 0) {
|
|
|
|
offset = leftOverflow + 5
|
|
|
|
menu.css({cssText: `right: -${offset}px !important;`});
|
2019-12-26 10:38:26 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
2017-06-23 21:00:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|