Merge pull request #27 from hawken93/fix_503

Stop pagination and adding a library from being able to trigger multiple times
This commit is contained in:
Vasily 2019-01-19 19:51:06 +03:00 committed by GitHub
commit 7417b844f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 267 additions and 110 deletions

View File

@ -2,30 +2,48 @@ define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionsed
"use strict";
function onSubmit(e) {
if (e.preventDefault(), e.stopPropagation(), 0 == pathInfos.length) return require(["alert"], function(alert) {
alert({
text: Globalize.translate("PleaseAddAtLeastOneFolder"),
type: "error"
})
}), !1;
var form = this,
dlg = $(form).parents(".dialog")[0],
name = $("#txtValue", form).val(),
type = $("#selectCollectionType", form).val();
"mixed" == type && (type = null);
var libraryOptions = libraryoptionseditor.getLibraryOptions(dlg.querySelector(".libraryOptions"));
return libraryOptions.PathInfos = pathInfos, ApiClient.addVirtualFolder(name, type, currentOptions.refresh, libraryOptions).then(function() {
hasChanges = !0, dialogHelper.close(dlg)
}, function() {
require(["toast"], function(toast) {
toast(Globalize.translate("ErrorAddingMediaPathToVirtualFolder"))
})
}), !1
e.preventDefault();
e.stopPropagation();
if (isCreating) return false;
if (pathInfos.length == 0) {
require(["alert"], function(alert) {
alert({
text: Globalize.translate("PleaseAddAtLeastOneFolder"),
type: "error"
})
});
} else {
isCreating = true;
loading.show();
var form = this,
dlg = $(form).parents(".dialog")[0],
name = $("#txtValue", form).val(),
type = $("#selectCollectionType", form).val();
if (type == "mixed") type = null;
var libraryOptions = libraryoptionseditor.getLibraryOptions(dlg.querySelector(".libraryOptions"));
libraryOptions.PathInfos = pathInfos;
ApiClient.addVirtualFolder(name, type, currentOptions.refresh, libraryOptions).then(function() {
hasChanges = true;
isCreating = false;
loading.hide();
dialogHelper.close(dlg);
}, function() {
require(["toast"], function(toast) {
toast(Globalize.translate("ErrorAddingMediaPathToVirtualFolder"))
})
isCreating = false;
loading.hide();
});
}
return false;
}
function getCollectionTypeOptionsHtml(collectionTypeOptions) {
return collectionTypeOptions.filter(function(i) {
return !1 !== i.isSelectable
return i.isSelectable
}).map(function(i) {
return '<option value="' + i.value + '">' + i.name + "</option>"
}).join("")
@ -35,9 +53,15 @@ define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionsed
$("#selectCollectionType", page).html(getCollectionTypeOptionsHtml(collectionTypeOptions)).val("").on("change", function() {
var value = this.value,
dlg = $(this).parents(".dialog")[0];
if (libraryoptionseditor.setContentType(dlg.querySelector(".libraryOptions"), "mixed" == value ? "" : value), value ? dlg.querySelector(".libraryOptions").classList.remove("hide") : dlg.querySelector(".libraryOptions").classList.add("hide"), "mixed" != value) {
libraryoptionseditor.setContentType(dlg.querySelector(".libraryOptions"), value == "mixed" ? "" : value);
if (value)
dlg.querySelector(".libraryOptions").classList.remove("hide");
else
dlg.querySelector(".libraryOptions").classList.add("hide");
if (value != "mixed") {
var index = this.selectedIndex;
if (-1 != index) {
if (index != -1) {
var name = this.options[index].innerHTML.replace("*", "").replace("&amp;", "&");
$("#txtValue", dlg).val(name);
var folderOption = collectionTypeOptions.filter(function(i) {
@ -59,7 +83,7 @@ define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionsed
require(["directorybrowser"], function(directoryBrowser) {
var picker = new directoryBrowser;
picker.show({
enableNetworkSharePath: !0,
enableNetworkSharePath: true,
callback: function(path, networkSharePath) {
path && addMediaLocation(page, path, networkSharePath), picker.close()
}
@ -101,7 +125,10 @@ define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionsed
}
function onDialogClosed() {
loading.hide(), currentResolve(hasChanges)
// I can't see any corresponding call to loading.show,
// so I think this is not supposed to be here.
loading.hide();
currentResolve(hasChanges);
}
function initLibraryOptions(dlg) {
@ -113,23 +140,36 @@ define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionsed
function editor() {
this.show = function(options) {
return new Promise(function(resolve, reject) {
currentOptions = options, currentResolve = resolve, hasChanges = !1;
currentOptions = options, currentResolve = resolve, hasChanges = false;
var xhr = new XMLHttpRequest;
xhr.open("GET", "components/medialibrarycreator/medialibrarycreator.template.html", !0), xhr.onload = function(e) {
xhr.open("GET", "components/medialibrarycreator/medialibrarycreator.template.html", true);
xhr.onload = function(e) {
var template = this.response,
dlg = dialogHelper.createDialog({
size: "medium-tall",
modal: !1,
removeOnClose: !0,
scrollY: !1
modal: false,
removeOnClose: true,
scrollY: false
});
dlg.classList.add("ui-body-a"), dlg.classList.add("background-theme-a"), dlg.classList.add("dlg-librarycreator"), dlg.classList.add("formDialog"), dlg.innerHTML = Globalize.translateDocument(template), initEditor(dlg, options.collectionTypeOptions), dlg.addEventListener("close", onDialogClosed), dialogHelper.open(dlg), dlg.querySelector(".btnCancel").addEventListener("click", function() {
dlg.classList.add("ui-body-a");
dlg.classList.add("background-theme-a");
dlg.classList.add("dlg-librarycreator");
dlg.classList.add("formDialog");
dlg.innerHTML = Globalize.translateDocument(template);
initEditor(dlg, options.collectionTypeOptions);
dlg.addEventListener("close", onDialogClosed);
dialogHelper.open(dlg);
dlg.querySelector(".btnCancel").addEventListener("click", function() {
dialogHelper.close(dlg)
}), pathInfos = [], renderPaths(dlg), initLibraryOptions(dlg)
}, xhr.send()
});
pathInfos = [];
renderPaths(dlg);
initLibraryOptions(dlg);
};
xhr.send();
})
}
}
var currentResolve, hasChanges, currentOptions, pathInfos = [];
var currentResolve, hasChanges, currentOptions, pathInfos = [], isCreating = false;
return editor
});
});

View File

@ -37,15 +37,21 @@ define(["loading", "events", "libraryBrowser", "imageLoader", "listView", "cardB
function reloadItems(page) {
loading.show();
isLoading = true;
var query = getQuery(page);
ApiClient.getItems(Dashboard.getCurrentUserId(), query).then(function(result) {
function onNextPageClick() {
query.StartIndex += query.Limit, reloadItems(tabContent)
if (isLoading) return;
query.StartIndex += query.Limit;
reloadItems(tabContent)
}
function onPreviousPageClick() {
query.StartIndex -= query.Limit, reloadItems(tabContent)
if (isLoading) return;
query.StartIndex -= query.Limit;
reloadItems(tabContent)
}
window.scrollTo(0, 0);
var html, pagingHtml = libraryBrowser.getQueryPagingHtml({
startIndex: query.StartIndex,
@ -80,16 +86,24 @@ define(["loading", "events", "libraryBrowser", "imageLoader", "listView", "cardB
scalable: !0,
overlayPlayButton: !0
});
var i, length, elems = tabContent.querySelectorAll(".paging");
for (i = 0, length = elems.length; i < length; i++) elems[i].innerHTML = pagingHtml;
for (elems = tabContent.querySelectorAll(".btnNextPage"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("click", onNextPageClick);
for (elems = tabContent.querySelectorAll(".btnPreviousPage"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("click", onPreviousPageClick);
itemsContainer.innerHTML = html, imageLoader.lazyChildren(itemsContainer), libraryBrowser.saveQueryValues(getSavedQueryKey(page), query), loading.hide()
var i, length, elems;
for (elems = tabContent.querySelectorAll(".paging"), i = 0, length = elems.length; i < length; i++)
elems[i].innerHTML = pagingHtml;
for (elems = tabContent.querySelectorAll(".btnNextPage"), i = 0, length = elems.length; i < length; i++)
elems[i].addEventListener("click", onNextPageClick);
for (elems = tabContent.querySelectorAll(".btnPreviousPage"), i = 0, length = elems.length; i < length; i++)
elems[i].addEventListener("click", onPreviousPageClick);
itemsContainer.innerHTML = html;
imageLoader.lazyChildren(itemsContainer);
libraryBrowser.saveQueryValues(getSavedQueryKey(page), query);
loading.hide();
isLoading = false;
})
}
var self = this,
pageSize = 100,
data = {};
data = {},
isLoading = false;
self.showFilterMenu = function() {
require(["components/filterdialog/filterdialog"], function(filterDialogFactory) {
var filterDialog = new filterDialogFactory({
@ -152,4 +166,4 @@ define(["loading", "events", "libraryBrowser", "imageLoader", "listView", "cardB
reloadItems(tabContent)
}, self.destroy = function() {}
}
});
});

View File

@ -30,10 +30,12 @@ define(["cardBuilder", "imageLoader", "libraryBrowser", "loading", "events", "em
function renderChannels(context, result) {
function onNextPageClick() {
if (isLoading) return;
query.StartIndex += query.Limit, reloadItems(context)
}
function onPreviousPageClick() {
if (isLoading) return;
query.StartIndex -= query.Limit, reloadItems(context)
}
var query = getQuery();
@ -68,17 +70,20 @@ define(["cardBuilder", "imageLoader", "libraryBrowser", "loading", "events", "em
function reloadItems(context, save) {
loading.show();
isLoading = true;
var query = getQuery(),
apiClient = ApiClient;
query.UserId = apiClient.getCurrentUserId(), apiClient.getLiveTvChannels(query).then(function(result) {
renderChannels(context, result), loading.hide()
renderChannels(context, result);
loading.hide();
isLoading = false;
})
}
var pageData, self = this;
var pageData, self = this, isLoading = false;
tabContent.querySelector(".btnFilter").addEventListener("click", function() {
showFilterMenu(tabContent)
}), self.renderTab = function() {
reloadItems(tabContent)
}
}
});
});

View File

@ -4,20 +4,25 @@ define(["loading", "events", "libraryBrowser", "imageLoader", "listView", "cardB
function getPageData(context) {
var key = getSavedQueryKey(context),
pageData = data[key];
return pageData || (pageData = data[key] = {
query: {
SortBy: "SortName",
SortOrder: "Ascending",
IncludeItemTypes: "BoxSet",
Recursive: !0,
Fields: "PrimaryImageAspectRatio,SortName",
ImageTypeLimit: 1,
EnableImageTypes: "Primary,Backdrop,Banner,Thumb",
StartIndex: 0,
Limit: pageSize
},
view: libraryBrowser.getSavedView(key) || "Poster"
}, pageData.query.ParentId = params.topParentId, libraryBrowser.loadSavedQueryValues(key, pageData.query)), pageData
if (!pageData) {
pageData = data[key] = {
query: {
SortBy: "SortName",
SortOrder: "Ascending",
IncludeItemTypes: "BoxSet",
Recursive: true,
Fields: "PrimaryImageAspectRatio,SortName",
ImageTypeLimit: 1,
EnableImageTypes: "Primary,Backdrop,Banner,Thumb",
StartIndex: 0,
Limit: pageSize
},
view: libraryBrowser.getSavedView(key) || "Poster"
};
pageData.query.ParentId = params.topParentId;
libraryBrowser.loadSavedQueryValues(key, pageData.query);
}
return pageData;
}
function getQuery(context) {
@ -36,13 +41,16 @@ define(["loading", "events", "libraryBrowser", "imageLoader", "listView", "cardB
function reloadItems(page) {
loading.show();
isLoading = true;
var query = getQuery(page);
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then(function(result) {
function onNextPageClick() {
if (isLoading) return;
query.StartIndex += query.Limit, reloadItems(tabContent)
}
function onPreviousPageClick() {
if (isLoading) return;
query.StartIndex -= query.Limit, reloadItems(tabContent)
}
window.scrollTo(0, 0);
@ -106,12 +114,17 @@ define(["loading", "events", "libraryBrowser", "imageLoader", "listView", "cardB
for (elems = tabContent.querySelectorAll(".btnPreviousPage"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("click", onPreviousPageClick);
result.Items.length || (html = '<p style="text-align:center;">' + Globalize.translate("MessageNoCollectionsAvailable") + "</p>");
var itemsContainer = tabContent.querySelector(".itemsContainer");
itemsContainer.innerHTML = html, imageLoader.lazyChildren(itemsContainer), libraryBrowser.saveQueryValues(getSavedQueryKey(page), query), loading.hide()
itemsContainer.innerHTML = html;
imageLoader.lazyChildren(itemsContainer);
libraryBrowser.saveQueryValues(getSavedQueryKey(page), query);
loading.hide();
isLoading = false;
})
}
var self = this,
pageSize = 100,
data = {};
data = {},
isLoading = false;
self.getCurrentViewStyle = function() {
return getPageData(tabContent).view
},
@ -160,4 +173,4 @@ define(["loading", "events", "libraryBrowser", "imageLoader", "listView", "cardB
reloadItems(tabContent)
}, self.destroy = function() {}
}
});
});

View File

@ -1,8 +1,16 @@
define(["layoutManager", "userSettings", "events", "libraryBrowser", "alphaPicker", "listView", "cardBuilder", "emby-itemscontainer"], function(layoutManager, userSettings, events, libraryBrowser, alphaPicker, listView, cardBuilder) {
define(["loading", "layoutManager", "userSettings", "events", "libraryBrowser", "alphaPicker", "listView", "cardBuilder", "emby-itemscontainer"],
function(loading, layoutManager, userSettings, events, libraryBrowser, alphaPicker, listView, cardBuilder) {
"use strict";
return function(view, params, tabContent, options) {
function onViewStyleChange() {
"List" == self.getCurrentViewStyle() ? (itemsContainer.classList.add("vertical-list"), itemsContainer.classList.remove("vertical-wrap")) : (itemsContainer.classList.remove("vertical-list"), itemsContainer.classList.add("vertical-wrap")), itemsContainer.innerHTML = ""
if (self.getCurrentViewStyle() == "List") {
itemsContainer.classList.add("vertical-list");
itemsContainer.classList.remove("vertical-wrap");
} else {
itemsContainer.classList.remove("vertical-list");
itemsContainer.classList.add("vertical-wrap");
}
itemsContainer.innerHTML = "";
}
function updateFilterControls() {
@ -10,19 +18,26 @@ define(["layoutManager", "userSettings", "events", "libraryBrowser", "alphaPicke
}
function fetchData() {
isLoading = true;
loading.show();
return ApiClient.getItems(ApiClient.getCurrentUserId(), query)
}
function afterRefresh(result) {
function onNextPageClick() {
query.StartIndex += query.Limit, itemsContainer.refreshItems()
if (isLoading) return;
query.StartIndex += query.Limit;
itemsContainer.refreshItems();
}
function onPreviousPageClick() {
query.StartIndex -= query.Limit, itemsContainer.refreshItems()
if (isLoading) return;
query.StartIndex -= query.Limit;
itemsContainer.refreshItems();
}
window.scrollTo(0, 0), updateFilterControls();
var i, length, pagingHtml = libraryBrowser.getQueryPagingHtml({
window.scrollTo(0, 0);
updateFilterControls();
var i, length, elems, pagingHtml = libraryBrowser.getQueryPagingHtml({
startIndex: query.StartIndex,
limit: query.Limit,
totalRecordCount: result.TotalRecordCount,
@ -31,11 +46,15 @@ define(["layoutManager", "userSettings", "events", "libraryBrowser", "alphaPicke
addLayoutButton: !1,
sortButton: !1,
filterButton: !1
}),
elems = tabContent.querySelectorAll(".paging");
for (i = 0, length = elems.length; i < length; i++) elems[i].innerHTML = pagingHtml;
for (elems = tabContent.querySelectorAll(".btnNextPage"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("click", onNextPageClick);
for (elems = tabContent.querySelectorAll(".btnPreviousPage"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("click", onPreviousPageClick)
});
for (elems = tabContent.querySelectorAll(".paging"), i = 0, length = elems.length; i < length; i++)
elems[i].innerHTML = pagingHtml;
for (elems = tabContent.querySelectorAll(".btnNextPage"), i = 0, length = elems.length; i < length; i++)
elems[i].addEventListener("click", onNextPageClick);
for (elems = tabContent.querySelectorAll(".btnPreviousPage"), i = 0, length = elems.length; i < length; i++)
elems[i].addEventListener("click", onPreviousPageClick)
isLoading = false;
loading.hide();
}
function getItemsHtml(items) {
@ -89,15 +108,27 @@ define(["layoutManager", "userSettings", "events", "libraryBrowser", "alphaPicke
}
function initPage(tabContent) {
itemsContainer.fetchData = fetchData, itemsContainer.getItemsHtml = getItemsHtml, itemsContainer.afterRefresh = afterRefresh;
itemsContainer.fetchData = fetchData;
itemsContainer.getItemsHtml = getItemsHtml;
itemsContainer.afterRefresh = afterRefresh;
var alphaPickerElement = tabContent.querySelector(".alphaPicker");
alphaPickerElement && (alphaPickerElement.addEventListener("alphavaluechanged", function(e) {
var newValue = e.detail.value;
query.NameStartsWithOrGreater = newValue, query.StartIndex = 0, itemsContainer.refreshItems()
}), self.alphaPicker = new alphaPicker({
element: alphaPickerElement,
valueChangeEvent: "click"
}), (layoutManager.desktop || layoutManager.mobile) && (alphaPickerElement.classList.add("alphabetPicker-right"), itemsContainer.classList.remove("padded-left-withalphapicker"), itemsContainer.classList.add("padded-right-withalphapicker")));
if (alphaPickerElement) {
alphaPickerElement.addEventListener("alphavaluechanged", function(e) {
var newValue = e.detail.value;
query.NameStartsWithOrGreater = newValue;
query.StartIndex = 0;
itemsContainer.refreshItems();
});
self.alphaPicker = new alphaPicker({
element: alphaPickerElement,
valueChangeEvent: "click"
});
if (layoutManager.desktop || layoutManager.mobile) {
alphaPickerElement.classList.add("alphabetPicker-right");
itemsContainer.classList.remove("padded-left-withalphapicker");
itemsContainer.classList.add("padded-right-withalphapicker");
}
}
var btnFilter = tabContent.querySelector(".btnFilter");
btnFilter && btnFilter.addEventListener("click", function() {
self.showFilterMenu()
@ -145,7 +176,10 @@ define(["layoutManager", "userSettings", "events", "libraryBrowser", "alphaPicke
libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), "Banner,List,Poster,PosterCard,Thumb,ThumbCard".split(","))
}), btnSelectView.addEventListener("layoutchange", function(e) {
var viewStyle = e.detail.viewStyle;
userSettings.set(savedViewKey, viewStyle), query.StartIndex = 0, onViewStyleChange(), itemsContainer.refreshItems()
userSettings.set(savedViewKey, viewStyle);
query.StartIndex = 0;
onViewStyleChange();
itemsContainer.refreshItems();
})
}
var self = this,
@ -163,8 +197,11 @@ define(["layoutManager", "userSettings", "events", "libraryBrowser", "alphaPicke
StartIndex: 0,
Limit: 100,
ParentId: params.topParentId
};
"favorites" === options.mode && (query.IsFavorite = !0), query = userSettings.loadQuerySettings(savedQueryKey, query), self.showFilterMenu = function() {
},
isLoading = false;
if (options.mode === "favorites") query.IsFavorite = true;
query = userSettings.loadQuerySettings(savedQueryKey, query);
self.showFilterMenu = function() {
require(["components/filterdialog/filterdialog"], function(filterDialogFactory) {
var filterDialog = new filterDialogFactory({
query: query,
@ -175,14 +212,20 @@ define(["layoutManager", "userSettings", "events", "libraryBrowser", "alphaPicke
query.StartIndex = 0, itemsContainer.refreshItems()
}), filterDialog.show()
})
}, self.getCurrentViewStyle = function() {
};
self.getCurrentViewStyle = function() {
return userSettings.get(savedViewKey) || "Poster"
}, self.initTab = function() {
initPage(tabContent), onViewStyleChange()
}, self.renderTab = function() {
itemsContainer.refreshItems(), updateFilterControls()
}, self.destroy = function() {
};
self.initTab = function() {
initPage(tabContent);
onViewStyleChange();
};
self.renderTab = function() {
itemsContainer.refreshItems();
updateFilterControls();
};
self.destroy = function() {
itemsContainer = null
}
}
});
});

View File

@ -30,13 +30,16 @@ define(["layoutManager", "loading", "events", "libraryBrowser", "imageLoader", "
function reloadItems() {
loading.show();
isLoading = true;
var query = getQuery(tabContent);
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then(function(result) {
function onNextPageClick() {
if (isLoading) return;
query.StartIndex += query.Limit, reloadItems()
}
function onPreviousPageClick() {
if (isLoading) return;
query.StartIndex -= query.Limit, reloadItems()
}
window.scrollTo(0, 0), updateFilterControls(tabContent);
@ -98,7 +101,11 @@ define(["layoutManager", "loading", "events", "libraryBrowser", "imageLoader", "
for (elems = tabContent.querySelectorAll(".btnPreviousPage"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("click", onPreviousPageClick);
result.Items.length || (html = '<p style="text-align:center;">' + Globalize.translate("MessageNoTrailersFound") + "</p>");
var itemsContainer = tabContent.querySelector(".itemsContainer");
itemsContainer.innerHTML = html, imageLoader.lazyChildren(itemsContainer), libraryBrowser.saveQueryValues(getSavedQueryKey(tabContent), query), loading.hide()
itemsContainer.innerHTML = html;
imageLoader.lazyChildren(itemsContainer);
libraryBrowser.saveQueryValues(getSavedQueryKey(tabContent), query);
loading.hide();
isLoading = false;
})
}
@ -108,7 +115,8 @@ define(["layoutManager", "loading", "events", "libraryBrowser", "imageLoader", "
}
var self = this,
pageSize = 100,
data = {};
data = {},
isLoading = false;
self.showFilterMenu = function() {
require(["components/filterdialog/filterdialog"], function(filterDialogFactory) {
var filterDialog = new filterDialogFactory({
@ -174,4 +182,4 @@ define(["layoutManager", "loading", "events", "libraryBrowser", "imageLoader", "
reloadItems(), updateFilterControls(tabContent)
}, self.destroy = function() {}
}
});
});

View File

@ -50,13 +50,16 @@ define(["layoutManager", "playbackManager", "loading", "events", "libraryBrowser
function reloadItems(page) {
loading.show();
isLoading = true;
var query = getQuery();
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then(function(result) {
function onNextPageClick() {
if (isLoading) return;
query.StartIndex += query.Limit, reloadItems(tabContent)
}
function onPreviousPageClick() {
if (isLoading) return;
query.StartIndex -= query.Limit, reloadItems(tabContent)
}
window.scrollTo(0, 0), updateFilterControls(page);
@ -100,7 +103,11 @@ define(["layoutManager", "playbackManager", "loading", "events", "libraryBrowser
for (elems = tabContent.querySelectorAll(".btnNextPage"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("click", onNextPageClick);
for (elems = tabContent.querySelectorAll(".btnPreviousPage"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("click", onPreviousPageClick);
var itemsContainer = tabContent.querySelector(".itemsContainer");
itemsContainer.innerHTML = html, imageLoader.lazyChildren(itemsContainer), libraryBrowser.saveQueryValues(getSavedQueryKey(), query), loading.hide()
itemsContainer.innerHTML = html;
imageLoader.lazyChildren(itemsContainer);
libraryBrowser.saveQueryValues(getSavedQueryKey(), query);
loading.hide();
isLoading = false;
})
}
@ -109,7 +116,8 @@ define(["layoutManager", "playbackManager", "loading", "events", "libraryBrowser
self.alphaPicker.value(query.NameStartsWithOrGreater)
}
var savedQueryKey, pageData, self = this,
pageSize = 100;
pageSize = 100,
isLoading = false;
self.showFilterMenu = function() {
require(["components/filterdialog/filterdialog"], function(filterDialogFactory) {
var filterDialog = new filterDialogFactory({
@ -179,4 +187,4 @@ define(["layoutManager", "playbackManager", "loading", "events", "libraryBrowser
reloadItems(tabContent), updateFilterControls(tabContent)
}, self.destroy = function() {}
}
});
});

View File

@ -35,13 +35,16 @@ define(["layoutManager", "loading", "events", "libraryBrowser", "imageLoader", "
function reloadItems(page) {
loading.show();
isLoading = true;
var query = getQuery(page);
("albumartists" == self.mode ? ApiClient.getAlbumArtists(ApiClient.getCurrentUserId(), query) : ApiClient.getArtists(ApiClient.getCurrentUserId(), query)).then(function(result) {
function onNextPageClick() {
if (isLoading) return;
query.StartIndex += query.Limit, reloadItems(tabContent)
}
function onPreviousPageClick() {
if (isLoading) return;
query.StartIndex -= query.Limit, reloadItems(tabContent)
}
window.scrollTo(0, 0), updateFilterControls(page);
@ -81,7 +84,11 @@ define(["layoutManager", "loading", "events", "libraryBrowser", "imageLoader", "
for (elems = tabContent.querySelectorAll(".btnNextPage"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("click", onNextPageClick);
for (elems = tabContent.querySelectorAll(".btnPreviousPage"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("click", onPreviousPageClick);
var itemsContainer = tabContent.querySelector(".itemsContainer");
itemsContainer.innerHTML = html, imageLoader.lazyChildren(itemsContainer), libraryBrowser.saveQueryValues(getSavedQueryKey(page), query), loading.hide()
itemsContainer.innerHTML = html;
imageLoader.lazyChildren(itemsContainer);
libraryBrowser.saveQueryValues(getSavedQueryKey(page), query);
loading.hide();
isLoading = false;
})
}
@ -90,7 +97,8 @@ define(["layoutManager", "loading", "events", "libraryBrowser", "imageLoader", "
self.alphaPicker.value(query.NameStartsWithOrGreater)
}
var self = this,
data = {};
data = {},
isLoading = false;
self.showFilterMenu = function() {
require(["components/filterdialog/filterdialog"], function(filterDialogFactory) {
var filterDialog = new filterDialogFactory({
@ -133,4 +141,4 @@ define(["layoutManager", "loading", "events", "libraryBrowser", "imageLoader", "
reloadItems(tabContent), updateFilterControls(tabContent)
}, self.destroy = function() {}
}
});
});

View File

@ -29,13 +29,16 @@ define(["events", "libraryBrowser", "imageLoader", "listView", "loading", "emby-
function reloadItems(page) {
loading.show();
isLoading = true;
var query = getQuery(page);
ApiClient.getItems(Dashboard.getCurrentUserId(), query).then(function(result) {
function onNextPageClick() {
if (isLoading) return;
query.StartIndex += query.Limit, reloadItems(tabContent)
}
function onPreviousPageClick() {
if (isLoading) return;
query.StartIndex -= query.Limit, reloadItems(tabContent)
}
window.scrollTo(0, 0);
@ -61,11 +64,16 @@ define(["events", "libraryBrowser", "imageLoader", "listView", "loading", "emby-
for (elems = tabContent.querySelectorAll(".btnNextPage"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("click", onNextPageClick);
for (elems = tabContent.querySelectorAll(".btnPreviousPage"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("click", onPreviousPageClick);
var itemsContainer = tabContent.querySelector(".itemsContainer");
itemsContainer.innerHTML = html, imageLoader.lazyChildren(itemsContainer), libraryBrowser.saveQueryValues(getSavedQueryKey(page), query), loading.hide()
itemsContainer.innerHTML = html;
imageLoader.lazyChildren(itemsContainer);
libraryBrowser.saveQueryValues(getSavedQueryKey(page), query);
loading.hide();
isLoading = false;
})
}
var self = this,
data = {};
data = {},
isLoading = false;
self.showFilterMenu = function() {
require(["components/filterdialog/filterdialog"], function(filterDialogFactory) {
var filterDialog = new filterDialogFactory({
@ -124,4 +132,4 @@ define(["events", "libraryBrowser", "imageLoader", "listView", "loading", "emby-
reloadItems(tabContent)
}, self.destroy = function() {}
}
});
});

View File

@ -36,14 +36,19 @@ define(["layoutManager", "loading", "events", "libraryBrowser", "imageLoader", "
function reloadItems(page) {
loading.show();
isLoading = true;
var query = getQuery(page);
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then(function(result) {
function onNextPageClick() {
query.StartIndex += query.Limit, reloadItems(tabContent)
if (isLoading) return;
query.StartIndex += query.Limit;
reloadItems(tabContent);
}
function onPreviousPageClick() {
query.StartIndex -= query.Limit, reloadItems(tabContent)
if (isLoading) return;
query.StartIndex -= query.Limit;
reloadItems(tabContent);
}
window.scrollTo(0, 0), updateFilterControls(page);
var html, pagingHtml = libraryBrowser.getQueryPagingHtml({
@ -103,7 +108,11 @@ define(["layoutManager", "loading", "events", "libraryBrowser", "imageLoader", "
for (elems = tabContent.querySelectorAll(".btnNextPage"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("click", onNextPageClick);
for (elems = tabContent.querySelectorAll(".btnPreviousPage"), i = 0, length = elems.length; i < length; i++) elems[i].addEventListener("click", onPreviousPageClick);
var itemsContainer = tabContent.querySelector(".itemsContainer");
itemsContainer.innerHTML = html, imageLoader.lazyChildren(itemsContainer), libraryBrowser.saveQueryValues(getSavedQueryKey(page), query), loading.hide()
itemsContainer.innerHTML = html;
imageLoader.lazyChildren(itemsContainer);
libraryBrowser.saveQueryValues(getSavedQueryKey(page), query);
loading.hide();
isLoading = false;
})
}
@ -113,7 +122,8 @@ define(["layoutManager", "loading", "events", "libraryBrowser", "imageLoader", "
}
var self = this,
pageSize = 100,
data = {};
data = {},
isLoading = false;
self.showFilterMenu = function() {
require(["components/filterdialog/filterdialog"], function(filterDialogFactory) {
var filterDialog = new filterDialogFactory({
@ -183,4 +193,4 @@ define(["layoutManager", "loading", "events", "libraryBrowser", "imageLoader", "
reloadItems(tabContent), updateFilterControls(tabContent)
}, self.destroy = function() {}
}
});
});

View File

@ -37,7 +37,7 @@ define(["loading", "libraryMenu", "emby-linkbutton"], function(loading, libraryM
var userId = params.userId,
currentPassword = view.querySelector("#txtCurrentPassword").value,
newPassword = view.querySelector("#txtNewPassword").value;
if(view.querySelector("#fldCurrentPassword").classList.contains("hide")) {
if (view.querySelector("#fldCurrentPassword").classList.contains("hide")) {
// Firefox does not respect autocomplete=off, so clear it if the field is supposed to be hidden (and blank)
// This should only happen when user.HasConfiguredPassword is false, but this information is not passed on
currentPassword = "";