Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vueify start of showheader #5087

Merged
merged 23 commits into from
Sep 8, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions themes-default/slim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"gulp-changed": "3.2.0",
"gulp-imagemin": "4.1.0",
"imagemin-pngquant": "6.0.0",
"is-visible": "2.2.0",
"jquery": "3.3.1",
"lodash": "4.17.10",
"mini-css-extract-plugin": "0.4.2",
Expand All @@ -74,6 +75,7 @@
"vue-meta": "1.5.3",
"vue-native-websocket": "2.0.8",
"vue-router": "3.0.1",
"vue-scrollto": "2.11.0",
"vue-snotify": "3.2.1",
"vue-template-compiler": "2.5.17",
"vue-truncate-collapsed": "2.1.0",
Expand Down
119 changes: 79 additions & 40 deletions themes-default/slim/src/components/display-show.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script>
import { isVisible } from 'is-visible';
import { scrollTo } from 'vue-scrollto';
import { mapState, mapGetters } from 'vuex';
import { api, apiRoute } from '../api';
import AppLink from './app-link.vue';
Expand All @@ -11,6 +13,20 @@ export default {
AppLink,
PlotInfo
},
props: {
/**
* Show id
*/
showId: {
type: Number
},
/**
* Show indexer
*/
showIndexer: {
type: String
}
},
metaInfo() {
if (!this.show || !this.show.title) {
return {
Expand All @@ -31,10 +47,10 @@ export default {
'getShowById'
]),
indexer() {
return this.$route.query.indexername;
return this.showIndexer || this.$route.query.indexername;
},
id() {
return this.$route.query.seriesid;
return this.showId || this.$route.query.seriesid;
},
show() {
const { indexer, id, getShowById, shows, $store } = this;
Expand All @@ -52,6 +68,11 @@ export default {
return show;
}
},
beforeMount() {
// Get detailed show from API
const { $store, id, indexer } = this;
$store.dispatch('getShow', { id, indexer, detailed: true });
},
mounted() {
const {
setQuality,
Expand All @@ -62,13 +83,13 @@ export default {
showHideRows
} = this;

$(window).on('resize', () => {
this.reflowLayout();
['load', 'resize'].map(event => {
return window.addEventListener(event, () => {
this.reflowLayout();
});
});

window.addEventListener('load', () => {
this.reflowLayout();

$.ajaxEpSearch({
colorRow: true
});
Expand All @@ -78,17 +99,6 @@ export default {
$.ajaxEpRedownloadSubtitle();
});

$(document.body).on('change', '#seasonJump', event => {
const id = $('#seasonJump option:selected').val();
if (id && id !== 'jump') {
const season = $('#seasonJump option:selected').data('season');
$('html,body').animate({ scrollTop: $('[name="' + id.substring(1) + '"]').offset().top - 100 }, 'slow');
$('#collapseSeason-' + season).collapse('show');
location.hash = id;
}
$(event.currentTarget).val('jump');
});

$(document.body).on('click', '#changeStatus', () => {
const epArr = [];
const status = $('#statusSelect').val();
Expand Down Expand Up @@ -158,24 +168,28 @@ export default {
});
});

// Selects all visible episode checkboxes.
$(document.body).on('click', '.seriesCheck', () => {
$('.epCheck:visible').each((index, element) => {
element.checked = true;
});
$('.seasonCheck:visible').each((index, element) => {
element.checked = true;
});
// Selects all visible episode checkboxes
document.addEventListener('click', event => {
if (event.target && event.target.className.includes('clearAll')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That class is incorrect, should be seriesCheck.

[...document.getElementsByClassName('epCheck')].filter(isVisible).forEach(element => {
element.checked = true;
});
[...document.getElementsByClassName('seasonCheck')].filter(isVisible).forEach(element => {
element.checked = true;
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use this instead of the two loops, but it's probably going to be replaced later..

[...document.querySelectorAll('.epCheck, .seasonCheck')].filter(isVisible).forEach(element => {
    element.checked = true;
});

}
});

// Clears all visible episode checkboxes and the season selectors
$(document.body).on('click', '.clearAll', () => {
$('.epCheck:visible').each((index, element) => {
element.checked = false;
});
$('.seasonCheck:visible').each((index, element) => {
element.checked = false;
});
document.addEventListener('click', event => {
OmgImAlexis marked this conversation as resolved.
Show resolved Hide resolved
if (event.target && event.target.className.includes('clearAll')) {
[...document.getElementsByClassName('epCheck')].filter(isVisible).forEach(element => {
element.checked = false;
});
[...document.getElementsByClassName('seasonCheck')].filter(isVisible).forEach(element => {
element.checked = false;
});
}
});

// Show/hide different types of rows when the checkboxes are changed
Expand Down Expand Up @@ -265,25 +279,20 @@ export default {
$.tablesorter.columnSelector.attachTo($('#showTable, #animeTable'), '#popover-target');
});

// Moved and rewritten this from displayShow. This changes the button when clicked for collapsing/expanding the
// Season to Show Episodes or Hide Episodes.
$('.collapse.toggle').on('hide.bs.collapse', function() {
// Changes the button when clicked for collapsing/expanding the season to show/hide episodes
document.addEventListener('hide.bs.collapse', function() {
const reg = /collapseSeason-(\d+)/g;
const result = reg.exec(this.id);
$('#showseason-' + result[1]).text('Show Episodes');
$('#season-' + result[1] + '-cols').addClass('shadow');
});
$('.collapse.toggle').on('show.bs.collapse', function() {
document.addEventListener('show.bs.collapse', function() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a good chance this is broken.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest:

document.querySelectorAll('.collapse.toggle').forEach(element => {
    element.addEventListener('hide.bs.collapse', function() {
        // on hide
    });
    element.addEventListener('show.bs.collapse', function() {
        // on show
    });
));

And to test this you need to disable Show all seasons in General Config -> Interface.

const reg = /collapseSeason-(\d+)/g;
const result = reg.exec(this.id);
$('#showseason-' + result[1]).text('Hide Episodes');
$('#season-' + result[1] + '-cols').removeClass('shadow');
});

// Generate IMDB stars
$('.imdbstars').each((index, element) => {
$(element).html($('<span/>').width($(element).text() * 12));
});
attachImdbTooltip(); // eslint-disable-line no-undef
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tooltip is not working. It's possible you need to put this in reflowLayout().


// Get the season exceptions and the xem season mappings.
Expand Down Expand Up @@ -504,6 +513,36 @@ export default {
$('#' + seasonNo + '-cols').show();
}
});
},
jumpToSeason(event) {
const { id } = event.currentTarget;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is incorrect, it uses #jumpToSeason which is the <select> id, not the target id.


// Don't jump until an option is selected
if (id && id !== 'jump') {
scrollTo(id, 600, {
container: 'body',
easing: 'ease-in',
offset: -100
});

// Update URL hash
location.hash = id;

// Reset jump
event.currentTarget.value = 'jump';
}
},
toggleSpecials() {
this.$store.dispatch('setConfig', {
layout: {
show: {
specials: !this.config.layout.show.specials
}
}
});
},
reverse(array) {
return array.slice().reverse();
}
}
};
Expand Down
3 changes: 3 additions & 0 deletions themes-default/slim/src/components/snatch-selection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export default {
$('#summaryBackground').height(height);
$('#summaryBackground').offset({ top, left: 0 });
$('#summaryBackground').show();
},
reverse(array) {
return array.slice().reverse();
}
},
mounted() {
Expand Down
Loading