1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #1730 from Camc314/remove-self

Remove Aliasing this in Music
This commit is contained in:
dkanada 2020-08-25 09:44:18 +09:00 committed by GitHub
commit fd102348ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 69 additions and 74 deletions

View file

@ -69,8 +69,8 @@ import 'emby-itemscontainer';
return savedQueryKey;
}
function onViewStyleChange() {
const viewStyle = self.getCurrentViewStyle();
const onViewStyleChange = () => {
const viewStyle = this.getCurrentViewStyle();
const itemsContainer = tabContent.querySelector('.itemsContainer');
if (viewStyle == 'List') {
@ -82,13 +82,13 @@ import 'emby-itemscontainer';
}
itemsContainer.innerHTML = '';
}
};
function reloadItems(page) {
const reloadItems = (page) => {
loading.show();
isLoading = true;
const query = getQuery();
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then(function (result) {
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then((result) => {
function onNextPageClick() {
if (isLoading) {
return;
@ -124,7 +124,7 @@ import 'emby-itemscontainer';
sortButton: false,
filterButton: false
});
const viewStyle = self.getCurrentViewStyle();
const viewStyle = this.getCurrentViewStyle();
if (viewStyle == 'List') {
html = listView.getListViewHtml({
items: result.Items,
@ -182,19 +182,18 @@ import 'emby-itemscontainer';
autoFocuser.autoFocus(tabContent);
});
});
}
};
function updateFilterControls(tabContent) {
const updateFilterControls = (tabContent) => {
const query = getQuery();
self.alphaPicker.value(query.NameStartsWithOrGreater);
}
this.alphaPicker.value(query.NameStartsWithOrGreater);
};
let savedQueryKey;
let pageData;
const self = this;
let isLoading = false;
self.showFilterMenu = function () {
this.showFilterMenu = function () {
import('components/filterdialog/filterdialog').then(({default: filterDialogFactory}) => {
const filterDialog = new filterDialogFactory({
query: getQuery(),
@ -209,11 +208,11 @@ import 'emby-itemscontainer';
});
};
self.getCurrentViewStyle = function () {
this.getCurrentViewStyle = function () {
return getPageData().view;
};
function initPage(tabContent) {
const initPage = (tabContent) => {
const alphaPickerElement = tabContent.querySelector('.alphaPicker');
const itemsContainer = tabContent.querySelector('.itemsContainer');
@ -224,7 +223,7 @@ import 'emby-itemscontainer';
query.StartIndex = 0;
reloadItems(tabContent);
});
self.alphaPicker = new AlphaPicker({
this.alphaPicker = new AlphaPicker({
element: alphaPickerElement,
valueChangeEvent: 'click'
});
@ -233,10 +232,10 @@ 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) {
tabContent.querySelector('.btnSort').addEventListener('click', (e) => {
libraryBrowser.showSortMenu({
items: [{
name: globalize.translate('OptionNameSort'),
@ -269,8 +268,8 @@ import 'emby-itemscontainer';
});
});
const btnSelectView = tabContent.querySelector('.btnSelectView');
btnSelectView.addEventListener('click', function (e) {
libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), 'List,Poster,PosterCard'.split(','));
btnSelectView.addEventListener('click', (e) => {
libraryBrowser.showLayoutMenu(e.target, this.getCurrentViewStyle(), 'List,Poster,PosterCard'.split(','));
});
btnSelectView.addEventListener('layoutchange', function (e) {
const viewStyle = e.detail.viewStyle;
@ -282,17 +281,17 @@ import 'emby-itemscontainer';
});
tabContent.querySelector('.btnPlayAll').addEventListener('click', playAll);
tabContent.querySelector('.btnShuffle').addEventListener('click', shuffle);
}
};
initPage(tabContent);
onViewStyleChange();
self.renderTab = function () {
this.renderTab = function () {
reloadItems(tabContent);
updateFilterControls(tabContent);
};
self.destroy = function () {};
this.destroy = function () {};
}
/* eslint-enable indent */

View file

@ -45,16 +45,16 @@ import 'emby-itemscontainer';
return getPageData(context).query;
}
function getSavedQueryKey(context) {
const getSavedQueryKey = (context) => {
if (!context.savedQueryKey) {
context.savedQueryKey = libraryBrowser.getSavedQueryKey(self.mode);
context.savedQueryKey = libraryBrowser.getSavedQueryKey(this.mode);
}
return context.savedQueryKey;
}
};
function onViewStyleChange() {
const viewStyle = self.getCurrentViewStyle();
const onViewStyleChange = () => {
const viewStyle = this.getCurrentViewStyle();
const itemsContainer = tabContent.querySelector('.itemsContainer');
if (viewStyle == 'List') {
@ -66,16 +66,16 @@ import 'emby-itemscontainer';
}
itemsContainer.innerHTML = '';
}
};
function reloadItems(page) {
const reloadItems = (page) => {
loading.show();
isLoading = true;
const query = getQuery(page);
const promise = self.mode == 'albumartists' ?
const promise = this.mode == 'albumartists' ?
ApiClient.getAlbumArtists(ApiClient.getCurrentUserId(), query) :
ApiClient.getArtists(ApiClient.getCurrentUserId(), query);
promise.then(function (result) {
promise.then((result) => {
function onNextPageClick() {
if (isLoading) {
return;
@ -111,7 +111,7 @@ import 'emby-itemscontainer';
sortButton: false,
filterButton: false
});
const viewStyle = self.getCurrentViewStyle();
const viewStyle = this.getCurrentViewStyle();
if (viewStyle == 'List') {
html = listView.getListViewHtml({
items: result.Items,
@ -165,22 +165,21 @@ import 'emby-itemscontainer';
autoFocuser.autoFocus(tabContent);
});
});
}
};
function updateFilterControls(tabContent) {
const updateFilterControls = (tabContent) => {
const query = getQuery(tabContent);
self.alphaPicker.value(query.NameStartsWithOrGreater);
}
this.alphaPicker.value(query.NameStartsWithOrGreater);
};
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),
mode: self.mode,
mode: this.mode,
serverId: ApiClient.serverId()
});
events.on(filterDialog, 'filterchange', function () {
@ -191,11 +190,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');
@ -206,7 +205,7 @@ import 'emby-itemscontainer';
query.StartIndex = 0;
reloadItems(tabContent);
});
self.alphaPicker = new AlphaPicker({
this.alphaPicker = new AlphaPicker({
element: alphaPickerElement,
valueChangeEvent: 'click'
});
@ -215,12 +214,12 @@ 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();
});
const btnSelectView = tabContent.querySelector('.btnSelectView');
btnSelectView.addEventListener('click', function (e) {
libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), 'List,Poster,PosterCard'.split(','));
libraryBrowser.showLayoutMenu(e.target, this.getCurrentViewStyle(), 'List,Poster,PosterCard'.split(','));
});
btnSelectView.addEventListener('layoutchange', function (e) {
const viewStyle = e.detail.viewStyle;
@ -230,17 +229,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 */

View file

@ -42,11 +42,11 @@ import loading from 'loading';
return ApiClient.getGenres(ApiClient.getCurrentUserId(), query);
}
function reloadItems(context, promise) {
const reloadItems = (context, promise) => {
const query = getQuery();
promise.then(function (result) {
promise.then((result) => {
let html = '';
const viewStyle = self.getCurrentViewStyle();
const viewStyle = this.getCurrentViewStyle();
if (viewStyle == 'Thumb') {
html = cardBuilder.getCardsHtml({
@ -96,38 +96,37 @@ import loading from 'loading';
autoFocuser.autoFocus(context);
});
});
}
};
function fullyReload() {
self.preRender();
self.renderTab();
this.preRender();
this.renderTab();
}
const self = this;
const data = {};
self.getViewStyles = function () {
this.getViewStyles = function () {
return 'Poster,PosterCard,Thumb,ThumbCard'.split(',');
};
self.getCurrentViewStyle = function () {
this.getCurrentViewStyle = function () {
return getPageData().view;
};
self.setCurrentViewStyle = function (viewStyle) {
this.setCurrentViewStyle = function (viewStyle) {
getPageData().view = viewStyle;
libraryBrowser.saveViewSetting(getSavedQueryKey(), viewStyle);
fullyReload();
};
self.enableViewSelection = true;
this.enableViewSelection = true;
let promise;
self.preRender = function () {
this.preRender = function () {
promise = getPromise();
};
self.renderTab = function () {
this.renderTab = function () {
reloadItems(tabContent, promise);
};
}

View file

@ -69,20 +69,19 @@ import loading from 'loading';
});
}
const self = this;
const data = {};
self.getCurrentViewStyle = function () {
this.getCurrentViewStyle = function () {
return getPageData().view;
};
let promise;
self.preRender = function () {
this.preRender = function () {
promise = getPromise();
};
self.renderTab = function () {
this.renderTab = function () {
reloadItems(tabContent, promise);
};
}

View file

@ -263,7 +263,7 @@ import 'flexStyles';
mainTabsManager.setTabs(view, currentTabIndex, getTabs, getTabContainers, onBeforeTabChange, onTabChange);
}
function getTabController(page, index, callback) {
const getTabController = (page, index, callback) => {
let depends;
switch (index) {
@ -298,7 +298,7 @@ import 'flexStyles';
if (index == 0) {
tabContent = view.querySelector(".pageTabContent[data-index='" + index + "']");
self.tabContent = tabContent;
this.tabContent = tabContent;
}
let controller = tabControllers[index];
@ -307,7 +307,7 @@ import 'flexStyles';
tabContent = view.querySelector(".pageTabContent[data-index='" + index + "']");
if (index === 0) {
controller = self;
controller = this;
} else if (index === 7) {
controller = new controllerFactory(view, tabContent, {
collectionType: 'music',
@ -331,7 +331,7 @@ import 'flexStyles';
callback(controller);
});
}
};
function preLoadTab(page, index) {
getTabController(page, index, function (controller) {
@ -359,10 +359,9 @@ import 'flexStyles';
}
}
var self = this;
var currentTabIndex = parseInt(params.tab || getDefaultTabIndex(params.topParentId));
let currentTabIndex = parseInt(params.tab || getDefaultTabIndex(params.topParentId));
self.initTab = function () {
this.initTab = function () {
const tabContent = view.querySelector(".pageTabContent[data-index='0']");
const containers = tabContent.querySelectorAll('.itemsContainer');
@ -371,7 +370,7 @@ import 'flexStyles';
}
};
self.renderTab = function () {
this.renderTab = function () {
reload();
};