2016-07-18 11:53:04 -07:00
|
|
|
|
define(['scrollHelper', 'viewManager', 'appSettings', 'appStorage', 'apphost', 'datetime', 'itemHelper', 'mediaInfo', 'scroller', 'indicators', 'dom', 'scrollStyles'], function (scrollHelper, viewManager, appSettings, appStorage, appHost, datetime, itemHelper, mediaInfo, scroller, indicators, dom) {
|
2016-05-09 12:27:38 -07:00
|
|
|
|
|
2016-05-16 10:11:49 -07:00
|
|
|
|
function fadeInRight(elem) {
|
|
|
|
|
|
2016-07-17 09:59:14 -07:00
|
|
|
|
var pct = browserInfo.mobile ? '3%' : '0.5%';
|
2016-05-16 10:11:49 -07:00
|
|
|
|
|
|
|
|
|
var keyframes = [
|
|
|
|
|
{ opacity: '0', transform: 'translate3d(' + pct + ', 0, 0)', offset: 0 },
|
|
|
|
|
{ opacity: '1', transform: 'none', offset: 1 }];
|
|
|
|
|
|
|
|
|
|
elem.animate(keyframes, {
|
2016-05-16 22:45:06 -07:00
|
|
|
|
duration: 160,
|
2016-05-16 10:11:49 -07:00
|
|
|
|
iterations: 1,
|
|
|
|
|
easing: 'ease-out'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-16 13:48:56 -07:00
|
|
|
|
function animateSelectionBar(button) {
|
|
|
|
|
|
|
|
|
|
var elem = button.querySelector('.pageTabButtonSelectionBar');
|
|
|
|
|
|
2016-05-17 22:34:10 -07:00
|
|
|
|
if (!elem) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-16 13:48:56 -07:00
|
|
|
|
var keyframes = [
|
|
|
|
|
{ transform: 'translate3d(-100%, 0, 0)', offset: 0 },
|
|
|
|
|
{ transform: 'none', offset: 1 }];
|
|
|
|
|
|
|
|
|
|
if (!elem.animate) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
elem.animate(keyframes, {
|
2016-05-16 22:45:06 -07:00
|
|
|
|
duration: 120,
|
2016-05-16 13:48:56 -07:00
|
|
|
|
iterations: 1,
|
|
|
|
|
easing: 'ease-out'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var libraryBrowser = (function (window, document, screen) {
|
|
|
|
|
|
|
|
|
|
// Regular Expressions for parsing tags and attributes
|
|
|
|
|
var SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g,
|
|
|
|
|
// Match everything outside of normal chars and " (quote character)
|
|
|
|
|
NON_ALPHANUMERIC_REGEXP = /([^\#-~| |!])/g;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Escapes all potentially dangerous characters, so that the
|
|
|
|
|
* resulting string can be safely inserted into attribute or
|
|
|
|
|
* element text.
|
|
|
|
|
* @param value
|
|
|
|
|
* @returns {string} escaped text
|
|
|
|
|
*/
|
|
|
|
|
function htmlEncode(value) {
|
|
|
|
|
return value.
|
|
|
|
|
replace(/&/g, '&').
|
|
|
|
|
replace(SURROGATE_PAIR_REGEXP, function (value) {
|
|
|
|
|
var hi = value.charCodeAt(0);
|
|
|
|
|
var low = value.charCodeAt(1);
|
|
|
|
|
return '&#' + (((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000) + ';';
|
|
|
|
|
}).
|
|
|
|
|
replace(NON_ALPHANUMERIC_REGEXP, function (value) {
|
|
|
|
|
return '&#' + value.charCodeAt(0) + ';';
|
|
|
|
|
}).
|
|
|
|
|
replace(/</g, '<').
|
|
|
|
|
replace(/>/g, '>');
|
2016-01-21 14:30:59 -07:00
|
|
|
|
}
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var pageSizeKey = 'pagesize_v4';
|
2013-05-16 12:00:42 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
function getDesiredAspect(shape) {
|
2013-05-16 12:00:42 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (shape) {
|
|
|
|
|
shape = shape.toLowerCase();
|
|
|
|
|
if (shape.indexOf('portrait') != -1) {
|
|
|
|
|
return (2 / 3);
|
|
|
|
|
}
|
|
|
|
|
if (shape.indexOf('backdrop') != -1) {
|
|
|
|
|
return (16 / 9);
|
|
|
|
|
}
|
|
|
|
|
if (shape.indexOf('square') != -1) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2014-09-09 17:28:59 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return null;
|
|
|
|
|
}
|
2014-09-09 17:28:59 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var libraryBrowser = {
|
|
|
|
|
getDefaultPageSize: function (key, defaultValue) {
|
2014-07-05 12:57:18 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return 100;
|
|
|
|
|
},
|
2015-10-14 21:32:10 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getDefaultItemsView: function (view, mobileView) {
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return browserInfo.mobile ? mobileView : view;
|
2013-10-16 19:43:55 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
},
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getSavedQueryKey: function (modifier) {
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return window.location.href.split('#')[0] + (modifier || '');
|
|
|
|
|
},
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
loadSavedQueryValues: function (key, query) {
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var values = appStorage.getItem(key + '_' + Dashboard.getCurrentUserId());
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (values) {
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
values = JSON.parse(values);
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
2016-03-16 14:30:49 -07:00
|
|
|
|
return Object.assign(query, values);
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2014-07-03 19:22:57 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return query;
|
|
|
|
|
},
|
2014-01-14 08:50:39 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
saveQueryValues: function (key, query) {
|
2014-01-14 08:50:39 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var values = {};
|
2014-07-02 11:34:08 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (query.SortBy) {
|
|
|
|
|
values.SortBy = query.SortBy;
|
|
|
|
|
}
|
|
|
|
|
if (query.SortOrder) {
|
|
|
|
|
values.SortOrder = query.SortOrder;
|
|
|
|
|
}
|
2014-01-13 09:25:18 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
try {
|
|
|
|
|
appStorage.setItem(key + '_' + Dashboard.getCurrentUserId(), JSON.stringify(values));
|
|
|
|
|
} catch (e) {
|
2015-08-15 11:46:57 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
2015-08-15 11:46:57 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
saveViewSetting: function (key, value) {
|
2015-08-15 11:46:57 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
try {
|
|
|
|
|
appStorage.setItem(key + '_' + Dashboard.getCurrentUserId() + '_view', value);
|
|
|
|
|
} catch (e) {
|
2014-01-13 09:25:18 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
2014-01-13 09:25:18 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getSavedView: function (key) {
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var val = appStorage.getItem(key + '_' + Dashboard.getCurrentUserId() + '_view');
|
2015-06-29 22:45:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return val;
|
|
|
|
|
},
|
2015-06-30 10:21:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getSavedViewSetting: function (key) {
|
2015-06-29 22:45:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return new Promise(function (resolve, reject) {
|
2015-06-29 22:45:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var val = LibraryBrowser.getSavedView(key);
|
|
|
|
|
resolve(val);
|
|
|
|
|
});
|
|
|
|
|
},
|
2015-07-01 22:08:05 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
allowSwipe: function (target) {
|
2015-07-01 08:47:41 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
function allowSwipeOn(elem) {
|
2015-07-01 08:47:41 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (elem.classList) {
|
2016-05-09 12:27:38 -07:00
|
|
|
|
return !elem.classList.contains('hiddenScrollX') && !elem.classList.contains('smoothScrollX') && !elem.classList.contains('libraryViewNav');
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var parent = target;
|
|
|
|
|
while (parent != null) {
|
|
|
|
|
if (!allowSwipeOn(parent)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
parent = parent.parentNode;
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return true;
|
|
|
|
|
},
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-05-09 12:27:38 -07:00
|
|
|
|
selectedTab: function (tabs, selected) {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
|
2016-03-24 11:11:03 -07:00
|
|
|
|
if (selected == null) {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
|
2016-05-18 10:02:56 -07:00
|
|
|
|
return tabs.selectedTabIndex || 0;
|
2016-03-24 11:11:03 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
|
2016-05-09 12:27:38 -07:00
|
|
|
|
var current = LibraryBrowser.selectedTab(tabs);
|
2016-05-18 10:02:56 -07:00
|
|
|
|
tabs.selectedTabIndex = selected;
|
2016-05-09 12:27:38 -07:00
|
|
|
|
if (current == selected) {
|
2016-06-29 09:31:01 -07:00
|
|
|
|
tabs.dispatchEvent(new CustomEvent("beforetabchange", {
|
|
|
|
|
detail: {
|
|
|
|
|
selectedTabIndex: selected
|
|
|
|
|
}
|
|
|
|
|
}));
|
2016-05-09 12:27:38 -07:00
|
|
|
|
tabs.dispatchEvent(new CustomEvent("tabchange", {
|
|
|
|
|
detail: {
|
|
|
|
|
selectedTabIndex: selected
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
} else {
|
2016-05-15 09:30:32 -07:00
|
|
|
|
var tabButtons = tabs.querySelectorAll('.pageTabButton');
|
2016-05-09 12:27:38 -07:00
|
|
|
|
tabButtons[selected].click();
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}
|
2016-03-24 11:11:03 -07:00
|
|
|
|
},
|
2015-07-01 08:47:41 -07:00
|
|
|
|
|
2016-05-09 12:27:38 -07:00
|
|
|
|
configureSwipeTabs: function (ownerpage, tabs) {
|
2016-03-24 11:11:03 -07:00
|
|
|
|
|
2016-05-15 09:30:32 -07:00
|
|
|
|
var pageCount = ownerpage.querySelectorAll('.pageTabContent').length;
|
2015-09-23 19:31:40 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
require(['hammer'], function (Hammer) {
|
2015-09-01 12:18:25 -07:00
|
|
|
|
|
2016-05-15 09:30:32 -07:00
|
|
|
|
var hammertime = new Hammer(ownerpage);
|
2016-02-17 19:55:15 -07:00
|
|
|
|
hammertime.get('swipe').set({ direction: Hammer.DIRECTION_HORIZONTAL });
|
2015-09-01 12:18:25 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
hammertime.on('swipeleft', function (e) {
|
|
|
|
|
if (LibraryBrowser.allowSwipe(e.target)) {
|
2016-05-09 12:27:38 -07:00
|
|
|
|
var selected = parseInt(LibraryBrowser.selectedTab(tabs) || '0');
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (selected < (pageCount - 1)) {
|
2016-05-09 12:27:38 -07:00
|
|
|
|
LibraryBrowser.selectedTab(tabs, selected + 1);
|
2015-09-07 18:00:46 -07:00
|
|
|
|
}
|
2015-09-01 12:18:25 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
});
|
2015-09-01 12:18:25 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
hammertime.on('swiperight', function (e) {
|
|
|
|
|
if (LibraryBrowser.allowSwipe(e.target)) {
|
2016-05-09 12:27:38 -07:00
|
|
|
|
var selected = parseInt(LibraryBrowser.selectedTab(tabs) || '0');
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (selected > 0) {
|
2016-05-09 12:27:38 -07:00
|
|
|
|
LibraryBrowser.selectedTab(tabs, selected - 1);
|
2015-09-07 18:00:46 -07:00
|
|
|
|
}
|
2015-09-01 12:18:25 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
});
|
2015-09-01 12:18:25 -07:00
|
|
|
|
});
|
2016-02-17 19:55:15 -07:00
|
|
|
|
},
|
2015-07-01 08:47:41 -07:00
|
|
|
|
|
2016-05-16 10:11:49 -07:00
|
|
|
|
configurePaperLibraryTabs: function (ownerpage, tabs, panels, animateTabs) {
|
2015-09-01 08:31:50 -07:00
|
|
|
|
|
2016-05-09 12:27:38 -07:00
|
|
|
|
if (!browserInfo.safari) {
|
|
|
|
|
LibraryBrowser.configureSwipeTabs(ownerpage, tabs);
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2015-07-01 08:47:41 -07:00
|
|
|
|
|
2016-05-18 10:02:56 -07:00
|
|
|
|
if (!browserInfo.safari || !AppInfo.isNativeApp) {
|
|
|
|
|
var buttons = tabs.querySelectorAll('.pageTabButton');
|
|
|
|
|
for (var i = 0, length = buttons.length; i < length; i++) {
|
|
|
|
|
var div = document.createElement('div');
|
|
|
|
|
div.classList.add('pageTabButtonSelectionBar');
|
|
|
|
|
buttons[i].appendChild(div);
|
|
|
|
|
}
|
2016-05-15 09:30:32 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tabs.addEventListener('click', function (e) {
|
2015-07-01 08:47:41 -07:00
|
|
|
|
|
2016-05-15 09:30:32 -07:00
|
|
|
|
var current = tabs.querySelector('.is-active');
|
2016-07-18 11:53:04 -07:00
|
|
|
|
var link = dom.parentWithClass(e.target, 'pageTabButton');
|
2015-07-01 08:47:41 -07:00
|
|
|
|
|
2016-05-15 09:30:32 -07:00
|
|
|
|
if (link && link != current) {
|
|
|
|
|
|
|
|
|
|
if (current) {
|
|
|
|
|
current.classList.remove('is-active');
|
|
|
|
|
panels[parseInt(current.getAttribute('data-index'))].classList.remove('is-active');
|
|
|
|
|
}
|
2016-05-16 10:11:49 -07:00
|
|
|
|
|
2016-05-15 09:30:32 -07:00
|
|
|
|
link.classList.add('is-active');
|
2016-05-16 13:48:56 -07:00
|
|
|
|
animateSelectionBar(link);
|
2016-05-15 09:30:32 -07:00
|
|
|
|
var index = parseInt(link.getAttribute('data-index'));
|
2016-05-16 10:11:49 -07:00
|
|
|
|
var newPanel = panels[index];
|
2016-05-15 09:30:32 -07:00
|
|
|
|
|
2016-06-29 09:31:01 -07:00
|
|
|
|
tabs.dispatchEvent(new CustomEvent("beforetabchange", {
|
|
|
|
|
detail: {
|
|
|
|
|
selectedTabIndex: index
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
2016-05-15 09:30:32 -07:00
|
|
|
|
// If toCenter is called syncronously within the click event, it sometimes ends up canceling it
|
2016-05-16 10:11:49 -07:00
|
|
|
|
setTimeout(function () {
|
|
|
|
|
|
2016-05-16 22:45:06 -07:00
|
|
|
|
if (animateTabs && animateTabs.indexOf(index) != -1 && /*browserInfo.animate &&*/ newPanel.animate) {
|
|
|
|
|
fadeInRight(newPanel);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-07 08:56:49 -07:00
|
|
|
|
tabs.selectedTabIndex = index;
|
|
|
|
|
|
2016-05-16 10:11:49 -07:00
|
|
|
|
tabs.dispatchEvent(new CustomEvent("tabchange", {
|
|
|
|
|
detail: {
|
|
|
|
|
selectedTabIndex: index
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
newPanel.classList.add('is-active');
|
2016-05-16 22:45:06 -07:00
|
|
|
|
}, 120);
|
2016-07-07 08:56:49 -07:00
|
|
|
|
|
|
|
|
|
if (tabs.scroller) {
|
|
|
|
|
tabs.scroller.toCenter(link, false);
|
|
|
|
|
}
|
2016-03-16 22:04:32 -07:00
|
|
|
|
}
|
2016-05-09 12:27:38 -07:00
|
|
|
|
});
|
2015-07-01 22:08:05 -07:00
|
|
|
|
|
2016-03-15 22:33:31 -07:00
|
|
|
|
ownerpage.addEventListener('viewbeforeshow', LibraryBrowser.onTabbedpagebeforeshow);
|
2016-07-07 08:56:49 -07:00
|
|
|
|
|
|
|
|
|
var contentScrollSlider = tabs.querySelector('.contentScrollSlider');
|
|
|
|
|
if (contentScrollSlider) {
|
|
|
|
|
tabs.scroller = new scroller(tabs, {
|
|
|
|
|
horizontal: 1,
|
|
|
|
|
itemNav: 0,
|
|
|
|
|
mouseDragging: 1,
|
|
|
|
|
touchDragging: 1,
|
|
|
|
|
slidee: tabs.querySelector('.contentScrollSlider'),
|
|
|
|
|
smart: true,
|
|
|
|
|
releaseSwing: true,
|
|
|
|
|
scrollBy: 200,
|
|
|
|
|
speed: 120,
|
|
|
|
|
elasticBounds: 1,
|
|
|
|
|
dragHandle: 1,
|
|
|
|
|
dynamicHandle: 1,
|
|
|
|
|
clickBar: 1,
|
|
|
|
|
//centerOffset: window.innerWidth * .05,
|
|
|
|
|
hiddenScroll: true,
|
|
|
|
|
requireAnimation: true
|
|
|
|
|
});
|
|
|
|
|
tabs.scroller.init();
|
|
|
|
|
} else {
|
|
|
|
|
tabs.classList.add('hiddenScrollX');
|
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
},
|
2015-07-01 22:08:05 -07:00
|
|
|
|
|
2016-03-15 22:33:31 -07:00
|
|
|
|
onTabbedpagebeforeshow: function (e) {
|
2015-07-01 22:08:05 -07:00
|
|
|
|
|
2016-03-15 22:33:31 -07:00
|
|
|
|
var page = e.target;
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var delay = 0;
|
|
|
|
|
var isFirstLoad = false;
|
2015-09-01 07:01:59 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (!page.getAttribute('data-firstload')) {
|
|
|
|
|
delay = 300;
|
|
|
|
|
isFirstLoad = true;
|
|
|
|
|
page.setAttribute('data-firstload', '1');
|
|
|
|
|
}
|
2015-09-01 07:01:59 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (delay) {
|
|
|
|
|
setTimeout(function () {
|
2015-09-01 07:01:59 -07:00
|
|
|
|
|
2016-03-15 22:33:31 -07:00
|
|
|
|
LibraryBrowser.onTabbedpagebeforeshowInternal(page, e, isFirstLoad);
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}, delay);
|
|
|
|
|
} else {
|
2016-03-15 22:33:31 -07:00
|
|
|
|
LibraryBrowser.onTabbedpagebeforeshowInternal(page, e, isFirstLoad);
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
2015-09-01 07:01:59 -07:00
|
|
|
|
|
2016-03-15 22:33:31 -07:00
|
|
|
|
onTabbedpagebeforeshowInternal: function (page, e, isFirstLoad) {
|
2015-07-01 22:08:05 -07:00
|
|
|
|
|
2016-05-15 09:30:32 -07:00
|
|
|
|
var pageTabsContainer = page.querySelector('.libraryViewNav');
|
2016-03-15 23:07:11 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (isFirstLoad) {
|
2015-07-05 11:34:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
console.log('selected tab is null, checking query string');
|
2015-07-05 11:34:52 -07:00
|
|
|
|
|
2016-05-09 12:27:38 -07:00
|
|
|
|
var selected = page.firstTabIndex != null ? page.firstTabIndex : parseInt(getParameterByName('tab') || '0');
|
2015-07-05 11:34:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
console.log('selected tab will be ' + selected);
|
2015-07-05 11:34:52 -07:00
|
|
|
|
|
2016-05-09 12:27:38 -07:00
|
|
|
|
LibraryBrowser.selectedTab(pageTabsContainer, selected);
|
2015-09-01 08:31:50 -07:00
|
|
|
|
|
2015-08-25 08:08:04 -07:00
|
|
|
|
} else {
|
2015-09-01 08:40:36 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
// Go back to the first tab
|
2016-05-09 12:27:38 -07:00
|
|
|
|
if (!e.detail.isRestored) {
|
|
|
|
|
LibraryBrowser.selectedTab(pageTabsContainer, 0);
|
|
|
|
|
return;
|
2015-08-27 21:19:08 -07:00
|
|
|
|
}
|
2016-06-29 09:31:01 -07:00
|
|
|
|
pageTabsContainer.dispatchEvent(new CustomEvent("beforetabchange", {
|
|
|
|
|
detail: {
|
|
|
|
|
selectedTabIndex: LibraryBrowser.selectedTab(pageTabsContainer)
|
|
|
|
|
}
|
|
|
|
|
}));
|
2016-03-24 11:11:03 -07:00
|
|
|
|
pageTabsContainer.dispatchEvent(new CustomEvent("tabchange", {
|
|
|
|
|
detail: {
|
2016-03-25 19:37:18 -07:00
|
|
|
|
selectedTabIndex: LibraryBrowser.selectedTab(pageTabsContainer)
|
2016-03-24 11:11:03 -07:00
|
|
|
|
}
|
|
|
|
|
}));
|
2015-08-27 21:19:08 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
},
|
2015-07-01 22:08:05 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
showTab: function (url, index) {
|
2015-08-28 08:02:22 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var afterNavigate = function () {
|
2016-03-16 22:04:32 -07:00
|
|
|
|
|
|
|
|
|
document.removeEventListener('pagebeforeshow', afterNavigate);
|
2015-08-28 08:02:22 -07:00
|
|
|
|
|
2016-05-09 12:27:38 -07:00
|
|
|
|
if (window.location.href.toLowerCase().indexOf(url.toLowerCase()) != -1) {
|
2015-09-24 10:08:10 -07:00
|
|
|
|
|
2016-05-09 12:27:38 -07:00
|
|
|
|
this.firstTabIndex = index;
|
2015-08-28 08:02:22 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
};
|
2015-08-28 10:39:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (window.location.href.toLowerCase().indexOf(url.toLowerCase()) != -1) {
|
2015-08-28 08:02:22 -07:00
|
|
|
|
|
2016-06-11 10:10:06 -07:00
|
|
|
|
afterNavigate.call(viewManager.currentView());
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else {
|
2016-05-09 12:27:38 -07:00
|
|
|
|
|
2016-03-16 22:04:32 -07:00
|
|
|
|
pageClassOn('pagebeforeshow', 'page', afterNavigate);
|
2016-02-17 19:55:15 -07:00
|
|
|
|
Dashboard.navigate(url);
|
|
|
|
|
}
|
|
|
|
|
},
|
2015-08-28 08:02:22 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getDateParamValue: function (date) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
function formatDigit(i) {
|
|
|
|
|
return i < 10 ? "0" + i : i;
|
|
|
|
|
}
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var d = date;
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return "" + d.getFullYear() + formatDigit(d.getMonth() + 1) + formatDigit(d.getDate()) + formatDigit(d.getHours()) + formatDigit(d.getMinutes()) + formatDigit(d.getSeconds());
|
|
|
|
|
},
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
playAllFromHere: function (fn, index) {
|
2014-08-21 08:55:35 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
fn(index, 100, "MediaSources,Chapters").then(function (result) {
|
2014-08-21 08:55:35 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
MediaController.play({
|
|
|
|
|
items: result.Items
|
|
|
|
|
});
|
2014-08-21 08:55:35 -07:00
|
|
|
|
});
|
2016-02-17 19:55:15 -07:00
|
|
|
|
},
|
2014-08-21 08:55:35 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
queueAllFromHere: function (query, index) {
|
2014-08-21 08:55:35 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
fn(index, 100, "MediaSources,Chapters").then(function (result) {
|
2014-08-21 08:55:35 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
MediaController.queue({
|
|
|
|
|
items: result.Items
|
|
|
|
|
});
|
2014-08-21 08:55:35 -07:00
|
|
|
|
});
|
2016-02-17 19:55:15 -07:00
|
|
|
|
},
|
2014-08-21 08:55:35 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getItemCountsHtml: function (options, item) {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var counts = [];
|
2013-09-10 13:23:41 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var childText;
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.Type == 'Playlist') {
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
childText = '';
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.CumulativeRunTimeTicks) {
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var minutes = item.CumulativeRunTimeTicks / 600000000;
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
minutes = minutes || 1;
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
childText += Globalize.translate('ValueMinutes', Math.round(minutes));
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else {
|
|
|
|
|
childText += Globalize.translate('ValueMinutes', 0);
|
|
|
|
|
}
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
counts.push(childText);
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
else if (options.context == "movies") {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.MovieCount) {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
childText = item.MovieCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneMovie') :
|
|
|
|
|
Globalize.translate('ValueMovieCount', item.MovieCount);
|
2013-09-10 13:23:41 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
counts.push(childText);
|
|
|
|
|
}
|
|
|
|
|
if (item.TrailerCount) {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
childText = item.TrailerCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneTrailer') :
|
|
|
|
|
Globalize.translate('ValueTrailerCount', item.TrailerCount);
|
2013-09-10 13:23:41 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
counts.push(childText);
|
|
|
|
|
}
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else if (options.context == "tv") {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.SeriesCount) {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
childText = item.SeriesCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneSeries') :
|
|
|
|
|
Globalize.translate('ValueSeriesCount', item.SeriesCount);
|
2013-09-10 13:23:41 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
counts.push(childText);
|
|
|
|
|
}
|
|
|
|
|
if (item.EpisodeCount) {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
childText = item.EpisodeCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneEpisode') :
|
|
|
|
|
Globalize.translate('ValueEpisodeCount', item.EpisodeCount);
|
2013-09-10 13:23:41 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
counts.push(childText);
|
|
|
|
|
}
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else if (options.context == "games") {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.GameCount) {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
childText = item.GameCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneGame') :
|
|
|
|
|
Globalize.translate('ValueGameCount', item.GameCount);
|
2013-09-10 13:23:41 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
counts.push(childText);
|
|
|
|
|
}
|
|
|
|
|
} else if (options.context == "music") {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.AlbumCount) {
|
2013-09-18 16:33:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
childText = item.AlbumCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneAlbum') :
|
|
|
|
|
Globalize.translate('ValueAlbumCount', item.AlbumCount);
|
2013-09-18 16:33:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
counts.push(childText);
|
|
|
|
|
}
|
|
|
|
|
if (item.SongCount) {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
childText = item.SongCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneSong') :
|
|
|
|
|
Globalize.translate('ValueSongCount', item.SongCount);
|
2013-09-10 13:23:41 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
counts.push(childText);
|
|
|
|
|
}
|
|
|
|
|
if (item.MusicVideoCount) {
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
childText = item.MusicVideoCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneMusicVideo') :
|
|
|
|
|
Globalize.translate('ValueMusicVideoCount', item.MusicVideoCount);
|
2013-09-10 13:23:41 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
counts.push(childText);
|
|
|
|
|
}
|
2013-09-10 11:56:00 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return counts.join(' • ');
|
|
|
|
|
},
|
2013-09-10 11:56:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getArtistLinksHtml: function (artists, cssClass) {
|
2015-03-13 08:54:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var html = [];
|
2015-03-13 08:54:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
for (var i = 0, length = artists.length; i < length; i++) {
|
2015-03-13 08:54:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var artist = artists[i];
|
2015-03-13 08:54:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var css = cssClass ? (' class="' + cssClass + '"') : '';
|
|
|
|
|
html.push('<a' + css + ' href="itemdetails.html?id=' + artist.Id + '">' + artist.Name + '</a>');
|
2015-03-13 08:54:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2015-03-13 08:54:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html = html.join(' / ');
|
2015-03-13 08:54:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2015-03-13 08:54:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
playInExternalPlayer: function (id) {
|
2015-06-02 10:46:44 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
Dashboard.loadExternalPlayer().then(function () {
|
|
|
|
|
ExternalPlayer.showMenu(id);
|
|
|
|
|
});
|
|
|
|
|
},
|
2015-05-25 10:32:22 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
editImages: function (itemId) {
|
2015-09-19 19:06:56 -07:00
|
|
|
|
|
2016-06-28 21:05:16 -07:00
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
|
|
|
|
|
require(['components/imageeditor/imageeditor'], function (ImageEditor) {
|
2016-01-06 09:38:19 -07:00
|
|
|
|
|
2016-06-28 21:05:16 -07:00
|
|
|
|
ImageEditor.show(itemId).then(resolve, reject);
|
|
|
|
|
});
|
2016-02-17 19:55:15 -07:00
|
|
|
|
});
|
|
|
|
|
},
|
2015-09-19 19:06:56 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
editMetadata: function (itemId) {
|
2014-08-07 21:36:51 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
require(['components/metadataeditor/metadataeditor'], function (metadataeditor) {
|
2014-08-07 21:36:51 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
metadataeditor.show(itemId);
|
2015-02-05 22:39:07 -07:00
|
|
|
|
});
|
2016-02-17 19:55:15 -07:00
|
|
|
|
},
|
2014-10-06 16:58:46 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getHref: function (item, context, topParentId) {
|
2015-10-04 09:15:08 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var href = LibraryBrowser.getHrefInternal(item, context);
|
2013-04-30 10:21:21 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (context == 'tv') {
|
|
|
|
|
if (!topParentId) {
|
|
|
|
|
topParentId = LibraryMenu.getTopParentId();
|
|
|
|
|
}
|
2014-05-29 12:34:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (topParentId) {
|
|
|
|
|
href += href.indexOf('?') == -1 ? "?topParentId=" : "&topParentId=";
|
|
|
|
|
href += topParentId;
|
|
|
|
|
}
|
2015-09-21 18:05:33 -07:00
|
|
|
|
}
|
2014-07-16 20:17:14 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return href;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getHrefInternal: function (item, context) {
|
|
|
|
|
|
|
|
|
|
if (!item) {
|
|
|
|
|
throw new Error('item cannot be null');
|
2015-09-21 18:05:33 -07:00
|
|
|
|
}
|
2014-07-16 20:17:14 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.url) {
|
|
|
|
|
return item.url;
|
|
|
|
|
}
|
2014-05-29 12:34:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
// Handle search hints
|
|
|
|
|
var id = item.Id || item.ItemId;
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.CollectionType == 'livetv') {
|
|
|
|
|
return 'livetv.html';
|
|
|
|
|
}
|
2014-05-04 17:46:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.CollectionType == 'channels') {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return 'channels.html';
|
|
|
|
|
}
|
2013-04-27 06:05:33 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (context != 'folders') {
|
|
|
|
|
if (item.CollectionType == 'movies') {
|
|
|
|
|
return 'movies.html?topParentId=' + item.Id;
|
|
|
|
|
}
|
2014-06-07 12:46:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.CollectionType == 'boxsets') {
|
2016-06-18 12:21:28 -07:00
|
|
|
|
return 'itemlist.html?topParentId=' + item.Id + '&parentId=' + item.Id;
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2015-05-07 07:04:10 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.CollectionType == 'tvshows') {
|
|
|
|
|
return 'tv.html?topParentId=' + item.Id;
|
|
|
|
|
}
|
2014-06-07 12:46:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.CollectionType == 'music') {
|
|
|
|
|
return 'music.html?topParentId=' + item.Id;
|
|
|
|
|
}
|
2014-06-07 12:46:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.CollectionType == 'games') {
|
2016-05-18 14:46:56 -07:00
|
|
|
|
return id ? "itemlist.html?parentId=" + id : "#";
|
|
|
|
|
//return 'gamesrecommended.html?topParentId=' + item.Id;
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
if (item.CollectionType == 'playlists') {
|
|
|
|
|
return 'playlists.html?topParentId=' + item.Id;
|
|
|
|
|
}
|
|
|
|
|
if (item.CollectionType == 'photos') {
|
|
|
|
|
return 'photos.html?topParentId=' + item.Id;
|
|
|
|
|
}
|
2014-08-14 06:24:30 -07:00
|
|
|
|
}
|
2016-04-15 12:20:04 -07:00
|
|
|
|
else if (item.IsFolder) {
|
|
|
|
|
return id ? "itemlist.html?parentId=" + id : "#";
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.Type == 'CollectionFolder') {
|
2016-03-18 12:43:17 -07:00
|
|
|
|
return 'itemlist.html?topParentId=' + item.Id + '&parentId=' + item.Id;
|
2014-08-14 06:24:30 -07:00
|
|
|
|
}
|
2014-05-06 19:28:19 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.Type == "PhotoAlbum") {
|
|
|
|
|
return "itemlist.html?context=photos&parentId=" + id;
|
2014-08-14 06:24:30 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.Type == "Playlist") {
|
|
|
|
|
return "itemdetails.html?id=" + id;
|
2014-08-14 06:24:30 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.Type == "TvChannel") {
|
|
|
|
|
return "itemdetails.html?id=" + id;
|
2014-08-14 06:24:30 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.Type == "Channel") {
|
|
|
|
|
return "channelitems.html?id=" + id;
|
|
|
|
|
}
|
2016-03-19 08:38:05 -07:00
|
|
|
|
if ((item.IsFolder && item.SourceType == 'Channel') || item.Type == 'ChannelFolderItem') {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return "channelitems.html?id=" + item.ChannelId + '&folderId=' + item.Id;
|
|
|
|
|
}
|
|
|
|
|
if (item.Type == "Program") {
|
|
|
|
|
return "itemdetails.html?id=" + id;
|
2015-04-19 08:54:20 -07:00
|
|
|
|
}
|
2014-05-06 19:28:19 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.Type == "BoxSet") {
|
|
|
|
|
return "itemdetails.html?id=" + id;
|
|
|
|
|
}
|
|
|
|
|
if (item.Type == "MusicAlbum") {
|
|
|
|
|
return "itemdetails.html?id=" + id;
|
|
|
|
|
}
|
|
|
|
|
if (item.Type == "GameSystem") {
|
|
|
|
|
return "itemdetails.html?id=" + id;
|
|
|
|
|
}
|
|
|
|
|
if (item.Type == "Genre") {
|
|
|
|
|
return "itemdetails.html?id=" + id;
|
|
|
|
|
}
|
|
|
|
|
if (item.Type == "MusicGenre") {
|
|
|
|
|
return "itemdetails.html?id=" + id;
|
|
|
|
|
}
|
|
|
|
|
if (item.Type == "GameGenre") {
|
|
|
|
|
return "itemdetails.html?id=" + id;
|
|
|
|
|
}
|
|
|
|
|
if (item.Type == "Studio") {
|
|
|
|
|
return "itemdetails.html?id=" + id;
|
|
|
|
|
}
|
|
|
|
|
if (item.Type == "Person") {
|
|
|
|
|
return "itemdetails.html?id=" + id;
|
|
|
|
|
}
|
|
|
|
|
if (item.Type == "Recording") {
|
|
|
|
|
return "itemdetails.html?id=" + id;
|
|
|
|
|
}
|
2015-08-20 20:21:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.Type == "MusicArtist") {
|
|
|
|
|
return "itemdetails.html?id=" + id;
|
|
|
|
|
}
|
2013-11-26 09:22:11 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var contextSuffix = context ? ('&context=' + context) : '';
|
2015-08-20 20:21:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.Type == "Series" || item.Type == "Season" || item.Type == "Episode") {
|
|
|
|
|
return "itemdetails.html?id=" + id + contextSuffix;
|
|
|
|
|
}
|
2015-08-20 20:21:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.IsFolder) {
|
|
|
|
|
return id ? "itemlist.html?parentId=" + id : "#";
|
|
|
|
|
}
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return "itemdetails.html?id=" + id;
|
|
|
|
|
},
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getImageUrl: function (item, type, index, options) {
|
2013-04-12 07:13:47 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
options = options || {};
|
|
|
|
|
options.type = type;
|
|
|
|
|
options.index = index;
|
2013-04-11 20:50:47 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (type == 'Backdrop') {
|
|
|
|
|
options.tag = item.BackdropImageTags[index];
|
|
|
|
|
} else if (type == 'Screenshot') {
|
|
|
|
|
options.tag = item.ScreenshotImageTags[index];
|
|
|
|
|
} else if (type == 'Primary') {
|
|
|
|
|
options.tag = item.PrimaryImageTag || item.ImageTags[type];
|
|
|
|
|
} else {
|
|
|
|
|
options.tag = item.ImageTags[type];
|
|
|
|
|
}
|
2013-04-21 21:38:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
// For search hints
|
|
|
|
|
return ApiClient.getScaledImageUrl(item.Id || item.ItemId, options);
|
2013-04-12 07:13:47 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
},
|
2013-04-11 20:50:47 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getUserDataCssClass: function (key) {
|
2014-09-29 21:47:30 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (!key) return '';
|
2014-10-04 11:05:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return 'libraryItemUserData' + key.replace(new RegExp(' ', 'g'), '');
|
|
|
|
|
},
|
2014-07-26 10:30:15 -07:00
|
|
|
|
|
2016-04-23 21:24:16 -07:00
|
|
|
|
getItemDataAttributesList: function (item, options, index) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var atts = [];
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-07-17 09:59:14 -07:00
|
|
|
|
atts.push({
|
|
|
|
|
name: 'serverid',
|
2016-07-17 11:55:07 -07:00
|
|
|
|
value: item.ServerId || options.serverId
|
2016-07-17 09:59:14 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
atts.push({
|
|
|
|
|
name: 'id',
|
|
|
|
|
value: item.Id
|
|
|
|
|
});
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.context) {
|
2016-04-23 21:24:16 -07:00
|
|
|
|
atts.push({
|
|
|
|
|
name: 'context',
|
|
|
|
|
value: options.context || ''
|
|
|
|
|
});
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2015-07-06 00:06:09 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.IsFolder) {
|
2016-04-23 21:24:16 -07:00
|
|
|
|
atts.push({
|
|
|
|
|
name: 'isfolder',
|
|
|
|
|
value: item.IsFolder
|
|
|
|
|
});
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2016-02-12 13:26:03 -07:00
|
|
|
|
|
2016-04-23 21:24:16 -07:00
|
|
|
|
atts.push({
|
2016-07-17 19:55:07 -07:00
|
|
|
|
name: 'type',
|
2016-04-23 21:24:16 -07:00
|
|
|
|
value: item.Type
|
|
|
|
|
});
|
2015-07-06 00:06:09 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.MediaType) {
|
2016-04-23 21:24:16 -07:00
|
|
|
|
atts.push({
|
|
|
|
|
name: 'mediatype',
|
|
|
|
|
value: item.MediaType || ''
|
|
|
|
|
});
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2015-03-04 13:37:35 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
if (item.UserData && item.UserData.PlaybackPositionTicks) {
|
2016-04-23 21:24:16 -07:00
|
|
|
|
atts.push({
|
|
|
|
|
name: 'positionticks',
|
|
|
|
|
value: (item.UserData.PlaybackPositionTicks || 0)
|
|
|
|
|
});
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-04-27 22:00:15 -07:00
|
|
|
|
atts.push({
|
|
|
|
|
name: 'index',
|
|
|
|
|
value: index
|
|
|
|
|
});
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.ChannelId) {
|
2016-04-23 21:24:16 -07:00
|
|
|
|
atts.push({
|
|
|
|
|
name: 'channelid',
|
|
|
|
|
value: item.ChannelId
|
|
|
|
|
});
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2015-08-16 21:08:33 -07:00
|
|
|
|
|
2016-07-20 13:45:50 -07:00
|
|
|
|
if (options.collectionId) {
|
|
|
|
|
atts.push({
|
|
|
|
|
name: 'collectionid',
|
|
|
|
|
value: options.collectionId
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-23 21:24:16 -07:00
|
|
|
|
return atts;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getItemDataAttributes: function (item, options, index) {
|
|
|
|
|
|
|
|
|
|
var atts = LibraryBrowser.getItemDataAttributesList(item, options, index).map(function (i) {
|
|
|
|
|
return 'data-' + i.name + '="' + i.value + '"';
|
|
|
|
|
});
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var html = atts.join(' ');
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (html) {
|
|
|
|
|
html = ' ' + html;
|
|
|
|
|
}
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-07-22 10:30:39 -07:00
|
|
|
|
shapes: ['square', 'portrait', 'banner', 'smallBackdrop', 'backdrop', 'overflowBackdrop', 'overflowPortrait', 'overflowSquare'],
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getPostersPerRow: function (screenWidth) {
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
function getValue(shape) {
|
2016-03-16 22:04:32 -07:00
|
|
|
|
|
|
|
|
|
switch (shape) {
|
2016-03-24 11:11:03 -07:00
|
|
|
|
|
2016-03-16 22:04:32 -07:00
|
|
|
|
case 'portrait':
|
|
|
|
|
if (screenWidth >= 2200) return 10;
|
|
|
|
|
if (screenWidth >= 2100) return 9;
|
|
|
|
|
if (screenWidth >= 1600) return 8;
|
|
|
|
|
if (screenWidth >= 1400) return 7;
|
|
|
|
|
if (screenWidth >= 1200) return 6;
|
|
|
|
|
if (screenWidth >= 800) return 5;
|
|
|
|
|
if (screenWidth >= 640) return 4;
|
|
|
|
|
return 3;
|
|
|
|
|
case 'square':
|
|
|
|
|
if (screenWidth >= 2100) return 9;
|
|
|
|
|
if (screenWidth >= 1800) return 8;
|
|
|
|
|
if (screenWidth >= 1400) return 7;
|
|
|
|
|
if (screenWidth >= 1200) return 6;
|
|
|
|
|
if (screenWidth >= 900) return 5;
|
|
|
|
|
if (screenWidth >= 700) return 4;
|
|
|
|
|
if (screenWidth >= 500) return 3;
|
|
|
|
|
return 2;
|
|
|
|
|
case 'banner':
|
|
|
|
|
if (screenWidth >= 2200) return 4;
|
|
|
|
|
if (screenWidth >= 1200) return 3;
|
|
|
|
|
if (screenWidth >= 800) return 2;
|
|
|
|
|
return 1;
|
|
|
|
|
case 'backdrop':
|
|
|
|
|
if (screenWidth >= 2500) return 6;
|
|
|
|
|
if (screenWidth >= 2100) return 5;
|
|
|
|
|
if (screenWidth >= 1200) return 4;
|
|
|
|
|
if (screenWidth >= 770) return 3;
|
|
|
|
|
if (screenWidth >= 420) return 2;
|
|
|
|
|
return 1;
|
2016-07-07 08:56:49 -07:00
|
|
|
|
case 'smallBackdrop':
|
2016-07-09 14:09:21 -07:00
|
|
|
|
if (screenWidth >= 1440) return 8;
|
2016-07-07 08:56:49 -07:00
|
|
|
|
if (screenWidth >= 1100) return 6;
|
|
|
|
|
if (screenWidth >= 800) return 5;
|
|
|
|
|
if (screenWidth >= 600) return 4;
|
|
|
|
|
if (screenWidth >= 540) return 3;
|
|
|
|
|
if (screenWidth >= 420) return 2;
|
|
|
|
|
return 1;
|
|
|
|
|
case 'overflowPortrait':
|
|
|
|
|
if (screenWidth >= 1000) return 100 / 23;
|
|
|
|
|
if (screenWidth >= 640) return 100 / 36;
|
|
|
|
|
return 2.5;
|
|
|
|
|
case 'overflowSquare':
|
|
|
|
|
if (screenWidth >= 1000) return 100 / 22;
|
|
|
|
|
if (screenWidth >= 640) return 100 / 30;
|
|
|
|
|
return 100 / 42;
|
|
|
|
|
case 'overflowBackdrop':
|
|
|
|
|
if (screenWidth >= 1000) return 100 / 40;
|
|
|
|
|
if (screenWidth >= 640) return 100 / 60;
|
|
|
|
|
return 100 / 84;
|
2016-03-16 22:04:32 -07:00
|
|
|
|
default:
|
2016-07-07 08:56:49 -07:00
|
|
|
|
return 4;
|
2016-03-16 22:04:32 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var info = {};
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
for (var i = 0, length = LibraryBrowser.shapes.length; i < length; i++) {
|
|
|
|
|
var currentShape = LibraryBrowser.shapes[i];
|
|
|
|
|
info[currentShape] = getValue(currentShape);
|
|
|
|
|
}
|
|
|
|
|
return info;
|
|
|
|
|
},
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
posterSizes: [],
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getPosterViewInfo: function () {
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
2016-03-16 22:04:32 -07:00
|
|
|
|
var screenWidth = window.innerWidth;
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
2016-07-07 20:24:22 -07:00
|
|
|
|
if (!browserInfo.mobile) {
|
|
|
|
|
var roundScreenTo = 100;
|
|
|
|
|
screenWidth = Math.ceil(screenWidth / roundScreenTo) * roundScreenTo;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var cachedResults = LibraryBrowser.posterSizes;
|
2015-05-06 21:14:35 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
for (var i = 0, length = cachedResults.length; i < length; i++) {
|
2015-05-06 22:12:13 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (cachedResults[i].screenWidth == screenWidth) {
|
|
|
|
|
return cachedResults[i];
|
|
|
|
|
}
|
2015-05-06 21:14:35 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var result = LibraryBrowser.getPosterViewInfoInternal(screenWidth);
|
|
|
|
|
result.screenWidth = screenWidth;
|
2015-05-06 21:14:35 -07:00
|
|
|
|
|
2016-07-07 08:56:49 -07:00
|
|
|
|
cachedResults.push(result);
|
2015-05-06 21:14:35 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return result;
|
|
|
|
|
},
|
2015-05-06 21:14:35 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getPosterViewInfoInternal: function (screenWidth) {
|
2015-05-06 21:14:35 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var imagesPerRow = LibraryBrowser.getPostersPerRow(screenWidth);
|
2015-05-06 21:14:35 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var result = {};
|
|
|
|
|
result.screenWidth = screenWidth;
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -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
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var shapeWidth = screenWidth / imagesPerRow[currentShape];
|
2015-05-06 21:14:35 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
result[currentShape + 'Width'] = Math.round(shapeWidth);
|
|
|
|
|
}
|
2015-05-06 22:12:13 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return result;
|
|
|
|
|
},
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
2016-04-23 21:24:16 -07:00
|
|
|
|
setPosterViewData: function (options) {
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var items = options.items;
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
options.shape = options.shape || "portrait";
|
2013-04-25 17:52:55 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -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
|
|
|
|
|
2016-05-18 10:02:56 -07:00
|
|
|
|
if (options.shape == 'auto' || options.shape == 'autohome' || options.shape == 'autooverflow') {
|
2014-01-04 22:15:38 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (isThumbAspectRatio) {
|
2016-05-18 10:02:56 -07:00
|
|
|
|
options.shape = options.shape == 'autooverflow' ? 'overflowBackdrop' : 'backdrop';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else if (isSquareAspectRatio) {
|
|
|
|
|
options.coverImage = true;
|
2016-05-18 10:02:56 -07:00
|
|
|
|
options.shape = options.shape == 'autooverflow' ? 'overflowSquare' : 'square';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else if (primaryImageAspectRatio && primaryImageAspectRatio > 1.9) {
|
|
|
|
|
options.shape = 'banner';
|
|
|
|
|
options.coverImage = true;
|
|
|
|
|
} else if (primaryImageAspectRatio && Math.abs(primaryImageAspectRatio - 0.6666667) < .2) {
|
2016-05-18 10:02:56 -07:00
|
|
|
|
options.shape = options.shape == 'autooverflow' ? 'overflowPortrait' : 'portrait';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else {
|
2016-05-18 10:02:56 -07:00
|
|
|
|
options.shape = options.defaultShape || (options.shape == 'autooverflow' ? 'overflowSquare' : 'square');
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2014-06-19 21:50:30 -07:00
|
|
|
|
}
|
2014-01-05 18:59:21 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var posterInfo = LibraryBrowser.getPosterViewInfo();
|
2015-05-06 20:11:51 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var thumbWidth = posterInfo.backdropWidth;
|
|
|
|
|
var posterWidth = posterInfo.portraitWidth;
|
|
|
|
|
var squareSize = posterInfo.squareWidth;
|
|
|
|
|
var bannerWidth = posterInfo.bannerWidth;
|
2015-05-06 22:12:13 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (isThumbAspectRatio) {
|
|
|
|
|
posterWidth = thumbWidth;
|
|
|
|
|
}
|
|
|
|
|
else if (isSquareAspectRatio) {
|
|
|
|
|
posterWidth = squareSize;
|
|
|
|
|
}
|
2015-05-12 06:58:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.shape == 'overflowBackdrop') {
|
|
|
|
|
thumbWidth = posterInfo.overflowBackdropWidth;
|
|
|
|
|
}
|
|
|
|
|
else if (options.shape == 'overflowPortrait') {
|
|
|
|
|
posterWidth = posterInfo.overflowPortraitWidth;
|
|
|
|
|
}
|
|
|
|
|
else if (options.shape == 'overflowSquare') {
|
|
|
|
|
squareSize = posterInfo.overflowSquareWidth;
|
|
|
|
|
}
|
|
|
|
|
else if (options.shape == 'smallBackdrop') {
|
|
|
|
|
thumbWidth = posterInfo.smallBackdropWidth;
|
|
|
|
|
}
|
|
|
|
|
else if (options.shape == 'detailPagePortrait') {
|
|
|
|
|
posterWidth = 200;
|
|
|
|
|
}
|
|
|
|
|
else if (options.shape == 'detailPageSquare') {
|
|
|
|
|
posterWidth = 240;
|
|
|
|
|
squareSize = 240;
|
|
|
|
|
}
|
|
|
|
|
else if (options.shape == 'detailPage169') {
|
|
|
|
|
posterWidth = 320;
|
|
|
|
|
thumbWidth = 320;
|
|
|
|
|
}
|
2015-05-25 10:32:22 -07:00
|
|
|
|
|
2016-04-23 21:24:16 -07:00
|
|
|
|
options.uiAspect = getDesiredAspect(options.shape);
|
|
|
|
|
options.primaryImageAspectRatio = primaryImageAspectRatio;
|
|
|
|
|
options.posterWidth = posterWidth;
|
|
|
|
|
options.thumbWidth = thumbWidth;
|
|
|
|
|
options.bannerWidth = bannerWidth;
|
|
|
|
|
options.squareSize = squareSize;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getPosterViewHtml: function (options) {
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.setPosterViewData(options);
|
|
|
|
|
|
|
|
|
|
var items = options.items;
|
|
|
|
|
var currentIndexValue;
|
|
|
|
|
|
|
|
|
|
options.shape = options.shape || "portrait";
|
|
|
|
|
|
|
|
|
|
var html = "";
|
|
|
|
|
|
|
|
|
|
var primaryImageAspectRatio;
|
|
|
|
|
var thumbWidth = options.thumbWidth;
|
|
|
|
|
var posterWidth = options.posterWidth;
|
|
|
|
|
var squareSize = options.squareSize;
|
|
|
|
|
var bannerWidth = options.bannerWidth;
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var dateText;
|
2016-04-23 21:24:16 -07:00
|
|
|
|
var uiAspect = options.uiAspect;
|
2015-05-08 12:10:53 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
for (var i = 0, length = items.length; i < length; i++) {
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var item = items[i];
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
dateText = null;
|
2015-05-08 12:10:53 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
primaryImageAspectRatio = LibraryBrowser.getAveragePrimaryImageAspectRatio([item]);
|
2014-01-22 17:39:26 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.showStartDateIndex) {
|
2015-03-19 10:34:53 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.StartDate) {
|
|
|
|
|
try {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-05-05 21:50:06 -07:00
|
|
|
|
dateText = LibraryBrowser.getFutureDateText(datetime.parseISO8601Date(item.StartDate, true), true);
|
2015-03-19 10:34:53 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} catch (err) {
|
|
|
|
|
}
|
2015-03-19 10:34:53 -07:00
|
|
|
|
}
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var newIndexValue = dateText || Globalize.translate('HeaderUnknownDate');
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (newIndexValue != currentIndexValue) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += '<h1 class="timelineHeader" style="text-align:center;">' + newIndexValue + '</h1>';
|
|
|
|
|
currentIndexValue = newIndexValue;
|
|
|
|
|
}
|
|
|
|
|
} else if (options.timeline) {
|
|
|
|
|
var year = item.ProductionYear || Globalize.translate('HeaderUnknownYear');
|
2014-01-02 14:21:06 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (year != currentIndexValue) {
|
2014-01-02 14:21:06 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += '<h1 class="timelineHeader">' + year + '</h1>';
|
|
|
|
|
currentIndexValue = year;
|
|
|
|
|
}
|
2014-01-02 14:21:06 -07:00
|
|
|
|
}
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += LibraryBrowser.getPosterViewItemHtml(item, i, options, primaryImageAspectRatio, thumbWidth, posterWidth, squareSize, bannerWidth, uiAspect);
|
|
|
|
|
}
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-12-22 10:16:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getPosterViewItemHtml: function (item, index, options, primaryImageAspectRatio, thumbWidth, posterWidth, squareSize, bannerWidth, uiAspect) {
|
2014-05-23 16:58:28 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var html = '';
|
|
|
|
|
var imgUrl = null;
|
|
|
|
|
var icon;
|
|
|
|
|
var width = null;
|
|
|
|
|
var height = null;
|
2014-06-30 21:06:28 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var forceName = false;
|
2014-06-30 21:06:28 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var enableImageEnhancers = options.enableImageEnhancers !== false;
|
2014-06-30 21:06:28 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var cssClass = "card";
|
2015-06-18 21:23:55 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.fullWidthOnMobile) {
|
|
|
|
|
cssClass += " fullWidthCardOnMobile";
|
|
|
|
|
}
|
2015-07-17 15:32:00 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var showTitle = options.showTitle == 'auto' ? true : options.showTitle;
|
2016-04-27 10:52:27 -07:00
|
|
|
|
|
2016-05-15 11:52:36 -07:00
|
|
|
|
// Force the title for these
|
|
|
|
|
if (item.Type == 'PhotoAlbum' || item.Type == 'Folder') {
|
2016-04-27 10:52:27 -07:00
|
|
|
|
showTitle = true;
|
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var coverImage = options.coverImage;
|
2016-05-06 11:17:02 -07:00
|
|
|
|
var imageItem = item.Type == 'Timer' ? (item.ProgramInfo || item) : item;
|
2015-08-28 08:02:22 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
if (options.autoThumb && imageItem.ImageTags && imageItem.ImageTags.Primary && imageItem.PrimaryImageAspectRatio && imageItem.PrimaryImageAspectRatio >= 1.34) {
|
2014-06-30 21:06:28 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
width = posterWidth;
|
|
|
|
|
height = primaryImageAspectRatio ? Math.round(posterWidth / primaryImageAspectRatio) : null;
|
2014-06-30 21:06:28 -07:00
|
|
|
|
|
2016-07-07 08:56:49 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
type: "Primary",
|
|
|
|
|
maxHeight: height,
|
|
|
|
|
maxWidth: width,
|
2016-05-06 11:17:02 -07:00
|
|
|
|
tag: imageItem.ImageTags.Primary,
|
2016-02-17 19:55:15 -07:00
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2016-01-21 14:30:59 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (primaryImageAspectRatio) {
|
|
|
|
|
if (uiAspect) {
|
|
|
|
|
if (Math.abs(primaryImageAspectRatio - uiAspect) <= .2) {
|
|
|
|
|
coverImage = true;
|
|
|
|
|
}
|
2016-01-24 12:39:13 -07:00
|
|
|
|
}
|
2016-01-21 14:30:59 -07:00
|
|
|
|
}
|
2013-04-25 17:52:55 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
} else if (options.autoThumb && imageItem.ImageTags && imageItem.ImageTags.Thumb) {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxWidth: thumbWidth,
|
2016-05-06 11:17:02 -07:00
|
|
|
|
tag: imageItem.ImageTags.Thumb,
|
2016-02-17 19:55:15 -07:00
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
} else if (options.preferBackdrop && imageItem.BackdropImageTags && imageItem.BackdropImageTags.length) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
type: "Backdrop",
|
|
|
|
|
maxWidth: thumbWidth,
|
2016-05-06 11:17:02 -07:00
|
|
|
|
tag: imageItem.BackdropImageTags[0],
|
2016-02-17 19:55:15 -07:00
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2014-03-30 18:00:47 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
} else if (options.preferThumb && imageItem.ImageTags && imageItem.ImageTags.Thumb) {
|
2014-03-30 18:00:47 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxWidth: thumbWidth,
|
2016-05-06 11:17:02 -07:00
|
|
|
|
tag: imageItem.ImageTags.Thumb,
|
2016-02-17 19:55:15 -07:00
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
} else if (options.preferBanner && imageItem.ImageTags && imageItem.ImageTags.Banner) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
type: "Banner",
|
|
|
|
|
maxWidth: bannerWidth,
|
2016-05-06 11:17:02 -07:00
|
|
|
|
tag: imageItem.ImageTags.Banner,
|
2016-02-17 19:55:15 -07:00
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-07-04 23:01:31 -07:00
|
|
|
|
} else if (options.preferThumb && imageItem.SeriesThumbImageTag && options.inheritThumb !== false) {
|
|
|
|
|
|
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(imageItem.SeriesId, {
|
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxWidth: thumbWidth,
|
|
|
|
|
tag: imageItem.SeriesThumbImageTag,
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
} else if (options.preferThumb && imageItem.ParentThumbItemId && options.inheritThumb !== false) {
|
2013-12-22 10:16:24 -07:00
|
|
|
|
|
2016-07-04 22:40:18 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(imageItem.ParentThumbItemId, {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxWidth: thumbWidth,
|
2016-07-10 10:11:48 -07:00
|
|
|
|
enableImageEnhancers: enableImageEnhancers,
|
|
|
|
|
tag: imageItem.ParentThumbImageTag
|
2016-02-17 19:55:15 -07:00
|
|
|
|
});
|
2014-09-15 20:39:13 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
} else if (options.preferThumb && imageItem.BackdropImageTags && imageItem.BackdropImageTags.length) {
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
type: "Backdrop",
|
|
|
|
|
maxWidth: thumbWidth,
|
2016-05-06 11:17:02 -07:00
|
|
|
|
tag: imageItem.BackdropImageTags[0],
|
2016-02-17 19:55:15 -07:00
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
forceName = true;
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
} else if (imageItem.ImageTags && imageItem.ImageTags.Primary) {
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
width = posterWidth;
|
|
|
|
|
height = primaryImageAspectRatio ? Math.round(posterWidth / primaryImageAspectRatio) : null;
|
2013-07-18 07:59:58 -07:00
|
|
|
|
|
2016-07-07 08:56:49 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
type: "Primary",
|
|
|
|
|
maxHeight: height,
|
|
|
|
|
maxWidth: width,
|
2016-05-06 11:17:02 -07:00
|
|
|
|
tag: imageItem.ImageTags.Primary,
|
2016-02-17 19:55:15 -07:00
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2016-01-21 14:30:59 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (primaryImageAspectRatio) {
|
|
|
|
|
if (uiAspect) {
|
|
|
|
|
if (Math.abs(primaryImageAspectRatio - uiAspect) <= .2) {
|
|
|
|
|
coverImage = true;
|
|
|
|
|
}
|
2016-01-24 12:39:13 -07:00
|
|
|
|
}
|
2016-01-21 14:30:59 -07:00
|
|
|
|
}
|
2015-11-12 12:49:19 -07:00
|
|
|
|
}
|
2016-05-06 11:17:02 -07:00
|
|
|
|
else if (imageItem.ParentPrimaryImageTag) {
|
2013-07-18 07:59:58 -07:00
|
|
|
|
|
2016-07-07 08:56:49 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(imageItem.ParentPrimaryImageItemId, {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
type: "Primary",
|
|
|
|
|
maxWidth: posterWidth,
|
|
|
|
|
tag: item.ParentPrimaryImageTag,
|
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
|
|
|
|
}
|
2016-05-06 11:17:02 -07:00
|
|
|
|
else if (imageItem.AlbumId && imageItem.AlbumPrimaryImageTag) {
|
2014-09-15 20:39:13 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
height = squareSize;
|
|
|
|
|
width = primaryImageAspectRatio ? Math.round(height * primaryImageAspectRatio) : null;
|
2014-09-15 20:39:13 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(imageItem.AlbumId, {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
type: "Primary",
|
|
|
|
|
maxHeight: height,
|
|
|
|
|
maxWidth: width,
|
2016-05-06 11:17:02 -07:00
|
|
|
|
tag: imageItem.AlbumPrimaryImageTag,
|
2016-02-17 19:55:15 -07:00
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2016-01-21 14:30:59 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (primaryImageAspectRatio) {
|
|
|
|
|
if (uiAspect) {
|
|
|
|
|
if (Math.abs(primaryImageAspectRatio - uiAspect) <= .2) {
|
|
|
|
|
coverImage = true;
|
|
|
|
|
}
|
2016-01-24 12:39:13 -07:00
|
|
|
|
}
|
2016-01-21 14:30:59 -07:00
|
|
|
|
}
|
2015-11-12 12:49:19 -07:00
|
|
|
|
}
|
2016-05-06 11:17:02 -07:00
|
|
|
|
else if (imageItem.Type == 'Season' && imageItem.ImageTags && imageItem.ImageTags.Thumb) {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxWidth: thumbWidth,
|
2016-05-06 11:17:02 -07:00
|
|
|
|
tag: imageItem.ImageTags.Thumb,
|
2016-02-17 19:55:15 -07:00
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2016-05-06 11:17:02 -07:00
|
|
|
|
else if (imageItem.BackdropImageTags && imageItem.BackdropImageTags.length) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
type: "Backdrop",
|
|
|
|
|
maxWidth: thumbWidth,
|
2016-05-06 11:17:02 -07:00
|
|
|
|
tag: imageItem.BackdropImageTags[0],
|
2016-02-17 19:55:15 -07:00
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
} else if (imageItem.ImageTags && imageItem.ImageTags.Thumb) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(imageItem.Id, {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxWidth: thumbWidth,
|
2016-05-06 11:17:02 -07:00
|
|
|
|
tag: imageItem.ImageTags.Thumb,
|
2016-02-17 19:55:15 -07:00
|
|
|
|
enableImageEnhancers: enableImageEnhancers
|
|
|
|
|
});
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
} else if (imageItem.ParentThumbItemId) {
|
2014-01-03 13:32:27 -07:00
|
|
|
|
|
2016-07-10 10:11:48 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(imageItem.ParentThumbItemId, {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxWidth: thumbWidth,
|
2016-07-10 10:11:48 -07:00
|
|
|
|
enableImageEnhancers: enableImageEnhancers,
|
|
|
|
|
tag: imageItem.ParentThumbImageTag
|
2016-02-17 19:55:15 -07:00
|
|
|
|
});
|
2013-12-28 16:09:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else if (item.MediaType == "Audio" || item.Type == "MusicAlbum" || item.Type == "MusicArtist") {
|
2013-12-28 16:09:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.Name && showTitle) {
|
2016-06-18 22:26:52 -07:00
|
|
|
|
icon = 'library_music';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
cssClass += " defaultBackground";
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else if (item.Type == "Recording" || item.Type == "Program" || item.Type == "TvChannel") {
|
|
|
|
|
|
|
|
|
|
if (item.Name && showTitle) {
|
2016-06-18 22:26:52 -07:00
|
|
|
|
icon = 'folder_open';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cssClass += " defaultBackground";
|
|
|
|
|
} else if (item.MediaType == "Video" || item.Type == "Season" || item.Type == "Series") {
|
|
|
|
|
|
|
|
|
|
if (item.Name && showTitle) {
|
|
|
|
|
icon = 'videocam';
|
|
|
|
|
}
|
|
|
|
|
cssClass += " defaultBackground";
|
|
|
|
|
} else if (item.Type == "Person") {
|
2014-01-03 13:32:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.Name && showTitle) {
|
|
|
|
|
icon = 'person';
|
|
|
|
|
}
|
|
|
|
|
cssClass += " defaultBackground";
|
|
|
|
|
} else {
|
|
|
|
|
if (item.Name && showTitle) {
|
2016-06-18 22:26:52 -07:00
|
|
|
|
icon = 'folder_open';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
cssClass += " defaultBackground";
|
2013-04-03 05:03:13 -07:00
|
|
|
|
}
|
2013-04-10 12:33:19 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
icon = item.icon || icon;
|
|
|
|
|
cssClass += ' ' + options.shape + 'Card';
|
|
|
|
|
|
|
|
|
|
var mediaSourceCount = item.MediaSourceCount || 1;
|
2013-04-28 11:30:58 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var href = options.linkItem === false ? '#' : LibraryBrowser.getHref(item, options.context);
|
|
|
|
|
|
|
|
|
|
if (options.showChildCountIndicator && item.ChildCount && options.showLatestItemsPopup !== false) {
|
|
|
|
|
cssClass += ' groupedCard';
|
2013-09-08 14:16:13 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if ((showTitle || options.showItemCounts) && !options.overlayText) {
|
|
|
|
|
cssClass += ' bottomPaddedCard';
|
2015-05-08 12:10:53 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
|
|
|
|
|
var dataAttributes = LibraryBrowser.getItemDataAttributes(item, options, index);
|
|
|
|
|
|
|
|
|
|
var defaultAction = options.defaultAction;
|
|
|
|
|
if (defaultAction == 'play' || defaultAction == 'playallfromhere') {
|
|
|
|
|
if (item.PlayAccess != 'Full') {
|
|
|
|
|
defaultAction = null;
|
|
|
|
|
}
|
2015-05-08 12:10:53 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var defaultActionAttribute = defaultAction ? (' data-action="' + defaultAction + '"') : '';
|
2013-04-28 11:30:58 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
// card
|
|
|
|
|
html += '<div' + dataAttributes + ' class="' + cssClass + '">';
|
2014-06-30 11:55:38 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var style = "";
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (imgUrl && !options.lazy) {
|
|
|
|
|
style += 'background-image:url(\'' + imgUrl + '\');';
|
|
|
|
|
}
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var imageCssClass = 'cardImage';
|
2014-09-01 13:10:54 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (icon) {
|
|
|
|
|
imageCssClass += " iconCardImage";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (coverImage) {
|
|
|
|
|
imageCssClass += " coveredCardImage";
|
2016-02-26 10:15:06 -07:00
|
|
|
|
if (item.MediaType == 'Photo' || item.Type == 'PhotoAlbum' || item.Type == 'Folder' || item.Type == 'Program' || item.Type == 'Recording') {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
imageCssClass += " noScale";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (options.centerImage) {
|
|
|
|
|
imageCssClass += " centeredCardImage";
|
|
|
|
|
}
|
2014-03-10 11:56:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var dataSrc = "";
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.lazy && imgUrl) {
|
|
|
|
|
imageCssClass += " lazy";
|
|
|
|
|
dataSrc = ' data-src="' + imgUrl + '"';
|
2013-04-25 17:52:55 -07:00
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var cardboxCssClass = 'cardBox';
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.cardLayout) {
|
|
|
|
|
cardboxCssClass += ' visualCardBox';
|
|
|
|
|
}
|
|
|
|
|
html += '<div class="' + cardboxCssClass + '">';
|
|
|
|
|
html += '<div class="cardScalable">';
|
2014-01-01 11:26:31 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += '<div class="cardPadder"></div>';
|
2014-04-08 11:22:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var anchorCssClass = "cardContent";
|
2014-11-09 21:20:11 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
anchorCssClass += ' mediaItem';
|
2015-11-12 12:49:19 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.defaultAction) {
|
2016-07-17 11:55:07 -07:00
|
|
|
|
anchorCssClass += ' itemAction';
|
2016-01-26 22:54:18 -07:00
|
|
|
|
}
|
2014-01-01 11:26:31 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var transition = options.transition === false || !AppInfo.enableSectionTransitions ? '' : ' data-transition="slide"';
|
|
|
|
|
var onclick = item.onclick ? ' onclick="' + item.onclick + '"' : '';
|
|
|
|
|
html += '<a' + onclick + transition + ' class="' + anchorCssClass + '" href="' + href + '"' + defaultActionAttribute + '>';
|
|
|
|
|
html += '<div class="' + imageCssClass + '" style="' + style + '"' + dataSrc + '>';
|
|
|
|
|
if (icon) {
|
2016-06-18 22:26:52 -07:00
|
|
|
|
html += '<i class="md-icon">' + icon + '</i>';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
html += '</div>';
|
2014-11-11 21:51:40 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.LocationType == "Virtual" || item.LocationType == "Offline") {
|
|
|
|
|
if (options.showLocationTypeIndicator !== false) {
|
|
|
|
|
html += LibraryBrowser.getOfflineIndicatorHtml(item);
|
|
|
|
|
}
|
|
|
|
|
} else if (options.showUnplayedIndicator !== false) {
|
2016-07-17 09:59:14 -07:00
|
|
|
|
html += indicators.getPlayedIndicatorHtml(item);
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else if (options.showChildCountIndicator) {
|
|
|
|
|
html += LibraryBrowser.getGroupCountIndicator(item);
|
|
|
|
|
}
|
2014-11-11 21:51:40 -07:00
|
|
|
|
|
2016-05-09 20:36:43 -07:00
|
|
|
|
if (item.SeriesTimerId) {
|
2016-06-18 22:26:52 -07:00
|
|
|
|
html += '<i class="md-icon seriesTimerIndicator">fiber_smart_record</i>';
|
2016-05-09 20:36:43 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += LibraryBrowser.getSyncIndicator(item);
|
2013-12-28 22:32:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (mediaSourceCount > 1) {
|
|
|
|
|
html += '<div class="mediaSourceIndicator">' + mediaSourceCount + '</div>';
|
|
|
|
|
}
|
2014-01-14 22:01:58 -07:00
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
var progressHtml = options.showProgress === false || item.IsFolder ? '' : LibraryBrowser.getItemProgressBarHtml((item.Type == 'Recording' ? item : item.UserData || {}));
|
2014-01-01 11:26:31 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var footerOverlayed = false;
|
2015-05-09 21:29:04 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.overlayText || (forceName && !showTitle)) {
|
2014-02-28 21:12:56 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var footerCssClass = progressHtml ? 'cardFooter fullCardFooter' : 'cardFooter';
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
2016-07-21 21:59:58 -07:00
|
|
|
|
html += LibraryBrowser.getCardFooterText(item, options, showTitle, imgUrl, forceName, footerCssClass, progressHtml, false);
|
2016-02-17 19:55:15 -07:00
|
|
|
|
footerOverlayed = true;
|
2014-01-01 11:26:31 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
else if (progressHtml) {
|
|
|
|
|
html += '<div class="cardFooter fullCardFooter lightCardFooter">';
|
|
|
|
|
html += "<div class='cardProgress cardText'>";
|
|
|
|
|
html += progressHtml;
|
|
|
|
|
html += "</div>";
|
|
|
|
|
//cardFooter
|
|
|
|
|
html += "</div>";
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
progressHtml = '';
|
|
|
|
|
}
|
2015-06-01 22:46:06 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
// cardContent
|
|
|
|
|
html += '</a>';
|
2013-04-25 20:33:54 -07:00
|
|
|
|
|
2016-06-30 07:49:36 -07:00
|
|
|
|
if (options.overlayPlayButton && !item.IsPlaceHolder && (item.LocationType != 'Virtual' || !item.MediaType || item.Type == 'Program') && item.Type != 'Person' && item.PlayAccess == 'Full') {
|
2016-07-17 13:08:04 -07:00
|
|
|
|
html += '<div class="cardOverlayButtonContainer"><button is="paper-icon-button-light" class="cardOverlayPlayButton itemAction autoSize" data-action="playmenu" onclick="return false;"><i class="md-icon">play_arrow</i></button></div>';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
if (options.overlayMoreButton) {
|
2016-07-17 13:08:04 -07:00
|
|
|
|
html += '<div class="cardOverlayButtonContainer"><button is="paper-icon-button-light" class="cardOverlayMoreButton itemAction autoSize" data-action="menu" onclick="return false;"><i class="md-icon">' + AppInfo.moreIcon.replace('-', '_') + '</i></button></div>';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
// cardScalable
|
|
|
|
|
html += '</div>';
|
2013-12-22 10:16:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (!options.overlayText && !footerOverlayed) {
|
2016-07-21 21:59:58 -07:00
|
|
|
|
html += LibraryBrowser.getCardFooterText(item, options, showTitle, imgUrl, forceName, 'cardFooter outerCardFooter', progressHtml, true);
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2015-05-11 09:32:15 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
// cardBox
|
|
|
|
|
html += '</div>';
|
2015-05-11 09:32:15 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
// card
|
2015-05-08 12:10:53 -07:00
|
|
|
|
html += "</div>";
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2015-05-08 12:10:53 -07:00
|
|
|
|
|
2016-07-21 21:59:58 -07:00
|
|
|
|
getTextActionButton: function (item, text) {
|
|
|
|
|
|
|
|
|
|
if (!text) {
|
|
|
|
|
text = itemHelper.getDisplayName(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var html = '<button data-id="' + item.Id + '" data-type="' + item.Type + '" data-mediatype="' + item.MediaType + '" data-isfolder="' + item.IsFolder + '" type="button" class="itemAction textActionButton" data-action="link">';
|
|
|
|
|
html += text;
|
|
|
|
|
html += '</button>';
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getCardFooterText: function (item, options, showTitle, imgUrl, forceName, footerClass, progressHtml, isOuterFooter) {
|
2015-07-06 00:06:09 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var html = '';
|
2015-05-08 12:10:53 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.cardLayout) {
|
|
|
|
|
html += '<div class="cardButtonContainer">';
|
2016-07-17 13:08:04 -07:00
|
|
|
|
html += '<button is="paper-icon-button-light" class="itemAction btnCardOptions autoSize" data-action="menu"><i class="md-icon">' + AppInfo.moreIcon.replace('-', '_') + '</i></button>';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += "</div>";
|
|
|
|
|
}
|
2015-05-08 12:10:53 -07:00
|
|
|
|
|
2016-05-11 10:46:44 -07:00
|
|
|
|
var name = options.showTitle == 'auto' && !item.IsFolder && item.MediaType == 'Photo' ? '' : itemHelper.getDisplayName(item);
|
2015-05-08 12:10:53 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (!imgUrl && !showTitle) {
|
|
|
|
|
html += "<div class='cardDefaultText'>";
|
|
|
|
|
html += htmlEncode(name);
|
|
|
|
|
html += "</div>";
|
|
|
|
|
}
|
2015-05-08 12:10:53 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var cssClass = options.centerText ? "cardText cardTextCentered" : "cardText";
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var lines = [];
|
2013-05-03 19:33:44 -07:00
|
|
|
|
|
2016-07-21 21:59:58 -07:00
|
|
|
|
var parentTitleUnderneath = item.Type == 'MusicAlbum' || item.Type == 'Audio' || item.Type == 'MusicVideo';
|
|
|
|
|
if (options.showParentTitle && !parentTitleUnderneath) {
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-07-21 21:59:58 -07:00
|
|
|
|
if (isOuterFooter && item.Type == 'Episode' && item.SeriesName && item.SeriesId) {
|
|
|
|
|
|
|
|
|
|
lines.push(LibraryBrowser.getTextActionButton({
|
|
|
|
|
Id: item.SeriesId,
|
|
|
|
|
Name: item.SeriesName,
|
|
|
|
|
Type: 'Series',
|
|
|
|
|
IsFolder: true
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
lines.push(item.EpisodeTitle ? item.Name : (item.SeriesName || item.Album || item.AlbumArtist || item.GameSystem || ""));
|
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2014-11-10 20:41:19 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (showTitle || forceName) {
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
lines.push(htmlEncode(name));
|
|
|
|
|
}
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-07-21 21:59:58 -07:00
|
|
|
|
if (options.showParentTitle && parentTitleUnderneath) {
|
|
|
|
|
|
|
|
|
|
if (isOuterFooter && item.AlbumArtists && item.AlbumArtists.length) {
|
|
|
|
|
item.AlbumArtists[0].Type = 'MusicArtist';
|
|
|
|
|
item.AlbumArtists[0].IsFolder = true;
|
|
|
|
|
lines.push(LibraryBrowser.getTextActionButton(item.AlbumArtists[0]));
|
|
|
|
|
} else {
|
|
|
|
|
lines.push(item.EpisodeTitle ? item.Name : (item.SeriesName || item.Album || item.AlbumArtist || item.GameSystem || ""));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.showItemCounts) {
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var itemCountHtml = LibraryBrowser.getItemCountsHtml(options, item);
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
lines.push(itemCountHtml);
|
|
|
|
|
}
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -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-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.showSongCount) {
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var songLine = '';
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.SongCount) {
|
|
|
|
|
songLine = item.SongCount == 1 ?
|
|
|
|
|
Globalize.translate('ValueOneSong') :
|
|
|
|
|
Globalize.translate('ValueSongCount', item.SongCount);
|
|
|
|
|
}
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
lines.push(songLine);
|
|
|
|
|
}
|
2013-04-25 17:52:55 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.showPremiereDate) {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.PremiereDate) {
|
|
|
|
|
try {
|
2015-01-24 23:34:50 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
lines.push(LibraryBrowser.getPremiereDateText(item));
|
2014-11-10 20:41:19 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} catch (err) {
|
|
|
|
|
lines.push('');
|
2014-11-10 20:41:19 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
lines.push('');
|
|
|
|
|
}
|
2014-11-10 20:41:19 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.showYear) {
|
2014-11-10 20:41:19 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
lines.push(item.ProductionYear || '');
|
|
|
|
|
}
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-05-06 11:54:14 -07:00
|
|
|
|
if (options.showChannelName) {
|
|
|
|
|
|
|
|
|
|
lines.push(item.ChannelName || '');
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-06 11:17:02 -07:00
|
|
|
|
if (options.showAirTime) {
|
|
|
|
|
|
|
|
|
|
var airTimeText;
|
|
|
|
|
if (item.StartDate) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
var date = datetime.parseISO8601Date(item.StartDate);
|
|
|
|
|
|
|
|
|
|
airTimeText = date.toLocaleDateString();
|
|
|
|
|
|
|
|
|
|
airTimeText += ', ' + datetime.getDisplayTime(date);
|
|
|
|
|
|
|
|
|
|
if (item.EndDate) {
|
|
|
|
|
date = datetime.parseISO8601Date(item.EndDate);
|
|
|
|
|
airTimeText += ' - ' + datetime.getDisplayTime(date);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (e) {
|
|
|
|
|
console.log("Error parsing date: " + item.PremiereDate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lines.push(airTimeText || '');
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-09 12:27:38 -07:00
|
|
|
|
if (item.Type == 'TvChannel') {
|
2016-05-05 22:13:29 -07:00
|
|
|
|
|
|
|
|
|
if (item.CurrentProgram) {
|
2016-05-11 10:46:44 -07:00
|
|
|
|
lines.push(itemHelper.getDisplayName(item.CurrentProgram));
|
2016-05-05 22:13:29 -07:00
|
|
|
|
} else {
|
|
|
|
|
lines.push('');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.showSeriesYear) {
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.Status == "Continuing") {
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
lines.push(Globalize.translate('ValueSeriesYearToPresent', item.ProductionYear || ''));
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else {
|
|
|
|
|
lines.push(item.ProductionYear || '');
|
2015-05-12 21:55:19 -07:00
|
|
|
|
}
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.showProgramAirInfo) {
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-05-05 21:50:06 -07:00
|
|
|
|
var date = datetime.parseISO8601Date(item.StartDate, true);
|
2014-11-10 20:41:19 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var text = item.StartDate ?
|
|
|
|
|
date.toLocaleString() :
|
|
|
|
|
'';
|
2014-11-10 20:41:19 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
lines.push(text || ' ');
|
2014-11-10 20:41:19 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
lines.push(item.ChannelName || ' ');
|
2014-11-10 20:41:19 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += LibraryBrowser.getCardTextLines(lines, cssClass, !options.overlayText);
|
2014-11-10 20:41:19 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.overlayText) {
|
2015-03-19 09:16:33 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (progressHtml) {
|
|
|
|
|
html += "<div class='cardText cardProgress'>";
|
|
|
|
|
html += progressHtml;
|
|
|
|
|
html += "</div>";
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-19 09:16:33 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (html) {
|
|
|
|
|
html = '<div class="' + footerClass + '">' + html;
|
2015-03-19 09:16:33 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
//cardFooter
|
|
|
|
|
html += "</div>";
|
|
|
|
|
}
|
2015-03-19 09:16:33 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2015-03-19 09:16:33 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getListItemInfo: function (elem) {
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var elemWithAttributes = elem;
|
2014-08-01 19:34:45 -07:00
|
|
|
|
|
2016-07-17 19:55:07 -07:00
|
|
|
|
while (!elemWithAttributes.getAttribute('data-id')) {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
elemWithAttributes = elemWithAttributes.parentNode;
|
2014-08-01 19:34:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-17 19:55:07 -07:00
|
|
|
|
var itemId = elemWithAttributes.getAttribute('data-id');
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var index = elemWithAttributes.getAttribute('data-index');
|
|
|
|
|
var mediaType = elemWithAttributes.getAttribute('data-mediatype');
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return {
|
|
|
|
|
id: itemId,
|
|
|
|
|
index: index,
|
|
|
|
|
mediaType: mediaType,
|
|
|
|
|
context: elemWithAttributes.getAttribute('data-context')
|
|
|
|
|
};
|
|
|
|
|
},
|
2013-05-27 18:59:26 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getCardTextLines: function (lines, cssClass, forceLines) {
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var html = '';
|
2015-05-09 21:29:04 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var valid = 0;
|
|
|
|
|
var i, length;
|
2015-05-09 21:29:04 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
for (i = 0, length = lines.length; i < length; i++) {
|
2015-05-09 21:29:04 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var text = lines[i];
|
2015-05-09 21:29:04 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (text) {
|
|
|
|
|
html += "<div class='" + cssClass + "'>";
|
|
|
|
|
html += text;
|
|
|
|
|
html += "</div>";
|
|
|
|
|
valid++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-10 10:28:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (forceLines) {
|
|
|
|
|
while (valid < length) {
|
|
|
|
|
html += "<div class='" + cssClass + "'> </div>";
|
|
|
|
|
valid++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-10 10:28:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2014-05-10 10:28:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getFutureDateText: function (date) {
|
2014-05-10 10:28:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var weekday = [];
|
|
|
|
|
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');
|
2014-05-10 10:28:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var day = weekday[date.getDay()];
|
|
|
|
|
date = date.toLocaleDateString();
|
2014-05-10 10:28:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (date.toLowerCase().indexOf(day.toLowerCase()) == -1) {
|
|
|
|
|
return day + " " + date;
|
2014-05-10 10:28:03 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return date;
|
|
|
|
|
},
|
2014-05-10 10:28:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getPremiereDateText: function (item, date) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-07-04 22:40:18 -07:00
|
|
|
|
var studio = (item.Studios || [])[0];
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (!date) {
|
2013-11-19 10:17:14 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var text = '';
|
2013-12-28 16:09:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.AirTime) {
|
|
|
|
|
text += item.AirTime;
|
|
|
|
|
}
|
2013-12-26 19:23:57 -07:00
|
|
|
|
|
2016-07-04 22:40:18 -07:00
|
|
|
|
if (studio) {
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (text) {
|
2016-07-04 22:40:18 -07:00
|
|
|
|
text += " on " + studio;
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else {
|
2016-07-04 22:40:18 -07:00
|
|
|
|
text += studio;
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return text;
|
|
|
|
|
}
|
2013-10-25 13:58:31 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var day = LibraryBrowser.getFutureDateText(date);
|
2013-10-26 15:01:21 -07:00
|
|
|
|
|
2013-10-25 13:58:31 -07:00
|
|
|
|
if (item.AirTime) {
|
2016-02-17 19:55:15 -07:00
|
|
|
|
day += " at " + item.AirTime;
|
2013-10-25 13:58:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-04 22:40:18 -07:00
|
|
|
|
if (studio) {
|
|
|
|
|
day += " on " + studio;
|
2013-10-25 13:58:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return day;
|
|
|
|
|
},
|
2013-10-24 10:49:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getOfflineIndicatorHtml: function (item) {
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.LocationType == "Offline") {
|
|
|
|
|
return '<div class="posterRibbon offlinePosterRibbon">' + Globalize.translate('HeaderOffline') + '</div>';
|
|
|
|
|
}
|
2013-10-16 19:43:55 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.Type == 'Episode') {
|
|
|
|
|
try {
|
2013-10-16 19:43:55 -07:00
|
|
|
|
|
2016-05-05 21:50:06 -07:00
|
|
|
|
var date = datetime.parseISO8601Date(item.PremiereDate, true);
|
2015-06-03 21:50:10 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -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
|
|
|
|
|
2015-06-03 21:50:10 -07:00
|
|
|
|
}
|
2013-10-25 07:18:53 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return '<div class="posterRibbon missingPosterRibbon">' + Globalize.translate('HeaderMissing') + '</div>';
|
2013-10-16 19:43:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return '';
|
|
|
|
|
},
|
2013-12-28 16:09:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getGroupCountIndicator: function (item) {
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.ChildCount) {
|
|
|
|
|
return '<div class="playedIndicator">' + item.ChildCount + '</div>';
|
|
|
|
|
}
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return '';
|
|
|
|
|
},
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getSyncIndicator: function (item) {
|
2015-06-01 22:46:06 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.SyncStatus == 'Synced') {
|
2015-06-02 10:46:44 -07:00
|
|
|
|
|
2016-06-18 22:26:52 -07:00
|
|
|
|
return '<div class="syncIndicator"><i class="md-icon">sync</i></div>';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2015-06-02 10:46:44 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var syncPercent = item.SyncPercent;
|
|
|
|
|
if (syncPercent) {
|
2016-06-18 22:26:52 -07:00
|
|
|
|
return '<div class="syncIndicator"><i class="md-icon">sync</i></div>';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2015-06-01 22:46:06 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.SyncStatus == 'Queued' || item.SyncStatus == 'Converting' || item.SyncStatus == 'ReadyToTransfer' || item.SyncStatus == 'Transferring') {
|
2015-06-01 22:46:06 -07:00
|
|
|
|
|
2016-06-18 22:26:52 -07:00
|
|
|
|
return '<div class="syncIndicator"><i class="md-icon">sync</i></div>';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2015-06-01 22:46:06 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return '';
|
|
|
|
|
},
|
2015-06-01 22:46:06 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getAveragePrimaryImageAspectRatio: function (items) {
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var values = [];
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
for (var i = 0, length = items.length; i < length; i++) {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var ratio = items[i].PrimaryImageAspectRatio || 0;
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (!ratio) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
values[values.length] = ratio;
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (!values.length) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
// Use the median
|
|
|
|
|
values.sort(function (a, b) { return a - b; });
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var half = Math.floor(values.length / 2);
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var result;
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (values.length % 2)
|
|
|
|
|
result = values[half];
|
|
|
|
|
else
|
|
|
|
|
result = (values[half - 1] + values[half]) / 2.0;
|
2013-10-12 09:55:58 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
// If really close to 2:3 (poster image), just return 2:3
|
|
|
|
|
if (Math.abs(0.66666666667 - result) <= .15) {
|
|
|
|
|
return 0.66666666667;
|
|
|
|
|
}
|
2013-10-03 08:51:05 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
// If really close to 16:9 (episode image), just return 16:9
|
|
|
|
|
if (Math.abs(1.777777778 - result) <= .2) {
|
|
|
|
|
return 1.777777778;
|
|
|
|
|
}
|
2013-10-03 08:51:05 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
// If really close to 1 (square image), just return 1
|
|
|
|
|
if (Math.abs(1 - result) <= .15) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2013-10-03 08:51:05 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
// If really close to 4:3 (poster image), just return 2:3
|
|
|
|
|
if (Math.abs(1.33333333333 - result) <= .15) {
|
|
|
|
|
return 1.33333333333;
|
|
|
|
|
}
|
2013-10-03 08:51:05 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return result;
|
|
|
|
|
},
|
2013-11-08 08:35:36 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
metroColors: ["#6FBD45", "#4BB3DD", "#4164A5", "#E12026", "#800080", "#E1B222", "#008040", "#0094FF", "#FF00C7", "#FF870F", "#7F0037"],
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getRandomMetroColor: function () {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var index = Math.floor(Math.random() * (LibraryBrowser.metroColors.length - 1));
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return LibraryBrowser.metroColors[index];
|
|
|
|
|
},
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getMetroColor: function (str) {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (str) {
|
|
|
|
|
var character = String(str.substr(0, 1).charCodeAt());
|
|
|
|
|
var sum = 0;
|
|
|
|
|
for (var i = 0; i < character.length; i++) {
|
|
|
|
|
sum += parseInt(character.charAt(i));
|
|
|
|
|
}
|
|
|
|
|
var index = String(sum).substr(-1);
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return LibraryBrowser.metroColors[index];
|
|
|
|
|
} else {
|
|
|
|
|
return LibraryBrowser.getRandomMetroColor();
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
},
|
2013-04-05 11:35:37 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
renderName: function (item, nameElem, linkToElement, context) {
|
2013-05-04 21:49:49 -07:00
|
|
|
|
|
2016-05-11 10:46:44 -07:00
|
|
|
|
var name = itemHelper.getDisplayName(item, {
|
|
|
|
|
includeParentInfo: false
|
|
|
|
|
});
|
2013-05-27 18:59:26 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
Dashboard.setPageTitle(name);
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (linkToElement) {
|
2016-06-24 09:51:13 -07:00
|
|
|
|
nameElem.innerHTML = '<a class="detailPageParentLink" href="' + LibraryBrowser.getHref(item, context) + '">' + name + '</a>';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else {
|
2016-06-24 09:51:13 -07:00
|
|
|
|
nameElem.innerHTML = name;
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
2013-05-14 21:05:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
renderParentName: function (item, parentNameElem, context) {
|
2013-05-14 21:05:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var html = [];
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var contextParam = context ? ('&context=' + context) : '';
|
2014-09-29 21:47:30 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.AlbumArtists) {
|
|
|
|
|
html.push(LibraryBrowser.getArtistLinksHtml(item.AlbumArtists, "detailPageParentLink"));
|
|
|
|
|
} else if (item.ArtistItems && item.ArtistItems.length && item.Type == "MusicVideo") {
|
|
|
|
|
html.push(LibraryBrowser.getArtistLinksHtml(item.ArtistItems, "detailPageParentLink"));
|
|
|
|
|
} else if (item.SeriesName && item.Type == "Episode") {
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -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
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.SeriesName && item.Type == "Season") {
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -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
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else if (item.ParentIndexNumber != null && item.Type == "Episode") {
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -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
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else if (item.Album && item.Type == "Audio" && (item.AlbumId || item.ParentId)) {
|
|
|
|
|
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
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else if (item.Album && item.Type == "MusicVideo" && item.AlbumId) {
|
|
|
|
|
html.push('<a class="detailPageParentLink" href="itemdetails.html?id=' + item.AlbumId + contextParam + '">' + item.Album + '</a>');
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else if (item.Album) {
|
|
|
|
|
html.push(item.Album);
|
|
|
|
|
} else if (item.Type == 'Program' && item.EpisodeTitle) {
|
|
|
|
|
html.push(item.Name);
|
|
|
|
|
}
|
2013-05-14 21:05:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (html.length) {
|
2016-06-24 09:51:13 -07:00
|
|
|
|
parentNameElem.classList.remove('hide');
|
|
|
|
|
parentNameElem.innerHTML = html.join(' - ');
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else {
|
2016-06-24 09:51:13 -07:00
|
|
|
|
parentNameElem.classList.add('hide');
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
2013-05-04 14:20:27 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
renderLinks: function (linksElem, item) {
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var links = [];
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.HomePageUrl) {
|
|
|
|
|
links.push('<a class="textlink" href="' + item.HomePageUrl + '" target="_blank">' + Globalize.translate('ButtonWebsite') + '</a>');
|
|
|
|
|
}
|
2013-04-12 07:13:47 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.ExternalUrls) {
|
2013-04-14 08:14:10 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
for (var i = 0, length = item.ExternalUrls.length; i < length; i++) {
|
2014-02-07 15:40:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var url = item.ExternalUrls[i];
|
2014-02-09 14:11:11 -07:00
|
|
|
|
|
2016-02-17 19:55: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
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (links.length) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var html = links.join(' / ');
|
2014-09-16 18:38:50 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html = Globalize.translate('ValueLinks', html);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
linksElem.innerHTML = html;
|
2016-03-16 22:04:32 -07:00
|
|
|
|
linksElem.classList.remove('hide');
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else {
|
2016-03-16 22:04:32 -07:00
|
|
|
|
linksElem.classList.add('hide');
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2016-04-23 21:24:16 -07:00
|
|
|
|
showLayoutMenu: function (button, currentLayout, views) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-04-23 21:24:16 -07:00
|
|
|
|
var dispatchEvent = true;
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-04-23 21:24:16 -07:00
|
|
|
|
if (!views) {
|
2015-08-15 16:10:50 -07:00
|
|
|
|
|
2016-04-23 21:24:16 -07:00
|
|
|
|
dispatchEvent = false;
|
|
|
|
|
// Add banner and list once all screens support them
|
|
|
|
|
views = button.getAttribute('data-layouts');
|
2015-09-01 15:04:54 -07:00
|
|
|
|
|
2016-04-23 21:24:16 -07:00
|
|
|
|
views = views ? views.split(',') : ['List', 'Poster', 'PosterCard', 'Thumb', 'ThumbCard'];
|
|
|
|
|
}
|
2015-08-15 16:10:50 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var menuItems = views.map(function (v) {
|
|
|
|
|
return {
|
|
|
|
|
name: Globalize.translate('Option' + v),
|
|
|
|
|
id: v,
|
2016-04-23 21:24:16 -07:00
|
|
|
|
selected: currentLayout == v
|
2016-02-17 19:55:15 -07:00
|
|
|
|
};
|
|
|
|
|
});
|
2015-08-15 16:10:50 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
require(['actionsheet'], function (actionsheet) {
|
2015-08-15 16:10:50 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
actionsheet.show({
|
|
|
|
|
items: menuItems,
|
|
|
|
|
positionTo: button,
|
|
|
|
|
callback: function (id) {
|
2015-08-15 16:10:50 -07:00
|
|
|
|
|
2016-05-27 10:18:22 -07:00
|
|
|
|
button.dispatchEvent(new CustomEvent('layoutchange', {
|
|
|
|
|
detail: {
|
|
|
|
|
viewStyle: id
|
|
|
|
|
},
|
|
|
|
|
bubbles: true,
|
|
|
|
|
cancelable: false
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
if (!dispatchEvent) {
|
2016-05-28 23:04:11 -07:00
|
|
|
|
if (window.$) {
|
2016-04-23 21:24:16 -07:00
|
|
|
|
$(button).trigger('layoutchange', [id]);
|
2016-05-28 23:04:11 -07:00
|
|
|
|
}
|
2016-04-23 21:24:16 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
2015-08-15 16:10:50 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
});
|
2015-08-15 16:10:50 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
},
|
2015-08-15 16:10:50 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getQueryPagingHtml: function (options) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var startIndex = options.startIndex;
|
|
|
|
|
var limit = options.limit;
|
|
|
|
|
var totalRecordCount = options.totalRecordCount;
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (limit && options.updatePageSizeSetting !== false) {
|
|
|
|
|
try {
|
|
|
|
|
appStorage.setItem(options.pageSizeKey || pageSizeKey, limit);
|
|
|
|
|
} catch (e) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2014-07-19 21:46:29 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var html = '';
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var recordsEnd = Math.min(startIndex + limit, totalRecordCount);
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
// 20 is the minimum page size
|
|
|
|
|
var showControls = totalRecordCount > 20 || limit < totalRecordCount;
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += '<div class="listPaging">';
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (showControls) {
|
|
|
|
|
html += '<span style="vertical-align:middle;">';
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var startAtDisplay = totalRecordCount ? startIndex + 1 : 0;
|
|
|
|
|
html += startAtDisplay + '-' + recordsEnd + ' of ' + totalRecordCount;
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += '</span>';
|
|
|
|
|
}
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (showControls || options.viewButton || options.filterButton || options.sortButton || options.addLayoutButton) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-06-14 20:12:32 -07:00
|
|
|
|
html += '<div style="display:inline-block;">';
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (showControls) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-07-07 20:24:22 -07:00
|
|
|
|
html += '<button is="paper-icon-button-light" class="btnPreviousPage autoSize" ' + (startIndex ? '' : 'disabled') + '><i class="md-icon"></i></button>';
|
2016-06-14 12:21:26 -07:00
|
|
|
|
html += '<button is="paper-icon-button-light" class="btnNextPage autoSize" ' + (startIndex + limit >= totalRecordCount ? 'disabled' : '') + '><i class="md-icon">arrow_forward</i></button>';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.addLayoutButton) {
|
2015-08-15 16:10:50 -07:00
|
|
|
|
|
2016-06-14 12:21:26 -07:00
|
|
|
|
html += '<button is="paper-icon-button-light" title="' + Globalize.translate('ButtonSelectView') + '" class="btnChangeLayout autoSize" data-layouts="' + (options.layouts || '') + '" onclick="LibraryBrowser.showLayoutMenu(this, \'' + (options.currentLayout || '') + '\');"><i class="md-icon">view_comfy</i></button>';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2015-08-15 16:10:50 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.sortButton) {
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-06-14 12:21:26 -07:00
|
|
|
|
html += '<button is="paper-icon-button-light" class="btnSort autoSize" title="' + Globalize.translate('ButtonSort') + '"><i class="md-icon">sort_by_alpha</i></button>';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (options.filterButton) {
|
2016-02-14 13:34:54 -07:00
|
|
|
|
|
2016-06-14 12:21:26 -07:00
|
|
|
|
html += '<button is="paper-icon-button-light" class="btnFilter autoSize" title="' + Globalize.translate('ButtonFilter') + '"><i class="md-icon">filter_list</i></button>';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += '</div>';
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (showControls && options.showLimit) {
|
2015-06-18 21:23:55 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var id = "selectPageSize";
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-04-23 21:24:16 -07:00
|
|
|
|
var pageSizes = options.pageSizes || [20, 50, 100, 200, 300, 400, 500];
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var optionsHtml = pageSizes.map(function (val) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (limit == val) {
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return '<option value="' + val + '" selected="selected">' + val + '</option>';
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else {
|
|
|
|
|
return '<option value="' + val + '">' + val + '</option>';
|
|
|
|
|
}
|
|
|
|
|
}).join('');
|
2014-07-19 21:46:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
// Add styles to defeat jquery mobile
|
|
|
|
|
html += '<div class="pageSizeContainer"><label 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
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += '</div>';
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
showSortMenu: function (options) {
|
2015-09-17 20:43:30 -07:00
|
|
|
|
|
2016-07-10 00:01:25 -07:00
|
|
|
|
require(['dialogHelper', 'emby-radio'], function (dialogHelper) {
|
2015-09-17 20:43:30 -07:00
|
|
|
|
|
2016-03-23 12:03:17 -07:00
|
|
|
|
var dlg = dialogHelper.createDialog({
|
2016-02-17 19:55:15 -07:00
|
|
|
|
removeOnClose: true,
|
|
|
|
|
modal: false,
|
|
|
|
|
entryAnimationDuration: 160,
|
|
|
|
|
exitAnimationDuration: 200
|
|
|
|
|
});
|
2016-01-30 13:59:09 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
dlg.classList.add('ui-body-a');
|
|
|
|
|
dlg.classList.add('background-theme-a');
|
2016-05-31 10:04:49 -07:00
|
|
|
|
dlg.classList.add('formDialog');
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var html = '';
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-03-31 11:46:03 -07:00
|
|
|
|
html += '<div style="margin:0;padding:1.25em 1.5em 1.5em;">';
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += '<h2 style="margin:0 0 .5em;">';
|
|
|
|
|
html += Globalize.translate('HeaderSortBy');
|
|
|
|
|
html += '</h2>';
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-07-10 00:01:25 -07:00
|
|
|
|
var i, length;
|
|
|
|
|
var isChecked;
|
|
|
|
|
|
|
|
|
|
html += '<div>';
|
|
|
|
|
for (i = 0, length = options.items.length; i < length; i++) {
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var option = options.items[i];
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-07-10 00:01:25 -07:00
|
|
|
|
var radioValue = option.id.replace(',', '_');
|
|
|
|
|
isChecked = (options.query.SortBy || '').replace(',', '_') == radioValue ? ' checked' : '';
|
|
|
|
|
html += '<label class="block"><input type="radio" is="emby-radio" name="SortBy" data-id="' + option.id + '" value="' + radioValue + '" class="menuSortBy" ' + isChecked + ' /><span>' + option.name + '</span></label>';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2016-07-10 00:01:25 -07:00
|
|
|
|
html += '</div>';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
|
|
|
|
|
html += '<h2 style="margin: 1em 0 .5em;">';
|
|
|
|
|
html += Globalize.translate('HeaderSortOrder');
|
|
|
|
|
html += '</h2>';
|
2016-07-10 00:01:25 -07:00
|
|
|
|
html += '<div>';
|
|
|
|
|
isChecked = options.query.SortOrder == 'Ascending' ? ' checked' : '';
|
|
|
|
|
html += '<label class="block"><input type="radio" is="emby-radio" name="SortOrder" value="Ascending" class="menuSortOrder" ' + isChecked + ' /><span>' + Globalize.translate('OptionAscending') + '</span></label>';
|
|
|
|
|
isChecked = options.query.SortOrder == 'Descending' ? ' checked' : '';
|
|
|
|
|
html += '<label class="block"><input type="radio" is="emby-radio" name="SortOrder" value="Descending" class="menuSortOrder" ' + isChecked + ' /><span>' + Globalize.translate('OptionDescending') + '</span></label>';
|
|
|
|
|
html += '</div>';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += '</div>';
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
dlg.innerHTML = html;
|
|
|
|
|
document.body.appendChild(dlg);
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-02-26 21:39:11 -07:00
|
|
|
|
// Seeing an issue in Firefox and IE where it's initially visible in the bottom right, then moves to the center
|
|
|
|
|
var delay = browserInfo.animate ? 0 : 100;
|
2016-03-16 14:30:49 -07:00
|
|
|
|
setTimeout(function () {
|
2016-03-23 12:03:17 -07:00
|
|
|
|
dialogHelper.open(dlg);
|
2016-02-26 21:39:11 -07:00
|
|
|
|
}, delay);
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-07-10 00:01:25 -07:00
|
|
|
|
function onSortByChange() {
|
|
|
|
|
var newValue = this.value;
|
|
|
|
|
if (this.checked) {
|
|
|
|
|
var changed = options.query.SortBy != newValue;
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-07-10 00:01:25 -07:00
|
|
|
|
options.query.SortBy = newValue.replace('_', ',');
|
|
|
|
|
options.query.StartIndex = 0;
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-07-10 00:01:25 -07:00
|
|
|
|
if (options.callback && changed) {
|
|
|
|
|
options.callback();
|
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2016-07-10 00:01:25 -07:00
|
|
|
|
}
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-07-10 00:01:25 -07:00
|
|
|
|
var sortBys = dlg.querySelectorAll('.menuSortBy');
|
|
|
|
|
for (i = 0, length = sortBys.length; i < length; i++) {
|
|
|
|
|
sortBys[i].addEventListener('change', onSortByChange);
|
|
|
|
|
}
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-07-10 00:01:25 -07:00
|
|
|
|
function onSortOrderChange() {
|
|
|
|
|
var newValue = this.value;
|
|
|
|
|
if (this.checked) {
|
|
|
|
|
var changed = options.query.SortOrder != newValue;
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-07-10 00:01:25 -07:00
|
|
|
|
options.query.SortOrder = newValue;
|
|
|
|
|
options.query.StartIndex = 0;
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-07-10 00:01:25 -07:00
|
|
|
|
if (options.callback && changed) {
|
|
|
|
|
options.callback();
|
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2016-07-10 00:01:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sortOrders = dlg.querySelectorAll('.menuSortOrder');
|
|
|
|
|
for (i = 0, length = sortOrders.length; i < length; i++) {
|
|
|
|
|
sortOrders[i].addEventListener('change', onSortOrderChange);
|
|
|
|
|
}
|
2015-09-18 10:50:24 -07:00
|
|
|
|
});
|
2016-02-17 19:55:15 -07:00
|
|
|
|
},
|
2015-08-25 19:13:28 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
getItemProgressBarHtml: function (item) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2014-01-14 13:24:56 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.Type == "Recording" && item.CompletionPercentage) {
|
2014-01-14 22:01:58 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return '<progress class="itemProgressBar recordingProgressBar" min="0" max="100" value="' + item.CompletionPercentage + '"></progress>';
|
|
|
|
|
}
|
2014-01-14 22:01:58 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var pct = item.PlayedPercentage;
|
2013-04-15 19:36:12 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (pct && pct < 100) {
|
2013-04-15 19:36:12 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return '<progress class="itemProgressBar" min="0" max="100" value="' + pct + '"></progress>';
|
|
|
|
|
}
|
2013-04-15 19:36:12 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return null;
|
|
|
|
|
},
|
2013-05-03 19:33:44 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
renderDetailImage: function (elem, item, editable, preferThumb) {
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var imageTags = item.ImageTags || {};
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.PrimaryImageTag) {
|
|
|
|
|
imageTags.Primary = item.PrimaryImageTag;
|
|
|
|
|
}
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var html = '';
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var url;
|
|
|
|
|
var shape = 'portrait';
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var imageHeight = 360;
|
|
|
|
|
var detectRatio = false;
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (preferThumb && imageTags.Thumb) {
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
url = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxHeight: imageHeight,
|
|
|
|
|
tag: item.ImageTags.Thumb
|
|
|
|
|
});
|
|
|
|
|
shape = 'thumb';
|
|
|
|
|
}
|
|
|
|
|
else if (imageTags.Primary) {
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
url = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Primary",
|
|
|
|
|
maxHeight: imageHeight,
|
|
|
|
|
tag: item.ImageTags.Primary
|
|
|
|
|
});
|
|
|
|
|
detectRatio = true;
|
|
|
|
|
}
|
|
|
|
|
else if (item.BackdropImageTags && item.BackdropImageTags.length) {
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
url = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Backdrop",
|
|
|
|
|
maxHeight: imageHeight,
|
|
|
|
|
tag: item.BackdropImageTags[0]
|
|
|
|
|
});
|
|
|
|
|
shape = 'thumb';
|
|
|
|
|
}
|
|
|
|
|
else if (imageTags.Thumb) {
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
url = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Thumb",
|
|
|
|
|
maxHeight: imageHeight,
|
|
|
|
|
tag: item.ImageTags.Thumb
|
|
|
|
|
});
|
|
|
|
|
shape = 'thumb';
|
|
|
|
|
}
|
|
|
|
|
else if (imageTags.Disc) {
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
url = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Disc",
|
|
|
|
|
maxHeight: imageHeight,
|
|
|
|
|
tag: item.ImageTags.Disc
|
|
|
|
|
});
|
|
|
|
|
shape = 'square';
|
|
|
|
|
}
|
|
|
|
|
else if (item.AlbumId && item.AlbumPrimaryImageTag) {
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
url = ApiClient.getScaledImageUrl(item.AlbumId, {
|
|
|
|
|
type: "Primary",
|
|
|
|
|
maxHeight: 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';
|
|
|
|
|
}
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += '<div style="position:relative;">';
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (editable) {
|
2016-06-28 21:05:16 -07:00
|
|
|
|
html += "<a class='itemDetailGalleryLink' href='#'>";
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2015-02-05 22:59:55 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (detectRatio && item.PrimaryImageAspectRatio) {
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.PrimaryImageAspectRatio >= 1.48) {
|
|
|
|
|
shape = 'thumb';
|
|
|
|
|
} else if (item.PrimaryImageAspectRatio >= .85 && item.PrimaryImageAspectRatio <= 1.34) {
|
|
|
|
|
shape = 'square';
|
|
|
|
|
}
|
2015-02-02 21:54:52 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += "<img class='itemDetailImage lazy' src='css/images/empty.png' />";
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (editable) {
|
|
|
|
|
html += "</a>";
|
|
|
|
|
}
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var progressHtml = item.IsFolder || !item.UserData ? '' : LibraryBrowser.getItemProgressBarHtml((item.Type == 'Recording' ? item : item.UserData));
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += '<div class="detailImageProgressContainer">';
|
|
|
|
|
if (progressHtml) {
|
|
|
|
|
html += progressHtml;
|
|
|
|
|
}
|
|
|
|
|
html += "</div>";
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html += "</div>";
|
2015-06-28 08:43:49 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
elem.innerHTML = html;
|
2015-09-24 22:15:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (shape == 'thumb') {
|
|
|
|
|
elem.classList.add('thumbDetailImageContainer');
|
|
|
|
|
elem.classList.remove('portraitDetailImageContainer');
|
|
|
|
|
elem.classList.remove('squareDetailImageContainer');
|
|
|
|
|
}
|
|
|
|
|
else if (shape == 'square') {
|
|
|
|
|
elem.classList.remove('thumbDetailImageContainer');
|
|
|
|
|
elem.classList.remove('portraitDetailImageContainer');
|
|
|
|
|
elem.classList.add('squareDetailImageContainer');
|
|
|
|
|
} else {
|
|
|
|
|
elem.classList.remove('thumbDetailImageContainer');
|
|
|
|
|
elem.classList.add('portraitDetailImageContainer');
|
|
|
|
|
elem.classList.remove('squareDetailImageContainer');
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}
|
2015-02-02 21:54:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var img = elem.querySelector('img');
|
|
|
|
|
img.onload = function () {
|
|
|
|
|
if (img.src.indexOf('empty.png') == -1) {
|
|
|
|
|
img.classList.add('loaded');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
ImageLoader.lazyImage(img, url);
|
|
|
|
|
},
|
2015-08-23 19:08:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
refreshDetailImageUserData: function (elem, item) {
|
2015-08-23 19:08:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var progressHtml = item.IsFolder || !item.UserData ? '' : LibraryBrowser.getItemProgressBarHtml((item.Type == 'Recording' ? item : item.UserData));
|
2015-08-23 19:08:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var detailImageProgressContainer = elem.querySelector('.detailImageProgressContainer');
|
2015-08-23 19:08:20 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
detailImageProgressContainer.innerHTML = progressHtml || '';
|
|
|
|
|
},
|
2015-05-22 12:16:14 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
renderOverview: function (elems, item) {
|
2013-04-21 21:38:03 -07:00
|
|
|
|
|
2016-03-16 22:04:32 -07:00
|
|
|
|
for (var i = 0, length = elems.length; i < length; i++) {
|
|
|
|
|
var elem = elems[i];
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var overview = item.Overview || '';
|
2013-04-21 21:38:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (overview) {
|
|
|
|
|
elem.innerHTML = overview;
|
2015-08-17 21:22:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
elem.classList.remove('empty');
|
2016-03-16 22:04:32 -07:00
|
|
|
|
|
|
|
|
|
var anchors = elem.querySelectorAll('a');
|
|
|
|
|
for (var j = 0, length2 = anchors.length; j < length2; j++) {
|
|
|
|
|
anchors[j].setAttribute("target", "_blank");
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else {
|
|
|
|
|
elem.innerHTML = '';
|
2015-08-17 21:22:45 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
elem.classList.add('empty');
|
|
|
|
|
}
|
2016-03-16 22:04:32 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
},
|
2013-04-21 21:38:03 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
renderStudios: function (elem, item, isStatic) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.Studios && item.Studios.length && item.Type != "Series") {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var html = '';
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
for (var i = 0, length = item.Studios.length; i < length; i++) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (i > 0) {
|
|
|
|
|
html += ' / ';
|
|
|
|
|
}
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (isStatic) {
|
|
|
|
|
html += item.Studios[i].Name;
|
|
|
|
|
} else {
|
|
|
|
|
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
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var translationKey = item.Studios.length > 1 ? "ValueStudios" : "ValueStudio";
|
2014-09-16 18:38:50 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
html = Globalize.translate(translationKey, html);
|
2014-09-16 18:38:50 -07:00
|
|
|
|
|
2016-06-24 08:12:13 -07:00
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
elem.classList.remove('hide');
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else {
|
2016-06-24 08:12:13 -07:00
|
|
|
|
elem.classList.add('hide');
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
renderGenres: function (elem, item, limit, isStatic) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var html = '';
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var genres = item.Genres || [];
|
2013-07-18 07:59:58 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
for (var i = 0, length = genres.length; i < length; i++) {
|
2013-06-29 09:21:22 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (limit && i >= limit) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
2015-01-31 19:41:35 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (i > 0) {
|
|
|
|
|
html += '<span> / </span>';
|
|
|
|
|
}
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var param = item.Type == "Audio" || item.Type == "MusicArtist" || item.Type == "MusicAlbum" ? "musicgenre" : "genre";
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.MediaType == "Game") {
|
|
|
|
|
param = "gamegenre";
|
|
|
|
|
}
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (isStatic) {
|
|
|
|
|
html += genres[i];
|
|
|
|
|
} else {
|
|
|
|
|
html += '<a class="textlink" href="itemdetails.html?' + param + '=' + ApiClient.encodeName(genres[i]) + '">' + genres[i] + '</a>';
|
|
|
|
|
}
|
2015-07-03 04:51:45 -07:00
|
|
|
|
}
|
2013-12-21 11:37:34 -07:00
|
|
|
|
|
2016-05-15 22:38:17 -07:00
|
|
|
|
elem.innerHTML = html;
|
2016-02-17 19:55:15 -07:00
|
|
|
|
},
|
2013-04-18 07:27:21 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
renderPremiereDate: function (elem, item) {
|
|
|
|
|
if (item.PremiereDate) {
|
|
|
|
|
try {
|
2013-04-24 13:28:42 -07:00
|
|
|
|
|
2016-05-05 21:50:06 -07:00
|
|
|
|
var date = datetime.parseISO8601Date(item.PremiereDate, true);
|
2013-04-24 13:28:42 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var translationKey = new Date().getTime() > date.getTime() ? "ValuePremiered" : "ValuePremieres";
|
2014-09-16 18:38:50 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
elem.show().html(Globalize.translate(translationKey, date.toLocaleDateString()));
|
2013-04-24 13:28:42 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} catch (err) {
|
|
|
|
|
elem.hide();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2013-04-18 22:08:18 -07:00
|
|
|
|
elem.hide();
|
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
},
|
2013-04-12 17:42:51 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
renderAwardSummary: function (elem, item) {
|
|
|
|
|
if (item.AwardSummary) {
|
2016-06-24 08:12:13 -07:00
|
|
|
|
elem.classList.remove('hide');
|
|
|
|
|
elem.innerHTML = Globalize.translate('ValueAwards', item.AwardSummary);
|
2016-02-17 19:55:15 -07:00
|
|
|
|
} else {
|
2016-06-24 08:12:13 -07:00
|
|
|
|
elem.classList.add('hide');
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
|
|
|
|
},
|
2014-01-18 11:10:21 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
renderDetailPageBackdrop: function (page, item) {
|
2013-05-15 07:12:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var screenWidth = screen.availWidth;
|
2013-05-15 07:12:24 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
var imgUrl;
|
|
|
|
|
var hasbackdrop = false;
|
2013-05-14 21:05:52 -07:00
|
|
|
|
|
2016-03-16 22:04:32 -07:00
|
|
|
|
var itemBackdropElement = page.querySelector('#itemBackdrop');
|
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
if (item.BackdropImageTags && item.BackdropImageTags.length) {
|
2013-05-14 21:05:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
|
|
|
|
|
type: "Backdrop",
|
|
|
|
|
index: 0,
|
|
|
|
|
maxWidth: screenWidth,
|
|
|
|
|
tag: item.BackdropImageTags[0]
|
|
|
|
|
});
|
2013-05-14 21:05:52 -07:00
|
|
|
|
|
2016-03-16 22:04:32 -07:00
|
|
|
|
itemBackdropElement.classList.remove('noBackdrop');
|
2016-05-15 18:22:22 -07:00
|
|
|
|
ImageLoader.lazyImage(itemBackdropElement, imgUrl, false);
|
2016-02-17 19:55:15 -07:00
|
|
|
|
hasbackdrop = true;
|
|
|
|
|
}
|
|
|
|
|
else if (item.ParentBackdropItemId && item.ParentBackdropImageTags && item.ParentBackdropImageTags.length) {
|
2013-05-14 21:05:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(item.ParentBackdropItemId, {
|
|
|
|
|
type: 'Backdrop',
|
|
|
|
|
index: 0,
|
|
|
|
|
tag: item.ParentBackdropImageTags[0],
|
|
|
|
|
maxWidth: screenWidth
|
|
|
|
|
});
|
2013-05-14 21:05:52 -07:00
|
|
|
|
|
2016-03-16 22:04:32 -07:00
|
|
|
|
itemBackdropElement.classList.remove('noBackdrop');
|
2016-05-15 18:22:22 -07:00
|
|
|
|
ImageLoader.lazyImage(itemBackdropElement, imgUrl, false);
|
2016-02-17 19:55:15 -07:00
|
|
|
|
hasbackdrop = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
2016-03-16 22:04:32 -07:00
|
|
|
|
itemBackdropElement.classList.add('noBackdrop');
|
|
|
|
|
itemBackdropElement.style.backgroundImage = '';
|
2016-02-17 19:55:15 -07:00
|
|
|
|
}
|
2013-05-14 21:05:52 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return hasbackdrop;
|
2013-05-14 21:05:52 -07:00
|
|
|
|
}
|
2016-02-17 19:55:15 -07:00
|
|
|
|
};
|
2015-08-18 10:54:29 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
return libraryBrowser;
|
2015-08-24 20:13:04 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
})(window, document, screen);
|
2015-08-24 20:13:04 -07:00
|
|
|
|
|
2016-02-17 19:55:15 -07:00
|
|
|
|
window.LibraryBrowser = libraryBrowser;
|
|
|
|
|
|
|
|
|
|
return libraryBrowser;
|
|
|
|
|
});
|