KawAnime/pages/seasons.vue

374 lines
11 KiB
Vue
Raw Normal View History

2017-04-15 14:16:14 +00:00
<template xmlns:v-tooltip="http://www.w3.org/1999/xhtml">
2017-07-11 08:47:14 +00:00
<div style="min-height: 95vh">
2017-05-13 14:38:17 +00:00
<loader v-if="!season[1].items"></loader>
2017-04-15 14:16:14 +00:00
2017-07-11 08:47:14 +00:00
<v-container fluid v-else style="padding: 20px 0 0">
<v-layout row wrap justify-center class="form-container">
<v-flex sm3 xs8 class="season-container">
2017-05-13 14:38:17 +00:00
<v-select
2017-07-06 20:21:00 +00:00
v-bind:items="seasonChoices"
v-model="$store.state.season"
label="Season"
dark
item-text="name"
item-value="value"/>
2017-07-11 08:47:14 +00:00
</v-flex>
<v-flex offset-sm1 sm3 xs8 class="year-container">
2017-05-13 14:38:17 +00:00
<v-text-field name="input-year"
type="number" min="2010"
2017-05-13 14:38:17 +00:00
label="Year"
2017-07-03 20:32:05 +00:00
v-model="$store.state.year"
2017-05-13 14:38:17 +00:00
dark>
</v-text-field>
2017-07-11 08:47:14 +00:00
</v-flex>
<v-flex offset-sm1 sm2 xs8 class="refresh-button">
2017-07-19 07:50:10 +00:00
<v-btn secondary block dark @click="refreshSeason()">Refresh</v-btn>
2017-07-11 08:47:14 +00:00
</v-flex>
</v-layout>
2017-04-15 14:16:14 +00:00
2017-07-11 08:47:14 +00:00
<v-tabs id="tabs" dark fixed centered>
<v-tabs-bar slot="activators" class="mablue">
<v-tabs-slider class="primary"></v-tabs-slider>
<v-tabs-item v-for="i in 3"
:href="'#' + i"
:key="i">
{{ season[i].name }}
</v-tabs-item>
</v-tabs-bar>
<v-tabs-content v-for="i in 3"
lazy
2017-07-11 08:47:14 +00:00
v-bind:id="`${i}`"
:key="i">
<v-text-field class="query"
v-model="query"
label="Search entry" dark>
</v-text-field>
<v-layout row wrap class="elems">
<transition-group name="list">
<v-flex md6 xs12 v-for="item in computedSeason[i].items"
style="display: inline-block"
:key="item.key">
<v-layout row wrap class="elem elevation-3" v-ripple="true">
2017-05-13 14:38:17 +00:00
<!-- Header of elem -->
2017-07-11 08:47:14 +00:00
<v-flex xs12 v-tooltip:bottom="{ html: item.title }">
<h6 class="title ellipsis white--text">
2017-05-13 14:38:17 +00:00
{{ item.title }}
</h6>
2017-07-11 08:47:14 +00:00
</v-flex>
<v-flex xs8 v-tooltip:bottom="{ html: item.genres.join(' ') }">
2017-05-13 14:38:17 +00:00
<p class="genres ellipsis">{{ item.genres.join(' ') }}</p>
2017-07-11 08:47:14 +00:00
</v-flex>
<v-flex xs3 v-tooltip:bottom="{ html: item.fromType }">
2017-05-13 14:38:17 +00:00
<p class="from-type ellipsis">
{{ item.fromType }}
</p>
2017-07-11 08:47:14 +00:00
</v-flex>
<v-flex xs1></v-flex>
2017-05-13 14:38:17 +00:00
<!-- Picture of elem -->
2017-07-11 08:47:14 +00:00
<v-flex xs4 class="image-container">
<lazy-component>
<img :src="item.picture" onerror="this.src='static/images/error.jpg'" class="image"/>
</lazy-component>
2017-07-11 08:47:14 +00:00
</v-flex>
<v-flex xs8 class="bottom-right">
<v-layout wrap justify-space-between align-center>
<v-flex xs12>
<div class="synopsis">
{{ reduced(item.synopsis) }}
</div>
</v-flex>
<v-flex xs12>
<v-layout wrap justify-space-between>
<v-flex xs3 class="date">{{ getDate(item.releaseDate) }}</v-flex>
<v-flex xs4 class="nb-ep">{{ item.nbEp }} {{ episode(item.npEp) }}</v-flex>
</v-layout>
<v-layout wrap justify-space-between>
<v-flex xs8 class="producers"><strong>{{ item.producers.join(' ') }}</strong></v-flex>
<v-flex xs4 class="dropdown-container">
<!-- Add open-on-hover when vuetify repaired it -->
<v-menu transition="slide-x-transition">
2017-07-11 08:47:14 +00:00
<v-btn flat dark slot="activator">
More
</v-btn>
2017-08-03 05:57:31 +00:00
<v-list class="dark">
2017-07-19 19:44:59 +00:00
<v-list-tile @click="openModal(item.title, item.synopsis)">
2017-07-11 08:47:14 +00:00
<v-list-tile-action>
<v-icon>more</v-icon>
</v-list-tile-action>
<v-list-tile-title>
Check synopsis
</v-list-tile-title>
</v-list-tile>
<v-list-tile @click="$store.dispatch('searchInfoFromName', item.title)">
2017-07-11 08:47:14 +00:00
<v-list-tile-action>
<v-icon>info_outline</v-icon>
</v-list-tile-action>
<v-list-tile-title>Information</v-list-tile-title>
</v-list-tile>
2017-07-19 07:50:10 +00:00
<v-list-tile @click="showChoices(item.title)">
2017-07-11 08:47:14 +00:00
<v-list-tile-action>
<v-icon>add_box</v-icon>
</v-list-tile-action>
<v-list-tile-title>
Add to
</v-list-tile-title>
</v-list-tile>
</v-list>
</v-menu>
</v-flex>
</v-layout>
</v-flex>
</v-layout>
</v-flex>
</v-layout>
</v-flex>
</transition-group>
</v-layout>
</v-tabs-content>
2017-05-13 14:38:17 +00:00
</v-tabs>
<div class="text-xs-center modal-container">
<v-dialog v-model="modal" width="70%">
<v-card class="secondary white--text">
<v-card-text class="white--text">
2017-07-11 08:47:14 +00:00
<h2 class="headline white--text">{{ modalTitle }}</h2>
2017-05-13 14:38:17 +00:00
</v-card-text>
2017-07-11 08:47:14 +00:00
<v-card-text class="text white--text">
2017-05-13 14:38:17 +00:00
{{ modalText }}
</v-card-text>
2017-07-11 08:47:14 +00:00
<v-card-actions>
2017-05-13 14:38:17 +00:00
<v-spacer></v-spacer>
2017-07-11 08:47:14 +00:00
<v-btn class="blue--text darken-1" flat
2017-05-13 14:38:17 +00:00
style="width: 100px"
v-on:click.native="modal = false">Thanks!
</v-btn>
2017-07-11 08:47:14 +00:00
</v-card-actions>
2017-05-13 14:38:17 +00:00
</v-card>
</v-dialog>
</div>
<choice-window :entry="choiceTitle"></choice-window>
2017-05-13 14:38:17 +00:00
</v-container>
2017-07-11 08:47:14 +00:00
</div>
2017-04-15 14:16:14 +00:00
</template>
<script>
export default {
2017-05-13 14:38:17 +00:00
data () {
2017-04-15 14:16:14 +00:00
return {
query: '',
choiceTitle: '',
choices: [],
2017-04-15 14:16:14 +00:00
modalTitle: '',
modalText: '',
modal: false,
seasonChoices: [
{name: 'Winter', value: 'winter'},
{name: 'Spring', value: 'spring'},
{name: 'Summer', value: 'summer'},
{name: 'Fall', value: 'fall'}
2017-07-03 20:32:05 +00:00
]
2017-04-15 14:16:14 +00:00
}
},
computed: {
seasons: function () {
return this.$store.state.seasons
},
stats: function () {
return this.$store.state.seasonsStats
},
TVs: function () {
return this.seasons.TV
},
OVAs: function () {
return this.seasons.OVAs
},
Movies: function () {
return this.seasons.Movies
},
season: function () {
return [
'',
2017-04-15 14:16:14 +00:00
{name: 'TV', items: this.TVs},
{name: 'OVA', items: this.OVAs},
{name: 'Movies', items: this.Movies}
]
},
computedSeason: function () {
const query = this.query.toLowerCase()
return query === ''
? this.season
: this.season.map((list) => {
if (list.items) {
return {
name: list.name,
items: list.items.filter((elem) => {
return elem.title.toLowerCase().indexOf(query) !== -1
})
}
} else return ''
2017-07-07 11:07:44 +00:00
})
2017-04-15 14:16:14 +00:00
}
},
methods: {
2017-05-13 14:38:17 +00:00
reduced (text) {
2017-04-15 14:16:14 +00:00
return text.length > 270
2017-05-13 14:38:17 +00:00
? text.slice(0, 300) + '...'
: text
2017-04-15 14:16:14 +00:00
},
2017-05-13 14:38:17 +00:00
getDate (string) {
2017-04-15 14:16:14 +00:00
return string.split(' ').slice(0, 3).join(' ')
},
2017-05-13 14:38:17 +00:00
episode (nbEp) {
return parseInt(nbEp) !== 1
2017-05-13 14:38:17 +00:00
? 'episodes'
: 'episode'
2017-04-15 14:16:14 +00:00
},
2017-05-13 14:38:17 +00:00
refreshSeason () {
2017-04-15 14:16:14 +00:00
this.$store.dispatch('refreshSeasons')
},
2017-05-13 14:38:17 +00:00
openModal (title, text) {
2017-05-03 18:22:07 +00:00
console.log(`[${(new Date()).toLocaleTimeString()}]Opening modal for ${title}`)
2017-04-15 14:16:14 +00:00
this.modalTitle = title
this.modalText = text
this.modal = true
},
showChoices (name) {
this.choiceTitle = name
this.$store.commit('setAddToChoice', true)
2017-04-15 14:16:14 +00:00
}
}
}
</script>
<style scoped>
2017-05-13 14:38:17 +00:00
h6
{
margin: 0;
}
2017-04-15 14:16:14 +00:00
div.input-group
{
padding-bottom: 5px !important;
margin-top: 8px !important;
}
2017-07-11 08:47:14 +00:00
.text
2017-05-13 14:38:17 +00:00
{
2017-07-11 08:47:14 +00:00
text-align: justify;
text-align-last: center;
padding: 20px;
font-size: 16px;
2017-05-13 14:38:17 +00:00
}
2017-04-15 14:16:14 +00:00
.refresh-button
{
display: flex;
align-items: center;
}
.query
{
margin: 30px 0 0;
margin-left: 10%;
width: 25%;
}
2017-05-13 14:38:17 +00:00
/* ----------- ELEM ---------- */
.ellipsis
{
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.elems
{
padding: 0 1% 2% 1%;
2017-05-13 14:38:17 +00:00
}
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.elem
{
position: relative;
margin: 5px 0 10px;
2017-05-13 14:38:17 +00:00
background-color: rgb(60, 60, 60);
}
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.elem:hover
{
transition: all 0.25s;
2017-05-13 14:38:17 +00:00
box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12) !important;
}
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.title
{
margin-top: 10px;
margin-bottom: 10px;
padding-left: 10px;
line-height: 26px;
2017-05-13 14:38:17 +00:00
}
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.from-type
{
margin-bottom: 5px;
text-align: right;
font-weight: 700;
font-size: 120%;
}
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.genres
{
padding-left: 5px;
font-weight: 600;
}
2017-04-23 15:43:33 +00:00
2017-05-13 14:38:17 +00:00
.image-container
{
padding: 0;
2017-07-11 08:47:14 +00:00
max-height: 220px;
2017-05-13 14:38:17 +00:00
}
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.image
{
2017-07-11 08:47:14 +00:00
max-height: 220px;
max-width: 100%;
2017-05-13 14:38:17 +00:00
}
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.bottom-right
{
position: relative;
2017-07-11 08:47:14 +00:00
display: flex;
2017-05-13 14:38:17 +00:00
}
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.synopsis
{
padding-left: 15px;
padding-right: 15px;
text-align: justify;
2017-07-11 08:47:14 +00:00
display: block;
text-overflow: ellipsis;
word-wrap: break-word;
overflow: hidden;
height: 7.5em;
line-height: 1.5em;
2017-05-13 14:38:17 +00:00
}
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.date
{
margin-top: 5%;
}
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.nb-ep
{
text-align: right;
margin-top: 5%;
padding-right: 20px;
}
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.producers
{
margin-top: 4%;
}
</style>