2015-06-25 14:50:56 -07:00
|
|
|
|
var LibraryBrowser = (function (window, document, $, screen) {
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2014-12-18 21:20:07 -07:00
|
|
|
|
var pageSizeKey = 'pagesize_v4';
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2015-08-24 20:13:04 -07:00
|
|
|
|
var libraryBrowser = {
|
2015-06-30 10:21:20 -07:00
|
|
|
|
getDefaultPageSize: function (key, defaultValue) {
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2015-09-03 18:34:57 -07:00
|
|
|
|
return 100;
|
2015-06-25 14:50:56 -07:00
|
|
|
|
var saved = appStorage.getItem(key || pageSizeKey);
|
2013-05-16 12:00:42 -07:00
|
|
|
|
|
2013-05-15 12:26:52 -07:00
|
|
|
|
if (saved) {
|
|
|
|
|
return parseInt(saved);
|
|
|
|
|
}
|
2013-05-16 12:00:42 -07:00
|
|
|
|
|
2014-09-09 17:28:59 -07:00
|
|
|
|
if (defaultValue) {
|
|
|
|
|
return defaultValue;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-15 16:10:50 -07:00
|
|
|
|
return 100;
|
2013-04-10 12:33:19 -07:00
|
|
|
|
},
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2015-06-30 10:21:20 -07:00
|
|
|
|
getDefaultItemsView: function (view, mobileView) {
|
2014-07-05 12:57:18 -07:00
|
|
|
|
|
2014-08-16 22:38:13 -07:00
|
|
|
|
return $.browser.mobile ? mobileView : view;
|
2014-07-05 12:57:18 -07:00
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
2015-10-14 21:32:10 -07:00
|
|
|
|
getSavedQueryKey: function (modifier) {
|
|
|
|
|
|
|
|
|
|
return getWindowUrl().split('#')[0] + (modifier || '');
|
|
|
|
|
},
|
|
|
|
|
|
2015-06-30 10:21:20 -07:00
|
|
|
|
loadSavedQueryValues: function (key, query) {
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
2015-06-25 14:50:56 -07:00
|
|
|
|
var values = appStorage.getItem(key + '_' + Dashboard.getCurrentUserId());
|
2013-10-16 19:43:55 -07:00
|
|
|
|
|
2014-04-06 10:53:23 -07:00
|
|
|
|
if (values) {
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
2014-04-06 10:53:23 -07:00
|
|
|
|
values = JSON.parse(values);
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
2014-04-06 10:53:23 -07:00
|
|
|
|
return $.extend(query, values);
|
|
|
|
|
}
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
|
|
|
|
return query;
|
|
|
|
|
},
|
|
|
|
|
|
2015-06-30 10:21:20 -07:00
|
|
|
|
saveQueryValues: function (key, query) {
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
|
|
|
|
var values = {};
|
|
|
|
|
|
|
|
|
|
if (query.SortBy) {
|
|
|
|
|
values.SortBy = query.SortBy;
|
|
|
|
|
}
|
|
|
|
|
if (query.SortOrder) {
|
|
|
|
|
values.SortOrder = query.SortOrder;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-02 11:34:08 -07:00
|
|
|
|
try {
|
2015-06-25 14:50:56 -07:00
|
|
|
|
appStorage.setItem(key + '_' + Dashboard.getCurrentUserId(), JSON.stringify(values));
|
2014-07-02 11:34:08 -07:00
|
|
|
|
} catch (e) {
|
2014-07-03 19:22:57 -07:00
|
|
|
|
|
2014-07-02 11:34:08 -07:00
|
|
|
|
}
|
2013-10-12 09:55:58 -07:00
|
|
|
|
},
|
2014-01-14 08:50:39 -07:00
|
|
|
|
|
2015-06-30 10:21:20 -07:00
|
|
|
|
saveViewSetting: function (key, value) {
|
2014-01-14 08:50:39 -07:00
|
|
|
|
|
2014-07-02 11:34:08 -07:00
|
|
|
|
try {
|
2015-06-25 14:50:56 -07:00
|
|
|
|
appStorage.setItem(key + '_' + Dashboard.getCurrentUserId() + '_view', value);
|
2014-07-02 11:34:08 -07:00
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
|
|
}
|
2014-01-13 09:25:18 -07:00
|
|
|
|
},
|
|
|
|
|
|
2015-08-15 11:46:57 -07:00
|
|
|
|
getSavedView: function (key) {
|
|
|
|
|
|
|
|
|
|
var val = appStorage.getItem(key + '_' + Dashboard.getCurrentUserId() + '_view');
|
|
|
|
|
|
|
|
|
|
return val;
|
|
|
|
|
},
|
|
|
|
|
|
2015-06-30 10:21:20 -07:00
|
|
|
|
getSavedViewSetting: function (key) {
|
2014-01-13 09:25:18 -07:00
|
|
|
|
|
|
|
|
|
var deferred = $.Deferred();
|
2015-08-15 11:46:57 -07:00
|
|
|
|
var val = LibraryBrowser.getSavedView(key);
|
2014-01-13 09:25:18 -07:00
|
|
|
|
|
|
|
|
|
deferred.resolveWith(null, [val]);
|
|
|
|
|
return deferred.promise();
|
|
|
|
|
},
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
2015-06-30 10:21:20 -07:00
|
|
|
|
needsRefresh: function (elem) {
|
2015-06-29 22:45:20 -07:00
|
|
|
|
|
2015-06-30 10:21:20 -07:00
|
|
|
|
var last = parseInt(elem.getAttribute('data-lastrefresh') || '0');
|
|
|
|
|
|
|
|
|
|
if (!last) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-06-29 22:45:20 -07:00
|
|
|
|
|
|
|
|
|
if (NavHelper.isBack()) {
|
2015-07-05 11:34:52 -07:00
|
|
|
|
Logger.log('Not refreshing data because IsBack=true');
|
2015-06-29 22:45:20 -07:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var now = new Date().getTime();
|
2015-07-01 22:08:05 -07:00
|
|
|
|
var cacheDuration;
|
|
|
|
|
|
|
|
|
|
if (AppInfo.isNativeApp) {
|
2015-08-15 13:33:53 -07:00
|
|
|
|
cacheDuration = 300000;
|
2015-09-08 07:35:52 -07:00
|
|
|
|
} else if ($.browser.ipad || $.browser.iphone || $.browser.android) {
|
2015-06-30 10:21:20 -07:00
|
|
|
|
cacheDuration = 10000;
|
2015-09-08 07:35:52 -07:00
|
|
|
|
} else {
|
2015-07-10 19:23:28 -07:00
|
|
|
|
cacheDuration = 60000;
|
2015-06-30 10:21:20 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((now - last) < cacheDuration) {
|
2015-07-05 11:34:52 -07:00
|
|
|
|
Logger.log('Not refreshing data due to age');
|
2015-06-29 22:45:20 -07:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
|
2015-06-30 10:21:20 -07:00
|
|
|
|
setLastRefreshed: function (elem) {
|
|
|
|
|
|
2015-06-29 22:45:20 -07:00
|
|
|
|
elem.setAttribute('data-lastrefresh', new Date().getTime());
|
2015-06-30 10:21:20 -07:00
|
|
|
|
elem.classList.add('hasrefreshtime');
|
2015-06-29 22:45:20 -07:00
|
|
|
|
},
|
|
|
|
|
|
2015-09-07 18:00:46 -07:00
|
|
|
|
enableFullPaperTabs: function () {
|
|
|
|
|
return AppInfo.isNativeApp;
|
|
|
|
|
},
|
|
|
|
|
|
2015-09-03 12:27:48 -07:00
|
|
|
|
animatePaperTabs: function () {
|
2015-09-07 18:00:46 -07:00
|
|
|
|
|
|
|
|
|
if (!LibraryBrowser.enableFullPaperTabs()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($.browser.safari) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (typeof ($.browser.androidVersion) == 'number' && !isNaN($.browser.androidVersion)) {
|
2015-09-08 10:07:35 -07:00
|
|
|
|
if ($.browser.androidVersion < 5) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-09-07 18:00:46 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-08 10:07:35 -07:00
|
|
|
|
return false;
|
2015-09-03 12:27:48 -07:00
|
|
|
|
},
|
|
|
|
|
|
2015-09-23 19:31:40 -07:00
|
|
|
|
allowSwipe: function (target) {
|
2015-07-01 08:47:41 -07:00
|
|
|
|
|
2015-07-13 14:26:11 -07:00
|
|
|
|
function allowSwipeOn(elem) {
|
|
|
|
|
|
|
|
|
|
if (elem.tagName == 'PAPER-SLIDER') {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (elem.classList) {
|
|
|
|
|
return !elem.classList.contains('hiddenScrollX') && !elem.classList.contains('smoothScrollX');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-23 19:31:40 -07:00
|
|
|
|
var parent = target;
|
|
|
|
|
while (parent != null) {
|
|
|
|
|
if (!allowSwipeOn(parent)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
parent = parent.parentNode;
|
|
|
|
|
}
|
2015-07-01 08:47:41 -07:00
|
|
|
|
|
2015-09-23 19:31:40 -07:00
|
|
|
|
return true;
|
|
|
|
|
},
|
2015-07-01 08:47:41 -07:00
|
|
|
|
|
2015-09-23 19:31:40 -07:00
|
|
|
|
configureSwipeTabs: function (ownerpage, tabs, pages) {
|
2015-07-01 08:47:41 -07:00
|
|
|
|
|
2015-09-23 19:31:40 -07:00
|
|
|
|
if (LibraryBrowser.animatePaperTabs()) {
|
|
|
|
|
// Safari doesn't handle the horizontal swiping very well
|
|
|
|
|
pages.entryAnimation = 'slide-from-right-animation';
|
|
|
|
|
pages.exitAnimation = 'slide-left-animation';
|
2015-07-01 08:47:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-23 19:31:40 -07:00
|
|
|
|
var pageCount = pages.querySelectorAll('neon-animatable').length;
|
|
|
|
|
|
2015-09-01 12:18:25 -07:00
|
|
|
|
require(['hammer'], function (Hammer) {
|
|
|
|
|
|
|
|
|
|
var hammertime = new Hammer(pages);
|
|
|
|
|
hammertime.get('swipe').set({ direction: Hammer.DIRECTION_HORIZONTAL });
|
|
|
|
|
|
|
|
|
|
hammertime.on('swipeleft', function (e) {
|
2015-09-23 19:31:40 -07:00
|
|
|
|
if (LibraryBrowser.allowSwipe(e.target)) {
|
2015-09-01 12:18:25 -07:00
|
|
|
|
var selected = parseInt(pages.selected || '0');
|
|
|
|
|
if (selected < (pageCount - 1)) {
|
2015-09-07 18:00:46 -07:00
|
|
|
|
if (LibraryBrowser.animatePaperTabs()) {
|
|
|
|
|
pages.entryAnimation = 'slide-from-right-animation';
|
|
|
|
|
pages.exitAnimation = 'slide-left-animation';
|
|
|
|
|
}
|
2015-09-01 12:18:25 -07:00
|
|
|
|
tabs.selectNext();
|
|
|
|
|
}
|
2015-07-01 08:47:41 -07:00
|
|
|
|
}
|
2015-09-01 12:18:25 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
hammertime.on('swiperight', function (e) {
|
2015-09-23 19:31:40 -07:00
|
|
|
|
if (LibraryBrowser.allowSwipe(e.target)) {
|
2015-09-01 12:18:25 -07:00
|
|
|
|
var selected = parseInt(pages.selected || '0');
|
|
|
|
|
if (selected > 0) {
|
2015-09-07 18:00:46 -07:00
|
|
|
|
if (LibraryBrowser.animatePaperTabs()) {
|
|
|
|
|
pages.entryAnimation = 'slide-from-left-animation';
|
|
|
|
|
pages.exitAnimation = 'slide-right-animation';
|
|
|
|
|
}
|
2015-09-01 12:18:25 -07:00
|
|
|
|
tabs.selectPrevious();
|
|
|
|
|
}
|
2015-07-01 08:47:41 -07:00
|
|
|
|
}
|
2015-09-01 12:18:25 -07:00
|
|
|
|
});
|
2015-07-01 08:47:41 -07:00
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
navigateOnLibraryTabSelect: function () {
|
|
|
|
|
return !LibraryBrowser.enableFullPaperTabs();
|
|
|
|
|
},
|
|
|
|
|
|
2015-09-01 08:31:50 -07:00
|
|
|
|
configurePaperLibraryTabs: function (ownerpage, tabs, pages, baseUrl) {
|
|
|
|
|
|
|
|
|
|
// Causing iron-select to not fire in IE and safari
|
|
|
|
|
if ($.browser.chrome) {
|
|
|
|
|
tabs.noink = true;
|
|
|
|
|
}
|
2015-07-01 08:47:41 -07:00
|
|
|
|
|
|
|
|
|
if (LibraryBrowser.enableFullPaperTabs()) {
|
|
|
|
|
|
2015-09-03 12:27:48 -07:00
|
|
|
|
if ($.browser.safari) {
|
2015-09-08 10:07:35 -07:00
|
|
|
|
tabs.noSlide = true;
|
2015-07-01 22:08:05 -07:00
|
|
|
|
tabs.noBar = true;
|
2015-09-08 07:35:52 -07:00
|
|
|
|
} else {
|
2015-07-01 22:08:05 -07:00
|
|
|
|
LibraryBrowser.configureSwipeTabs(ownerpage, tabs, pages);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('.libraryViewNav', ownerpage).addClass('paperLibraryViewNav').removeClass('libraryViewNavWithMinHeight');
|
2015-07-01 08:47:41 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
tabs.noSlide = true;
|
|
|
|
|
tabs.noBar = true;
|
|
|
|
|
|
2015-08-24 20:13:04 -07:00
|
|
|
|
var legacyTabs = $('.legacyTabs', ownerpage);
|
2015-07-01 08:47:41 -07:00
|
|
|
|
|
|
|
|
|
$(pages).on('iron-select', function (e) {
|
|
|
|
|
|
|
|
|
|
var selected = this.selected;
|
|
|
|
|
$('a', legacyTabs).removeClass('ui-btn-active')[selected].classList.add('ui-btn-active');
|
|
|
|
|
});
|
2015-07-01 22:08:05 -07:00
|
|
|
|
|
|
|
|
|
$('.libraryViewNav', ownerpage).removeClass('libraryViewNavWithMinHeight');
|
2015-07-01 08:47:41 -07:00
|
|
|
|
}
|
2015-07-01 22:08:05 -07:00
|
|
|
|
|
2015-09-25 19:31:13 -07:00
|
|
|
|
$(ownerpage).on('pagebeforeshow', LibraryBrowser.onTabbedpagebeforeshow);
|
2015-07-12 12:33:00 -07:00
|
|
|
|
|
2015-09-01 08:31:50 -07:00
|
|
|
|
pages.addEventListener('iron-select', function () {
|
2015-07-12 12:33:00 -07:00
|
|
|
|
// When transition animations are used, add a content loading delay to allow the animations to finish
|
|
|
|
|
// Otherwise with both operations happening at the same time, it can cause the animation to not run at full speed.
|
|
|
|
|
var pgs = this;
|
2015-09-08 10:07:35 -07:00
|
|
|
|
var delay = LibraryBrowser.animatePaperTabs() || !tabs.noSlide ? 500 : 0;
|
2015-09-03 12:27:48 -07:00
|
|
|
|
|
2015-07-12 12:33:00 -07:00
|
|
|
|
setTimeout(function () {
|
|
|
|
|
$(pgs).trigger('tabchange');
|
|
|
|
|
}, delay);
|
|
|
|
|
});
|
2015-09-01 08:31:50 -07:00
|
|
|
|
|
2015-09-21 11:39:18 -07:00
|
|
|
|
function fadeOutLeft(elem, iterations) {
|
2015-09-21 08:43:10 -07:00
|
|
|
|
var keyframes = [{ opacity: '1', transform: 'none', offset: 0 },
|
2015-09-21 11:39:18 -07:00
|
|
|
|
{ opacity: '0', transform: 'translate3d(-100%, 0, 0)', offset: 1 }];
|
2015-09-21 18:05:33 -07:00
|
|
|
|
var timing = { duration: 400, iterations: iterations };
|
2015-09-21 08:43:10 -07:00
|
|
|
|
return elem.animate(keyframes, timing);
|
|
|
|
|
}
|
2015-09-01 08:40:36 -07:00
|
|
|
|
if (!LibraryBrowser.navigateOnLibraryTabSelect()) {
|
|
|
|
|
tabs.addEventListener('iron-select', function () {
|
2015-09-21 08:43:10 -07:00
|
|
|
|
|
2015-09-21 18:05:33 -07:00
|
|
|
|
var animateTab = !$.browser.safari;
|
2015-09-22 09:06:27 -07:00
|
|
|
|
animateTab = false;
|
2015-09-21 08:43:10 -07:00
|
|
|
|
var selected = pages.selected;
|
2015-09-21 18:05:33 -07:00
|
|
|
|
if (selected != null && animateTab) {
|
2015-09-21 08:43:10 -07:00
|
|
|
|
var newValue = this.selected;
|
2015-09-21 11:39:18 -07:00
|
|
|
|
var currentTab = pages.querySelectorAll('.pageTabContent')[selected];
|
|
|
|
|
|
|
|
|
|
fadeOutLeft(currentTab, 1).onfinish = function () {
|
2015-09-21 08:43:10 -07:00
|
|
|
|
pages.selected = newValue;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
pages.selected = this.selected;
|
|
|
|
|
}
|
2015-09-01 08:40:36 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2015-07-01 22:08:05 -07:00
|
|
|
|
},
|
|
|
|
|
|
2015-08-31 23:22:46 -07:00
|
|
|
|
onTabbedpagebeforeshow: function () {
|
2015-07-01 22:08:05 -07:00
|
|
|
|
|
2015-07-20 11:32:55 -07:00
|
|
|
|
var page = this;
|
2015-09-01 07:01:59 -07:00
|
|
|
|
var delay = 0;
|
2015-09-01 08:31:50 -07:00
|
|
|
|
var isFirstLoad = false;
|
2015-09-01 07:01:59 -07:00
|
|
|
|
|
|
|
|
|
if (!page.getAttribute('data-firstload')) {
|
|
|
|
|
delay = 300;
|
2015-09-01 08:31:50 -07:00
|
|
|
|
isFirstLoad = true;
|
2015-09-01 07:01:59 -07:00
|
|
|
|
page.setAttribute('data-firstload', '1');
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 08:31:50 -07:00
|
|
|
|
if (delay) {
|
|
|
|
|
setTimeout(function () {
|
2015-09-01 07:01:59 -07:00
|
|
|
|
|
2015-09-01 08:31:50 -07:00
|
|
|
|
LibraryBrowser.onTabbedpagebeforeshowInternal(page, isFirstLoad);
|
|
|
|
|
}, delay);
|
|
|
|
|
} else {
|
|
|
|
|
LibraryBrowser.onTabbedpagebeforeshowInternal(page, isFirstLoad);
|
|
|
|
|
}
|
|
|
|
|
},
|
2015-09-01 07:01:59 -07:00
|
|
|
|
|
2015-09-01 08:31:50 -07:00
|
|
|
|
onTabbedpagebeforeshowInternal: function (page, isFirstLoad) {
|
2015-07-01 22:08:05 -07:00
|
|
|
|
|
2015-09-01 08:31:50 -07:00
|
|
|
|
if (isFirstLoad) {
|
2015-07-05 11:34:52 -07:00
|
|
|
|
|
|
|
|
|
Logger.log('selected tab is null, checking query string');
|
|
|
|
|
|
2015-09-01 08:31:50 -07:00
|
|
|
|
var selected = parseInt(getParameterByName('tab') || '0');
|
2015-07-05 11:34:52 -07:00
|
|
|
|
|
|
|
|
|
Logger.log('selected tab will be ' + selected);
|
|
|
|
|
|
2015-08-25 08:08:04 -07:00
|
|
|
|
if (LibraryBrowser.enableFullPaperTabs()) {
|
2015-09-01 08:31:50 -07:00
|
|
|
|
|
2015-09-07 21:22:38 -07:00
|
|
|
|
var tabs = page.querySelector('paper-tabs');
|
|
|
|
|
if (tabs.selected) {
|
|
|
|
|
// showTab was called
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
tabs.selected = selected;
|
2015-09-01 08:31:50 -07:00
|
|
|
|
|
2015-08-25 08:08:04 -07:00
|
|
|
|
} else {
|
2015-07-05 11:34:52 -07:00
|
|
|
|
page.querySelector('neon-animated-pages').selected = selected;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
2015-09-01 08:40:36 -07:00
|
|
|
|
|
2015-08-27 21:19:08 -07:00
|
|
|
|
var pages = page.querySelector('neon-animated-pages');
|
2015-09-01 08:40:36 -07:00
|
|
|
|
|
|
|
|
|
// Go back to the first tab
|
|
|
|
|
if (LibraryBrowser.enableFullPaperTabs() && !NavHelper.isBack()) {
|
2015-08-27 21:19:08 -07:00
|
|
|
|
if (pages.selected) {
|
|
|
|
|
|
|
|
|
|
var entryAnimation = pages.entryAnimation;
|
|
|
|
|
var exitAnimation = pages.exitAnimation;
|
|
|
|
|
pages.entryAnimation = null;
|
|
|
|
|
pages.exitAnimation = null;
|
|
|
|
|
|
2015-09-01 08:31:50 -07:00
|
|
|
|
page.querySelector('paper-tabs').selected = 0;
|
2015-08-27 21:19:08 -07:00
|
|
|
|
|
|
|
|
|
pages.entryAnimation = entryAnimation;
|
|
|
|
|
pages.exitAnimation = exitAnimation;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Events.trigger(pages, 'tabchange');
|
2015-07-01 22:08:05 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
showTab: function (url, index) {
|
|
|
|
|
|
|
|
|
|
if (!LibraryBrowser.enableFullPaperTabs()) {
|
|
|
|
|
|
|
|
|
|
if (index) {
|
|
|
|
|
url = replaceQueryString(url, 'tab', index);
|
|
|
|
|
}
|
|
|
|
|
Dashboard.navigate(url);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-28 10:39:52 -07:00
|
|
|
|
var afterNavigate = function () {
|
2015-08-28 08:02:22 -07:00
|
|
|
|
if (getWindowUrl().toLowerCase().indexOf(url.toLowerCase()) != -1) {
|
|
|
|
|
|
|
|
|
|
var pages = this.querySelector('neon-animated-pages');
|
|
|
|
|
|
|
|
|
|
if (pages) {
|
|
|
|
|
|
|
|
|
|
var entryAnimation = pages.entryAnimation;
|
|
|
|
|
var exitAnimation = pages.exitAnimation;
|
|
|
|
|
pages.entryAnimation = null;
|
|
|
|
|
pages.exitAnimation = null;
|
|
|
|
|
|
|
|
|
|
var tabs = this.querySelector('paper-tabs');
|
|
|
|
|
|
2015-09-24 10:08:10 -07:00
|
|
|
|
// For some reason the live tv page will not switch tabs in IE and safari
|
|
|
|
|
var delay = $.browser.chrome ? 0 : 100;
|
|
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
var noSlide = tabs.noSlide;
|
|
|
|
|
tabs.noSlide = true;
|
|
|
|
|
tabs.selected = index;
|
|
|
|
|
|
|
|
|
|
pages.entryAnimation = entryAnimation;
|
|
|
|
|
pages.exitAnimation = exitAnimation;
|
|
|
|
|
tabs.noSlide = noSlide;
|
|
|
|
|
|
|
|
|
|
}, delay);
|
2015-08-28 08:02:22 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-28 10:39:52 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (getWindowUrl().toLowerCase().indexOf(url.toLowerCase()) != -1) {
|
2015-08-28 08:02:22 -07:00
|
|
|
|
|
2015-08-28 10:39:52 -07:00
|
|
|
|
afterNavigate.call($($.mobile.activePage)[0]);
|
|
|
|
|
} else {
|
2015-09-25 19:31:13 -07:00
|
|
|
|
$(document).one('pagebeforeshow', '.page', afterNavigate);
|
2015-08-28 10:39:52 -07:00
|
|
|
|
Dashboard.navigate(url);
|
|
|
|
|
}
|
2015-08-28 08:02:22 -07:00
|
|
|
|
},
|
|
|
|
|
|
2015-07-01 22:08:05 -07:00
|
|
|
|
canShare: function (item, user) {
|
|
|
|
|
|
|
|
|
|
return user.Policy.EnablePublicSharing;
|
2015-07-01 08:47:41 -07:00
|
|
|
|
},
|
|
|
|
|
|
2013-10-24 10:49:24 -07:00
|
|
|
|
getDateParamValue: function (date) {
|
|
|
|
|
|
|
|
|
|
function formatDigit(i) {
|
|
|
|
|
return i < 10 ? "0" + i : i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var d = date;
|
|
|
|
|
|
|
|
|
|
return "" + d.getFullYear() + formatDigit(d.getMonth() + 1) + formatDigit(d.getDate()) + formatDigit(d.getHours()) + formatDigit(d.getMinutes()) + formatDigit(d.getSeconds());
|
|
|
|
|
},
|
|
|
|
|
|
2015-01-29 23:32:20 -07:00
|
|
|
|
playAllFromHere: function (fn, index) {
|
2014-08-21 08:55:35 -07:00
|
|
|
|
|
2015-01-29 23:32:20 -07:00
|
|
|
|
fn(index, 100, "MediaSources,Chapters").done(function (result) {
|
2014-08-21 08:55:35 -07:00
|
|
|
|
|
|
|
|
|
MediaController.play({
|
|
|
|
|
items: result.Items
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
queueAllFromHere: function (query, index) {
|
|
|
|
|
|
2015-01-29 23:32:20 -07:00
|
|
|
|
fn(index, 100, "MediaSources,Chapters").done(function (result) {
|
2014-08-21 08:55:35 -07:00
|
|
|
|
|
|
|
|
|
MediaController.queue({
|
|
|
|
|
items: result.Items
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2013-09-10 11:56:00 -07:00
|
|
|
|
getItemCountsHtml: function (options, item) {
|
|
|
|
|
|
2013-09-10 13:23:41 -07:00
|
|
|
|
var counts = [];
|
|
|
|
|
|
2013-09-10 11:56:00 -07:00
|
|
|
|
var childText;
|
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
if (item.Type == 'Playlist') {
|
|
|
|
|
|
|
|
|
|
childText = '';
|
|
|
|
|
|
|
|
|
|
if (item.CumulativeRunTimeTicks) {
|
|
|
|
|
|
|
|
|
|
var minutes = item.CumulativeRunTimeTicks / 600000000;
|
|
|
|
|
|
|
|
|
|
minutes = minutes || 1;
|
|
|
|
|
|
2014-09-14 17:39:24 -07:00
|
|
|
|
childText += Globalize.translate('ValueMinutes', Math.round(minutes));
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
2014-09-14 17:39:24 -07:00
|
|
|
|
childText += Globalize.translate('ValueMinutes', 0);
|
2014-08-02 19:16:37 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
counts.push(childText);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (options.context == "movies") {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
|
|
|
|
if (item.MovieCount) {
|
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
childText = item.MovieCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneMovie') :
|
|
|
|
|
Globalize.translate('ValueMovieCount', item.MovieCount);
|
2013-09-10 13:23:41 -07:00
|
|
|
|
|
|
|
|
|
counts.push(childText);
|
2013-09-10 11:56:00 -07:00
|
|
|
|
}
|
2013-09-10 13:23:41 -07:00
|
|
|
|
if (item.TrailerCount) {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
childText = item.TrailerCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneTrailer') :
|
|
|
|
|
Globalize.translate('ValueTrailerCount', item.TrailerCount);
|
2013-09-10 13:23:41 -07:00
|
|
|
|
|
|
|
|
|
counts.push(childText);
|
2013-09-10 11:56:00 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else if (options.context == "tv") {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
|
|
|
|
if (item.SeriesCount) {
|
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
childText = item.SeriesCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneSeries') :
|
|
|
|
|
Globalize.translate('ValueSeriesCount', item.SeriesCount);
|
2013-09-10 13:23:41 -07:00
|
|
|
|
|
|
|
|
|
counts.push(childText);
|
2013-09-10 11:56:00 -07:00
|
|
|
|
}
|
2013-09-10 13:23:41 -07:00
|
|
|
|
if (item.EpisodeCount) {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
childText = item.EpisodeCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneEpisode') :
|
|
|
|
|
Globalize.translate('ValueEpisodeCount', item.EpisodeCount);
|
2013-09-10 13:23:41 -07:00
|
|
|
|
|
|
|
|
|
counts.push(childText);
|
2013-09-10 11:56:00 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else if (options.context == "games") {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
|
|
|
|
if (item.GameCount) {
|
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
childText = item.GameCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneGame') :
|
|
|
|
|
Globalize.translate('ValueGameCount', item.GameCount);
|
2013-09-10 13:23:41 -07:00
|
|
|
|
|
|
|
|
|
counts.push(childText);
|
2013-09-10 11:56:00 -07:00
|
|
|
|
}
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else if (options.context == "music") {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2013-09-18 16:33:27 -07:00
|
|
|
|
if (item.AlbumCount) {
|
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
childText = item.AlbumCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneAlbum') :
|
|
|
|
|
Globalize.translate('ValueAlbumCount', item.AlbumCount);
|
2013-09-18 16:33:27 -07:00
|
|
|
|
|
|
|
|
|
counts.push(childText);
|
|
|
|
|
}
|
2013-09-10 11:56:00 -07:00
|
|
|
|
if (item.SongCount) {
|
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
childText = item.SongCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneSong') :
|
|
|
|
|
Globalize.translate('ValueSongCount', item.SongCount);
|
2013-09-10 13:23:41 -07:00
|
|
|
|
|
|
|
|
|
counts.push(childText);
|
2013-09-10 11:56:00 -07:00
|
|
|
|
}
|
2013-09-10 13:23:41 -07:00
|
|
|
|
if (item.MusicVideoCount) {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
childText = item.MusicVideoCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneMusicVideo') :
|
|
|
|
|
Globalize.translate('ValueMusicVideoCount', item.MusicVideoCount);
|
2013-09-10 13:23:41 -07:00
|
|
|
|
|
|
|
|
|
counts.push(childText);
|
2013-09-10 11:56:00 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-29 19:41:22 -07:00
|
|
|
|
return counts.join(' • ');
|
2013-09-10 11:56:00 -07:00
|
|
|
|
},
|
|
|
|
|
|
2015-03-13 10:25:28 -07:00
|
|
|
|
getArtistLinksHtml: function (artists, cssClass) {
|
2015-03-13 08:54:20 -07:00
|
|
|
|
|
|
|
|
|
var html = [];
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = artists.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var artist = artists[i];
|
|
|
|
|
|
|
|
|
|
var css = cssClass ? (' class="' + cssClass + '"') : '';
|
2015-08-20 20:21:27 -07:00
|
|
|
|
html.push('<a' + css + ' href="itemdetails.html?id=' + artist.Id + '">' + artist.Name + '</a>');
|
2015-03-13 08:54:20 -07:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html = html.join(' / ');
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
},
|
|
|
|
|
|
2015-06-02 10:46:44 -07:00
|
|
|
|
playInExternalPlayer: function (id) {
|
|
|
|
|
|
|
|
|
|
Dashboard.loadExternalPlayer().done(function () {
|
2015-05-25 10:32:22 -07:00
|
|
|
|
ExternalPlayer.showMenu(id);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2015-06-19 15:01:47 -07:00
|
|
|
|
showPlayMenu: function (positionTo, itemId, itemType, isFolder, mediaType, resumePositionTicks) {
|
2013-05-23 18:47:07 -07:00
|
|
|
|
|
2015-05-25 10:32:22 -07:00
|
|
|
|
var externalPlayers = AppSettings.enableExternalPlayers();
|
2014-09-15 20:33:30 -07:00
|
|
|
|
|
2014-03-29 11:20:42 -07:00
|
|
|
|
if (!resumePositionTicks && mediaType != "Audio" && !isFolder) {
|
2014-09-15 20:33:30 -07:00
|
|
|
|
|
2015-05-25 10:32:22 -07:00
|
|
|
|
if (!externalPlayers || mediaType != "Video") {
|
2014-09-15 20:33:30 -07:00
|
|
|
|
MediaController.play(itemId);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-04-30 10:21:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-19 15:01:47 -07:00
|
|
|
|
var menuItems = [];
|
2013-04-30 10:21:21 -07:00
|
|
|
|
|
2015-06-19 15:01:47 -07:00
|
|
|
|
if (resumePositionTicks) {
|
|
|
|
|
menuItems.push({
|
|
|
|
|
name: Globalize.translate('ButtonResume'),
|
|
|
|
|
id: 'resume',
|
|
|
|
|
ironIcon: 'play-arrow'
|
|
|
|
|
});
|
2014-09-15 20:33:30 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-19 15:01:47 -07:00
|
|
|
|
menuItems.push({
|
|
|
|
|
name: Globalize.translate('ButtonPlay'),
|
|
|
|
|
id: 'play',
|
|
|
|
|
ironIcon: 'play-arrow'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!isFolder && externalPlayers && mediaType != "Audio") {
|
|
|
|
|
menuItems.push({
|
|
|
|
|
name: Globalize.translate('ButtonPlayExternalPlayer'),
|
|
|
|
|
id: 'externalplayer',
|
|
|
|
|
ironIcon: 'airplay'
|
|
|
|
|
});
|
2013-06-07 09:06:32 -07:00
|
|
|
|
}
|
2013-04-30 10:21:21 -07:00
|
|
|
|
|
2014-07-15 12:16:16 -07:00
|
|
|
|
if (MediaController.canQueueMediaType(mediaType, itemType)) {
|
2015-06-19 15:01:47 -07:00
|
|
|
|
menuItems.push({
|
|
|
|
|
name: Globalize.translate('ButtonQueue'),
|
|
|
|
|
id: 'queue',
|
|
|
|
|
ironIcon: 'playlist-add'
|
|
|
|
|
});
|
2013-04-30 10:21:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-28 12:35:30 -07:00
|
|
|
|
if (itemType == "Audio" || itemType == "MusicAlbum" || itemType == "MusicArtist" || itemType == "MusicGenre") {
|
2015-06-19 15:01:47 -07:00
|
|
|
|
menuItems.push({
|
|
|
|
|
name: Globalize.translate('ButtonInstantMix'),
|
|
|
|
|
id: 'instantmix',
|
|
|
|
|
ironIcon: 'shuffle'
|
|
|
|
|
});
|
2014-06-28 12:35:30 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isFolder || itemType == "MusicArtist" || itemType == "MusicGenre") {
|
2015-06-19 15:01:47 -07:00
|
|
|
|
menuItems.push({
|
|
|
|
|
name: Globalize.translate('ButtonShuffle'),
|
|
|
|
|
id: 'shuffle',
|
|
|
|
|
ironIcon: 'shuffle'
|
|
|
|
|
});
|
2014-08-07 21:36:51 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-19 15:01:47 -07:00
|
|
|
|
require(['actionsheet'], function () {
|
2013-04-30 10:21:21 -07:00
|
|
|
|
|
2015-06-19 15:01:47 -07:00
|
|
|
|
ActionSheetElement.show({
|
|
|
|
|
items: menuItems,
|
|
|
|
|
positionTo: positionTo,
|
|
|
|
|
callback: function (id) {
|
2013-04-30 10:21:21 -07:00
|
|
|
|
|
2015-06-19 15:01:47 -07:00
|
|
|
|
switch (id) {
|
2013-04-30 10:21:21 -07:00
|
|
|
|
|
2015-06-19 15:01:47 -07:00
|
|
|
|
case 'play':
|
|
|
|
|
MediaController.play(itemId);
|
|
|
|
|
break;
|
|
|
|
|
case 'externalplayer':
|
|
|
|
|
LibraryBrowser.playInExternalPlayer(itemId);
|
|
|
|
|
break;
|
|
|
|
|
case 'resume':
|
|
|
|
|
MediaController.play({
|
|
|
|
|
ids: [itemId],
|
|
|
|
|
startPositionTicks: resumePositionTicks
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case 'queue':
|
|
|
|
|
MediaController.queue(itemId);
|
|
|
|
|
break;
|
|
|
|
|
case 'instantmix':
|
|
|
|
|
MediaController.instantMix(itemId);
|
|
|
|
|
break;
|
|
|
|
|
case 'shuffle':
|
|
|
|
|
MediaController.shuffle(itemId);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-04-30 10:21:21 -07:00
|
|
|
|
|
2015-06-19 15:01:47 -07:00
|
|
|
|
});
|
2013-04-30 10:21:21 -07:00
|
|
|
|
},
|
|
|
|
|
|
2014-08-07 21:36:51 -07:00
|
|
|
|
getMoreCommands: function (item, user) {
|
|
|
|
|
|
|
|
|
|
var commands = [];
|
|
|
|
|
|
2015-10-13 22:46:11 -07:00
|
|
|
|
if (LibraryBrowser.supportsAddingToCollection(item)) {
|
2015-02-02 21:54:52 -07:00
|
|
|
|
commands.push('addtocollection');
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-07 21:36:51 -07:00
|
|
|
|
if (PlaylistManager.supportsPlaylists(item)) {
|
|
|
|
|
commands.push('playlist');
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-06 16:58:46 -07:00
|
|
|
|
if (item.Type == 'BoxSet' || item.Type == 'Playlist') {
|
|
|
|
|
commands.push('delete');
|
|
|
|
|
}
|
2015-02-05 22:39:07 -07:00
|
|
|
|
else if (item.CanDelete) {
|
2014-10-06 16:58:46 -07:00
|
|
|
|
commands.push('delete');
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-19 23:06:27 -07:00
|
|
|
|
if (user.Policy.IsAdministrator) {
|
2015-09-16 21:19:15 -07:00
|
|
|
|
|
2015-08-24 13:37:34 -07:00
|
|
|
|
commands.push('edit');
|
2015-09-16 21:19:15 -07:00
|
|
|
|
|
2015-09-17 09:04:04 -07:00
|
|
|
|
if (item.MediaType == 'Video' && item.Type != 'TvChannel' && item.Type != 'Program' && item.LocationType != 'Virtual') {
|
|
|
|
|
commands.push('editsubtitles');
|
2015-09-16 21:19:15 -07:00
|
|
|
|
}
|
2015-09-17 09:04:04 -07:00
|
|
|
|
commands.push('editimages');
|
2014-08-07 21:36:51 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-06 16:58:46 -07:00
|
|
|
|
commands.push('refresh');
|
|
|
|
|
|
2015-02-11 09:23:24 -07:00
|
|
|
|
if (SyncManager.isAvailable(item, user)) {
|
2014-12-10 23:20:28 -07:00
|
|
|
|
commands.push('sync');
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-05 22:39:07 -07:00
|
|
|
|
if (item.CanDownload) {
|
|
|
|
|
commands.push('download');
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-05 09:58:27 -07:00
|
|
|
|
if (LibraryBrowser.canShare(item, user)) {
|
|
|
|
|
commands.push('share');
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-04 09:15:08 -07:00
|
|
|
|
if (item.Type == "Movie" ||
|
|
|
|
|
item.Type == "Trailer" ||
|
|
|
|
|
item.Type == "Series" ||
|
|
|
|
|
item.Type == "Game" ||
|
|
|
|
|
item.Type == "BoxSet" ||
|
|
|
|
|
item.Type == "Person" ||
|
|
|
|
|
item.Type == "Book" ||
|
|
|
|
|
item.Type == "MusicAlbum" ||
|
|
|
|
|
item.Type == "MusicArtist") {
|
|
|
|
|
|
|
|
|
|
commands.push('identify');
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-07 21:36:51 -07:00
|
|
|
|
return commands;
|
|
|
|
|
},
|
|
|
|
|
|
2014-10-06 16:58:46 -07:00
|
|
|
|
refreshItem: function (itemId) {
|
|
|
|
|
|
|
|
|
|
ApiClient.refreshItem(itemId, {
|
|
|
|
|
|
|
|
|
|
Recursive: true,
|
|
|
|
|
ImageRefreshMode: 'FullRefresh',
|
|
|
|
|
MetadataRefreshMode: 'FullRefresh',
|
|
|
|
|
ReplaceAllImages: false,
|
|
|
|
|
ReplaceAllMetadata: true
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dashboard.alert(Globalize.translate('MessageRefreshQueued'));
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
deleteItem: function (itemId) {
|
|
|
|
|
|
|
|
|
|
// The timeout allows the flyout to close
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
|
2015-06-19 15:01:47 -07:00
|
|
|
|
var msg = Globalize.translate('ConfirmDeleteItem');
|
2014-10-06 16:58:46 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.confirm(msg, Globalize.translate('HeaderDeleteItem'), function (result) {
|
|
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
|
ApiClient.deleteItem(itemId);
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
Events.trigger(LibraryBrowser, 'itemdeleting', [itemId]);
|
2014-10-06 16:58:46 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
2014-12-26 10:45:06 -07:00
|
|
|
|
|
2014-10-06 16:58:46 -07:00
|
|
|
|
}, 250);
|
|
|
|
|
},
|
|
|
|
|
|
2015-09-17 09:04:04 -07:00
|
|
|
|
editImages: function (itemId) {
|
|
|
|
|
|
|
|
|
|
require(['components/imageeditor/imageeditor'], function () {
|
|
|
|
|
|
|
|
|
|
ImageEditor.show(itemId);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2015-09-16 18:33:46 -07:00
|
|
|
|
editSubtitles: function (itemId) {
|
|
|
|
|
|
2015-09-17 09:04:04 -07:00
|
|
|
|
require(['components/subtitleeditor/subtitleeditor'], function () {
|
2015-09-16 18:33:46 -07:00
|
|
|
|
|
|
|
|
|
SubtitleEditor.show(itemId);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2015-09-19 19:06:56 -07:00
|
|
|
|
editMetadata: function (itemId) {
|
|
|
|
|
|
|
|
|
|
Dashboard.navigate('edititemmetadata.html?id=' + itemId);
|
|
|
|
|
return;
|
|
|
|
|
require(['components/metadataeditor/metadataeditor'], function () {
|
|
|
|
|
|
|
|
|
|
MetadataEditor.show(itemId);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2014-08-07 21:36:51 -07:00
|
|
|
|
showMoreCommands: function (positionTo, itemId, commands) {
|
|
|
|
|
|
2015-06-19 11:34:21 -07:00
|
|
|
|
var items = [];
|
2014-08-07 21:36:51 -07:00
|
|
|
|
|
2015-02-02 21:54:52 -07:00
|
|
|
|
if (commands.indexOf('addtocollection') != -1) {
|
2015-06-19 11:34:21 -07:00
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('ButtonAddToCollection'),
|
2015-06-19 21:48:45 -07:00
|
|
|
|
id: 'addtocollection',
|
|
|
|
|
ironIcon: 'add'
|
2015-06-19 11:34:21 -07:00
|
|
|
|
});
|
2015-02-02 21:54:52 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-07 21:36:51 -07:00
|
|
|
|
if (commands.indexOf('playlist') != -1) {
|
2015-06-19 11:34:21 -07:00
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('ButtonAddToPlaylist'),
|
2015-06-19 21:48:45 -07:00
|
|
|
|
id: 'playlist',
|
|
|
|
|
ironIcon: 'playlist-add'
|
2015-06-19 11:34:21 -07:00
|
|
|
|
});
|
2014-08-07 21:36:51 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-05 22:39:07 -07:00
|
|
|
|
if (commands.indexOf('delete') != -1) {
|
2015-06-19 11:34:21 -07:00
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('ButtonDelete'),
|
2015-06-19 21:48:45 -07:00
|
|
|
|
id: 'delete',
|
|
|
|
|
ironIcon: 'delete'
|
2015-06-19 11:34:21 -07:00
|
|
|
|
});
|
2014-08-07 21:36:51 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
if (commands.indexOf('download') != -1) {
|
2015-06-19 11:34:21 -07:00
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('ButtonDownload'),
|
2015-06-19 21:48:45 -07:00
|
|
|
|
id: 'download',
|
|
|
|
|
ironIcon: 'file-download'
|
2015-02-05 22:39:07 -07:00
|
|
|
|
});
|
2014-10-06 16:58:46 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-05 22:39:07 -07:00
|
|
|
|
if (commands.indexOf('edit') != -1) {
|
2015-06-19 11:34:21 -07:00
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('ButtonEdit'),
|
2015-06-19 21:48:45 -07:00
|
|
|
|
id: 'edit',
|
|
|
|
|
ironIcon: 'mode-edit'
|
2015-06-19 11:34:21 -07:00
|
|
|
|
});
|
2015-02-05 22:39:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-17 09:04:04 -07:00
|
|
|
|
if (commands.indexOf('editimages') != -1) {
|
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('ButtonEditImages'),
|
|
|
|
|
id: 'editimages',
|
|
|
|
|
ironIcon: 'photo'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (commands.indexOf('editsubtitles') != -1) {
|
2015-09-16 18:33:46 -07:00
|
|
|
|
items.push({
|
2015-09-16 19:33:45 -07:00
|
|
|
|
name: Globalize.translate('ButtonEditSubtitles'),
|
2015-09-17 09:04:04 -07:00
|
|
|
|
id: 'editsubtitles',
|
2015-09-16 18:33:46 -07:00
|
|
|
|
ironIcon: 'closed-caption'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-04 09:15:08 -07:00
|
|
|
|
if (commands.indexOf('identify') != -1) {
|
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('ButtonIdentify'),
|
|
|
|
|
id: 'identify',
|
|
|
|
|
ironIcon: 'info'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-05 22:39:07 -07:00
|
|
|
|
if (commands.indexOf('refresh') != -1) {
|
2015-06-19 11:34:21 -07:00
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('ButtonRefresh'),
|
2015-06-19 21:48:45 -07:00
|
|
|
|
id: 'refresh',
|
|
|
|
|
ironIcon: 'refresh'
|
2015-06-19 11:34:21 -07:00
|
|
|
|
});
|
2014-10-06 16:58:46 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-05 09:58:27 -07:00
|
|
|
|
if (commands.indexOf('share') != -1) {
|
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('ButtonShare'),
|
|
|
|
|
id: 'share',
|
|
|
|
|
ironIcon: 'share'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-19 11:34:21 -07:00
|
|
|
|
require(['actionsheet'], function () {
|
|
|
|
|
|
|
|
|
|
ActionSheetElement.show({
|
|
|
|
|
items: items,
|
2015-06-25 14:50:56 -07:00
|
|
|
|
positionTo: positionTo,
|
2015-06-19 11:34:21 -07:00
|
|
|
|
callback: function (id) {
|
|
|
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
|
|
2015-09-05 09:58:27 -07:00
|
|
|
|
case 'share':
|
|
|
|
|
require(['sharingmanager'], function () {
|
|
|
|
|
SharingManager.showMenu(Dashboard.getCurrentUserId(), itemId);
|
|
|
|
|
});
|
|
|
|
|
break;
|
2015-06-19 11:34:21 -07:00
|
|
|
|
case 'addtocollection':
|
2015-10-13 22:46:11 -07:00
|
|
|
|
require(['collectioneditor'], function (collectioneditor) {
|
|
|
|
|
|
|
|
|
|
new collectioneditor().show([itemId]);
|
|
|
|
|
});
|
2015-06-19 11:34:21 -07:00
|
|
|
|
break;
|
2015-06-19 15:01:47 -07:00
|
|
|
|
case 'playlist':
|
|
|
|
|
PlaylistManager.showPanel([itemId]);
|
2015-06-19 11:34:21 -07:00
|
|
|
|
break;
|
|
|
|
|
case 'delete':
|
|
|
|
|
LibraryBrowser.deleteItem(itemId);
|
|
|
|
|
break;
|
|
|
|
|
case 'download':
|
|
|
|
|
{
|
|
|
|
|
var downloadHref = ApiClient.getUrl("Items/" + itemId + "/Download", {
|
|
|
|
|
api_key: ApiClient.accessToken()
|
|
|
|
|
});
|
|
|
|
|
window.location.href = downloadHref;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 'edit':
|
2015-09-19 19:06:56 -07:00
|
|
|
|
LibraryBrowser.editMetadata(itemId);
|
2015-06-19 11:34:21 -07:00
|
|
|
|
break;
|
2015-09-17 09:04:04 -07:00
|
|
|
|
case 'editsubtitles':
|
2015-09-16 18:33:46 -07:00
|
|
|
|
LibraryBrowser.editSubtitles(itemId);
|
|
|
|
|
break;
|
2015-09-17 09:04:04 -07:00
|
|
|
|
case 'editimages':
|
|
|
|
|
LibraryBrowser.editImages(itemId);
|
|
|
|
|
break;
|
2015-10-04 09:15:08 -07:00
|
|
|
|
case 'identify':
|
|
|
|
|
LibraryBrowser.identifyItem(itemId);
|
|
|
|
|
break;
|
2015-06-19 11:34:21 -07:00
|
|
|
|
case 'refresh':
|
|
|
|
|
ApiClient.refreshItem(itemId, {
|
|
|
|
|
|
|
|
|
|
Recursive: true,
|
|
|
|
|
ImageRefreshMode: 'FullRefresh',
|
|
|
|
|
MetadataRefreshMode: 'FullRefresh',
|
|
|
|
|
ReplaceAllImages: false,
|
|
|
|
|
ReplaceAllMetadata: true
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-10-06 16:58:46 -07:00
|
|
|
|
});
|
2015-06-19 11:34:21 -07:00
|
|
|
|
|
2014-10-06 16:58:46 -07:00
|
|
|
|
});
|
2014-08-07 21:36:51 -07:00
|
|
|
|
},
|
|
|
|
|
|
2015-10-04 09:15:08 -07:00
|
|
|
|
identifyItem: function (itemId) {
|
|
|
|
|
|
|
|
|
|
require(['components/itemidentifier/itemidentifier'], function () {
|
|
|
|
|
|
|
|
|
|
ItemIdentifier.show(itemId);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2014-07-16 20:17:14 -07:00
|
|
|
|
getHref: function (item, context, topParentId) {
|
2013-04-30 10:21:21 -07:00
|
|
|
|
|
2014-08-14 06:24:30 -07:00
|
|
|
|
var href = LibraryBrowser.getHrefInternal(item, context);
|
2014-05-29 12:34:20 -07:00
|
|
|
|
|
2015-09-21 18:05:33 -07:00
|
|
|
|
if (context == 'tv') {
|
|
|
|
|
if (!topParentId) {
|
|
|
|
|
topParentId = LibraryMenu.getTopParentId();
|
|
|
|
|
}
|
2014-07-16 20:17:14 -07:00
|
|
|
|
|
2015-09-21 18:05:33 -07:00
|
|
|
|
if (topParentId) {
|
|
|
|
|
href += href.indexOf('?') == -1 ? "?topParentId=" : "&topParentId=";
|
|
|
|
|
href += topParentId;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-16 20:17:14 -07:00
|
|
|
|
|
2014-05-29 12:34:20 -07:00
|
|
|
|
return href;
|
|
|
|
|
},
|
|
|
|
|
|
2014-08-14 06:24:30 -07:00
|
|
|
|
getHrefInternal: function (item, context) {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2014-04-07 21:17:18 -07:00
|
|
|
|
if (!item) {
|
|
|
|
|
throw new Error('item cannot be null');
|
|
|
|
|
}
|
2014-05-04 17:46:52 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
if (item.url) {
|
|
|
|
|
return item.url;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-27 06:05:33 -07:00
|
|
|
|
// Handle search hints
|
|
|
|
|
var id = item.Id || item.ItemId;
|
|
|
|
|
|
2014-06-07 12:46:24 -07:00
|
|
|
|
if (item.CollectionType == 'livetv') {
|
2015-08-02 16:56:21 -07:00
|
|
|
|
return 'livetv.html';
|
2014-06-07 12:46:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.CollectionType == 'channels') {
|
2015-05-07 07:04:10 -07:00
|
|
|
|
|
2015-07-18 11:07:03 -07:00
|
|
|
|
return 'channels.html';
|
2014-06-07 12:46:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-14 06:24:30 -07:00
|
|
|
|
if (context != 'folders') {
|
|
|
|
|
if (item.CollectionType == 'movies') {
|
2015-08-15 11:30:52 -07:00
|
|
|
|
return 'movies.html?topParentId=' + item.Id;
|
2014-08-14 06:24:30 -07:00
|
|
|
|
}
|
2014-06-07 12:46:24 -07:00
|
|
|
|
|
2014-08-14 06:24:30 -07:00
|
|
|
|
if (item.CollectionType == 'boxsets') {
|
|
|
|
|
return 'collections.html?topParentId=' + item.Id;
|
|
|
|
|
}
|
2014-05-06 19:28:19 -07:00
|
|
|
|
|
2014-08-14 06:24:30 -07:00
|
|
|
|
if (item.CollectionType == 'tvshows') {
|
2015-09-21 11:39:18 -07:00
|
|
|
|
return 'tv.html?topParentId=' + item.Id;
|
2014-08-14 06:24:30 -07:00
|
|
|
|
}
|
2014-05-06 19:28:19 -07:00
|
|
|
|
|
2014-08-14 06:24:30 -07:00
|
|
|
|
if (item.CollectionType == 'music') {
|
2015-09-03 12:04:29 -07:00
|
|
|
|
return 'music.html?topParentId=' + item.Id;
|
2014-08-14 06:24:30 -07:00
|
|
|
|
}
|
2014-05-06 19:28:19 -07:00
|
|
|
|
|
2014-08-14 06:24:30 -07:00
|
|
|
|
if (item.CollectionType == 'games') {
|
|
|
|
|
return 'gamesrecommended.html?topParentId=' + item.Id;
|
|
|
|
|
}
|
|
|
|
|
if (item.CollectionType == 'playlists') {
|
|
|
|
|
return 'playlists.html?topParentId=' + item.Id;
|
|
|
|
|
}
|
2015-04-19 08:54:20 -07:00
|
|
|
|
if (item.CollectionType == 'photos') {
|
|
|
|
|
return 'photos.html?topParentId=' + item.Id;
|
|
|
|
|
}
|
2014-08-02 19:16:37 -07:00
|
|
|
|
}
|
2014-05-06 19:28:19 -07:00
|
|
|
|
if (item.Type == 'CollectionFolder') {
|
|
|
|
|
return 'itemlist.html?topParentId=' + item.Id + '&parentid=' + item.Id;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-26 11:17:38 -07:00
|
|
|
|
if (item.Type == "PhotoAlbum") {
|
|
|
|
|
return "itemlist.html?context=photos&parentId=" + id;
|
2015-04-19 08:54:20 -07:00
|
|
|
|
}
|
2014-08-02 19:16:37 -07:00
|
|
|
|
if (item.Type == "Playlist") {
|
2015-08-19 21:06:49 -07:00
|
|
|
|
return "itemdetails.html?id=" + id;
|
2014-08-02 19:16:37 -07:00
|
|
|
|
}
|
2014-03-17 18:45:41 -07:00
|
|
|
|
if (item.Type == "TvChannel") {
|
2015-08-17 21:22:45 -07:00
|
|
|
|
return "itemdetails.html?id=" + id;
|
2013-11-24 16:37:38 -07:00
|
|
|
|
}
|
2014-03-18 10:05:57 -07:00
|
|
|
|
if (item.Type == "Channel") {
|
|
|
|
|
return "channelitems.html?id=" + id;
|
|
|
|
|
}
|
2014-05-23 07:09:58 -07:00
|
|
|
|
if (item.Type == "ChannelFolderItem") {
|
|
|
|
|
return "channelitems.html?id=" + item.ChannelId + '&folderId=' + item.Id;
|
2014-05-04 17:46:52 -07:00
|
|
|
|
}
|
2014-01-02 21:58:22 -07:00
|
|
|
|
if (item.Type == "Program") {
|
2015-07-28 20:42:03 -07:00
|
|
|
|
return "itemdetails.html?id=" + id;
|
2014-01-02 21:58:22 -07:00
|
|
|
|
}
|
2015-08-20 20:21:27 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
if (item.Type == "BoxSet") {
|
2015-08-20 20:21:27 -07:00
|
|
|
|
return "itemdetails.html?id=" + id;
|
2013-04-10 22:27:27 -07:00
|
|
|
|
}
|
2013-04-22 08:10:54 -07:00
|
|
|
|
if (item.Type == "MusicAlbum") {
|
2015-08-20 20:21:27 -07:00
|
|
|
|
return "itemdetails.html?id=" + id;
|
2013-04-22 08:10:54 -07:00
|
|
|
|
}
|
2013-09-21 14:00:04 -07:00
|
|
|
|
if (item.Type == "GameSystem") {
|
2015-08-20 20:21:27 -07:00
|
|
|
|
return "itemdetails.html?id=" + id;
|
2013-04-28 11:42:54 -07:00
|
|
|
|
}
|
2013-04-11 15:09:08 -07:00
|
|
|
|
if (item.Type == "Genre") {
|
2015-08-20 20:21:27 -07:00
|
|
|
|
return "itemdetails.html?id=" + id;
|
2013-04-11 15:09:08 -07:00
|
|
|
|
}
|
2013-06-10 20:31:00 -07:00
|
|
|
|
if (item.Type == "MusicGenre") {
|
2015-08-20 20:21:27 -07:00
|
|
|
|
return "itemdetails.html?id=" + id;
|
2013-06-10 20:31:00 -07:00
|
|
|
|
}
|
2013-07-01 10:17:33 -07:00
|
|
|
|
if (item.Type == "GameGenre") {
|
2015-08-20 20:21:27 -07:00
|
|
|
|
return "itemdetails.html?id=" + id;
|
2013-07-01 10:17:33 -07:00
|
|
|
|
}
|
2013-04-11 15:09:08 -07:00
|
|
|
|
if (item.Type == "Studio") {
|
2015-08-20 20:21:27 -07:00
|
|
|
|
return "itemdetails.html?id=" + id;
|
2013-04-11 15:09:08 -07:00
|
|
|
|
}
|
|
|
|
|
if (item.Type == "Person") {
|
2015-08-20 20:21:27 -07:00
|
|
|
|
return "itemdetails.html?id=" + id;
|
2013-04-11 15:09:08 -07:00
|
|
|
|
}
|
2013-12-28 16:09:24 -07:00
|
|
|
|
if (item.Type == "Recording") {
|
2015-07-29 10:16:00 -07:00
|
|
|
|
return "itemdetails.html?id=" + id;
|
2013-12-28 16:09:24 -07:00
|
|
|
|
}
|
2013-11-26 09:22:11 -07:00
|
|
|
|
|
2013-11-21 13:48:26 -07:00
|
|
|
|
if (item.Type == "MusicArtist") {
|
2015-08-20 20:21:27 -07:00
|
|
|
|
return "itemdetails.html?id=" + id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var contextSuffix = context ? ('&context=' + context) : '';
|
|
|
|
|
|
|
|
|
|
if (item.Type == "Series" || item.Type == "Season" || item.Type == "Episode") {
|
2015-08-18 21:08:03 -07:00
|
|
|
|
return "itemdetails.html?id=" + id + contextSuffix;
|
2013-04-21 21:38:03 -07:00
|
|
|
|
}
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2014-05-29 12:34:20 -07:00
|
|
|
|
if (item.IsFolder) {
|
|
|
|
|
return id ? "itemlist.html?parentId=" + id : "#";
|
|
|
|
|
}
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2015-08-20 20:21:27 -07:00
|
|
|
|
return "itemdetails.html?id=" + id;
|
2013-04-10 22:27:27 -07:00
|
|
|
|
},
|
2013-04-12 07:13:47 -07:00
|
|
|
|
|
2013-04-21 21:38:03 -07:00
|
|
|
|
getImageUrl: function (item, type, index, options) {
|
2013-04-11 20:50:47 -07:00
|
|
|
|
|
|
|
|
|
options = options || {};
|
2013-04-21 21:38:03 -07:00
|
|
|
|
options.type = type;
|
|
|
|
|
options.index = index;
|
|
|
|
|
|
|
|
|
|
if (type == 'Backdrop') {
|
|
|
|
|
options.tag = item.BackdropImageTags[index];
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else if (type == 'Screenshot') {
|
2013-05-07 11:57:16 -07:00
|
|
|
|
options.tag = item.ScreenshotImageTags[index];
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else if (type == 'Primary') {
|
2013-05-07 11:57:16 -07:00
|
|
|
|
options.tag = item.PrimaryImageTag || item.ImageTags[type];
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else {
|
2013-04-21 21:38:03 -07:00
|
|
|
|
options.tag = item.ImageTags[type];
|
|
|
|
|
}
|
2013-04-12 07:13:47 -07:00
|
|
|
|
|
2013-04-27 06:05:33 -07:00
|
|
|
|
// For search hints
|
2014-05-23 16:58:28 -07:00
|
|
|
|
return ApiClient.getScaledImageUrl(item.Id || item.ItemId, options);
|
2013-04-11 20:50:47 -07:00
|
|
|
|
|
|
|
|
|
},
|
2014-07-05 14:15:25 -07:00
|
|
|
|
|
2014-08-16 22:38:13 -07:00
|
|
|
|
getListViewIndex: function (item, options) {
|
2014-07-05 12:57:18 -07:00
|
|
|
|
|
2014-08-16 22:38:13 -07:00
|
|
|
|
if (options.index == 'disc') {
|
|
|
|
|
|
2014-09-14 17:39:24 -07:00
|
|
|
|
return item.ParentIndexNumber == null ? '' : Globalize.translate('ValueDiscNumber', item.ParentIndexNumber);
|
2014-08-16 22:38:13 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sortBy = (options.sortBy || '').toLowerCase();
|
2014-07-05 14:15:25 -07:00
|
|
|
|
var code, name;
|
|
|
|
|
|
2014-07-05 12:57:18 -07:00
|
|
|
|
if (sortBy.indexOf('sortname') == 0) {
|
|
|
|
|
|
|
|
|
|
if (item.Type == 'Episode') return '';
|
2014-07-05 14:15:25 -07:00
|
|
|
|
|
2014-07-05 12:57:18 -07:00
|
|
|
|
// SortName
|
2015-01-27 15:45:59 -07:00
|
|
|
|
name = (item.SortName || item.Name || '?')[0].toUpperCase();
|
2014-07-05 14:15:25 -07:00
|
|
|
|
|
|
|
|
|
code = name.charCodeAt(0);
|
|
|
|
|
if (code < 65 || code > 90) {
|
2014-07-05 12:57:18 -07:00
|
|
|
|
return '#';
|
|
|
|
|
}
|
2014-07-05 14:15:25 -07:00
|
|
|
|
|
2014-07-05 12:57:18 -07:00
|
|
|
|
return name.toUpperCase();
|
|
|
|
|
}
|
|
|
|
|
if (sortBy.indexOf('officialrating') == 0) {
|
|
|
|
|
|
2014-09-14 17:39:24 -07:00
|
|
|
|
return item.OfficialRating || Globalize.translate('HeaderUnrated');
|
2014-07-05 12:57:18 -07:00
|
|
|
|
}
|
|
|
|
|
if (sortBy.indexOf('communityrating') == 0) {
|
|
|
|
|
|
|
|
|
|
if (item.CommunityRating == null) {
|
2014-09-14 17:39:24 -07:00
|
|
|
|
return Globalize.translate('HeaderUnrated');
|
2014-07-05 12:57:18 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Math.floor(item.CommunityRating);
|
|
|
|
|
}
|
|
|
|
|
if (sortBy.indexOf('criticrating') == 0) {
|
|
|
|
|
|
|
|
|
|
if (item.CriticRating == null) {
|
2014-09-14 17:39:24 -07:00
|
|
|
|
return Globalize.translate('HeaderUnrated');
|
2014-07-05 12:57:18 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Math.floor(item.CriticRating);
|
|
|
|
|
}
|
|
|
|
|
if (sortBy.indexOf('metascore') == 0) {
|
|
|
|
|
|
|
|
|
|
if (item.Metascore == null) {
|
2014-09-14 17:39:24 -07:00
|
|
|
|
return Globalize.translate('HeaderUnrated');
|
2014-07-05 12:57:18 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Math.floor(item.Metascore);
|
|
|
|
|
}
|
|
|
|
|
if (sortBy.indexOf('albumartist') == 0) {
|
|
|
|
|
|
|
|
|
|
// SortName
|
|
|
|
|
if (!item.AlbumArtist) return '';
|
|
|
|
|
|
2014-07-05 14:15:25 -07:00
|
|
|
|
name = item.AlbumArtist[0].toUpperCase();
|
|
|
|
|
|
|
|
|
|
code = name.charCodeAt(0);
|
|
|
|
|
if (code < 65 || code > 90) {
|
2014-07-05 12:57:18 -07:00
|
|
|
|
return '#';
|
|
|
|
|
}
|
2014-07-05 14:15:25 -07:00
|
|
|
|
|
|
|
|
|
return name.toUpperCase();
|
2014-07-05 12:57:18 -07:00
|
|
|
|
}
|
|
|
|
|
return '';
|
|
|
|
|
},
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
getUserDataCssClass: function (key) {
|
2014-09-29 21:47:30 -07:00
|
|
|
|
|
2014-10-04 11:05:24 -07:00
|
|
|
|
if (!key) return '';
|
|
|
|
|
|
2014-09-01 13:10:54 -07:00
|
|
|
|
return 'libraryItemUserData' + key.replace(new RegExp(' ', 'g'), '');
|
2014-07-26 10:30:15 -07:00
|
|
|
|
},
|
|
|
|
|
|
2014-07-05 09:51:39 -07:00
|
|
|
|
getListViewHtml: function (options) {
|
|
|
|
|
|
|
|
|
|
var outerHtml = "";
|
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
if (options.title) {
|
2015-09-04 10:34:50 -07:00
|
|
|
|
outerHtml += '<h1>';
|
2014-08-02 19:16:37 -07:00
|
|
|
|
outerHtml += options.title;
|
2015-09-04 10:34:50 -07:00
|
|
|
|
outerHtml += '</h1>';
|
2014-08-02 19:16:37 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-04 10:34:50 -07:00
|
|
|
|
outerHtml += '<div class="paperList itemsListview">';
|
|
|
|
|
|
2014-07-05 12:57:18 -07:00
|
|
|
|
var index = 0;
|
|
|
|
|
var groupTitle = '';
|
|
|
|
|
|
2014-07-05 09:51:39 -07:00
|
|
|
|
outerHtml += options.items.map(function (item) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
if (options.showIndex !== false) {
|
2014-08-16 22:38:13 -07:00
|
|
|
|
|
|
|
|
|
var itemGroupTitle = LibraryBrowser.getListViewIndex(item, options);
|
2014-07-05 14:15:25 -07:00
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
if (itemGroupTitle != groupTitle) {
|
2014-07-05 12:57:18 -07:00
|
|
|
|
|
2015-09-04 10:34:50 -07:00
|
|
|
|
outerHtml += '</div>';
|
|
|
|
|
|
2015-09-14 12:47:03 -07:00
|
|
|
|
if (index == 0) {
|
|
|
|
|
html += '<h1>';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
html += '<h1 style="margin-top:2em;">';
|
|
|
|
|
}
|
2014-08-02 19:16:37 -07:00
|
|
|
|
html += itemGroupTitle;
|
2015-09-04 10:34:50 -07:00
|
|
|
|
html += '</h1>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="paperList itemsListview">';
|
2014-07-05 12:57:18 -07:00
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
groupTitle = itemGroupTitle;
|
|
|
|
|
}
|
2014-07-05 12:57:18 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-29 23:32:20 -07:00
|
|
|
|
var dataAttributes = LibraryBrowser.getItemDataAttributes(item, options, index);
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-09-04 10:34:50 -07:00
|
|
|
|
var cssClass = 'listItem';
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2014-07-05 09:51:39 -07:00
|
|
|
|
var href = LibraryBrowser.getHref(item, options.context);
|
2015-09-04 10:34:50 -07:00
|
|
|
|
html += '<paper-icon-item class="' + cssClass + '"' + dataAttributes + ' data-itemid="' + item.Id + '" data-playlistitemid="' + (item.PlaylistItemId || '') + '" data-href="' + href + '" data-icon="false">';
|
2014-07-05 09:51:39 -07:00
|
|
|
|
|
|
|
|
|
var imgUrl;
|
|
|
|
|
|
2014-08-15 09:35:41 -07:00
|
|
|
|
var downloadWidth = options.smallIcon ? 70 : 80;
|
|
|
|
|
// Scaling 400w episode images to 80 doesn't turn out very well
|
|
|
|
|
var minScale = item.Type == 'Episode' || item.Type == 'Game' || options.smallIcon ? 2 : 1.5;
|
2014-07-05 09:51:39 -07:00
|
|
|
|
|
2014-08-15 09:35:41 -07:00
|
|
|
|
if (item.ImageTags.Primary) {
|
2014-07-05 12:57:18 -07:00
|
|
|
|
|
2014-07-05 09:51:39 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
|
2014-08-15 09:35:41 -07:00
|
|
|
|
width: downloadWidth,
|
2014-07-05 09:51:39 -07:00
|
|
|
|
tag: item.ImageTags.Primary,
|
|
|
|
|
type: "Primary",
|
2014-07-07 18:41:03 -07:00
|
|
|
|
index: 0,
|
|
|
|
|
minScale: minScale
|
2014-07-05 09:51:39 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
2014-08-05 16:59:24 -07:00
|
|
|
|
else if (item.AlbumId && item.AlbumPrimaryImageTag) {
|
|
|
|
|
|
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.AlbumId, {
|
|
|
|
|
type: "Primary",
|
2014-08-15 09:35:41 -07:00
|
|
|
|
width: downloadWidth,
|
|
|
|
|
tag: item.AlbumPrimaryImageTag,
|
|
|
|
|
minScale: minScale
|
2014-08-05 16:59:24 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (item.AlbumId && item.SeriesPrimaryImageTag) {
|
|
|
|
|
|
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.SeriesId, {
|
|
|
|
|
type: "Primary",
|
2014-08-15 09:35:41 -07:00
|
|
|
|
width: downloadWidth,
|
|
|
|
|
tag: item.SeriesPrimaryImageTag,
|
|
|
|
|
minScale: minScale
|
2014-08-05 16:59:24 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (item.ParentPrimaryImageTag) {
|
|
|
|
|
|
|
|
|
|
imgUrl = ApiClient.getImageUrl(item.ParentPrimaryImageItemId, {
|
|
|
|
|
type: "Primary",
|
2014-08-15 09:35:41 -07:00
|
|
|
|
width: downloadWidth,
|
|
|
|
|
tag: item.ParentPrimaryImageTag,
|
|
|
|
|
minScale: minScale
|
2014-08-05 16:59:24 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 09:51:39 -07:00
|
|
|
|
if (imgUrl) {
|
2015-01-22 23:15:15 -07:00
|
|
|
|
var minLazyIndex = 16;
|
2014-08-15 09:35:41 -07:00
|
|
|
|
if (options.smallIcon) {
|
2015-01-22 23:15:15 -07:00
|
|
|
|
if (index < minLazyIndex) {
|
2015-09-04 13:32:20 -07:00
|
|
|
|
html += '<div class="listviewImage small" style="background-image:url(\'' + imgUrl + '\');" item-icon></div>';
|
2014-08-15 09:35:41 -07:00
|
|
|
|
} else {
|
2015-09-04 13:32:20 -07:00
|
|
|
|
html += '<div class="listviewImage lazy small" data-src="' + imgUrl + '" item-icon></div>';
|
2014-08-15 09:35:41 -07:00
|
|
|
|
}
|
2014-07-05 12:57:18 -07:00
|
|
|
|
} else {
|
2015-01-22 23:15:15 -07:00
|
|
|
|
if (index < minLazyIndex) {
|
2015-09-04 13:32:20 -07:00
|
|
|
|
html += '<div class="listviewImage" style="background-image:url(\'' + imgUrl + '\');" item-icon></div>';
|
2014-08-15 09:35:41 -07:00
|
|
|
|
} else {
|
2015-09-04 13:32:20 -07:00
|
|
|
|
html += '<div class="listviewImage lazy" data-src="' + imgUrl + '" item-icon></div>';
|
2014-08-15 09:35:41 -07:00
|
|
|
|
}
|
2014-07-05 12:57:18 -07:00
|
|
|
|
}
|
2015-09-04 13:32:20 -07:00
|
|
|
|
} else {
|
|
|
|
|
if (options.smallIcon) {
|
|
|
|
|
html += '<div class="listviewImage small" item-icon></div>';
|
|
|
|
|
} else {
|
|
|
|
|
html += '<div class="listviewImage" item-icon></div>';
|
|
|
|
|
}
|
2014-07-05 09:51:39 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 14:15:25 -07:00
|
|
|
|
var textlines = [];
|
|
|
|
|
|
|
|
|
|
if (item.Type == 'Episode') {
|
2014-09-14 17:39:24 -07:00
|
|
|
|
textlines.push(item.SeriesName || ' ');
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else if (item.Type == 'MusicAlbum') {
|
2014-09-14 17:39:24 -07:00
|
|
|
|
textlines.push(item.AlbumArtist || ' ');
|
2014-07-05 14:15:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-17 11:12:17 -07:00
|
|
|
|
var displayName = LibraryBrowser.getPosterViewDisplayName(item);
|
|
|
|
|
|
|
|
|
|
if (options.showIndexNumber && item.IndexNumber != null) {
|
|
|
|
|
displayName = item.IndexNumber + ". " + displayName;
|
|
|
|
|
}
|
|
|
|
|
textlines.push(displayName);
|
2014-07-05 14:15:25 -07:00
|
|
|
|
|
2014-08-15 09:35:41 -07:00
|
|
|
|
if (item.Type == 'Audio') {
|
2015-03-13 10:25:28 -07:00
|
|
|
|
textlines.push(item.ArtistItems.map(function (a) {
|
2015-06-05 07:27:01 -07:00
|
|
|
|
return a.Name;
|
2015-03-13 10:25:28 -07:00
|
|
|
|
|
|
|
|
|
}).join(', ') || ' ');
|
2014-08-15 09:35:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 14:15:25 -07:00
|
|
|
|
if (item.Type == 'Game') {
|
2014-09-14 17:39:24 -07:00
|
|
|
|
textlines.push(item.GameSystem || ' ');
|
2014-07-05 14:15:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
else if (item.Type == 'MusicGenre') {
|
2014-09-14 17:39:24 -07:00
|
|
|
|
textlines.push(' ');
|
2014-08-02 19:16:37 -07:00
|
|
|
|
}
|
|
|
|
|
else if (item.Type == 'MusicArtist') {
|
2014-09-14 17:39:24 -07:00
|
|
|
|
textlines.push(' ');
|
2014-08-02 19:16:37 -07:00
|
|
|
|
}
|
2015-08-30 22:30:38 -07:00
|
|
|
|
else if (item.Type == 'TvChannel') {
|
2015-09-01 07:01:59 -07:00
|
|
|
|
|
2015-08-30 22:30:38 -07:00
|
|
|
|
if (item.CurrentProgram) {
|
|
|
|
|
textlines.push(LibraryBrowser.getPosterViewDisplayName(item.CurrentProgram));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-08-02 19:16:37 -07:00
|
|
|
|
else {
|
|
|
|
|
textlines.push(LibraryBrowser.getMiscInfoHtml(item));
|
|
|
|
|
}
|
2014-07-05 14:15:25 -07:00
|
|
|
|
|
2015-09-04 10:34:50 -07:00
|
|
|
|
if (textlines.length > 2) {
|
|
|
|
|
html += '<paper-item-body three-line>';
|
|
|
|
|
} else {
|
|
|
|
|
html += '<paper-item-body two-line>';
|
2014-07-05 14:15:25 -07:00
|
|
|
|
}
|
2014-07-05 09:51:39 -07:00
|
|
|
|
|
2015-09-04 10:34:50 -07:00
|
|
|
|
var defaultAction = options.defaultAction;
|
|
|
|
|
if (defaultAction == 'play' || defaultAction == 'playallfromhere') {
|
|
|
|
|
if (item.PlayAccess != 'Full') {
|
|
|
|
|
defaultAction = null;
|
|
|
|
|
}
|
2015-06-02 10:46:44 -07:00
|
|
|
|
}
|
2015-09-04 10:34:50 -07:00
|
|
|
|
var defaultActionAttribute = defaultAction ? (' data-action="' + defaultAction + '" class="itemWithAction mediaItem clearLink"') : ' class="mediaItem clearLink"';
|
|
|
|
|
html += '<a' + defaultActionAttribute + ' href="' + href + '">';
|
2015-06-02 10:46:44 -07:00
|
|
|
|
|
2015-09-04 10:34:50 -07:00
|
|
|
|
for (var i = 0, textLinesLength = textlines.length; i < textLinesLength; i++) {
|
2015-06-03 08:26:39 -07:00
|
|
|
|
|
2015-09-04 10:34:50 -07:00
|
|
|
|
if (i == 0) {
|
|
|
|
|
html += '<div>';
|
|
|
|
|
} else {
|
|
|
|
|
html += '<div secondary>';
|
2014-07-05 14:15:25 -07:00
|
|
|
|
}
|
2015-09-04 10:34:50 -07:00
|
|
|
|
html += textlines[i] || ' ';
|
|
|
|
|
html += '</div>';
|
2014-07-05 09:51:39 -07:00
|
|
|
|
}
|
2015-09-04 10:34:50 -07:00
|
|
|
|
|
|
|
|
|
//html += LibraryBrowser.getSyncIndicator(item);
|
|
|
|
|
|
|
|
|
|
//if (item.Type == 'Series' || item.Type == 'Season' || item.Type == 'BoxSet' || item.MediaType == 'Video') {
|
|
|
|
|
// if (item.UserData.UnplayedItemCount) {
|
|
|
|
|
// //html += '<span class="ui-li-count">' + item.UserData.UnplayedItemCount + '</span>';
|
|
|
|
|
// } else if (item.UserData.Played && item.Type != 'TvChannel') {
|
|
|
|
|
// html += '<div class="playedIndicator"><iron-icon icon="check"></iron-icon></div>';
|
|
|
|
|
// }
|
|
|
|
|
//}
|
2014-07-05 09:51:39 -07:00
|
|
|
|
html += '</a>';
|
2015-09-04 10:34:50 -07:00
|
|
|
|
html += '</paper-item-body>';
|
2014-07-05 09:51:39 -07:00
|
|
|
|
|
2015-07-14 09:39:34 -07:00
|
|
|
|
html += '<paper-icon-button icon="' + AppInfo.moreIcon + '" class="listviewMenuButton"></paper-icon-button>';
|
2015-06-07 14:21:30 -07:00
|
|
|
|
html += '<span class="listViewUserDataButtons">';
|
|
|
|
|
html += LibraryBrowser.getUserDataIconsHtml(item);
|
|
|
|
|
html += '</span>';
|
2014-07-05 09:51:39 -07:00
|
|
|
|
|
2015-09-04 10:34:50 -07:00
|
|
|
|
html += '</paper-icon-item>';
|
2014-07-05 09:51:39 -07:00
|
|
|
|
|
2014-08-21 08:55:35 -07:00
|
|
|
|
index++;
|
2014-07-05 09:51:39 -07:00
|
|
|
|
return html;
|
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
2015-09-04 10:34:50 -07:00
|
|
|
|
outerHtml += '</div>';
|
2014-07-05 09:51:39 -07:00
|
|
|
|
|
|
|
|
|
return outerHtml;
|
|
|
|
|
},
|
|
|
|
|
|
2015-01-29 23:32:20 -07:00
|
|
|
|
getItemDataAttributes: function (item, options, index) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
|
|
|
|
var atts = [];
|
|
|
|
|
|
2014-08-05 21:18:13 -07:00
|
|
|
|
var itemCommands = LibraryBrowser.getItemCommands(item, options);
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
|
|
|
|
atts.push('data-itemid="' + item.Id + '"');
|
|
|
|
|
atts.push('data-commands="' + itemCommands.join(',') + '"');
|
2015-07-06 00:06:09 -07:00
|
|
|
|
|
|
|
|
|
if (options.context) {
|
|
|
|
|
atts.push('data-context="' + (options.context || '') + '"');
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
atts.push('data-itemtype="' + item.Type + '"');
|
2015-07-06 00:06:09 -07:00
|
|
|
|
|
|
|
|
|
if (item.MediaType) {
|
|
|
|
|
atts.push('data-mediatype="' + (item.MediaType || '') + '"');
|
|
|
|
|
}
|
2015-03-04 13:37:35 -07:00
|
|
|
|
|
|
|
|
|
if (item.UserData.PlaybackPositionTicks) {
|
|
|
|
|
atts.push('data-positionticks="' + (item.UserData.PlaybackPositionTicks || 0) + '"');
|
|
|
|
|
}
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
|
|
|
|
atts.push('data-playaccess="' + (item.PlayAccess || '') + '"');
|
|
|
|
|
atts.push('data-locationtype="' + (item.LocationType || '') + '"');
|
2015-01-29 23:32:20 -07:00
|
|
|
|
atts.push('data-index="' + index + '"');
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-06-05 07:27:01 -07:00
|
|
|
|
if (item.AlbumId) {
|
|
|
|
|
atts.push('data-albumid="' + item.AlbumId + '"');
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-16 21:08:33 -07:00
|
|
|
|
if (item.ChannelId) {
|
|
|
|
|
atts.push('data-channelid="' + item.ChannelId + '"');
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-05 07:27:01 -07:00
|
|
|
|
if (item.ArtistItems && item.ArtistItems.length) {
|
|
|
|
|
atts.push('data-artistid="' + item.ArtistItems[0].Id + '"');
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
var html = atts.join(' ');
|
|
|
|
|
|
|
|
|
|
if (html) {
|
|
|
|
|
html = ' ' + html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
},
|
|
|
|
|
|
2015-10-13 22:46:11 -07:00
|
|
|
|
supportsAddingToCollection: function (item) {
|
|
|
|
|
|
|
|
|
|
var invalidTypes = ['Person', 'Genre', 'MusicGenre', 'Studio', 'GameGenre', 'BoxSet', 'Playlist', 'UserView', 'CollectionFolder', 'Audio', 'Episode', 'TvChannel', 'Program'];
|
|
|
|
|
|
|
|
|
|
return !item.CollectionType && invalidTypes.indexOf(item.Type) == -1 && item.MediaType != 'Photo';
|
|
|
|
|
},
|
|
|
|
|
|
2014-08-05 21:18:13 -07:00
|
|
|
|
getItemCommands: function (item, options) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
|
|
|
|
var itemCommands = [];
|
|
|
|
|
|
|
|
|
|
//if (MediaController.canPlay(item)) {
|
|
|
|
|
// itemCommands.push('playmenu');
|
|
|
|
|
//}
|
|
|
|
|
|
2015-08-24 13:37:34 -07:00
|
|
|
|
itemCommands.push('edit');
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
|
|
|
|
if (item.LocalTrailerCount) {
|
|
|
|
|
itemCommands.push('trailer');
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-27 21:19:08 -07:00
|
|
|
|
if (item.MediaType == "Audio" || item.Type == "MusicAlbum" || item.Type == "MusicArtist" || item.Type == "MusicGenre" || item.CollectionType == "music") {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
itemCommands.push('instantmix');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.IsFolder || item.Type == "MusicArtist" || item.Type == "MusicGenre") {
|
|
|
|
|
itemCommands.push('shuffle');
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
if (PlaylistManager.supportsPlaylists(item)) {
|
2014-08-05 21:18:13 -07:00
|
|
|
|
|
|
|
|
|
if (options.showRemoveFromPlaylist) {
|
|
|
|
|
itemCommands.push('removefromplaylist');
|
|
|
|
|
} else {
|
|
|
|
|
itemCommands.push('playlist');
|
|
|
|
|
}
|
2014-08-02 19:16:37 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-15 20:55:26 -07:00
|
|
|
|
if (options.showAddToCollection !== false) {
|
2015-10-13 22:46:11 -07:00
|
|
|
|
if (LibraryBrowser.supportsAddingToCollection(item)) {
|
2015-09-15 20:55:26 -07:00
|
|
|
|
itemCommands.push('addtocollection');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.showRemoveFromCollection) {
|
|
|
|
|
itemCommands.push('removefromcollection');
|
2015-01-23 21:50:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-21 08:55:35 -07:00
|
|
|
|
if (options.playFromHere) {
|
|
|
|
|
itemCommands.push('playfromhere');
|
|
|
|
|
itemCommands.push('queuefromhere');
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-18 19:45:12 -07:00
|
|
|
|
// There's no detail page with a dedicated delete function
|
2015-01-23 21:50:45 -07:00
|
|
|
|
if (item.Type == 'Playlist' || item.Type == 'BoxSet') {
|
2015-02-05 22:39:07 -07:00
|
|
|
|
|
|
|
|
|
if (item.CanDelete) {
|
|
|
|
|
itemCommands.push('delete');
|
|
|
|
|
}
|
2014-11-18 19:45:12 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-10 23:20:28 -07:00
|
|
|
|
if (SyncManager.isAvailable(item)) {
|
|
|
|
|
itemCommands.push('sync');
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-24 20:13:04 -07:00
|
|
|
|
if (item.Type == 'Program' && (!item.TimerId && !item.SeriesTimerId)) {
|
|
|
|
|
|
|
|
|
|
itemCommands.push('record');
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-17 09:04:04 -07:00
|
|
|
|
if (item.MediaType == 'Video' && item.Type != 'TvChannel' && item.Type != 'Program' && item.LocationType != 'Virtual') {
|
|
|
|
|
itemCommands.push('editsubtitles');
|
2015-09-16 18:33:46 -07:00
|
|
|
|
}
|
2015-09-17 09:04:04 -07:00
|
|
|
|
itemCommands.push('editimages');
|
2015-09-16 18:33:46 -07:00
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
return itemCommands;
|
|
|
|
|
},
|
|
|
|
|
|
2015-05-06 20:11:51 -07:00
|
|
|
|
screenWidth: function () {
|
2015-05-06 22:12:13 -07:00
|
|
|
|
|
2015-05-06 20:11:51 -07:00
|
|
|
|
var screenWidth = $(window).width();
|
|
|
|
|
|
|
|
|
|
return screenWidth;
|
|
|
|
|
},
|
|
|
|
|
|
2015-05-16 12:09:02 -07:00
|
|
|
|
shapes: ['square', 'portrait', 'banner', 'smallBackdrop', 'homePageSmallBackdrop', 'backdrop', 'overflowBackdrop', 'overflowPortrait', 'overflowSquare'],
|
|
|
|
|
|
2015-05-06 21:14:35 -07:00
|
|
|
|
getPostersPerRow: function (screenWidth) {
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
2015-06-15 21:52:01 -07:00
|
|
|
|
var cache = true;
|
2015-05-06 22:12:13 -07:00
|
|
|
|
function getValue(shape) {
|
|
|
|
|
var div = $('<div class="card ' + shape + 'Card"><div class="cardBox"><div class="cardImage"></div></div></div>').appendTo(document.body);
|
2015-06-15 21:52:01 -07:00
|
|
|
|
var innerWidth = $('.cardImage', div).innerWidth();
|
|
|
|
|
|
|
|
|
|
if (!innerWidth || isNaN(innerWidth)) {
|
|
|
|
|
cache = false;
|
|
|
|
|
innerWidth = Math.min(400, screenWidth / 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var width = screenWidth / innerWidth;
|
2015-05-06 22:12:13 -07:00
|
|
|
|
div.remove();
|
2015-05-13 22:42:55 -07:00
|
|
|
|
return Math.floor(width);
|
2015-05-06 22:12:13 -07:00
|
|
|
|
}
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
2015-05-06 22:12:13 -07:00
|
|
|
|
var info = {};
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
2015-05-16 12:09:02 -07:00
|
|
|
|
for (var i = 0, length = LibraryBrowser.shapes.length; i < length; i++) {
|
|
|
|
|
var currentShape = LibraryBrowser.shapes[i];
|
|
|
|
|
info[currentShape] = getValue(currentShape);
|
|
|
|
|
}
|
2015-06-15 21:52:01 -07:00
|
|
|
|
info.cache = cache;
|
2015-05-06 22:12:13 -07:00
|
|
|
|
return info;
|
2015-05-06 20:11:51 -07:00
|
|
|
|
},
|
|
|
|
|
|
2015-05-06 21:14:35 -07:00
|
|
|
|
posterSizes: [],
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
2015-05-06 21:14:35 -07:00
|
|
|
|
getPosterViewInfo: function () {
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
|
|
|
|
var screenWidth = LibraryBrowser.screenWidth();
|
|
|
|
|
|
2015-05-06 21:14:35 -07:00
|
|
|
|
var cachedResults = LibraryBrowser.posterSizes;
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = cachedResults.length; i < length; i++) {
|
2015-05-06 22:12:13 -07:00
|
|
|
|
|
2015-05-06 21:14:35 -07:00
|
|
|
|
if (cachedResults[i].screenWidth == screenWidth) {
|
|
|
|
|
return cachedResults[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = LibraryBrowser.getPosterViewInfoInternal(screenWidth);
|
2015-06-15 21:52:01 -07:00
|
|
|
|
result.screenWidth = screenWidth;
|
2015-05-06 21:14:35 -07:00
|
|
|
|
|
2015-06-15 21:52:01 -07:00
|
|
|
|
if (result.cache) {
|
|
|
|
|
cachedResults.push(result);
|
|
|
|
|
}
|
2015-05-06 21:14:35 -07:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getPosterViewInfoInternal: function (screenWidth) {
|
|
|
|
|
|
|
|
|
|
var imagesPerRow = LibraryBrowser.getPostersPerRow(screenWidth);
|
|
|
|
|
|
2015-05-16 12:09:02 -07:00
|
|
|
|
var result = {};
|
|
|
|
|
result.screenWidth = screenWidth;
|
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
if (!AppInfo.hasLowImageBandwidth) {
|
2015-06-15 21:52:01 -07:00
|
|
|
|
screenWidth *= 1.2;
|
2015-05-06 20:11:51 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-16 12:09:02 -07:00
|
|
|
|
var roundTo = 100;
|
2015-05-06 21:14:35 -07:00
|
|
|
|
|
2015-05-16 12:09:02 -07:00
|
|
|
|
for (var i = 0, length = LibraryBrowser.shapes.length; i < length; i++) {
|
|
|
|
|
var currentShape = LibraryBrowser.shapes[i];
|
2015-05-06 21:14:35 -07:00
|
|
|
|
|
2015-05-16 12:09:02 -07:00
|
|
|
|
var shapeWidth = screenWidth / imagesPerRow[currentShape];
|
2015-05-06 21:14:35 -07:00
|
|
|
|
|
2015-06-04 13:27:46 -07:00
|
|
|
|
if (!$.browser.mobile) {
|
2015-05-06 21:14:35 -07:00
|
|
|
|
|
2015-05-16 12:09:02 -07:00
|
|
|
|
shapeWidth = Math.round(shapeWidth / roundTo) * roundTo;
|
|
|
|
|
}
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
2015-05-16 12:09:02 -07:00
|
|
|
|
result[currentShape + 'Width'] = Math.round(shapeWidth);
|
2015-05-06 22:12:13 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-15 21:52:01 -07:00
|
|
|
|
result.cache = imagesPerRow.cache;
|
|
|
|
|
|
2015-05-16 12:09:02 -07:00
|
|
|
|
return result;
|
2015-05-06 20:11:51 -07:00
|
|
|
|
},
|
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
getPosterViewHtml: function (options) {
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var items = options.items;
|
2013-10-24 10:49:24 -07:00
|
|
|
|
var currentIndexValue;
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-25 17:52:55 -07:00
|
|
|
|
options.shape = options.shape || "portrait";
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var html = "";
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2015-05-12 06:58:03 -07:00
|
|
|
|
var primaryImageAspectRatio = LibraryBrowser.getAveragePrimaryImageAspectRatio(items);
|
|
|
|
|
var isThumbAspectRatio = primaryImageAspectRatio && Math.abs(primaryImageAspectRatio - 1.777777778) < .3;
|
|
|
|
|
var isSquareAspectRatio = primaryImageAspectRatio && Math.abs(primaryImageAspectRatio - 1) < .33 ||
|
|
|
|
|
primaryImageAspectRatio && Math.abs(primaryImageAspectRatio - 1.3333334) < .01;
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
if (options.shape == 'auto' || options.shape == 'autohome') {
|
2014-01-04 22:15:38 -07:00
|
|
|
|
|
2015-05-12 06:58:03 -07:00
|
|
|
|
if (isThumbAspectRatio) {
|
2015-01-22 23:15:15 -07:00
|
|
|
|
options.shape = options.shape == 'auto' ? 'backdrop' : 'backdrop';
|
2015-05-12 06:58:03 -07:00
|
|
|
|
} else if (isSquareAspectRatio) {
|
2014-05-17 14:23:48 -07:00
|
|
|
|
options.coverImage = true;
|
2015-01-04 07:18:28 -07:00
|
|
|
|
options.shape = 'square';
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else if (primaryImageAspectRatio && primaryImageAspectRatio > 1.9) {
|
2014-05-17 14:23:48 -07:00
|
|
|
|
options.shape = 'banner';
|
|
|
|
|
options.coverImage = true;
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else if (primaryImageAspectRatio && Math.abs(primaryImageAspectRatio - 0.6666667) < .2) {
|
2015-01-22 23:15:15 -07:00
|
|
|
|
options.shape = options.shape == 'auto' ? 'portrait' : 'portrait';
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else {
|
2015-08-21 20:30:19 -07:00
|
|
|
|
options.shape = options.defaultShape || (options.shape == 'auto' ? 'square' : 'square');
|
2014-06-19 21:50:30 -07:00
|
|
|
|
}
|
2014-01-04 22:15:38 -07:00
|
|
|
|
}
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
2015-05-06 22:12:13 -07:00
|
|
|
|
var posterInfo = LibraryBrowser.getPosterViewInfo();
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
2015-05-16 12:09:02 -07:00
|
|
|
|
var thumbWidth = posterInfo.backdropWidth;
|
|
|
|
|
var posterWidth = posterInfo.portraitWidth;
|
|
|
|
|
var squareSize = posterInfo.squareWidth;
|
2015-05-06 22:12:13 -07:00
|
|
|
|
var bannerWidth = posterInfo.bannerWidth;
|
|
|
|
|
|
2015-05-12 06:58:03 -07:00
|
|
|
|
if (isThumbAspectRatio) {
|
|
|
|
|
posterWidth = thumbWidth;
|
|
|
|
|
}
|
|
|
|
|
else if (isSquareAspectRatio) {
|
|
|
|
|
posterWidth = squareSize;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-16 12:09:02 -07:00
|
|
|
|
if (options.shape == 'overflowBackdrop') {
|
|
|
|
|
thumbWidth = posterInfo.overflowBackdropWidth;
|
2015-05-06 22:12:13 -07:00
|
|
|
|
}
|
2015-05-16 12:09:02 -07:00
|
|
|
|
else if (options.shape == 'overflowPortrait') {
|
|
|
|
|
posterWidth = posterInfo.overflowPortraitWidth;
|
2015-05-12 06:58:03 -07:00
|
|
|
|
}
|
2015-05-16 12:09:02 -07:00
|
|
|
|
else if (options.shape == 'overflowSquare') {
|
|
|
|
|
squareSize = posterInfo.overflowSquareWidth;
|
2015-05-12 06:58:03 -07:00
|
|
|
|
}
|
2015-05-16 12:09:02 -07:00
|
|
|
|
else if (options.shape == 'smallBackdrop') {
|
|
|
|
|
thumbWidth = posterInfo.smallBackdropWidth;
|
2015-05-12 06:58:03 -07:00
|
|
|
|
}
|
2015-05-16 12:09:02 -07:00
|
|
|
|
else if (options.shape == 'homePageSmallBackdrop') {
|
|
|
|
|
thumbWidth = posterInfo.homePageSmallBackdropWidth;
|
|
|
|
|
posterWidth = posterInfo.homePageSmallBackdropWidth;
|
2015-05-06 22:12:13 -07:00
|
|
|
|
}
|
2015-05-10 06:06:12 -07:00
|
|
|
|
else if (options.shape == 'detailPagePortrait') {
|
|
|
|
|
posterWidth = 200;
|
|
|
|
|
}
|
2015-05-16 12:09:02 -07:00
|
|
|
|
else if (options.shape == 'detailPageSquare') {
|
2015-09-14 21:31:12 -07:00
|
|
|
|
posterWidth = 240;
|
|
|
|
|
squareSize = 240;
|
2015-05-16 12:09:02 -07:00
|
|
|
|
}
|
2015-05-10 06:06:12 -07:00
|
|
|
|
else if (options.shape == 'detailPage169') {
|
2015-05-11 16:04:16 -07:00
|
|
|
|
posterWidth = 320;
|
|
|
|
|
thumbWidth = 320;
|
2015-05-10 06:06:12 -07:00
|
|
|
|
}
|
2015-05-25 10:32:22 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
var dateText;
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
for (var i = 0, length = items.length; i < length; i++) {
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-25 17:52:55 -07:00
|
|
|
|
var item = items[i];
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
dateText = null;
|
|
|
|
|
|
2014-04-03 15:50:04 -07:00
|
|
|
|
primaryImageAspectRatio = LibraryBrowser.getAveragePrimaryImageAspectRatio([item]);
|
2014-01-22 17:39:26 -07:00
|
|
|
|
|
2015-07-12 12:33:00 -07:00
|
|
|
|
if (options.showStartDateIndex) {
|
2015-03-19 10:34:53 -07:00
|
|
|
|
|
|
|
|
|
if (item.StartDate) {
|
|
|
|
|
try {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
dateText = LibraryBrowser.getFutureDateText(parseISO8601Date(item.StartDate, { toLocal: true }), true);
|
2015-03-19 10:34:53 -07:00
|
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
var newIndexValue = dateText || Globalize.translate('HeaderUnknownDate');
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
if (newIndexValue != currentIndexValue) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-09-02 08:33:20 -07:00
|
|
|
|
html += '<h1 class="timelineHeader" style="text-align:center;">' + newIndexValue + '</h1>';
|
2015-05-08 12:10:53 -07:00
|
|
|
|
currentIndexValue = newIndexValue;
|
2013-10-24 10:49:24 -07:00
|
|
|
|
}
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else if (options.timeline) {
|
2014-09-14 17:39:24 -07:00
|
|
|
|
var year = item.ProductionYear || Globalize.translate('HeaderUnknownYear');
|
2014-01-02 14:21:06 -07:00
|
|
|
|
|
|
|
|
|
if (year != currentIndexValue) {
|
|
|
|
|
|
2015-09-02 08:33:20 -07:00
|
|
|
|
html += '<h1 class="timelineHeader">' + year + '</h1>';
|
2014-01-02 14:21:06 -07:00
|
|
|
|
currentIndexValue = year;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
html += LibraryBrowser.getPosterViewItemHtml(item, i, options, primaryImageAspectRatio, thumbWidth, posterWidth, squareSize, bannerWidth);
|
|
|
|
|
}
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-12-22 10:16:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
getPosterViewItemHtml: function (item, index, options, primaryImageAspectRatio, thumbWidth, posterWidth, squareSize, bannerWidth) {
|
2014-05-23 16:58:28 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
var html = '';
|
|
|
|
|
var imgUrl = null;
|
|
|
|
|
var icon;
|
|
|
|
|
var width = null;
|
|
|
|
|
var height = null;
|
2014-06-30 21:06:28 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
var forceName = false;
|
2014-06-30 21:06:28 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
var enableImageEnhancers = options.enableImageEnhancers !== false;
|
2014-06-30 21:06:28 -07:00
|
|
|
|
|
2015-06-18 21:23:55 -07:00
|
|
|
|
var cssClass = "card";
|
|
|
|
|
|
2015-07-17 15:32:00 -07:00
|
|
|
|
if (options.fullWidthOnMobile) {
|
|
|
|
|
cssClass += " fullWidthCardOnMobile";
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
var showTitle = options.showTitle == 'auto' ? true : options.showTitle;
|
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
if (options.autoThumb && item.ImageTags && item.ImageTags.Primary && item.PrimaryImageAspectRatio && item.PrimaryImageAspectRatio >= 1.5) {
|
2014-06-30 21:06:28 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
width = posterWidth;
|
|
|
|
|
height = primaryImageAspectRatio ? Math.round(posterWidth / primaryImageAspectRatio) : null;
|
2014-06-30 21:06:28 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Primary",
|
|
|
|
|
height: height,
|
|
|
|
|
width: width,
|
|
|
|
|
tag: item.ImageTags.Primary,
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-04-25 17:52:55 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (options.autoThumb && item.ImageTags && item.ImageTags.Thumb) {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxWidth: thumbWidth,
|
|
|
|
|
tag: item.ImageTags.Thumb,
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (options.preferBackdrop && item.BackdropImageTags && item.BackdropImageTags.length) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Backdrop",
|
|
|
|
|
maxWidth: thumbWidth,
|
|
|
|
|
tag: item.BackdropImageTags[0],
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2014-03-30 18:00:47 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (options.preferThumb && item.ImageTags && item.ImageTags.Thumb) {
|
2014-03-30 18:00:47 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxWidth: thumbWidth,
|
|
|
|
|
tag: item.ImageTags.Thumb,
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (options.preferBanner && item.ImageTags && item.ImageTags.Banner) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Banner",
|
|
|
|
|
maxWidth: bannerWidth,
|
|
|
|
|
tag: item.ImageTags.Banner,
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (options.preferThumb && item.SeriesThumbImageTag && options.inheritThumb !== false) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.SeriesId, {
|
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxWidth: thumbWidth,
|
|
|
|
|
tag: item.SeriesThumbImageTag,
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-12-22 10:16:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (options.preferThumb && item.ParentThumbItemId && options.inheritThumb !== false) {
|
2013-12-22 10:16:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getThumbImageUrl(item.ParentThumbItemId, {
|
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxWidth: thumbWidth,
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2014-09-15 20:39:13 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (options.preferThumb && item.BackdropImageTags && item.BackdropImageTags.length) {
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Backdrop",
|
|
|
|
|
maxWidth: thumbWidth,
|
|
|
|
|
tag: item.BackdropImageTags[0],
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
forceName = true;
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (item.ImageTags && item.ImageTags.Primary) {
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
width = posterWidth;
|
|
|
|
|
height = primaryImageAspectRatio ? Math.round(posterWidth / primaryImageAspectRatio) : null;
|
2013-07-18 07:59:58 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Primary",
|
|
|
|
|
height: height,
|
|
|
|
|
width: width,
|
|
|
|
|
tag: item.ImageTags.Primary,
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-07-18 07:59:58 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
}
|
|
|
|
|
else if (item.ParentPrimaryImageTag) {
|
2013-07-18 07:59:58 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getImageUrl(item.ParentPrimaryImageItemId, {
|
|
|
|
|
type: "Primary",
|
|
|
|
|
width: posterWidth,
|
|
|
|
|
tag: item.ParentPrimaryImageTag,
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (item.AlbumId && item.AlbumPrimaryImageTag) {
|
2014-09-15 20:39:13 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
height = squareSize;
|
|
|
|
|
width = primaryImageAspectRatio ? Math.round(height * primaryImageAspectRatio) : null;
|
2014-09-15 20:39:13 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.AlbumId, {
|
|
|
|
|
type: "Primary",
|
|
|
|
|
height: height,
|
|
|
|
|
width: width,
|
|
|
|
|
tag: item.AlbumPrimaryImageTag,
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-04-25 17:52:55 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
}
|
|
|
|
|
else if (item.Type == 'Season' && item.ImageTags && item.ImageTags.Thumb) {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxWidth: thumbWidth,
|
|
|
|
|
tag: item.ImageTags.Thumb,
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
}
|
|
|
|
|
else if (item.BackdropImageTags && item.BackdropImageTags.length) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Backdrop",
|
|
|
|
|
maxWidth: thumbWidth,
|
|
|
|
|
tag: item.BackdropImageTags[0],
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (item.ImageTags && item.ImageTags.Thumb) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxWidth: thumbWidth,
|
|
|
|
|
tag: item.ImageTags.Thumb,
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (item.SeriesThumbImageTag) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.SeriesId, {
|
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxWidth: thumbWidth,
|
|
|
|
|
tag: item.SeriesThumbImageTag,
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (item.ParentThumbItemId) {
|
2014-01-03 13:32:27 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
imgUrl = ApiClient.getThumbImageUrl(item, {
|
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxWidth: thumbWidth,
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-12-28 16:09:24 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (item.MediaType == "Audio" || item.Type == "MusicAlbum" || item.Type == "MusicArtist") {
|
2013-12-28 16:09:24 -07:00
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
if (item.Name && showTitle) {
|
2015-08-15 14:58:52 -07:00
|
|
|
|
icon = 'library-music';
|
2015-05-08 12:10:53 -07:00
|
|
|
|
}
|
2015-06-18 21:23:55 -07:00
|
|
|
|
cssClass += " defaultBackground";
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (item.Type == "Recording" || item.Type == "Program" || item.Type == "TvChannel") {
|
2014-01-03 13:32:27 -07:00
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
if (item.Name && showTitle) {
|
2015-08-15 14:58:52 -07:00
|
|
|
|
icon = 'folder-open';
|
2013-04-03 05:03:13 -07:00
|
|
|
|
}
|
2013-04-10 12:33:19 -07:00
|
|
|
|
|
2015-06-18 21:23:55 -07:00
|
|
|
|
cssClass += " defaultBackground";
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (item.MediaType == "Video" || item.Type == "Season" || item.Type == "Series") {
|
2013-04-28 11:30:58 -07:00
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
if (item.Name && showTitle) {
|
2015-08-15 14:58:52 -07:00
|
|
|
|
icon = 'videocam';
|
2013-09-08 14:16:13 -07:00
|
|
|
|
}
|
2015-06-18 21:23:55 -07:00
|
|
|
|
cssClass += " defaultBackground";
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (item.Type == "Person") {
|
2013-09-08 14:16:13 -07:00
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
if (item.Name && showTitle) {
|
2015-08-15 14:58:52 -07:00
|
|
|
|
icon = 'person';
|
2015-05-08 12:10:53 -07:00
|
|
|
|
}
|
2015-06-18 21:23:55 -07:00
|
|
|
|
cssClass += " defaultBackground";
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else {
|
2015-08-28 08:02:22 -07:00
|
|
|
|
if (item.Name && showTitle) {
|
2015-08-15 14:58:52 -07:00
|
|
|
|
icon = 'folder-open';
|
2015-05-08 12:10:53 -07:00
|
|
|
|
}
|
2015-06-18 21:23:55 -07:00
|
|
|
|
cssClass += " defaultBackground";
|
2015-05-08 12:10:53 -07:00
|
|
|
|
}
|
2013-04-28 11:30:58 -07:00
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
icon = item.icon || icon;
|
2015-05-08 12:10:53 -07:00
|
|
|
|
cssClass += ' ' + options.shape + 'Card';
|
2014-06-30 11:55:38 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
var mediaSourceCount = item.MediaSourceCount || 1;
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
2015-08-26 11:17:38 -07:00
|
|
|
|
var href = options.linkItem === false ? '#' : LibraryBrowser.getHref(item, options.context);
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
2015-05-11 12:59:59 -07:00
|
|
|
|
if (options.showChildCountIndicator && item.ChildCount && options.showLatestItemsPopup !== false) {
|
2015-05-08 12:10:53 -07:00
|
|
|
|
cssClass += ' groupedCard';
|
|
|
|
|
}
|
2014-09-01 13:10:54 -07:00
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
if (showTitle && !options.overlayText) {
|
2015-05-08 12:10:53 -07:00
|
|
|
|
cssClass += ' bottomPaddedCard';
|
|
|
|
|
}
|
2014-03-10 11:56:37 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
var dataAttributes = LibraryBrowser.getItemDataAttributes(item, options, index);
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
var defaultAction = options.defaultAction;
|
|
|
|
|
if (defaultAction == 'play' || defaultAction == 'playallfromhere') {
|
|
|
|
|
if (item.PlayAccess != 'Full') {
|
|
|
|
|
defaultAction = null;
|
2013-04-25 17:52:55 -07:00
|
|
|
|
}
|
2015-05-08 12:10:53 -07:00
|
|
|
|
}
|
|
|
|
|
var defaultActionAttribute = defaultAction ? (' data-action="' + defaultAction + '"') : '';
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
// card
|
|
|
|
|
html += '<div' + dataAttributes + ' class="' + cssClass + '">';
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
var style = "";
|
2014-01-01 11:26:31 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
if (imgUrl && !options.lazy) {
|
|
|
|
|
style += 'background-image:url(\'' + imgUrl + '\');';
|
|
|
|
|
}
|
2014-04-08 11:22:03 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
var imageCssClass = 'cardImage';
|
2014-11-09 21:20:11 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
if (icon) {
|
|
|
|
|
imageCssClass += " iconCardImage";
|
|
|
|
|
}
|
|
|
|
|
if (options.coverImage) {
|
|
|
|
|
imageCssClass += " coveredCardImage";
|
|
|
|
|
}
|
|
|
|
|
if (options.centerImage) {
|
|
|
|
|
imageCssClass += " centeredCardImage";
|
|
|
|
|
}
|
2014-01-01 11:26:31 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
var dataSrc = "";
|
2014-11-11 21:51:40 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
if (options.lazy && imgUrl) {
|
|
|
|
|
imageCssClass += " lazy";
|
|
|
|
|
dataSrc = ' data-src="' + imgUrl + '"';
|
|
|
|
|
}
|
2014-11-11 21:51:40 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
var cardboxCssClass = 'cardBox';
|
2014-11-11 21:51:40 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
if (options.cardLayout) {
|
|
|
|
|
cardboxCssClass += ' visualCardBox';
|
|
|
|
|
}
|
|
|
|
|
html += '<div class="' + cardboxCssClass + '">';
|
|
|
|
|
html += '<div class="cardScalable">';
|
2013-12-28 22:32:03 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
html += '<div class="cardPadder"></div>';
|
2014-01-14 22:01:58 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
var anchorCssClass = "cardContent";
|
2014-01-01 11:26:31 -07:00
|
|
|
|
|
2015-05-09 21:29:04 -07:00
|
|
|
|
anchorCssClass += ' mediaItem';
|
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
if (options.defaultAction) {
|
|
|
|
|
anchorCssClass += ' itemWithAction';
|
|
|
|
|
}
|
2014-02-28 21:12:56 -07:00
|
|
|
|
|
2015-06-17 18:41:22 -07:00
|
|
|
|
var transition = options.transition === false || !AppInfo.enableSectionTransitions ? '' : ' data-transition="slide"';
|
2015-08-28 08:02:22 -07:00
|
|
|
|
var onclick = item.onclick ? ' onclick="' + item.onclick + '"' : '';
|
|
|
|
|
html += '<a' + onclick + transition + ' class="' + anchorCssClass + '" href="' + href + '"' + defaultActionAttribute + '>';
|
2015-05-08 12:10:53 -07:00
|
|
|
|
html += '<div class="' + imageCssClass + '" style="' + style + '"' + dataSrc + '>';
|
|
|
|
|
if (icon) {
|
2015-08-15 14:58:52 -07:00
|
|
|
|
html += '<iron-icon icon="' + icon + '"></iron-icon>';
|
2015-05-08 12:10:53 -07:00
|
|
|
|
}
|
|
|
|
|
html += '</div>';
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
html += '<div class="cardOverlayTarget"></div>';
|
2014-01-01 11:26:31 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
if (item.LocationType == "Offline" || item.LocationType == "Virtual") {
|
|
|
|
|
if (options.showLocationTypeIndicator !== false) {
|
|
|
|
|
html += LibraryBrowser.getOfflineIndicatorHtml(item);
|
2014-01-01 11:26:31 -07:00
|
|
|
|
}
|
2015-05-08 12:10:53 -07:00
|
|
|
|
} else if (options.showUnplayedIndicator !== false) {
|
|
|
|
|
html += LibraryBrowser.getPlayedIndicatorHtml(item);
|
|
|
|
|
} else if (options.showChildCountIndicator) {
|
|
|
|
|
html += LibraryBrowser.getGroupCountIndicator(item);
|
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-06-01 22:46:06 -07:00
|
|
|
|
html += LibraryBrowser.getSyncIndicator(item);
|
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
if (mediaSourceCount > 1) {
|
|
|
|
|
html += '<div class="mediaSourceIndicator">' + mediaSourceCount + '</div>';
|
|
|
|
|
}
|
2013-04-25 20:33:54 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
var progressHtml = options.showProgress === false || item.IsFolder ? '' : LibraryBrowser.getItemProgressBarHtml((item.Type == 'Recording' ? item : item.UserData));
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
var footerOverlayed = false;
|
2013-12-22 10:16:24 -07:00
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
if (options.overlayText || (forceName && !showTitle)) {
|
2015-05-11 09:32:15 -07:00
|
|
|
|
|
|
|
|
|
var footerCssClass = progressHtml ? 'cardFooter fullCardFooter' : 'cardFooter';
|
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
html += LibraryBrowser.getCardFooterText(item, options, showTitle, imgUrl, forceName, footerCssClass, progressHtml);
|
2015-05-08 12:10:53 -07:00
|
|
|
|
footerOverlayed = true;
|
|
|
|
|
}
|
|
|
|
|
else if (progressHtml) {
|
2015-05-11 12:59:59 -07:00
|
|
|
|
html += '<div class="cardFooter fullCardFooter lightCardFooter">';
|
2015-05-08 12:10:53 -07:00
|
|
|
|
html += "<div class='cardProgress cardText'>";
|
|
|
|
|
html += progressHtml;
|
|
|
|
|
html += "</div>";
|
|
|
|
|
//cardFooter
|
2014-11-10 20:41:19 -07:00
|
|
|
|
html += "</div>";
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
progressHtml = '';
|
2014-08-01 19:34:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
// cardContent
|
|
|
|
|
html += '</a>';
|
|
|
|
|
|
2015-08-22 08:54:29 -07:00
|
|
|
|
if (options.overlayPlayButton && !item.IsPlaceHolder && (item.LocationType != 'Virtual' || !item.MediaType || item.Type == 'Program')) {
|
2015-07-06 00:06:09 -07:00
|
|
|
|
html += '<paper-icon-button icon="play-arrow" class="cardOverlayPlayButton" onclick="return false;"></paper-icon-button>';
|
|
|
|
|
}
|
|
|
|
|
if (options.overlayMoreButton) {
|
2015-07-14 09:39:34 -07:00
|
|
|
|
html += '<paper-icon-button icon="' + AppInfo.moreIcon + '" class="cardOverlayMoreButton" onclick="return false;"></paper-icon-button>';
|
2015-07-06 00:06:09 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 12:10:53 -07:00
|
|
|
|
// cardScalable
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
if (!options.overlayText && !footerOverlayed) {
|
2015-08-28 08:02:22 -07:00
|
|
|
|
html += LibraryBrowser.getCardFooterText(item, options, showTitle, imgUrl, forceName, 'cardFooter outerCardFooter', progressHtml);
|
2015-05-08 12:10:53 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// cardBox
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
// card
|
|
|
|
|
html += "</div>";
|
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
getCardFooterText: function (item, options, showTitle, imgUrl, forceName, footerClass, progressHtml) {
|
2013-05-03 19:33:44 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
var html = '';
|
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
html += '<div class="' + footerClass + '">';
|
2013-12-22 10:16:24 -07:00
|
|
|
|
|
2014-11-10 20:41:19 -07:00
|
|
|
|
if (options.cardLayout) {
|
2015-06-07 14:21:30 -07:00
|
|
|
|
html += '<div class="cardButtonContainer">';
|
2015-07-14 09:39:34 -07:00
|
|
|
|
html += '<paper-icon-button icon="' + AppInfo.moreIcon + '" class="listviewMenuButton btnCardOptions"></paper-icon-button>';
|
2014-11-10 20:41:19 -07:00
|
|
|
|
html += "</div>";
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
var name = options.showTitle == 'auto' && !item.IsFolder && item.MediaType == 'Photo' ? '' : LibraryBrowser.getPosterViewDisplayName(item, options.displayAsSpecial);
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
if (!imgUrl && !showTitle) {
|
2014-08-01 19:34:45 -07:00
|
|
|
|
html += "<div class='cardDefaultText'>";
|
|
|
|
|
html += htmlEncode(name);
|
|
|
|
|
html += "</div>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var cssClass = options.centerText ? "cardText cardTextCentered" : "cardText";
|
|
|
|
|
|
|
|
|
|
var lines = [];
|
|
|
|
|
|
|
|
|
|
if (options.showParentTitle) {
|
|
|
|
|
|
|
|
|
|
lines.push(item.EpisodeTitle ? item.Name : (item.SeriesName || item.Album || item.AlbumArtist || item.GameSystem || ""));
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
if (showTitle || forceName) {
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
|
|
|
|
lines.push(htmlEncode(name));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.showItemCounts) {
|
|
|
|
|
|
|
|
|
|
var itemCountHtml = LibraryBrowser.getItemCountsHtml(options, item);
|
2013-04-25 17:52:55 -07:00
|
|
|
|
|
2014-08-01 19:34:45 -07:00
|
|
|
|
lines.push(itemCountHtml);
|
2013-04-08 22:06:13 -07:00
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2015-01-24 23:34:50 -07:00
|
|
|
|
if (options.textLines) {
|
|
|
|
|
var additionalLines = options.textLines(item);
|
|
|
|
|
for (var i = 0, length = additionalLines.length; i < length; i++) {
|
|
|
|
|
lines.push(additionalLines[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-10 20:41:19 -07:00
|
|
|
|
if (options.showSongCount) {
|
|
|
|
|
|
|
|
|
|
var songLine = '';
|
|
|
|
|
|
|
|
|
|
if (item.SongCount) {
|
|
|
|
|
songLine = item.SongCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneSong') :
|
|
|
|
|
Globalize.translate('ValueSongCount', item.SongCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lines.push(songLine);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
if (options.showPremiereDate) {
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
if (item.PremiereDate) {
|
|
|
|
|
try {
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
lines.push(LibraryBrowser.getPremiereDateText(item));
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
} catch (err) {
|
|
|
|
|
lines.push('');
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
lines.push('');
|
2014-08-01 19:34:45 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.showYear) {
|
|
|
|
|
|
|
|
|
|
lines.push(item.ProductionYear || '');
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-10 20:41:19 -07:00
|
|
|
|
if (options.showSeriesYear) {
|
|
|
|
|
|
|
|
|
|
if (item.Status == "Continuing") {
|
|
|
|
|
|
|
|
|
|
lines.push(Globalize.translate('ValueSeriesYearToPresent', item.ProductionYear || ''));
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
lines.push(item.ProductionYear || '');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-19 09:16:33 -07:00
|
|
|
|
if (options.showProgramAirInfo) {
|
|
|
|
|
|
|
|
|
|
var date = parseISO8601Date(item.StartDate, { toLocal: true });
|
|
|
|
|
|
|
|
|
|
var text = item.StartDate ?
|
|
|
|
|
date.toLocaleString() :
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
lines.push(text || ' ');
|
|
|
|
|
|
|
|
|
|
lines.push(item.ChannelName || ' ');
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
html += LibraryBrowser.getCardTextLines(lines, cssClass, !options.overlayText);
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
|
|
|
|
if (options.overlayText) {
|
|
|
|
|
|
|
|
|
|
if (progressHtml) {
|
|
|
|
|
html += "<div class='cardText cardProgress'>";
|
2014-09-14 17:39:24 -07:00
|
|
|
|
html += progressHtml;
|
2014-08-01 19:34:45 -07:00
|
|
|
|
html += "</div>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//cardFooter
|
|
|
|
|
html += "</div>";
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-05-27 18:59:26 -07:00
|
|
|
|
|
2015-05-09 21:29:04 -07:00
|
|
|
|
getListItemInfo: function (elem) {
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2015-05-09 21:29:04 -07:00
|
|
|
|
var elemWithAttributes = elem;
|
|
|
|
|
|
|
|
|
|
while (!elemWithAttributes.getAttribute('data-itemid')) {
|
|
|
|
|
elemWithAttributes = elemWithAttributes.parentNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var itemId = elemWithAttributes.getAttribute('data-itemid');
|
|
|
|
|
var index = elemWithAttributes.getAttribute('data-index');
|
|
|
|
|
var mediaType = elemWithAttributes.getAttribute('data-mediatype');
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
id: itemId,
|
|
|
|
|
index: index,
|
2015-05-14 19:16:57 -07:00
|
|
|
|
mediaType: mediaType,
|
|
|
|
|
context: elemWithAttributes.getAttribute('data-context')
|
2015-05-09 21:29:04 -07:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
getCardTextLines: function (lines, cssClass, forceLines) {
|
2014-05-10 10:28:03 -07:00
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
var valid = 0;
|
|
|
|
|
var i, length;
|
|
|
|
|
|
|
|
|
|
for (i = 0, length = lines.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var text = lines[i];
|
|
|
|
|
|
|
|
|
|
if (text) {
|
|
|
|
|
html += "<div class='" + cssClass + "'>";
|
|
|
|
|
html += text;
|
|
|
|
|
html += "</div>";
|
|
|
|
|
valid++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (forceLines) {
|
|
|
|
|
while (valid < length) {
|
|
|
|
|
html += "<div class='" + cssClass + "'> </div>";
|
|
|
|
|
valid++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
},
|
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
getFutureDateText: function (date) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
|
|
|
|
var weekday = [];
|
2014-09-16 18:38:50 -07:00
|
|
|
|
weekday[0] = Globalize.translate('OptionSunday');
|
|
|
|
|
weekday[1] = Globalize.translate('OptionMonday');
|
|
|
|
|
weekday[2] = Globalize.translate('OptionTuesday');
|
|
|
|
|
weekday[3] = Globalize.translate('OptionWednesday');
|
|
|
|
|
weekday[4] = Globalize.translate('OptionThursday');
|
|
|
|
|
weekday[5] = Globalize.translate('OptionFriday');
|
|
|
|
|
weekday[6] = Globalize.translate('OptionSaturday');
|
2013-11-19 10:17:14 -07:00
|
|
|
|
|
2013-12-26 19:23:57 -07:00
|
|
|
|
var day = weekday[date.getDay()];
|
|
|
|
|
date = date.toLocaleDateString();
|
2013-12-28 16:09:24 -07:00
|
|
|
|
|
2013-12-26 19:23:57 -07:00
|
|
|
|
if (date.toLowerCase().indexOf(day.toLowerCase()) == -1) {
|
|
|
|
|
return day + " " + date;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return date;
|
2013-10-24 10:49:24 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getPremiereDateText: function (item, date) {
|
|
|
|
|
|
2013-10-25 13:58:31 -07:00
|
|
|
|
if (!date) {
|
|
|
|
|
|
|
|
|
|
var text = '';
|
2013-10-26 15:01:21 -07:00
|
|
|
|
|
2013-10-25 13:58:31 -07:00
|
|
|
|
if (item.AirTime) {
|
|
|
|
|
text += item.AirTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.SeriesStudio) {
|
2013-10-26 15:01:21 -07:00
|
|
|
|
|
2013-10-25 13:58:31 -07:00
|
|
|
|
if (text) {
|
|
|
|
|
text += " on " + item.SeriesStudio;
|
|
|
|
|
} else {
|
|
|
|
|
text += item.SeriesStudio;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
}
|
2013-10-26 15:01:21 -07:00
|
|
|
|
|
2013-10-24 10:49:24 -07:00
|
|
|
|
var day = LibraryBrowser.getFutureDateText(date);
|
|
|
|
|
|
|
|
|
|
if (item.AirTime) {
|
|
|
|
|
day += " at " + item.AirTime;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-24 11:38:57 -07:00
|
|
|
|
if (item.SeriesStudio) {
|
|
|
|
|
day += " on " + item.SeriesStudio;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-24 10:49:24 -07:00
|
|
|
|
return day;
|
|
|
|
|
},
|
|
|
|
|
|
2014-01-24 11:09:50 -07:00
|
|
|
|
getPosterViewDisplayName: function (item, displayAsSpecial, includeParentInfo) {
|
2013-05-27 18:59:26 -07:00
|
|
|
|
|
2014-10-29 15:01:02 -07:00
|
|
|
|
if (!item) {
|
|
|
|
|
throw new Error("null item passed into getPosterViewDisplayName");
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-15 21:52:01 -07:00
|
|
|
|
var name = item.EpisodeTitle || item.Name || '';
|
2013-05-23 21:02:42 -07:00
|
|
|
|
|
2014-03-17 18:45:41 -07:00
|
|
|
|
if (item.Type == "TvChannel") {
|
2014-05-23 16:58:28 -07:00
|
|
|
|
|
|
|
|
|
if (item.Number) {
|
|
|
|
|
return item.Number + ' ' + name;
|
|
|
|
|
}
|
|
|
|
|
return name;
|
2014-01-07 11:39:35 -07:00
|
|
|
|
}
|
2013-12-08 13:33:24 -07:00
|
|
|
|
if (displayAsSpecial && item.Type == "Episode" && item.ParentIndexNumber == 0) {
|
2013-11-15 14:31:33 -07:00
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
name = Globalize.translate('ValueSpecialEpisodeName', name);
|
2013-11-15 14:31:33 -07:00
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else if (item.Type == "Episode" && item.IndexNumber != null && item.ParentIndexNumber != null) {
|
2013-05-23 21:02:42 -07:00
|
|
|
|
|
2013-12-22 10:16:24 -07:00
|
|
|
|
var displayIndexNumber = item.IndexNumber;
|
2013-05-23 21:02:42 -07:00
|
|
|
|
|
2014-01-24 11:09:50 -07:00
|
|
|
|
var number = "E" + displayIndexNumber;
|
2014-02-09 14:11:11 -07:00
|
|
|
|
|
2014-01-24 11:09:50 -07:00
|
|
|
|
if (includeParentInfo !== false) {
|
|
|
|
|
number = "S" + item.ParentIndexNumber + ", " + number;
|
|
|
|
|
}
|
2013-05-23 21:02:42 -07:00
|
|
|
|
|
|
|
|
|
if (item.IndexNumberEnd) {
|
|
|
|
|
|
2013-12-22 10:16:24 -07:00
|
|
|
|
displayIndexNumber = item.IndexNumberEnd;
|
|
|
|
|
number += "-" + displayIndexNumber;
|
2013-05-23 21:02:42 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name = number + " - " + name;
|
|
|
|
|
|
2013-11-15 14:31:33 -07:00
|
|
|
|
}
|
2013-05-23 21:02:42 -07:00
|
|
|
|
|
|
|
|
|
return name;
|
|
|
|
|
},
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2013-10-16 19:43:55 -07:00
|
|
|
|
getOfflineIndicatorHtml: function (item) {
|
|
|
|
|
|
|
|
|
|
if (item.LocationType == "Offline") {
|
2014-09-16 18:38:50 -07:00
|
|
|
|
return '<div class="posterRibbon offlinePosterRibbon">' + Globalize.translate('HeaderOffline') + '</div>';
|
2013-10-16 19:43:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-03 21:50:10 -07:00
|
|
|
|
if (item.Type == 'Episode') {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
var date = parseISO8601Date(item.PremiereDate, { toLocal: true });
|
2013-10-25 07:18:53 -07:00
|
|
|
|
|
2015-06-03 21:50:10 -07:00
|
|
|
|
if (item.PremiereDate && (new Date().getTime() < date.getTime())) {
|
|
|
|
|
return '<div class="posterRibbon unairedPosterRibbon">' + Globalize.translate('HeaderUnaired') + '</div>';
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
2013-10-25 07:18:53 -07:00
|
|
|
|
|
2013-10-16 19:43:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-03 21:50:10 -07:00
|
|
|
|
return '<div class="posterRibbon missingPosterRibbon">' + Globalize.translate('HeaderMissing') + '</div>';
|
2013-10-16 19:43:55 -07:00
|
|
|
|
}
|
2013-07-05 09:17:32 -07:00
|
|
|
|
|
2015-06-03 21:50:10 -07:00
|
|
|
|
return '';
|
2013-07-05 09:17:32 -07:00
|
|
|
|
},
|
2013-12-28 16:09:24 -07:00
|
|
|
|
|
2013-12-29 10:07:29 -07:00
|
|
|
|
getPlayedIndicatorHtml: function (item) {
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2014-01-22 15:38:55 -07:00
|
|
|
|
if (item.Type == "Series" || item.Type == "Season" || item.Type == "BoxSet" || item.MediaType == "Video" || item.MediaType == "Game" || item.MediaType == "Book") {
|
2014-07-03 19:22:57 -07:00
|
|
|
|
if (item.UserData.UnplayedItemCount) {
|
2015-10-04 20:24:24 -07:00
|
|
|
|
return '<div class="playedIndicator">' + item.UserData.UnplayedItemCount + '</div>';
|
2013-12-29 11:53:56 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-07 18:41:03 -07:00
|
|
|
|
if (item.Type != 'TvChannel') {
|
2014-11-30 12:01:33 -07:00
|
|
|
|
if (item.UserData.PlayedPercentage && item.UserData.PlayedPercentage >= 100 || (item.UserData && item.UserData.Played)) {
|
2015-06-29 21:33:53 -07:00
|
|
|
|
return '<div class="playedIndicator"><iron-icon icon="check"></iron-icon></div>';
|
2014-07-07 18:41:03 -07:00
|
|
|
|
}
|
2013-12-29 11:53:56 -07:00
|
|
|
|
}
|
2013-04-09 21:38:04 -07:00
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return '';
|
|
|
|
|
},
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2014-07-04 22:21:13 -07:00
|
|
|
|
getGroupCountIndicator: function (item) {
|
|
|
|
|
|
|
|
|
|
if (item.ChildCount) {
|
2015-10-04 20:24:24 -07:00
|
|
|
|
return '<div class="playedIndicator">' + item.ChildCount + '</div>';
|
2014-07-04 22:21:13 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return '';
|
|
|
|
|
},
|
|
|
|
|
|
2015-06-01 22:46:06 -07:00
|
|
|
|
getSyncIndicator: function (item) {
|
|
|
|
|
|
2015-09-19 19:06:56 -07:00
|
|
|
|
if (item.SyncStatus == 'Synced') {
|
2015-06-02 10:46:44 -07:00
|
|
|
|
|
2015-09-19 19:06:56 -07:00
|
|
|
|
return '<div class="syncIndicator"><iron-icon icon="sync"></iron-icon></div>';
|
2015-06-02 10:46:44 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-19 19:06:56 -07:00
|
|
|
|
var syncPercent = item.SyncPercent;
|
|
|
|
|
if (syncPercent) {
|
2015-09-21 08:43:10 -07:00
|
|
|
|
return '<div class="syncIndicator"><iron-icon icon="sync"></iron-icon></div>';
|
2015-09-19 19:06:56 -07:00
|
|
|
|
}
|
2015-06-01 22:46:06 -07:00
|
|
|
|
|
2015-09-19 19:06:56 -07:00
|
|
|
|
if (item.SyncStatus == 'Queued' || item.SyncStatus == 'Converting' || item.SyncStatus == 'ReadyToTransfer' || item.SyncStatus == 'Transferring') {
|
2015-06-01 22:46:06 -07:00
|
|
|
|
|
2015-09-21 08:43:10 -07:00
|
|
|
|
return '<div class="syncIndicator"><iron-icon icon="sync"></iron-icon></div>';
|
2015-06-01 22:46:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return '';
|
|
|
|
|
},
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
getAveragePrimaryImageAspectRatio: function (items) {
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var values = [];
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
for (var i = 0, length = items.length; i < length; i++) {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var ratio = items[i].PrimaryImageAspectRatio || 0;
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (!ratio) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
values[values.length] = ratio;
|
2013-04-03 05:03:13 -07:00
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (!values.length) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
// Use the median
|
|
|
|
|
values.sort(function (a, b) { return a - b; });
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var half = Math.floor(values.length / 2);
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-10-03 08:51:05 -07:00
|
|
|
|
var result;
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (values.length % 2)
|
2013-10-03 08:51:05 -07:00
|
|
|
|
result = values[half];
|
2013-04-10 12:33:19 -07:00
|
|
|
|
else
|
2013-10-03 08:51:05 -07:00
|
|
|
|
result = (values[half - 1] + values[half]) / 2.0;
|
|
|
|
|
|
|
|
|
|
// If really close to 2:3 (poster image), just return 2:3
|
2014-01-23 11:05:41 -07:00
|
|
|
|
if (Math.abs(0.66666666667 - result) <= .15) {
|
2013-10-03 08:51:05 -07:00
|
|
|
|
return 0.66666666667;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If really close to 16:9 (episode image), just return 16:9
|
2015-01-22 09:41:34 -07:00
|
|
|
|
if (Math.abs(1.777777778 - result) <= .2) {
|
2013-10-03 08:51:05 -07:00
|
|
|
|
return 1.777777778;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If really close to 1 (square image), just return 1
|
2014-01-23 11:05:41 -07:00
|
|
|
|
if (Math.abs(1 - result) <= .15) {
|
2013-10-03 08:51:05 -07:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-08 08:35:36 -07:00
|
|
|
|
// If really close to 4:3 (poster image), just return 2:3
|
2014-01-23 11:05:41 -07:00
|
|
|
|
if (Math.abs(1.33333333333 - result) <= .15) {
|
2013-11-08 08:35:36 -07:00
|
|
|
|
return 1.33333333333;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-03 08:51:05 -07:00
|
|
|
|
return result;
|
2013-04-10 12:33:19 -07:00
|
|
|
|
},
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
metroColors: ["#6FBD45", "#4BB3DD", "#4164A5", "#E12026", "#800080", "#E1B222", "#008040", "#0094FF", "#FF00C7", "#FF870F", "#7F0037"],
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
getRandomMetroColor: function () {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var index = Math.floor(Math.random() * (LibraryBrowser.metroColors.length - 1));
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return LibraryBrowser.metroColors[index];
|
|
|
|
|
},
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
getMetroColor: function (str) {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (str) {
|
2013-05-04 21:49:49 -07:00
|
|
|
|
var character = String(str.substr(0, 1).charCodeAt());
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var sum = 0;
|
2013-05-04 21:49:49 -07:00
|
|
|
|
for (var i = 0; i < character.length; i++) {
|
|
|
|
|
sum += parseInt(character.charAt(i));
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
|
|
|
|
var index = String(sum).substr(-1);
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return LibraryBrowser.metroColors[index];
|
|
|
|
|
} else {
|
|
|
|
|
return LibraryBrowser.getRandomMetroColor();
|
2013-04-08 22:06:13 -07:00
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
},
|
2013-04-05 11:35:37 -07:00
|
|
|
|
|
2014-07-05 09:51:39 -07:00
|
|
|
|
renderName: function (item, nameElem, linkToElement, context) {
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
2014-01-24 11:09:50 -07:00
|
|
|
|
var name = LibraryBrowser.getPosterViewDisplayName(item, false, false);
|
2013-05-27 18:59:26 -07:00
|
|
|
|
|
2013-05-23 21:30:34 -07:00
|
|
|
|
Dashboard.setPageTitle(name);
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2013-05-04 21:49:49 -07:00
|
|
|
|
if (linkToElement) {
|
2014-07-05 09:51:39 -07:00
|
|
|
|
nameElem.html('<a class="detailPageParentLink" href="' + LibraryBrowser.getHref(item, context) + '">' + name + '</a>').trigger('create');
|
2013-05-04 21:49:49 -07:00
|
|
|
|
} else {
|
|
|
|
|
nameElem.html(name);
|
|
|
|
|
}
|
2013-05-14 21:05:52 -07:00
|
|
|
|
},
|
|
|
|
|
|
2014-09-29 21:47:30 -07:00
|
|
|
|
renderParentName: function (item, parentNameElem, context) {
|
2013-05-14 21:05:52 -07:00
|
|
|
|
|
|
|
|
|
var html = [];
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2014-09-29 21:47:30 -07:00
|
|
|
|
var contextParam = context ? ('&context=' + context) : '';
|
|
|
|
|
|
2015-03-13 08:54:20 -07:00
|
|
|
|
if (item.AlbumArtists) {
|
2015-03-13 10:25:28 -07:00
|
|
|
|
html.push(LibraryBrowser.getArtistLinksHtml(item.AlbumArtists, "detailPageParentLink"));
|
|
|
|
|
} else if (item.ArtistItems && item.ArtistItems.length && item.Type == "MusicVideo") {
|
|
|
|
|
html.push(LibraryBrowser.getArtistLinksHtml(item.ArtistItems, "detailPageParentLink"));
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else if (item.SeriesName && item.Type == "Episode") {
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2014-09-29 21:47:30 -07:00
|
|
|
|
html.push('<a class="detailPageParentLink" href="itemdetails.html?id=' + item.SeriesId + contextParam + '">' + item.SeriesName + '</a>');
|
2013-05-04 14:20:27 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.SeriesName && item.Type == "Season") {
|
|
|
|
|
|
2014-09-29 21:47:30 -07:00
|
|
|
|
html.push('<a class="detailPageParentLink" href="itemdetails.html?id=' + item.SeriesId + contextParam + '">' + item.SeriesName + '</a>');
|
2014-09-16 18:38:50 -07:00
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else if (item.ParentIndexNumber != null && item.Type == "Episode") {
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2014-09-29 21:47:30 -07:00
|
|
|
|
html.push('<a class="detailPageParentLink" href="itemdetails.html?id=' + item.SeasonId + contextParam + '">' + item.SeasonName + '</a>');
|
2014-09-16 18:38:50 -07:00
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else if (item.Album && item.Type == "Audio" && (item.AlbumId || item.ParentId)) {
|
2014-09-29 21:47:30 -07:00
|
|
|
|
html.push('<a class="detailPageParentLink" href="itemdetails.html?id=' + (item.AlbumId || item.ParentId) + contextParam + '">' + item.Album + '</a>');
|
2013-07-22 16:59:28 -07:00
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else if (item.Album && item.Type == "MusicVideo" && item.AlbumId) {
|
2014-09-29 21:47:30 -07:00
|
|
|
|
html.push('<a class="detailPageParentLink" href="itemdetails.html?id=' + item.AlbumId + contextParam + '">' + item.Album + '</a>');
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} else if (item.Album) {
|
2013-05-14 21:05:52 -07:00
|
|
|
|
html.push(item.Album);
|
2015-07-28 20:42:03 -07:00
|
|
|
|
} else if (item.Type == 'Program' && item.EpisodeTitle) {
|
|
|
|
|
html.push(item.Name);
|
2013-05-04 14:20:27 -07:00
|
|
|
|
}
|
2013-05-14 21:05:52 -07:00
|
|
|
|
|
|
|
|
|
if (html.length) {
|
|
|
|
|
parentNameElem.show().html(html.join(' - ')).trigger('create');
|
|
|
|
|
} else {
|
2013-05-04 14:20:27 -07:00
|
|
|
|
parentNameElem.hide();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2013-04-14 08:14:10 -07:00
|
|
|
|
renderLinks: function (linksElem, item) {
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var links = [];
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-12 07:13:47 -07:00
|
|
|
|
if (item.HomePageUrl) {
|
2014-09-16 18:38:50 -07:00
|
|
|
|
links.push('<a class="textlink" href="' + item.HomePageUrl + '" target="_blank">' + Globalize.translate('ButtonWebsite') + '</a>');
|
2013-04-12 07:13:47 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-21 11:48:15 -07:00
|
|
|
|
if (item.ExternalUrls) {
|
2013-04-14 08:14:10 -07:00
|
|
|
|
|
2014-02-21 11:48:15 -07:00
|
|
|
|
for (var i = 0, length = item.ExternalUrls.length; i < length; i++) {
|
2014-02-07 15:40:03 -07:00
|
|
|
|
|
2014-02-21 11:48:15 -07:00
|
|
|
|
var url = item.ExternalUrls[i];
|
2014-02-09 14:11:11 -07:00
|
|
|
|
|
2014-02-21 11:48:15 -07:00
|
|
|
|
links.push('<a class="textlink" href="' + url.Url + '" target="_blank">' + url.Name + '</a>');
|
2013-10-26 16:19:26 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-14 08:14:10 -07:00
|
|
|
|
if (links.length) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
var html = links.join(' / ');
|
|
|
|
|
|
|
|
|
|
html = Globalize.translate('ValueLinks', html);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
linksElem.innerHTML = html;
|
|
|
|
|
$(linksElem).trigger('create');
|
|
|
|
|
$(linksElem).show();
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
} else {
|
2013-04-14 08:14:10 -07:00
|
|
|
|
$(linksElem).hide();
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
getDefaultPageSizeSelections: function () {
|
|
|
|
|
|
|
|
|
|
return [20, 50, 100, 200, 300, 400, 500];
|
|
|
|
|
},
|
|
|
|
|
|
2015-08-15 16:10:50 -07:00
|
|
|
|
showLayoutMenu: function (button, currentLayout) {
|
|
|
|
|
|
|
|
|
|
// Add banner and list once all screens support them
|
2015-09-01 15:04:54 -07:00
|
|
|
|
var views = button.getAttribute('data-layouts');
|
|
|
|
|
|
|
|
|
|
views = views ? views.split(',') : ['List', 'Poster', 'PosterCard', 'Thumb', 'ThumbCard'];
|
2015-08-15 16:10:50 -07:00
|
|
|
|
|
|
|
|
|
var menuItems = views.map(function (v) {
|
|
|
|
|
return {
|
|
|
|
|
name: Globalize.translate('Option' + v),
|
|
|
|
|
id: v,
|
|
|
|
|
ironIcon: currentLayout == v ? 'check' : null
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
require(['actionsheet'], function () {
|
|
|
|
|
|
|
|
|
|
ActionSheetElement.show({
|
|
|
|
|
items: menuItems,
|
|
|
|
|
positionTo: button,
|
|
|
|
|
callback: function (id) {
|
|
|
|
|
|
|
|
|
|
$(button).trigger('layoutchange', [id]);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
2015-09-12 09:39:24 -07:00
|
|
|
|
openViewPanel: function (btn, className) {
|
|
|
|
|
|
|
|
|
|
$('.' + className, jQuery(btn).parents('.page')).removeClass('hide').panel('toggle');
|
|
|
|
|
},
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
getQueryPagingHtml: function (options) {
|
|
|
|
|
|
|
|
|
|
var startIndex = options.startIndex;
|
|
|
|
|
var limit = options.limit;
|
|
|
|
|
var totalRecordCount = options.totalRecordCount;
|
|
|
|
|
|
|
|
|
|
if (limit && options.updatePageSizeSetting !== false) {
|
|
|
|
|
try {
|
2015-06-25 14:50:56 -07:00
|
|
|
|
appStorage.setItem(options.pageSizeKey || pageSizeKey, limit);
|
2014-07-19 21:46:29 -07:00
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
var recordsEnd = Math.min(startIndex + limit, totalRecordCount);
|
|
|
|
|
|
|
|
|
|
// 20 is the minimum page size
|
|
|
|
|
var showControls = totalRecordCount > 20 || limit < totalRecordCount;
|
|
|
|
|
|
|
|
|
|
html += '<div class="listPaging">';
|
|
|
|
|
|
2015-07-08 22:52:25 -07:00
|
|
|
|
if (showControls) {
|
|
|
|
|
html += '<span style="vertical-align:middle;">';
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-07-08 22:52:25 -07:00
|
|
|
|
var startAtDisplay = totalRecordCount ? startIndex + 1 : 0;
|
|
|
|
|
html += startAtDisplay + '-' + recordsEnd + ' of ' + totalRecordCount;
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-07-08 22:52:25 -07:00
|
|
|
|
html += '</span>';
|
|
|
|
|
}
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-09-23 09:16:06 -07:00
|
|
|
|
if (showControls || options.viewButton || options.sortButton || options.addLayoutButton) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2015-07-08 22:52:25 -07:00
|
|
|
|
html += '<div style="display:inline-block;margin-left:10px;">';
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
|
|
|
|
if (showControls) {
|
|
|
|
|
|
2015-09-05 14:15:36 -07:00
|
|
|
|
html += '<paper-icon-button class="btnPreviousPage" icon="arrow-back" ' + (startIndex ? '' : 'disabled') + '></paper-icon-button>';
|
|
|
|
|
html += '<paper-icon-button class="btnNextPage" icon="arrow-forward" ' + (startIndex + limit >= totalRecordCount ? 'disabled' : '') + '></paper-icon-button>';
|
2014-07-19 21:46:29 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-15 16:10:50 -07:00
|
|
|
|
if (options.addLayoutButton) {
|
|
|
|
|
|
2015-09-16 18:33:46 -07:00
|
|
|
|
html += '<paper-icon-button title="' + Globalize.translate('ButtonSelectView') + '" class="btnChangeLayout" data-layouts="' + (options.layouts || '') + '" onclick="LibraryBrowser.showLayoutMenu(this, \'' + (options.currentLayout || '') + '\');" icon="view-comfy"></paper-icon-button>';
|
2015-08-15 16:10:50 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-25 19:13:28 -07:00
|
|
|
|
if (options.sortButton) {
|
|
|
|
|
|
2015-09-05 14:15:36 -07:00
|
|
|
|
html += '<paper-icon-button class="btnSort" title="' + Globalize.translate('ButtonSort') + '" icon="sort-by-alpha"></paper-icon-button>';
|
2015-08-25 19:13:28 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
if (options.viewButton) {
|
|
|
|
|
|
2015-06-18 21:23:55 -07:00
|
|
|
|
//html += '<paper-button raised class="subdued notext"><iron-icon icon="view-comfy"></iron-icon></paper-button>';
|
2015-08-15 11:17:22 -07:00
|
|
|
|
var viewPanelClass = options.viewPanelClass || 'viewPanel';
|
2015-08-25 19:13:28 -07:00
|
|
|
|
var title = options.viewIcon == 'filter-list' ? Globalize.translate('ButtonFilter') : Globalize.translate('ButtonMenu');
|
2015-09-12 09:39:24 -07:00
|
|
|
|
html += '<paper-icon-button title="' + title + '" icon="' + (options.viewIcon || AppInfo.moreIcon) + '" onclick="LibraryBrowser.openViewPanel(this, \'' + viewPanelClass + '\');"></paper-icon-button>';
|
2014-07-19 21:46:29 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
if (showControls && options.showLimit) {
|
2015-06-18 21:23:55 -07:00
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
var id = "selectPageSize";
|
|
|
|
|
|
|
|
|
|
var pageSizes = options.pageSizes || LibraryBrowser.getDefaultPageSizeSelections();
|
|
|
|
|
|
|
|
|
|
var optionsHtml = pageSizes.map(function (val) {
|
|
|
|
|
|
|
|
|
|
if (limit == val) {
|
|
|
|
|
|
|
|
|
|
return '<option value="' + val + '" selected="selected">' + val + '</option>';
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return '<option value="' + val + '">' + val + '</option>';
|
|
|
|
|
}
|
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
|
|
// Add styles to defeat jquery mobile
|
2015-09-03 10:35:08 -07:00
|
|
|
|
html += '<div class="pageSizeContainer"><label style="font-size:inherit;" class="labelPageSize" for="' + id + '">' + Globalize.translate('LabelLimit') + '</label><select style="width:auto;" class="selectPageSize" id="' + id + '" data-inline="true" data-mini="true">' + optionsHtml + '</select></div>';
|
2014-07-19 21:46:29 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2015-08-25 19:13:28 -07:00
|
|
|
|
showSortMenu: function (options) {
|
|
|
|
|
|
2015-09-17 20:43:30 -07:00
|
|
|
|
var dlg = document.createElement('paper-dialog');
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2015-09-17 20:43:30 -07:00
|
|
|
|
dlg.setAttribute('with-backdrop', 'with-backdrop');
|
|
|
|
|
dlg.setAttribute('role', 'alertdialog');
|
|
|
|
|
|
2015-09-18 10:50:24 -07:00
|
|
|
|
dlg.entryAnimation = 'fade-in-animation';
|
2015-09-17 20:43:30 -07:00
|
|
|
|
dlg.exitAnimation = 'fade-out-animation';
|
|
|
|
|
|
|
|
|
|
var html = '';
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
|
|
|
|
// There seems to be a bug with this in safari causing it to immediately roll up to 0 height
|
2015-09-17 20:43:30 -07:00
|
|
|
|
// Have to disable this right now because it's causing the radio buttons to not function properly in other browsers besides chrome
|
2015-09-18 10:50:24 -07:00
|
|
|
|
var isScrollable = false;
|
|
|
|
|
if ($.browser.android) {
|
|
|
|
|
isScrollable = true;
|
|
|
|
|
}
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
|
|
|
|
html += '<h2>';
|
|
|
|
|
html += Globalize.translate('HeaderSortBy');
|
|
|
|
|
html += '</h2>';
|
|
|
|
|
|
|
|
|
|
if (isScrollable) {
|
|
|
|
|
html += '<paper-dialog-scrollable>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<paper-radio-group class="groupSortBy" selected="' + (options.query.SortBy || '').replace(',', '_') + '">';
|
|
|
|
|
for (var i = 0, length = options.items.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var option = options.items[i];
|
|
|
|
|
|
|
|
|
|
html += '<paper-radio-button class="menuSortBy block" data-id="' + option.id + '" name="' + option.id.replace(',', '_') + '">' + option.name + '</paper-radio-button>';
|
|
|
|
|
}
|
|
|
|
|
html += '</paper-radio-group>';
|
|
|
|
|
|
|
|
|
|
html += '<p>';
|
|
|
|
|
html += Globalize.translate('HeaderSortOrder');
|
|
|
|
|
html += '</p>';
|
|
|
|
|
html += '<paper-radio-group class="groupSortOrder" selected="' + (options.query.SortOrder || 'Ascending') + '">';
|
|
|
|
|
html += '<paper-radio-button name="Ascending" class="menuSortOrder block">' + Globalize.translate('OptionAscending') + '</paper-radio-button>';
|
|
|
|
|
html += '<paper-radio-button name="Descending" class="menuSortOrder block">' + Globalize.translate('OptionDescending') + '</paper-radio-button>';
|
|
|
|
|
html += '</paper-radio-group>';
|
|
|
|
|
|
|
|
|
|
if (isScrollable) {
|
|
|
|
|
html += '</paper-dialog-scrollable>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<div class="buttons">';
|
|
|
|
|
html += '<paper-button dialog-dismiss>' + Globalize.translate('ButtonClose') + '</paper-button>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2015-09-17 20:43:30 -07:00
|
|
|
|
dlg.innerHTML = html;
|
|
|
|
|
document.body.appendChild(dlg);
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2015-09-17 20:43:30 -07:00
|
|
|
|
$(dlg).on('iron-overlay-closed', function () {
|
|
|
|
|
$(this).remove();
|
|
|
|
|
});
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2015-09-17 20:43:30 -07:00
|
|
|
|
require(['components/paperdialoghelper'], function () {
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2015-10-14 21:32:10 -07:00
|
|
|
|
PaperDialogHelper.openWithHash(dlg, 'sortmenu');
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2015-09-18 10:50:24 -07:00
|
|
|
|
$('.groupSortBy', dlg).on('iron-select', function () {
|
|
|
|
|
options.query.SortBy = this.selected.replace('_', ',');
|
|
|
|
|
options.query.StartIndex = 0;
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2015-09-18 10:50:24 -07:00
|
|
|
|
if (options.callback) {
|
|
|
|
|
options.callback();
|
|
|
|
|
}
|
|
|
|
|
});
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2015-09-18 10:50:24 -07:00
|
|
|
|
$('.groupSortOrder', dlg).on('iron-select', function () {
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2015-09-18 10:50:24 -07:00
|
|
|
|
options.query.SortOrder = this.selected;
|
|
|
|
|
options.query.StartIndex = 0;
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2015-09-18 10:50:24 -07:00
|
|
|
|
if (options.callback) {
|
|
|
|
|
options.callback();
|
|
|
|
|
}
|
|
|
|
|
});
|
2015-09-17 20:43:30 -07:00
|
|
|
|
});
|
2015-08-25 19:13:28 -07:00
|
|
|
|
},
|
|
|
|
|
|
2014-01-16 10:23:30 -07:00
|
|
|
|
getRatingHtml: function (item, metascore) {
|
2013-05-05 20:58:45 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var html = "";
|
2013-05-05 21:50:40 -07:00
|
|
|
|
|
|
|
|
|
if (item.CommunityRating) {
|
|
|
|
|
|
2014-01-14 22:01:58 -07:00
|
|
|
|
html += "<div class='starRating' title='" + item.CommunityRating + "'></div>";
|
|
|
|
|
html += '<div class="starRatingValue">';
|
|
|
|
|
html += item.CommunityRating.toFixed(1);
|
|
|
|
|
html += '</div>';
|
2014-01-22 17:39:26 -07:00
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-05-27 18:59:26 -07:00
|
|
|
|
if (item.CriticRating != null) {
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-05-05 20:58:45 -07:00
|
|
|
|
if (item.CriticRating >= 60) {
|
2015-02-28 06:42:47 -07:00
|
|
|
|
html += '<div class="fresh rottentomatoesicon" title="Rotten Tomatoes"></div>';
|
2013-05-05 20:58:45 -07:00
|
|
|
|
} else {
|
2015-02-28 06:42:47 -07:00
|
|
|
|
html += '<div class="rotten rottentomatoesicon" title="Rotten Tomatoes"></div>';
|
2013-05-05 20:58:45 -07:00
|
|
|
|
}
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2015-02-28 06:42:47 -07:00
|
|
|
|
html += '<div class="criticRating" title="Rotten Tomatoes">' + item.CriticRating + '%</div>';
|
2013-04-10 22:27:27 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-17 21:22:45 -07:00
|
|
|
|
//if (item.Metascore && metascore !== false) {
|
2014-01-14 22:01:58 -07:00
|
|
|
|
|
2015-08-17 21:22:45 -07:00
|
|
|
|
// if (item.Metascore >= 60) {
|
|
|
|
|
// html += '<div class="metascore metascorehigh" title="Metascore">' + item.Metascore + '</div>';
|
|
|
|
|
// }
|
|
|
|
|
// else if (item.Metascore >= 40) {
|
|
|
|
|
// html += '<div class="metascore metascoremid" title="Metascore">' + item.Metascore + '</div>';
|
|
|
|
|
// } else {
|
|
|
|
|
// html += '<div class="metascore metascorelow" title="Metascore">' + item.Metascore + '</div>';
|
|
|
|
|
// }
|
|
|
|
|
//}
|
2014-01-14 22:01:58 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
|
|
|
|
|
2013-12-29 10:07:29 -07:00
|
|
|
|
getItemProgressBarHtml: function (item) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2014-01-14 13:24:56 -07:00
|
|
|
|
|
|
|
|
|
if (item.Type == "Recording" && item.CompletionPercentage) {
|
2014-01-14 22:01:58 -07:00
|
|
|
|
|
2014-01-14 13:24:56 -07:00
|
|
|
|
return '<progress class="itemProgressBar recordingProgressBar" min="0" max="100" value="' + item.CompletionPercentage + '"></progress>';
|
|
|
|
|
}
|
2014-01-14 22:01:58 -07:00
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
var pct = item.PlayedPercentage;
|
2013-04-15 19:36:12 -07:00
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
if (pct && pct < 100) {
|
2013-04-15 19:36:12 -07:00
|
|
|
|
|
2014-07-03 19:22:57 -07:00
|
|
|
|
return '<progress class="itemProgressBar" min="0" max="100" value="' + pct + '"></progress>';
|
2013-04-15 19:36:12 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-01 11:26:31 -07:00
|
|
|
|
return null;
|
2013-05-03 19:33:44 -07:00
|
|
|
|
},
|
|
|
|
|
|
2015-08-17 21:22:45 -07:00
|
|
|
|
getUserDataButtonHtml: function (method, itemId, btnCssClass, icon, tooltip, style) {
|
|
|
|
|
|
|
|
|
|
var tagName = style == 'fab' ? 'paper-fab' : 'paper-icon-button';
|
2015-01-03 12:38:22 -07:00
|
|
|
|
|
2015-08-17 21:22:45 -07:00
|
|
|
|
return '<' + tagName + ' title="' + tooltip + '" data-itemid="' + itemId + '" icon="' + icon + '" class="' + btnCssClass + '" onclick="LibraryBrowser.' + method + '(this);return false;"></' + tagName + '>';
|
2015-01-03 12:38:22 -07:00
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
2015-08-17 21:22:45 -07:00
|
|
|
|
getUserDataIconsHtml: function (item, includePlayed, style) {
|
2013-05-03 19:33:44 -07:00
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var userData = item.UserData || {};
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var itemId = item.Id;
|
2013-04-14 08:14:10 -07:00
|
|
|
|
|
2015-06-14 10:55:42 -07:00
|
|
|
|
if (includePlayed !== false) {
|
|
|
|
|
var tooltipPlayed = Globalize.translate('TooltipPlayed');
|
2014-09-16 18:38:50 -07:00
|
|
|
|
|
2015-07-06 00:06:09 -07:00
|
|
|
|
if (item.MediaType == 'Video' || item.Type == 'Series' || item.Type == 'Season' || item.Type == 'BoxSet' || item.Type == 'Playlist') {
|
2015-07-24 08:20:11 -07:00
|
|
|
|
if (item.Type != 'TvChannel') {
|
|
|
|
|
if (userData.Played) {
|
2015-08-17 21:22:45 -07:00
|
|
|
|
html += LibraryBrowser.getUserDataButtonHtml('markPlayed', itemId, 'btnUserItemRating btnUserItemRatingOn', 'check', tooltipPlayed, style);
|
2015-07-24 08:20:11 -07:00
|
|
|
|
} else {
|
2015-08-17 21:22:45 -07:00
|
|
|
|
html += LibraryBrowser.getUserDataButtonHtml('markPlayed', itemId, 'btnUserItemRating', 'check', tooltipPlayed, style);
|
2015-07-24 08:20:11 -07:00
|
|
|
|
}
|
2015-06-14 10:55:42 -07:00
|
|
|
|
}
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-10 10:11:23 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-18 12:45:41 -07:00
|
|
|
|
var tooltipLike = Globalize.translate('TooltipLike');
|
|
|
|
|
var tooltipDislike = Globalize.translate('TooltipDislike');
|
2014-09-16 18:38:50 -07:00
|
|
|
|
|
2015-08-18 12:45:41 -07:00
|
|
|
|
if (typeof userData.Likes == "undefined") {
|
|
|
|
|
html += LibraryBrowser.getUserDataButtonHtml('markDislike', itemId, 'btnUserItemRating', 'thumb-down', tooltipDislike, style);
|
|
|
|
|
html += LibraryBrowser.getUserDataButtonHtml('markLike', itemId, 'btnUserItemRating', 'thumb-up', tooltipLike, style);
|
|
|
|
|
}
|
|
|
|
|
else if (userData.Likes) {
|
|
|
|
|
html += LibraryBrowser.getUserDataButtonHtml('markDislike', itemId, 'btnUserItemRating', 'thumb-down', tooltipDislike, style);
|
|
|
|
|
html += LibraryBrowser.getUserDataButtonHtml('markLike', itemId, 'btnUserItemRating btnUserItemRatingOn', 'thumb-up', tooltipLike, style);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
html += LibraryBrowser.getUserDataButtonHtml('markDislike', itemId, 'btnUserItemRating btnUserItemRatingOn', 'thumb-down', tooltipDislike, style);
|
|
|
|
|
html += LibraryBrowser.getUserDataButtonHtml('markLike', itemId, 'btnUserItemRating', 'thumb-up', tooltipLike, style);
|
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2015-08-18 12:45:41 -07:00
|
|
|
|
var tooltipFavorite = Globalize.translate('TooltipFavorite');
|
|
|
|
|
if (userData.IsFavorite) {
|
2014-09-16 18:38:50 -07:00
|
|
|
|
|
2015-08-18 12:45:41 -07:00
|
|
|
|
html += LibraryBrowser.getUserDataButtonHtml('markFavorite', itemId, 'btnUserItemRating btnUserItemRatingOn', 'favorite', tooltipFavorite, style);
|
|
|
|
|
} else {
|
|
|
|
|
html += LibraryBrowser.getUserDataButtonHtml('markFavorite', itemId, 'btnUserItemRating', 'favorite', tooltipFavorite, style);
|
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
markPlayed: function (link) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var id = link.getAttribute('data-itemid');
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var markAsPlayed = !link.classList.contains('btnUserItemRatingOn');
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-10-28 07:56:57 -07:00
|
|
|
|
if (markAsPlayed) {
|
|
|
|
|
ApiClient.markPlayed(Dashboard.getCurrentUserId(), id);
|
2015-06-28 07:45:21 -07:00
|
|
|
|
link.classList.add('btnUserItemRatingOn');
|
2013-10-28 07:56:57 -07:00
|
|
|
|
} else {
|
|
|
|
|
ApiClient.markUnplayed(Dashboard.getCurrentUserId(), id);
|
2015-06-28 07:45:21 -07:00
|
|
|
|
link.classList.remove('btnUserItemRatingOn');
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
markFavorite: function (link) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var id = link.getAttribute('data-itemid');
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var $link = $(link);
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2015-06-13 08:52:46 -07:00
|
|
|
|
var markAsFavorite = !$link.hasClass('btnUserItemRatingOn');
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2014-02-22 13:20:22 -07:00
|
|
|
|
ApiClient.updateFavoriteStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (markAsFavorite) {
|
2015-06-13 08:52:46 -07:00
|
|
|
|
$link.addClass('btnUserItemRatingOn');
|
2013-04-10 12:33:19 -07:00
|
|
|
|
} else {
|
2015-06-13 08:52:46 -07:00
|
|
|
|
$link.removeClass('btnUserItemRatingOn');
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
markLike: function (link) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var id = link.getAttribute('data-itemid');
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var $link = $(link);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2015-06-13 08:52:46 -07:00
|
|
|
|
if (!$link.hasClass('btnUserItemRatingOn')) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2014-02-22 13:20:22 -07:00
|
|
|
|
ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, true);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2015-06-13 08:52:46 -07:00
|
|
|
|
$link.addClass('btnUserItemRatingOn');
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
} else {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2014-02-22 13:20:22 -07:00
|
|
|
|
ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), id);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2015-06-13 08:52:46 -07:00
|
|
|
|
$link.removeClass('btnUserItemRatingOn');
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2015-06-13 08:52:46 -07:00
|
|
|
|
$link.prev().removeClass('btnUserItemRatingOn');
|
2013-04-10 12:33:19 -07:00
|
|
|
|
},
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
markDislike: function (link) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var id = link.getAttribute('data-itemid');
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var $link = $(link);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2015-06-13 08:52:46 -07:00
|
|
|
|
if (!$link.hasClass('btnUserItemRatingOn')) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2014-02-22 13:20:22 -07:00
|
|
|
|
ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, false);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2015-06-13 08:52:46 -07:00
|
|
|
|
$link.addClass('btnUserItemRatingOn');
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
} else {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2014-02-22 13:20:22 -07:00
|
|
|
|
ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), id);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2015-06-13 08:52:46 -07:00
|
|
|
|
$link.removeClass('btnUserItemRatingOn');
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2015-06-13 08:52:46 -07:00
|
|
|
|
$link.next().removeClass('btnUserItemRatingOn');
|
2013-04-10 12:33:19 -07:00
|
|
|
|
},
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2015-09-17 09:04:04 -07:00
|
|
|
|
renderDetailImage: function (elem, item, editable, preferThumb) {
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
|
|
|
|
var imageTags = item.ImageTags || {};
|
|
|
|
|
|
|
|
|
|
if (item.PrimaryImageTag) {
|
|
|
|
|
imageTags.Primary = item.PrimaryImageTag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
var url;
|
|
|
|
|
var shape = 'portrait';
|
|
|
|
|
|
|
|
|
|
var imageHeight = 360;
|
|
|
|
|
var detectRatio = false;
|
|
|
|
|
|
|
|
|
|
if (preferThumb && imageTags.Thumb) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Thumb",
|
|
|
|
|
height: imageHeight,
|
|
|
|
|
tag: item.ImageTags.Thumb
|
|
|
|
|
});
|
|
|
|
|
shape = 'thumb';
|
|
|
|
|
}
|
|
|
|
|
else if (imageTags.Primary) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Primary",
|
|
|
|
|
height: imageHeight,
|
|
|
|
|
tag: item.ImageTags.Primary
|
|
|
|
|
});
|
|
|
|
|
detectRatio = true;
|
|
|
|
|
}
|
|
|
|
|
else if (item.BackdropImageTags && item.BackdropImageTags.length) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Backdrop",
|
|
|
|
|
height: imageHeight,
|
|
|
|
|
tag: item.BackdropImageTags[0]
|
|
|
|
|
});
|
|
|
|
|
shape = 'thumb';
|
|
|
|
|
}
|
|
|
|
|
else if (imageTags.Thumb) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Thumb",
|
|
|
|
|
height: imageHeight,
|
|
|
|
|
tag: item.ImageTags.Thumb
|
|
|
|
|
});
|
|
|
|
|
shape = 'thumb';
|
|
|
|
|
}
|
|
|
|
|
else if (imageTags.Disc) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Disc",
|
|
|
|
|
height: imageHeight,
|
|
|
|
|
tag: item.ImageTags.Disc
|
|
|
|
|
});
|
|
|
|
|
shape = 'square';
|
|
|
|
|
}
|
|
|
|
|
else if (item.AlbumId && item.AlbumPrimaryImageTag) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getScaledImageUrl(item.AlbumId, {
|
|
|
|
|
type: "Primary",
|
|
|
|
|
height: imageHeight,
|
|
|
|
|
tag: item.AlbumPrimaryImageTag
|
|
|
|
|
});
|
|
|
|
|
shape = 'square';
|
|
|
|
|
}
|
|
|
|
|
else if (item.MediaType == "Audio" || item.Type == "MusicAlbum" || item.Type == "MusicGenre") {
|
|
|
|
|
url = "css/images/items/detail/audio.png";
|
|
|
|
|
shape = 'square';
|
|
|
|
|
}
|
|
|
|
|
else if (item.MediaType == "Game" || item.Type == "GameGenre") {
|
|
|
|
|
url = "css/images/items/detail/game.png";
|
|
|
|
|
shape = 'square';
|
|
|
|
|
}
|
|
|
|
|
else if (item.Type == "Person") {
|
|
|
|
|
url = "css/images/items/detail/person.png";
|
|
|
|
|
shape = 'square';
|
|
|
|
|
}
|
|
|
|
|
else if (item.Type == "Genre" || item.Type == "Studio") {
|
|
|
|
|
url = "css/images/items/detail/video.png";
|
|
|
|
|
shape = 'square';
|
|
|
|
|
}
|
|
|
|
|
else if (item.Type == "TvChannel") {
|
|
|
|
|
url = "css/images/items/detail/tv.png";
|
|
|
|
|
shape = 'square';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
url = "css/images/items/detail/video.png";
|
|
|
|
|
shape = 'square';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<div style="position:relative;">';
|
|
|
|
|
|
2015-09-17 09:04:04 -07:00
|
|
|
|
if (editable) {
|
|
|
|
|
html += "<a onclick='LibraryBrowser.editImages(\"" + item.Id + "\");' class='itemDetailGalleryLink' href='#'>";
|
2015-02-05 22:59:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-02 21:54:52 -07:00
|
|
|
|
if (detectRatio && item.PrimaryImageAspectRatio) {
|
|
|
|
|
|
2015-02-02 23:57:45 -07:00
|
|
|
|
if (item.PrimaryImageAspectRatio >= 1.48) {
|
2015-02-02 21:54:52 -07:00
|
|
|
|
shape = 'thumb';
|
2015-02-02 23:57:45 -07:00
|
|
|
|
} else if (item.PrimaryImageAspectRatio >= .85 && item.PrimaryImageAspectRatio <= 1.34) {
|
2015-02-02 21:54:52 -07:00
|
|
|
|
shape = 'square';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-24 22:15:29 -07:00
|
|
|
|
html += "<img class='itemDetailImage lazy' src='css/images/empty.png' />";
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2015-09-17 09:04:04 -07:00
|
|
|
|
if (editable) {
|
2015-02-05 22:59:55 -07:00
|
|
|
|
html += "</a>";
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-03 04:51:45 -07:00
|
|
|
|
var progressHtml = item.IsFolder || !item.UserData ? '' : LibraryBrowser.getItemProgressBarHtml((item.Type == 'Recording' ? item : item.UserData));
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2015-08-23 19:08:20 -07:00
|
|
|
|
html += '<div class="detailImageProgressContainer">';
|
2015-02-02 21:54:52 -07:00
|
|
|
|
if (progressHtml) {
|
|
|
|
|
html += progressHtml;
|
|
|
|
|
}
|
2015-08-23 19:08:20 -07:00
|
|
|
|
html += "</div>";
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
|
|
|
|
html += "</div>";
|
|
|
|
|
|
2015-06-28 08:43:49 -07:00
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
|
2015-02-02 21:54:52 -07:00
|
|
|
|
if (shape == 'thumb') {
|
2015-06-28 08:43:49 -07:00
|
|
|
|
elem.classList.add('thumbDetailImageContainer');
|
2015-06-29 11:45:42 -07:00
|
|
|
|
elem.classList.remove('portraitDetailImageContainer');
|
|
|
|
|
elem.classList.remove('squareDetailImageContainer');
|
2015-02-02 21:54:52 -07:00
|
|
|
|
}
|
|
|
|
|
else if (shape == 'square') {
|
2015-06-29 11:45:42 -07:00
|
|
|
|
elem.classList.remove('thumbDetailImageContainer');
|
|
|
|
|
elem.classList.remove('portraitDetailImageContainer');
|
2015-06-28 08:43:49 -07:00
|
|
|
|
elem.classList.add('squareDetailImageContainer');
|
2015-02-02 21:54:52 -07:00
|
|
|
|
} else {
|
2015-06-29 11:45:42 -07:00
|
|
|
|
elem.classList.remove('thumbDetailImageContainer');
|
2015-06-28 08:43:49 -07:00
|
|
|
|
elem.classList.add('portraitDetailImageContainer');
|
|
|
|
|
elem.classList.remove('squareDetailImageContainer');
|
2015-02-02 21:54:52 -07:00
|
|
|
|
}
|
2015-09-24 22:15:29 -07:00
|
|
|
|
|
|
|
|
|
ImageLoader.lazyImage(elem.querySelector('img'), url);
|
2015-02-02 21:54:52 -07:00
|
|
|
|
},
|
|
|
|
|
|
2015-08-23 19:08:20 -07:00
|
|
|
|
refreshDetailImageUserData: function (elem, item) {
|
|
|
|
|
|
|
|
|
|
var progressHtml = item.IsFolder || !item.UserData ? '' : LibraryBrowser.getItemProgressBarHtml((item.Type == 'Recording' ? item : item.UserData));
|
|
|
|
|
|
|
|
|
|
var detailImageProgressContainer = elem.querySelector('.detailImageProgressContainer');
|
|
|
|
|
|
|
|
|
|
detailImageProgressContainer.innerHTML = progressHtml || '';
|
|
|
|
|
},
|
|
|
|
|
|
2015-05-22 12:16:14 -07:00
|
|
|
|
getDisplayTime: function (date) {
|
|
|
|
|
|
|
|
|
|
if ((typeof date).toString().toLowerCase() === 'string') {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
date = parseISO8601Date(date, { toLocal: true });
|
|
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
return date;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var lower = date.toLocaleTimeString().toLowerCase();
|
|
|
|
|
|
|
|
|
|
var hours = date.getHours();
|
|
|
|
|
var minutes = date.getMinutes();
|
|
|
|
|
|
|
|
|
|
var text;
|
|
|
|
|
|
|
|
|
|
if (lower.indexOf('am') != -1 || lower.indexOf('pm') != -1) {
|
|
|
|
|
|
|
|
|
|
var suffix = hours > 11 ? 'pm' : 'am';
|
|
|
|
|
|
|
|
|
|
hours = (hours % 12) || 12;
|
|
|
|
|
|
|
|
|
|
text = hours;
|
|
|
|
|
|
|
|
|
|
if (minutes) {
|
|
|
|
|
|
|
|
|
|
text += ':';
|
|
|
|
|
if (minutes < 10) {
|
|
|
|
|
text += '0';
|
|
|
|
|
}
|
|
|
|
|
text += minutes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
text += suffix;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
text = hours + ':';
|
|
|
|
|
|
|
|
|
|
if (minutes < 10) {
|
|
|
|
|
text += '0';
|
|
|
|
|
}
|
|
|
|
|
text += minutes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
},
|
|
|
|
|
|
2013-04-18 19:52:22 -07:00
|
|
|
|
getMiscInfoHtml: function (item) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var miscInfo = [];
|
2013-12-04 13:55:42 -07:00
|
|
|
|
var text, date;
|
2013-04-25 17:52:55 -07:00
|
|
|
|
|
2015-08-18 12:45:41 -07:00
|
|
|
|
if (item.IsSeries && !item.IsRepeat) {
|
|
|
|
|
|
|
|
|
|
require(['livetvcss']);
|
|
|
|
|
miscInfo.push('<span class="newTvProgram">' + Globalize.translate('LabelNewProgram') + '</span>');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.IsLive) {
|
|
|
|
|
|
|
|
|
|
miscInfo.push('<span class="liveTvProgram">' + Globalize.translate('LabelLiveProgram') + '</span>');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.ChannelId && item.ChannelName) {
|
|
|
|
|
if (item.Type == 'Program' || item.Type == 'Recording') {
|
|
|
|
|
miscInfo.push('<a class="textlink" href="itemdetails.html?id=' + item.ChannelId + '">' + item.ChannelName + '</a>');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-28 17:49:25 -07:00
|
|
|
|
if (item.Type == "Episode" || item.MediaType == 'Photo') {
|
2013-05-04 12:53:13 -07:00
|
|
|
|
|
|
|
|
|
if (item.PremiereDate) {
|
|
|
|
|
|
|
|
|
|
try {
|
2013-12-04 13:55:42 -07:00
|
|
|
|
date = parseISO8601Date(item.PremiereDate, { toLocal: true });
|
2013-05-04 12:53:13 -07:00
|
|
|
|
|
2013-05-11 23:05:51 -07:00
|
|
|
|
text = date.toLocaleDateString();
|
2013-05-04 12:53:13 -07:00
|
|
|
|
miscInfo.push(text);
|
|
|
|
|
}
|
|
|
|
|
catch (e) {
|
2015-06-26 20:27:38 -07:00
|
|
|
|
Logger.log("Error parsing date: " + item.PremiereDate);
|
2013-05-04 12:53:13 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-04 13:55:42 -07:00
|
|
|
|
if (item.StartDate) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
date = parseISO8601Date(item.StartDate, { toLocal: true });
|
|
|
|
|
|
|
|
|
|
text = date.toLocaleDateString();
|
|
|
|
|
miscInfo.push(text);
|
2013-12-21 11:37:34 -07:00
|
|
|
|
|
|
|
|
|
if (item.Type != "Recording") {
|
2015-05-22 12:16:14 -07:00
|
|
|
|
text = LibraryBrowser.getDisplayTime(date);
|
2013-12-21 11:37:34 -07:00
|
|
|
|
miscInfo.push(text);
|
|
|
|
|
}
|
2013-12-04 13:55:42 -07:00
|
|
|
|
}
|
|
|
|
|
catch (e) {
|
2015-06-26 20:27:38 -07:00
|
|
|
|
Logger.log("Error parsing date: " + item.PremiereDate);
|
2013-12-04 13:55:42 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-24 13:28:42 -07:00
|
|
|
|
if (item.ProductionYear && item.Type == "Series") {
|
2013-04-18 19:52:22 -07:00
|
|
|
|
|
|
|
|
|
if (item.Status == "Continuing") {
|
2014-09-16 18:38:50 -07:00
|
|
|
|
miscInfo.push(Globalize.translate('ValueSeriesYearToPresent', item.ProductionYear));
|
2013-04-24 13:28:42 -07:00
|
|
|
|
|
2014-03-02 13:44:48 -07:00
|
|
|
|
}
|
|
|
|
|
else if (item.ProductionYear) {
|
2013-04-24 13:28:42 -07:00
|
|
|
|
|
|
|
|
|
text = item.ProductionYear;
|
|
|
|
|
|
|
|
|
|
if (item.EndDate) {
|
|
|
|
|
|
|
|
|
|
try {
|
2013-06-09 06:35:50 -07:00
|
|
|
|
|
|
|
|
|
var endYear = parseISO8601Date(item.EndDate, { toLocal: true }).getFullYear();
|
2013-06-29 09:21:22 -07:00
|
|
|
|
|
2013-06-09 06:35:50 -07:00
|
|
|
|
if (endYear != item.ProductionYear) {
|
|
|
|
|
text += "-" + parseISO8601Date(item.EndDate, { toLocal: true }).getFullYear();
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-24 13:28:42 -07:00
|
|
|
|
}
|
|
|
|
|
catch (e) {
|
2015-06-26 20:27:38 -07:00
|
|
|
|
Logger.log("Error parsing date: " + item.EndDate);
|
2013-04-24 13:28:42 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
miscInfo.push(text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-28 17:49:25 -07:00
|
|
|
|
if (item.Type != "Series" && item.Type != "Episode" && item.MediaType != 'Photo') {
|
2013-04-25 17:52:55 -07:00
|
|
|
|
|
2013-04-24 13:28:42 -07:00
|
|
|
|
if (item.ProductionYear) {
|
|
|
|
|
|
2013-04-18 19:52:22 -07:00
|
|
|
|
miscInfo.push(item.ProductionYear);
|
|
|
|
|
}
|
2013-04-24 13:28:42 -07:00
|
|
|
|
else if (item.PremiereDate) {
|
2013-04-25 17:52:55 -07:00
|
|
|
|
|
2013-04-24 13:28:42 -07:00
|
|
|
|
try {
|
2013-06-04 20:40:17 -07:00
|
|
|
|
text = parseISO8601Date(item.PremiereDate, { toLocal: true }).getFullYear();
|
2013-04-24 13:28:42 -07:00
|
|
|
|
miscInfo.push(text);
|
|
|
|
|
}
|
|
|
|
|
catch (e) {
|
2015-06-26 20:27:38 -07:00
|
|
|
|
Logger.log("Error parsing date: " + item.PremiereDate);
|
2013-04-24 13:28:42 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-12-03 21:18:50 -07:00
|
|
|
|
var minutes;
|
|
|
|
|
|
2013-11-29 09:58:24 -07:00
|
|
|
|
if (item.RunTimeTicks && item.Type != "Series") {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-22 13:06:43 -07:00
|
|
|
|
if (item.Type == "Audio") {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-06-07 10:29:33 -07:00
|
|
|
|
miscInfo.push(Dashboard.getDisplayTime(item.RunTimeTicks));
|
2013-12-22 10:16:24 -07:00
|
|
|
|
|
2013-04-22 13:06:43 -07:00
|
|
|
|
} else {
|
2013-12-03 21:18:50 -07:00
|
|
|
|
minutes = item.RunTimeTicks / 600000000;
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-22 13:06:43 -07:00
|
|
|
|
minutes = minutes || 1;
|
|
|
|
|
|
2013-12-20 13:09:49 -07:00
|
|
|
|
miscInfo.push(Math.round(minutes) + "min");
|
2013-04-22 13:06:43 -07:00
|
|
|
|
}
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2015-08-19 21:06:49 -07:00
|
|
|
|
if (item.CumulativeRunTimeTicks && item.Type != "Series" && item.Type != "Season") {
|
|
|
|
|
|
|
|
|
|
miscInfo.push(Dashboard.getDisplayTime(item.CumulativeRunTimeTicks));
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:02:28 -07:00
|
|
|
|
if (item.OfficialRating && item.Type !== "Season" && item.Type !== "Episode") {
|
2013-05-04 12:53:13 -07:00
|
|
|
|
miscInfo.push(item.OfficialRating);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-18 12:45:41 -07:00
|
|
|
|
if (item.IsHD) {
|
|
|
|
|
|
|
|
|
|
miscInfo.push(Globalize.translate('LabelHDProgram'));
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-18 23:12:58 -07:00
|
|
|
|
//if (item.Audio) {
|
2015-08-18 12:45:41 -07:00
|
|
|
|
|
2015-08-18 23:12:58 -07:00
|
|
|
|
// miscInfo.push(item.Audio);
|
2015-08-18 12:45:41 -07:00
|
|
|
|
|
2015-08-18 23:12:58 -07:00
|
|
|
|
//}
|
2015-08-18 12:45:41 -07:00
|
|
|
|
|
2013-06-27 10:04:48 -07:00
|
|
|
|
if (item.Video3DFormat) {
|
|
|
|
|
miscInfo.push("3D");
|
2013-04-18 19:52:22 -07:00
|
|
|
|
}
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2014-08-28 17:49:25 -07:00
|
|
|
|
if (item.MediaType == 'Photo' && item.Width && item.Height) {
|
|
|
|
|
miscInfo.push(item.Width + "x" + item.Height);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-16 21:08:33 -07:00
|
|
|
|
if (item.SeriesTimerId) {
|
|
|
|
|
var html = '';
|
|
|
|
|
html += '<a href="livetvseriestimer.html?id=' + item.SeriesTimerId + '" title="' + Globalize.translate('ButtonViewSeriesRecording') + '">';
|
|
|
|
|
html += '<div class="timerCircle seriesTimerCircle"></div>';
|
|
|
|
|
html += '<div class="timerCircle seriesTimerCircle"></div>';
|
|
|
|
|
html += '<div class="timerCircle seriesTimerCircle"></div>';
|
|
|
|
|
html += '</a>';
|
|
|
|
|
miscInfo.push(html);
|
|
|
|
|
require(['livetvcss']);
|
|
|
|
|
}
|
2015-08-18 12:45:41 -07:00
|
|
|
|
else if (item.TimerId) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
html += '<a href="livetvtimer.html?id=' + item.TimerId + '">';
|
|
|
|
|
html += '<div class="timerCircle"></div>';
|
|
|
|
|
html += '</a>';
|
|
|
|
|
miscInfo.push(html);
|
|
|
|
|
require(['livetvcss']);
|
|
|
|
|
}
|
2015-08-16 21:08:33 -07:00
|
|
|
|
|
2013-05-05 20:58:45 -07:00
|
|
|
|
return miscInfo.join(' ');
|
2013-04-10 12:33:19 -07:00
|
|
|
|
},
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2015-07-06 07:20:23 -07:00
|
|
|
|
renderOverview: function (elems, item) {
|
2013-04-21 21:38:03 -07:00
|
|
|
|
|
2015-07-06 07:20:23 -07:00
|
|
|
|
$(elems).each(function () {
|
|
|
|
|
var elem = this;
|
|
|
|
|
var overview = item.Overview || '';
|
2013-04-21 21:38:03 -07:00
|
|
|
|
|
2015-07-06 07:20:23 -07:00
|
|
|
|
$('a', elem).each(function () {
|
|
|
|
|
this.setAttribute("target", "_blank");
|
|
|
|
|
});
|
2013-04-21 21:38:03 -07:00
|
|
|
|
|
2015-07-06 07:20:23 -07:00
|
|
|
|
if (overview) {
|
2015-08-17 21:22:45 -07:00
|
|
|
|
elem.innerHTML = overview;
|
|
|
|
|
|
2015-07-06 07:20:23 -07:00
|
|
|
|
elem.classList.remove('empty');
|
|
|
|
|
} else {
|
2015-08-17 21:22:45 -07:00
|
|
|
|
elem.innerHTML = '';
|
|
|
|
|
|
2015-07-06 07:20:23 -07:00
|
|
|
|
elem.classList.add('empty');
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-08-16 22:38:13 -07:00
|
|
|
|
|
2013-04-21 21:38:03 -07:00
|
|
|
|
},
|
|
|
|
|
|
2015-08-20 20:21:27 -07:00
|
|
|
|
renderStudios: function (elem, item, isStatic) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-10-16 16:35:11 -07:00
|
|
|
|
if (item.Studios && item.Studios.length && item.Type != "Series") {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
var html = '';
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
for (var i = 0, length = item.Studios.length; i < length; i++) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (i > 0) {
|
|
|
|
|
html += ' / ';
|
|
|
|
|
}
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2015-07-03 04:51:45 -07:00
|
|
|
|
if (isStatic) {
|
|
|
|
|
html += item.Studios[i].Name;
|
|
|
|
|
} else {
|
2015-08-20 20:21:27 -07:00
|
|
|
|
html += '<a class="textlink" href="itemdetails.html?id=' + item.Studios[i].Id + '">' + item.Studios[i].Name + '</a>';
|
2015-07-03 04:51:45 -07:00
|
|
|
|
}
|
2013-04-10 12:25:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
var translationKey = item.Studios.length > 1 ? "ValueStudios" : "ValueStudio";
|
|
|
|
|
|
|
|
|
|
html = Globalize.translate(translationKey, html);
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
elem.show().html(html).trigger('create');
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
} else {
|
|
|
|
|
elem.hide();
|
|
|
|
|
}
|
|
|
|
|
},
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2015-08-20 20:21:27 -07:00
|
|
|
|
renderGenres: function (elem, item, limit, isStatic) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-12-21 11:37:34 -07:00
|
|
|
|
var html = '';
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-12-21 11:37:34 -07:00
|
|
|
|
var genres = item.Genres || [];
|
2013-07-18 07:59:58 -07:00
|
|
|
|
|
2013-12-21 11:37:34 -07:00
|
|
|
|
for (var i = 0, length = genres.length; i < length; i++) {
|
2013-06-29 09:21:22 -07:00
|
|
|
|
|
2015-01-31 19:41:35 -07:00
|
|
|
|
if (limit && i >= limit) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-21 11:37:34 -07:00
|
|
|
|
if (i > 0) {
|
2014-01-15 15:19:45 -07:00
|
|
|
|
html += '<span> / </span>';
|
2013-04-10 12:25:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-21 11:37:34 -07:00
|
|
|
|
var param = item.Type == "Audio" || item.Type == "MusicArtist" || item.Type == "MusicAlbum" ? "musicgenre" : "genre";
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-12-21 11:37:34 -07:00
|
|
|
|
if (item.MediaType == "Game") {
|
|
|
|
|
param = "gamegenre";
|
|
|
|
|
}
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2015-07-03 04:51:45 -07:00
|
|
|
|
if (isStatic) {
|
|
|
|
|
html += genres[i];
|
|
|
|
|
} else {
|
2015-08-20 20:21:27 -07:00
|
|
|
|
html += '<a class="textlink" href="itemdetails.html?' + param + '=' + ApiClient.encodeName(genres[i]) + '">' + genres[i] + '</a>';
|
2015-07-03 04:51:45 -07:00
|
|
|
|
}
|
2013-04-18 07:27:21 -07:00
|
|
|
|
}
|
2013-12-21 11:37:34 -07:00
|
|
|
|
|
|
|
|
|
elem.html(html).trigger('create');
|
2013-04-18 07:27:21 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
renderPremiereDate: function (elem, item) {
|
|
|
|
|
if (item.PremiereDate) {
|
2013-04-18 22:08:18 -07:00
|
|
|
|
try {
|
2013-04-24 13:28:42 -07:00
|
|
|
|
|
|
|
|
|
var date = parseISO8601Date(item.PremiereDate, { toLocal: true });
|
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
var translationKey = new Date().getTime() > date.getTime() ? "ValuePremiered" : "ValuePremieres";
|
|
|
|
|
|
|
|
|
|
elem.show().html(Globalize.translate(translationKey, date.toLocaleDateString()));
|
2013-04-24 13:28:42 -07:00
|
|
|
|
|
2013-04-18 22:08:18 -07:00
|
|
|
|
} catch (err) {
|
|
|
|
|
elem.hide();
|
|
|
|
|
}
|
2013-04-18 07:27:21 -07:00
|
|
|
|
} else {
|
|
|
|
|
elem.hide();
|
2013-04-12 08:25:00 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
2013-04-12 17:42:51 -07:00
|
|
|
|
|
2013-04-12 08:25:00 -07:00
|
|
|
|
renderBudget: function (elem, item) {
|
2014-09-16 18:38:50 -07:00
|
|
|
|
|
2013-04-12 08:25:00 -07:00
|
|
|
|
if (item.Budget) {
|
2014-01-18 11:10:21 -07:00
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
elem.show().html(Globalize.translate('ValueBudget', '$' + item.Budget));
|
2013-04-10 12:33:19 -07:00
|
|
|
|
} else {
|
|
|
|
|
elem.hide();
|
|
|
|
|
}
|
2013-04-14 20:37:07 -07:00
|
|
|
|
},
|
|
|
|
|
|
2013-04-18 07:05:38 -07:00
|
|
|
|
renderRevenue: function (elem, item) {
|
2014-09-16 18:38:50 -07:00
|
|
|
|
|
2013-04-18 07:05:38 -07:00
|
|
|
|
if (item.Revenue) {
|
2014-01-18 11:10:21 -07:00
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
elem.show().html(Globalize.translate('ValueRevenue', '$' + item.Revenue));
|
2013-04-18 07:05:38 -07:00
|
|
|
|
} else {
|
|
|
|
|
elem.hide();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2014-01-18 11:10:21 -07:00
|
|
|
|
renderAwardSummary: function (elem, item) {
|
|
|
|
|
if (item.AwardSummary) {
|
2014-09-16 18:38:50 -07:00
|
|
|
|
elem.show().html(Globalize.translate('ValueAwards', item.AwardSummary));
|
2014-01-18 11:10:21 -07:00
|
|
|
|
} else {
|
|
|
|
|
elem.hide();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2013-05-14 21:05:52 -07:00
|
|
|
|
renderDetailPageBackdrop: function (page, item) {
|
2013-05-15 07:12:24 -07:00
|
|
|
|
|
2015-06-14 21:17:12 -07:00
|
|
|
|
var screenWidth = screen.availWidth;
|
2013-05-15 07:12:24 -07:00
|
|
|
|
|
2013-05-14 21:05:52 -07:00
|
|
|
|
var imgUrl;
|
2015-08-18 10:54:29 -07:00
|
|
|
|
var hasbackdrop = false;
|
2013-05-14 21:05:52 -07:00
|
|
|
|
|
|
|
|
|
if (item.BackdropImageTags && item.BackdropImageTags.length) {
|
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Backdrop",
|
|
|
|
|
index: 0,
|
|
|
|
|
maxWidth: screenWidth,
|
|
|
|
|
tag: item.BackdropImageTags[0]
|
2013-05-15 07:12:24 -07:00
|
|
|
|
});
|
2013-05-14 21:05:52 -07:00
|
|
|
|
|
2015-10-12 12:09:56 -07:00
|
|
|
|
ImageLoader.lazyImage($('#itemBackdrop', page).addClass('noFade').removeClass('noBackdrop')[0], imgUrl);
|
2015-08-18 10:54:29 -07:00
|
|
|
|
hasbackdrop = true;
|
2013-05-14 21:05:52 -07:00
|
|
|
|
}
|
|
|
|
|
else if (item.ParentBackdropItemId && item.ParentBackdropImageTags && item.ParentBackdropImageTags.length) {
|
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.ParentBackdropItemId, {
|
2013-05-14 21:05:52 -07:00
|
|
|
|
type: 'Backdrop',
|
|
|
|
|
index: 0,
|
2013-05-15 07:12:24 -07:00
|
|
|
|
tag: item.ParentBackdropImageTags[0],
|
2014-05-23 16:58:28 -07:00
|
|
|
|
maxWidth: screenWidth
|
2013-05-14 21:05:52 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-10-12 12:09:56 -07:00
|
|
|
|
ImageLoader.lazyImage($('#itemBackdrop', page).addClass('noFade').removeClass('noBackdrop')[0], imgUrl);
|
2015-08-18 10:54:29 -07:00
|
|
|
|
hasbackdrop = true;
|
2013-05-14 21:05:52 -07:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
$('#itemBackdrop', page).addClass('noBackdrop').css('background-image', 'none');
|
|
|
|
|
}
|
2015-08-18 10:54:29 -07:00
|
|
|
|
|
|
|
|
|
return hasbackdrop;
|
2013-04-28 13:02:14 -07:00
|
|
|
|
}
|
2013-04-10 12:33:19 -07:00
|
|
|
|
};
|
|
|
|
|
|
2015-08-24 20:13:04 -07:00
|
|
|
|
if (libraryBrowser.enableFullPaperTabs()) {
|
|
|
|
|
document.documentElement.classList.add('fullPaperLibraryTabs');
|
|
|
|
|
} else {
|
|
|
|
|
document.documentElement.classList.add('basicPaperLibraryTabs');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return libraryBrowser;
|
|
|
|
|
|
2015-06-25 14:50:56 -07:00
|
|
|
|
})(window, document, jQuery, screen);
|