diff --git a/src/scripts/librarybrowser.js b/src/scripts/librarybrowser.js
index 5278842d7f..f2edc9030c 100644
--- a/src/scripts/librarybrowser.js
+++ b/src/scripts/librarybrowser.js
@@ -1,101 +1,199 @@
-define(["userSettings"], function(userSettings) {
+define(["userSettings"], function (userSettings) {
"use strict";
+
var libraryBrowser = {
- getSavedQueryKey: function(modifier) {
- return window.location.href.split("#")[0] + (modifier || "")
+ getSavedQueryKey: function (modifier) {
+ return window.location.href.split("#")[0] + (modifier || "");
},
- loadSavedQueryValues: function(key, query) {
+ loadSavedQueryValues: function (key, query) {
var values = userSettings.get(key);
- return values ? (values = JSON.parse(values), Object.assign(query, values)) : query
+
+ if (values) {
+ values = JSON.parse(values);
+ return Object.assign(query, values);
+ }
+
+ return query;
},
- saveQueryValues: function(key, query) {
+ saveQueryValues: function (key, query) {
var values = {};
- query.SortBy && (values.SortBy = query.SortBy), query.SortOrder && (values.SortOrder = query.SortOrder), userSettings.set(key, JSON.stringify(values))
+
+ if (query.SortBy) {
+ values.SortBy = query.SortBy;
+ }
+
+ if (query.SortOrder) {
+ values.SortOrder = query.SortOrder;
+ }
+
+ userSettings.set(key, JSON.stringify(values));
},
- saveViewSetting: function(key, value) {
- userSettings.set(key + "-_view", value)
+ saveViewSetting: function (key, value) {
+ userSettings.set(key + "-_view", value);
},
- getSavedView: function(key) {
- return userSettings.get(key + "-_view")
+ getSavedView: function (key) {
+ return userSettings.get(key + "-_view");
},
- showLayoutMenu: function(button, currentLayout, views) {
- var dispatchEvent = !0;
- views || (dispatchEvent = !1, views = button.getAttribute("data-layouts"), views = views ? views.split(",") : ["List", "Poster", "PosterCard", "Thumb", "ThumbCard"]);
- var menuItems = views.map(function(v) {
+ showLayoutMenu: function (button, currentLayout, views) {
+ var dispatchEvent = true;
+
+ if (!views) {
+ dispatchEvent = false;
+ views = button.getAttribute("data-layouts");
+ views = views ? views.split(",") : ["List", "Poster", "PosterCard", "Thumb", "ThumbCard"];
+ }
+
+ var menuItems = views.map(function (v) {
return {
name: Globalize.translate("Option" + v),
id: v,
selected: currentLayout == v
- }
+ };
});
- require(["actionsheet"], function(actionsheet) {
+
+ require(["actionsheet"], function (actionsheet) {
actionsheet.show({
items: menuItems,
positionTo: button,
- callback: function(id) {
+ callback: function (id) {
button.dispatchEvent(new CustomEvent("layoutchange", {
detail: {
viewStyle: id
},
- bubbles: !0,
- cancelable: !1
- })), dispatchEvent || window.$ && $(button).trigger("layoutchange", [id])
+ bubbles: true,
+ cancelable: false
+ }));
+
+ if (!dispatchEvent) {
+ if (window.$) {
+ $(button).trigger("layoutchange", [id]);
+ }
+ }
}
- })
- })
+ });
+ });
},
- getQueryPagingHtml: function(options) {
- var startIndex = options.startIndex,
- limit = options.limit,
- totalRecordCount = options.totalRecordCount,
- html = "",
- recordsEnd = Math.min(startIndex + limit, totalRecordCount),
- showControls = limit < totalRecordCount;
+ getQueryPagingHtml: function (options) {
+ var startIndex = options.startIndex;
+ var limit = options.limit;
+ var totalRecordCount = options.totalRecordCount;
+ var html = "";
+ var recordsEnd = Math.min(startIndex + limit, totalRecordCount);
+ var showControls = limit < totalRecordCount;
+
if (html += '
', showControls) {
html += '
';
- html += (totalRecordCount ? startIndex + 1 : 0) + "-" + recordsEnd + " of " + totalRecordCount, html += ""
+ html += (totalRecordCount ? startIndex + 1 : 0) + "-" + recordsEnd + " of " + totalRecordCount;
+ html += "";
}
- return (showControls || options.viewButton || options.filterButton || options.sortButton || options.addLayoutButton) && (html += '
', showControls && (html += '', html += ''), options.addLayoutButton && (html += ''), options.sortButton && (html += ''), options.filterButton && (html += ''), html += "
"), html += "
"
+
+ if (showControls || options.viewButton || options.filterButton || options.sortButton || options.addLayoutButton) {
+ html += '';
+
+ if (showControls) {
+ html += '';
+ html += '';
+ }
+
+ if (options.addLayoutButton) {
+ html += '';
+ }
+
+ if (options.sortButton) {
+ html += '';
+ }
+
+ if (options.filterButton) {
+ html += '';
+ }
+
+ html += "
";
+ }
+
+ return html += "";
},
- showSortMenu: function(options) {
- require(["dialogHelper", "emby-radio"], function(dialogHelper) {
+ showSortMenu: function (options) {
+ require(["dialogHelper", "emby-radio"], function (dialogHelper) {
function onSortByChange() {
var newValue = this.value;
+
if (this.checked) {
var changed = options.query.SortBy != newValue;
- options.query.SortBy = newValue.replace("_", ","), options.query.StartIndex = 0, options.callback && changed && options.callback()
+ options.query.SortBy = newValue.replace("_", ",");
+ options.query.StartIndex = 0;
+
+ if (options.callback && changed) {
+ options.callback();
+ }
}
}
function onSortOrderChange() {
var newValue = this.value;
+
if (this.checked) {
var changed = options.query.SortOrder != newValue;
- options.query.SortOrder = newValue, options.query.StartIndex = 0, options.callback && changed && options.callback()
+ options.query.SortOrder = newValue;
+ options.query.StartIndex = 0;
+
+ if (options.callback && changed) {
+ options.callback();
+ }
}
}
+
var dlg = dialogHelper.createDialog({
- removeOnClose: !0,
- modal: !1,
+ removeOnClose: true,
+ modal: false,
entryAnimationDuration: 160,
exitAnimationDuration: 200
});
- dlg.classList.add("ui-body-a"), dlg.classList.add("background-theme-a"), dlg.classList.add("formDialog");
+ dlg.classList.add("ui-body-a");
+ dlg.classList.add("background-theme-a");
+ dlg.classList.add("formDialog");
var html = "";
- html += '', html += '
', html += Globalize.translate("HeaderSortBy"), html += "
";
- var i, length, isChecked;
+ html += '
';
+ html += '
';
+ html += Globalize.translate("HeaderSortBy");
+ html += "
";
+ var i;
+ var length;
+ var isChecked;
+
for (html += "
", i = 0, length = options.items.length; i < length; i++) {
- var option = options.items[i],
- radioValue = option.id.replace(",", "_");
- isChecked = (options.query.SortBy || "").replace(",", "_") == radioValue ? " checked" : "", html += '"
+ var option = options.items[i];
+ var radioValue = option.id.replace(",", "_");
+ isChecked = (options.query.SortBy || "").replace(",", "_") == radioValue ? " checked" : "";
+ html += '";
}
- html += "
", html += '
', html += Globalize.translate("HeaderSortOrder"), html += "
", html += "
", isChecked = "Ascending" == options.query.SortOrder ? " checked" : "", html += '", isChecked = "Descending" == options.query.SortOrder ? " checked" : "", html += '", html += "
", html += "
", dlg.innerHTML = html, dialogHelper.open(dlg);
+
+ html += "
";
+ html += '';
+ html += Globalize.translate("HeaderSortOrder");
+ html += "
";
+ html += "";
+ isChecked = "Ascending" == options.query.SortOrder ? " checked" : "";
+ html += '";
+ isChecked = "Descending" == options.query.SortOrder ? " checked" : "";
+ html += '";
+ html += "
";
+ html += "";
+ dlg.innerHTML = html;
+ dialogHelper.open(dlg);
var sortBys = dlg.querySelectorAll(".menuSortBy");
- for (i = 0, length = sortBys.length; i < length; i++) sortBys[i].addEventListener("change", onSortByChange);
+
+ for (i = 0, length = sortBys.length; i < length; i++) {
+ sortBys[i].addEventListener("change", onSortByChange);
+ }
+
var sortOrders = dlg.querySelectorAll(".menuSortOrder");
- for (i = 0, length = sortOrders.length; i < length; i++) sortOrders[i].addEventListener("change", onSortOrderChange)
- })
+
+ for (i = 0, length = sortOrders.length; i < length; i++) {
+ sortOrders[i].addEventListener("change", onSortOrderChange);
+ }
+ });
}
};
- return window.LibraryBrowser = libraryBrowser, libraryBrowser
-});
\ No newline at end of file
+ window.LibraryBrowser = libraryBrowser;
+ return libraryBrowser;
+});