diff --git a/dashboard-ui/scripts/Itemdetailpage.js b/dashboard-ui/scripts/Itemdetailpage.js
index 0e515a485..02cf34849 100644
--- a/dashboard-ui/scripts/Itemdetailpage.js
+++ b/dashboard-ui/scripts/Itemdetailpage.js
@@ -151,7 +151,7 @@
if (url) {
- var style = useBackgroundColor ? "background-color:" + Dashboard.getMetroColor(item.Id) + ";" : "";
+ var style = useBackgroundColor ? "background-color:" + LibraryBrowser.getMetroColor(item.Id) + ";" : "";
html += "
";
}
@@ -700,7 +700,7 @@
html += '
';
} else {
- var style = "background-color:" + Dashboard.getMetroColor(cast.Name) + ";";
+ var style = "background-color:" + LibraryBrowser.getMetroColor(cast.Name) + ";";
html += '
';
}
diff --git a/dashboard-ui/scripts/indexpage.js b/dashboard-ui/scripts/indexpage.js
index dfd932416..e2ae9d52b 100644
--- a/dashboard-ui/scripts/indexpage.js
+++ b/dashboard-ui/scripts/indexpage.js
@@ -19,7 +19,7 @@
apiClient.getItems(userId, options).done(function (result) {
- $('#divCollections', page).html(Dashboard.getPosterViewHtml({
+ $('#divCollections', page).html(LibraryBrowser.getPosterViewHtml({
items: result.Items,
showTitle: true
}));
diff --git a/dashboard-ui/scripts/itembynamedetailpage.js b/dashboard-ui/scripts/itembynamedetailpage.js
index d810a1fff..86d396fd9 100644
--- a/dashboard-ui/scripts/itembynamedetailpage.js
+++ b/dashboard-ui/scripts/itembynamedetailpage.js
@@ -95,7 +95,7 @@
}
if (url) {
- var style = useBackgroundColor ? "background-color:" + Dashboard.getMetroColor(item.Id) + ";" : "";
+ var style = useBackgroundColor ? "background-color:" + LibraryBrowser.getMetroColor(item.Id) + ";" : "";
html += "
";
}
diff --git a/dashboard-ui/scripts/itemlistpage.js b/dashboard-ui/scripts/itemlistpage.js
index 4d6d4e257..a2b0e827e 100644
--- a/dashboard-ui/scripts/itemlistpage.js
+++ b/dashboard-ui/scripts/itemlistpage.js
@@ -83,7 +83,7 @@
showTitle: query.Recursive
};
- var html = Dashboard.getPosterViewHtml(renderOptions);
+ var html = LibraryBrowser.getPosterViewHtml(renderOptions);
$('#listItems', $.mobile.activePage).html(html);
diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js
index 5f282702b..60075ca7c 100644
--- a/dashboard-ui/scripts/librarybrowser.js
+++ b/dashboard-ui/scripts/librarybrowser.js
@@ -1 +1,124 @@
-
\ No newline at end of file
+var LibraryBrowser = {
+
+ getPosterViewHtml: function (options) {
+
+ var items = options.items;
+
+ var primaryImageAspectRatio = options.useAverageAspectRatio ? LibraryBrowser.getAveragePrimaryImageAspectRatio(items) : null;
+
+ var html = "";
+
+ for (var i = 0, length = items.length; i < length; i++) {
+ var item = items[i];
+
+ var hasPrimaryImage = item.ImageTags && item.ImageTags.Primary;
+
+ var href = item.url || (item.IsFolder ? (item.Id ? "itemList.html?parentId=" + item.Id : "#") : "itemdetails.html?id=" + item.Id);
+
+ var showText = options.showTitle || !hasPrimaryImage || (item.Type !== 'Movie' && item.Type !== 'Series' && item.Type !== 'Season' && item.Type !== 'Trailer');
+
+ var cssClass = showText ? "posterViewItem" : "posterViewItem posterViewItemWithNoText";
+
+ html += "
';
diff --git a/dashboard-ui/scripts/movies.js b/dashboard-ui/scripts/movies.js
index dfa923b24..a3b3dc5df 100644
--- a/dashboard-ui/scripts/movies.js
+++ b/dashboard-ui/scripts/movies.js
@@ -63,7 +63,7 @@
}
else {
- html += '

';
+ html += '

';
}
html += '';
@@ -86,7 +86,7 @@
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) {
- $('#items', page).html(Dashboard.getPosterViewHtml({
+ $('#items', page).html(LibraryBrowser.getPosterViewHtml({
items: result.Items,
useAverageAspectRatio: true
diff --git a/dashboard-ui/scripts/moviesrecommended.js b/dashboard-ui/scripts/moviesrecommended.js
index 7ede94fb5..450f5f883 100644
--- a/dashboard-ui/scripts/moviesrecommended.js
+++ b/dashboard-ui/scripts/moviesrecommended.js
@@ -16,7 +16,7 @@
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
- $('#recentlyAddedItems', page).html(Dashboard.getPosterViewHtml({
+ $('#recentlyAddedItems', page).html(LibraryBrowser.getPosterViewHtml({
items: result.Items,
useAverageAspectRatio: true
}));
@@ -43,7 +43,7 @@
$('#resumableSection', page).hide();
}
- $('#resumableItems', page).html(Dashboard.getPosterViewHtml({
+ $('#resumableItems', page).html(LibraryBrowser.getPosterViewHtml({
items: result.Items,
useAverageAspectRatio: true
}));
diff --git a/dashboard-ui/scripts/plugincatalogpage.js b/dashboard-ui/scripts/plugincatalogpage.js
index 16e6d23c6..32d50dcf4 100644
--- a/dashboard-ui/scripts/plugincatalogpage.js
+++ b/dashboard-ui/scripts/plugincatalogpage.js
@@ -54,7 +54,7 @@
}
}
- var color = plugin.tileColor || Dashboard.getMetroColor(plugin.name);
+ var color = plugin.tileColor || LibraryBrowser.getMetroColor(plugin.name);
html += "
";
diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js
index 7b505a811..ed5de7361 100644
--- a/dashboard-ui/scripts/site.js
+++ b/dashboard-ui/scripts/site.js
@@ -421,105 +421,7 @@ var Dashboard = {
}, 500);
},
- getPosterViewHtml: function (options) {
- var items = options.items;
-
- var primaryImageAspectRatio = options.useAverageAspectRatio ? Dashboard.getAveragePrimaryImageAspectRatio(items) : null;
-
- var html = "";
-
- for (var i = 0, length = items.length; i < length; i++) {
- var item = items[i];
-
- var hasPrimaryImage = item.ImageTags && item.ImageTags.Primary;
-
- var href = item.url || (item.IsFolder ? (item.Id ? "itemList.html?parentId=" + item.Id : "#") : "itemdetails.html?id=" + item.Id);
-
- var showText = options.showTitle || !hasPrimaryImage || (item.Type !== 'Movie' && item.Type !== 'Series' && item.Type !== 'Season' && item.Type !== 'Trailer');
-
- var cssClass = showText ? "posterViewItem" : "posterViewItem posterViewItemWithNoText";
-
- html += "
";
- }
-
- return html;
- },
-
- getAveragePrimaryImageAspectRatio: function (items) {
-
- var values = [];
-
- for (var i = 0, length = items.length; i < length; i++) {
-
- var ratio = items[i].PrimaryImageAspectRatio || 0;
-
- if (!ratio) {
- continue;
- }
-
- values[values.length] = ratio;
- }
-
- if (!values.length) {
- return null;
- }
-
- // Use the median
- values.sort(function (a, b) { return a - b; });
-
- var half = Math.floor(values.length / 2);
-
- if (values.length % 2)
- return values[half];
- else
- return (values[half - 1] + values[half]) / 2.0;
- },
showUserFlyout: function () {
@@ -1149,29 +1051,8 @@ var Dashboard = {
if (title) {
document.title = title;
}
- },
-
- metroColors: ["#6FBD45", "#4BB3DD", "#4164A5", "#E12026", "#800080", "#E1B222", "#008040", "#0094FF", "#FF00C7", "#FF870F", "#7F0037"],
-
- getRandomMetroColor: function () {
-
- var index = Math.floor(Math.random() * (Dashboard.metroColors.length - 1));
-
- return Dashboard.metroColors[index];
- },
-
- getMetroColor: function (str) {
-
- if (str) {
- var char = str.substr(0,1).charCodeAt();
- var index = String(char).substr(char.length,1);
-
- return Dashboard.metroColors[index];
- }else {
- return Dashboard.getRandomMetroColor();
- }
-
}
+
};
diff --git a/dashboard-ui/scripts/tvrecommended.js b/dashboard-ui/scripts/tvrecommended.js
index 795447846..3a02f5ee5 100644
--- a/dashboard-ui/scripts/tvrecommended.js
+++ b/dashboard-ui/scripts/tvrecommended.js
@@ -16,7 +16,7 @@
ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) {
- $('#recentlyAddedItems', page).html(Dashboard.getPosterViewHtml({
+ $('#recentlyAddedItems', page).html(LibraryBrowser.getPosterViewHtml({
items: result.Items,
useAverageAspectRatio: true
}));
@@ -43,7 +43,7 @@
$('#resumableSection', page).hide();
}
- $('#resumableItems', page).html(Dashboard.getPosterViewHtml({
+ $('#resumableItems', page).html(LibraryBrowser.getPosterViewHtml({
items: result.Items,
useAverageAspectRatio: true
}));