Remove ailiasing this

This commit is contained in:
Cameron 2020-09-01 10:12:10 +01:00
parent d8cb606894
commit ab7fafa891

View File

@ -54,8 +54,8 @@ import 'emby-itemscontainer';
return context.savedQueryKey;
}
function onViewStyleChange() {
const viewStyle = self.getCurrentViewStyle();
const onViewStyleChange = () => {
const viewStyle = this.getCurrentViewStyle();
const itemsContainer = tabContent.querySelector('.itemsContainer');
if (viewStyle == 'List') {
@ -67,13 +67,13 @@ import 'emby-itemscontainer';
}
itemsContainer.innerHTML = '';
}
};
function reloadItems(page) {
const reloadItems = (page) => {
loading.show();
isLoading = true;
const query = getQuery(page);
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then(function (result) {
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then((result) => {
function onNextPageClick() {
if (isLoading) {
return;
@ -109,7 +109,7 @@ import 'emby-itemscontainer';
sortButton: false,
filterButton: false
});
const viewStyle = self.getCurrentViewStyle();
const viewStyle = this.getCurrentViewStyle();
if (viewStyle == 'Thumb') {
html = cardBuilder.getCardsHtml({
items: result.Items,
@ -196,25 +196,24 @@ import 'emby-itemscontainer';
});
}
function updateFilterControls(tabContent) {
const updateFilterControls = (tabContent) => {
const query = getQuery(tabContent);
if (self.alphaPicker) {
self.alphaPicker.value(query.NameStartsWithOrGreater);
if (this.alphaPicker) {
this.alphaPicker.value(query.NameStartsWithOrGreater);
if (query.SortBy.indexOf('SortName') === 0) {
self.alphaPicker.visible(true);
this.alphaPicker.visible(true);
} else {
self.alphaPicker.visible(false);
}
this.alphaPicker.visible(false);
}
}
};
const self = this;
const data = {};
let isLoading = false;
self.showFilterMenu = function () {
this.showFilterMenu = function () {
import('components/filterdialog/filterdialog').then(({default: filterDialogFactory}) => {
const filterDialog = new filterDialogFactory({
query: getQuery(tabContent),
@ -229,11 +228,11 @@ import 'emby-itemscontainer';
});
};
self.getCurrentViewStyle = function () {
this.getCurrentViewStyle = function () {
return getPageData(tabContent).view;
};
function initPage(tabContent) {
const initPage = (tabContent) => {
const alphaPickerElement = tabContent.querySelector('.alphaPicker');
const itemsContainer = tabContent.querySelector('.itemsContainer');
@ -244,7 +243,7 @@ import 'emby-itemscontainer';
query.StartIndex = 0;
reloadItems(tabContent);
});
self.alphaPicker = new AlphaPicker({
this.alphaPicker = new AlphaPicker({
element: alphaPickerElement,
valueChangeEvent: 'click'
});
@ -253,8 +252,8 @@ import 'emby-itemscontainer';
alphaPickerElement.classList.add('alphaPicker-fixed-right');
itemsContainer.classList.add('padded-right-withalphapicker');
tabContent.querySelector('.btnFilter').addEventListener('click', function () {
self.showFilterMenu();
tabContent.querySelector('.btnFilter').addEventListener('click', () => {
this.showFilterMenu();
});
tabContent.querySelector('.btnSort').addEventListener('click', function (e) {
libraryBrowser.showSortMenu({
@ -286,8 +285,8 @@ import 'emby-itemscontainer';
});
});
const btnSelectView = tabContent.querySelector('.btnSelectView');
btnSelectView.addEventListener('click', function (e) {
libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), 'Banner,List,Poster,PosterCard,Thumb,ThumbCard'.split(','));
btnSelectView.addEventListener('click', (e) => {
libraryBrowser.showLayoutMenu(e.target, this.getCurrentViewStyle(), 'Banner,List,Poster,PosterCard,Thumb,ThumbCard'.split(','));
});
btnSelectView.addEventListener('layoutchange', function (e) {
const viewStyle = e.detail.viewStyle;
@ -297,17 +296,17 @@ import 'emby-itemscontainer';
onViewStyleChange();
reloadItems(tabContent);
});
}
};
initPage(tabContent);
onViewStyleChange();
self.renderTab = function () {
this.renderTab = function () {
reloadItems(tabContent);
updateFilterControls(tabContent);
};
self.destroy = function () {};
this.destroy = function () {};
}
/* eslint-enable indent */