2016-06-01 23:08:47 -07:00
|
|
|
|
define(['appSettings', 'appStorage', 'libraryBrowser', 'apphost', 'itemHelper', 'mediaInfo'], function (appSettings, appStorage, LibraryBrowser, appHost, itemHelper, mediaInfo) {
|
2014-03-17 07:48:16 -07:00
|
|
|
|
|
2015-07-06 00:06:09 -07:00
|
|
|
|
function isClickable(target) {
|
|
|
|
|
|
|
|
|
|
while (target != null) {
|
|
|
|
|
var tagName = target.tagName || '';
|
2015-07-14 09:39:34 -07:00
|
|
|
|
if (tagName == 'A' || tagName.indexOf('BUTTON') != -1 || tagName.indexOf('INPUT') != -1) {
|
2015-07-06 00:06:09 -07:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
//target = target.parentNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
function onCardClick(e) {
|
2014-07-04 22:21:13 -07:00
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
var card = parentWithClass(e.target, 'card');
|
|
|
|
|
|
|
|
|
|
if (card) {
|
|
|
|
|
|
|
|
|
|
var itemSelectionPanel = card.querySelector('.itemSelectionPanel');
|
|
|
|
|
if (itemSelectionPanel) {
|
|
|
|
|
return onItemSelectionPanelClick(e, itemSelectionPanel);
|
|
|
|
|
}
|
2016-04-25 11:02:33 -07:00
|
|
|
|
else if (card.classList.contains('groupedCard')) {
|
2015-10-26 09:29:42 -07:00
|
|
|
|
return onGroupedCardClick(e, card);
|
2015-09-27 16:32:09 -07:00
|
|
|
|
}
|
2015-09-05 09:58:27 -07:00
|
|
|
|
}
|
2015-09-27 16:32:09 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onGroupedCardClick(e, card) {
|
|
|
|
|
|
2016-07-17 19:55:07 -07:00
|
|
|
|
var itemId = card.getAttribute('data-id');
|
2014-08-01 19:34:45 -07:00
|
|
|
|
var context = card.getAttribute('data-context');
|
2014-07-15 12:16:16 -07:00
|
|
|
|
|
2014-07-04 22:21:13 -07:00
|
|
|
|
var userId = Dashboard.getCurrentUserId();
|
|
|
|
|
|
2016-05-28 23:04:11 -07:00
|
|
|
|
var playedIndicator = card.querySelector('.playedIndicator');
|
|
|
|
|
var playedIndicatorHtml = playedIndicator ? playedIndicator.innerHTML : null;
|
2014-07-04 22:21:13 -07:00
|
|
|
|
var options = {
|
|
|
|
|
|
2016-05-28 23:04:11 -07:00
|
|
|
|
Limit: parseInt(playedIndicatorHtml || '10'),
|
2014-07-05 08:01:29 -07:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,DateCreated",
|
2014-07-04 22:21:13 -07:00
|
|
|
|
ParentId: itemId,
|
|
|
|
|
GroupItems: false
|
|
|
|
|
};
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var target = e.target;
|
2015-07-06 00:06:09 -07:00
|
|
|
|
if (isClickable(target)) {
|
2015-06-07 20:16:42 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) {
|
2015-05-14 19:16:57 -07:00
|
|
|
|
|
2015-06-07 18:23:56 -07:00
|
|
|
|
if (items.length == 1) {
|
|
|
|
|
Dashboard.navigate(LibraryBrowser.getHref(items[0], context));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-21 08:43:10 -07:00
|
|
|
|
var url = 'itemdetails.html?id=' + itemId;
|
|
|
|
|
if (context) {
|
|
|
|
|
url += '&context=' + context;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
Dashboard.navigate(url);
|
2015-05-14 19:16:57 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
e.stopPropagation();
|
2015-05-14 19:16:57 -07:00
|
|
|
|
e.preventDefault();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-05 09:58:27 -07:00
|
|
|
|
function parentWithClass(elem, className) {
|
|
|
|
|
|
|
|
|
|
while (!elem.classList || !elem.classList.contains(className)) {
|
|
|
|
|
elem = elem.parentNode;
|
|
|
|
|
|
|
|
|
|
if (!elem) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return elem;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-15 22:33:31 -07:00
|
|
|
|
LibraryBrowser.createCardMenus = function (curr, options) {
|
2014-03-17 07:48:16 -07:00
|
|
|
|
|
2016-03-15 22:33:31 -07:00
|
|
|
|
curr.removeEventListener('click', onCardClick);
|
|
|
|
|
curr.addEventListener('click', onCardClick);
|
2015-07-06 00:06:09 -07:00
|
|
|
|
|
2016-07-17 11:55:07 -07:00
|
|
|
|
//initTapHoldMenus(curr);
|
2016-03-15 22:33:31 -07:00
|
|
|
|
};
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2015-09-27 17:59:30 -07:00
|
|
|
|
function initTapHoldMenus(elem) {
|
|
|
|
|
|
|
|
|
|
if (elem.classList.contains('itemsContainer')) {
|
|
|
|
|
initTapHold(elem);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var elems = elem.querySelectorAll('.itemsContainer');
|
2015-09-28 20:35:50 -07:00
|
|
|
|
|
2015-09-27 17:59:30 -07:00
|
|
|
|
for (var i = 0, length = elems.length; i < length; i++) {
|
|
|
|
|
initTapHold(elems[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initTapHold(element) {
|
|
|
|
|
|
|
|
|
|
if (!LibraryBrowser.allowSwipe(element)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
if (element.classList.contains('hasTapHold')) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-27 17:59:30 -07:00
|
|
|
|
require(['hammer'], function (Hammer) {
|
|
|
|
|
|
2016-02-07 21:42:56 -07:00
|
|
|
|
var manager = new Hammer.Manager(element);
|
|
|
|
|
|
|
|
|
|
var press = new Hammer.Press({
|
|
|
|
|
time: 500
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
manager.add(press);
|
|
|
|
|
|
|
|
|
|
//var hammertime = new Hammer(element);
|
2015-12-14 08:43:03 -07:00
|
|
|
|
element.classList.add('hasTapHold');
|
2015-09-27 17:59:30 -07:00
|
|
|
|
|
2016-02-07 21:42:56 -07:00
|
|
|
|
manager.on('press', onTapHold);
|
2015-09-27 17:59:30 -07:00
|
|
|
|
});
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2015-10-20 15:06:49 -07:00
|
|
|
|
showTapHoldHelp(element);
|
2015-10-14 19:55:19 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-20 15:06:49 -07:00
|
|
|
|
function showTapHoldHelp(element) {
|
2015-10-14 19:55:19 -07:00
|
|
|
|
|
2016-03-17 20:39:59 -07:00
|
|
|
|
var page = parentWithClass(element, 'page');
|
2015-10-20 15:06:49 -07:00
|
|
|
|
|
|
|
|
|
if (!page) {
|
2015-10-14 21:32:10 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-14 19:55:19 -07:00
|
|
|
|
// Don't do this on the home page
|
2015-10-25 08:48:44 -07:00
|
|
|
|
if (page.classList.contains('homePage') || page.classList.contains('itemDetailPage') || page.classList.contains('liveTvPage')) {
|
2015-10-14 19:55:19 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-25 08:48:44 -07:00
|
|
|
|
var expectedValue = "8";
|
2015-10-14 19:55:19 -07:00
|
|
|
|
if (appStorage.getItem("tapholdhelp") == expectedValue) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
appStorage.setItem("tapholdhelp", expectedValue);
|
|
|
|
|
|
|
|
|
|
Dashboard.alert({
|
|
|
|
|
message: Globalize.translate('TryMultiSelectMessage'),
|
|
|
|
|
title: Globalize.translate('HeaderTryMultiSelect')
|
|
|
|
|
});
|
2015-09-27 17:59:30 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-23 09:16:06 -07:00
|
|
|
|
function onTapHold(e) {
|
2015-09-27 16:32:09 -07:00
|
|
|
|
|
|
|
|
|
var card = parentWithClass(e.target, 'card');
|
|
|
|
|
|
|
|
|
|
if (card) {
|
|
|
|
|
|
|
|
|
|
showSelections(card);
|
|
|
|
|
|
2016-04-19 19:29:15 -07:00
|
|
|
|
// It won't have this if it's a hammer event
|
2015-12-26 11:35:53 -07:00
|
|
|
|
if (e.stopPropagation) {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
e.stopPropagation();
|
|
|
|
|
}
|
2015-09-27 16:32:09 -07:00
|
|
|
|
e.preventDefault();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-12-14 08:43:03 -07:00
|
|
|
|
e.preventDefault();
|
2016-04-19 19:29:15 -07:00
|
|
|
|
// It won't have this if it's a hammer event
|
|
|
|
|
if (e.stopPropagation) {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
}
|
2015-12-14 08:43:03 -07:00
|
|
|
|
return false;
|
2015-09-27 16:32:09 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onItemSelectionPanelClick(e, itemSelectionPanel) {
|
|
|
|
|
|
|
|
|
|
// toggle the checkbox, if it wasn't clicked on
|
|
|
|
|
if (!parentWithClass(e.target, 'chkItemSelect')) {
|
|
|
|
|
var chkItemSelect = itemSelectionPanel.querySelector('.chkItemSelect');
|
|
|
|
|
|
|
|
|
|
if (chkItemSelect) {
|
2016-04-25 11:02:33 -07:00
|
|
|
|
|
|
|
|
|
if (chkItemSelect.classList.contains('checkedInitial')) {
|
|
|
|
|
chkItemSelect.classList.remove('checkedInitial');
|
|
|
|
|
} else {
|
|
|
|
|
var newValue = !chkItemSelect.checked;
|
|
|
|
|
chkItemSelect.checked = newValue;
|
|
|
|
|
updateItemSelection(chkItemSelect, newValue);
|
|
|
|
|
}
|
2015-09-27 16:32:09 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
2015-12-14 08:43:03 -07:00
|
|
|
|
e.stopPropagation();
|
2015-09-27 16:32:09 -07:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-13 22:02:30 -07:00
|
|
|
|
function onSelectionChange(e) {
|
|
|
|
|
updateItemSelection(this, this.checked);
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-25 11:02:33 -07:00
|
|
|
|
function showSelection(item, isChecked) {
|
2014-03-17 18:45:41 -07:00
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
var itemSelectionPanel = item.querySelector('.itemSelectionPanel');
|
2014-03-17 18:45:41 -07:00
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
if (!itemSelectionPanel) {
|
2014-03-17 18:45:41 -07:00
|
|
|
|
|
2015-12-26 11:35:53 -07:00
|
|
|
|
itemSelectionPanel = document.createElement('div');
|
|
|
|
|
itemSelectionPanel.classList.add('itemSelectionPanel');
|
2014-03-17 18:45:41 -07:00
|
|
|
|
|
2015-12-26 11:35:53 -07:00
|
|
|
|
item.querySelector('.cardContent').appendChild(itemSelectionPanel);
|
2014-03-17 18:45:41 -07:00
|
|
|
|
|
2016-04-25 11:02:33 -07:00
|
|
|
|
var cssClass = 'chkItemSelect';
|
|
|
|
|
if (isChecked && !browserInfo.firefox) {
|
|
|
|
|
// In firefox, the initial tap hold doesnt' get treated as a click
|
|
|
|
|
// In other browsers it does, so we need to make sure that initial click is ignored
|
|
|
|
|
cssClass += ' checkedInitial';
|
|
|
|
|
}
|
|
|
|
|
var checkedAttribute = isChecked ? ' checked' : '';
|
2016-06-13 21:06:57 -07:00
|
|
|
|
itemSelectionPanel.innerHTML = '<label class="checkboxContainer"><input type="checkbox" is="emby-checkbox" class="' + cssClass + '"' + checkedAttribute + '/><span></span></label>>';
|
|
|
|
|
var chkItemSelect = itemSelectionPanel.querySelector('.chkItemSelect');
|
2016-04-25 11:02:33 -07:00
|
|
|
|
chkItemSelect.addEventListener('change', onSelectionChange);
|
2015-09-27 16:32:09 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-11-09 21:20:11 -07:00
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
function showSelectionCommands() {
|
2014-11-09 21:20:11 -07:00
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
var selectionCommandsPanel = document.querySelector('.selectionCommandsPanel');
|
2014-11-09 21:20:11 -07:00
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
if (!selectionCommandsPanel) {
|
2014-11-09 21:20:11 -07:00
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
selectionCommandsPanel = document.createElement('div');
|
|
|
|
|
selectionCommandsPanel.classList.add('selectionCommandsPanel');
|
|
|
|
|
|
|
|
|
|
document.body.appendChild(selectionCommandsPanel);
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<div style="float:left;">';
|
2016-06-18 22:26:52 -07:00
|
|
|
|
html += '<button is="paper-icon-button-light" class="btnCloseSelectionPanel autoSize"><i class="md-icon">close</i></button>';
|
2015-09-27 16:32:09 -07:00
|
|
|
|
html += '<span class="itemSelectionCount"></span>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2016-06-18 22:26:52 -07:00
|
|
|
|
html += '<button is="paper-icon-button-light" class="btnSelectionPanelOptions autoSize" style="margin-left:auto;"><i class="md-icon">more_vert</i></button>';
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
selectionCommandsPanel.innerHTML = html;
|
|
|
|
|
|
2016-01-28 14:08:09 -07:00
|
|
|
|
selectionCommandsPanel.querySelector('.btnCloseSelectionPanel').addEventListener('click', hideSelections);
|
2015-10-07 18:49:40 -07:00
|
|
|
|
|
|
|
|
|
var btnSelectionPanelOptions = selectionCommandsPanel.querySelector('.btnSelectionPanelOptions');
|
|
|
|
|
|
2016-01-28 14:08:09 -07:00
|
|
|
|
btnSelectionPanelOptions.addEventListener('click', showMenuForSelectedItems);
|
2015-10-07 18:49:40 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
if (!browserInfo.mobile) {
|
2015-10-15 22:36:16 -07:00
|
|
|
|
shake(btnSelectionPanelOptions, 1);
|
|
|
|
|
}
|
2015-09-27 16:32:09 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-07 18:49:40 -07:00
|
|
|
|
function shake(elem, iterations) {
|
|
|
|
|
var keyframes = [
|
|
|
|
|
{ transform: 'translate3d(0, 0, 0)', offset: 0 },
|
|
|
|
|
{ transform: 'translate3d(-10px, 0, 0)', offset: 0.1 },
|
|
|
|
|
{ transform: 'translate3d(10px, 0, 0)', offset: 0.2 },
|
|
|
|
|
{ transform: 'translate3d(-10px, 0, 0)', offset: 0.3 },
|
|
|
|
|
{ transform: 'translate3d(10px, 0, 0)', offset: 0.4 },
|
|
|
|
|
{ transform: 'translate3d(-10px, 0, 0)', offset: 0.5 },
|
|
|
|
|
{ transform: 'translate3d(10px, 0, 0)', offset: 0.6 },
|
|
|
|
|
{ transform: 'translate3d(-10px, 0, 0)', offset: 0.7 },
|
|
|
|
|
{ transform: 'translate3d(10px, 0, 0)', offset: 0.8 },
|
|
|
|
|
{ transform: 'translate3d(-10px, 0, 0)', offset: 0.9 },
|
|
|
|
|
{ transform: 'translate3d(0, 0, 0)', offset: 1 }];
|
|
|
|
|
var timing = { duration: 900, iterations: iterations };
|
2016-04-25 11:02:33 -07:00
|
|
|
|
|
|
|
|
|
if (elem.animate) {
|
|
|
|
|
elem.animate(keyframes, timing);
|
|
|
|
|
}
|
2015-10-07 18:49:40 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
function showSelections(initialCard) {
|
|
|
|
|
|
2016-06-13 21:06:57 -07:00
|
|
|
|
require(['emby-checkbox'], function () {
|
2015-12-26 11:35:53 -07:00
|
|
|
|
var cards = document.querySelectorAll('.card');
|
|
|
|
|
for (var i = 0, length = cards.length; i < length; i++) {
|
2016-04-25 11:02:33 -07:00
|
|
|
|
showSelection(cards[i], initialCard == cards[i]);
|
2015-12-26 11:35:53 -07:00
|
|
|
|
}
|
2014-03-17 18:45:41 -07:00
|
|
|
|
|
2015-12-26 11:35:53 -07:00
|
|
|
|
showSelectionCommands();
|
|
|
|
|
updateItemSelection(initialCard, true);
|
|
|
|
|
});
|
2015-09-27 16:32:09 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hideSelections() {
|
|
|
|
|
|
|
|
|
|
var selectionCommandsPanel = document.querySelector('.selectionCommandsPanel');
|
|
|
|
|
if (selectionCommandsPanel) {
|
|
|
|
|
|
|
|
|
|
selectionCommandsPanel.parentNode.removeChild(selectionCommandsPanel);
|
|
|
|
|
|
|
|
|
|
selectedItems = [];
|
|
|
|
|
var elems = document.querySelectorAll('.itemSelectionPanel');
|
|
|
|
|
for (var i = 0, length = elems.length; i < length; i++) {
|
|
|
|
|
elems[i].parentNode.removeChild(elems[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-17 18:45:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
var selectedItems = [];
|
|
|
|
|
function updateItemSelection(chkItemSelect, selected) {
|
|
|
|
|
|
2016-07-17 19:55:07 -07:00
|
|
|
|
var id = parentWithClass(chkItemSelect, 'card').getAttribute('data-id');
|
2015-09-27 16:32:09 -07:00
|
|
|
|
|
|
|
|
|
if (selected) {
|
|
|
|
|
|
|
|
|
|
var current = selectedItems.filter(function (i) {
|
|
|
|
|
return i == id;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!current.length) {
|
|
|
|
|
selectedItems.push(id);
|
|
|
|
|
}
|
2014-03-17 18:45:41 -07:00
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
} else {
|
|
|
|
|
selectedItems = selectedItems.filter(function (i) {
|
|
|
|
|
return i != id;
|
|
|
|
|
});
|
2015-06-28 07:45:21 -07:00
|
|
|
|
}
|
2014-03-17 18:45:41 -07:00
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
if (selectedItems.length) {
|
|
|
|
|
var itemSelectionCount = document.querySelector('.itemSelectionCount');
|
|
|
|
|
if (itemSelectionCount) {
|
|
|
|
|
itemSelectionCount.innerHTML = selectedItems.length;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
hideSelections();
|
2015-06-28 07:45:21 -07:00
|
|
|
|
}
|
2014-03-17 18:45:41 -07:00
|
|
|
|
}
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
function showMenuForSelectedItems(e) {
|
2015-09-27 17:59:30 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
Dashboard.getCurrentUser().then(function (user) {
|
2015-09-27 16:32:09 -07:00
|
|
|
|
|
|
|
|
|
var items = [];
|
|
|
|
|
|
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('ButtonAddToCollection'),
|
|
|
|
|
id: 'addtocollection',
|
|
|
|
|
ironIcon: 'add'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('ButtonAddToPlaylist'),
|
|
|
|
|
id: 'playlist',
|
|
|
|
|
ironIcon: 'playlist-add'
|
|
|
|
|
});
|
|
|
|
|
|
2016-01-19 12:03:46 -07:00
|
|
|
|
if (user.Policy.EnableContentDeletion) {
|
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('ButtonDelete'),
|
|
|
|
|
id: 'delete',
|
|
|
|
|
ironIcon: 'delete'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-17 22:58:08 -07:00
|
|
|
|
if (user.Policy.EnableContentDownloading && appHost.supports('filedownload')) {
|
2015-12-30 10:02:11 -07:00
|
|
|
|
//items.push({
|
|
|
|
|
// name: Globalize.translate('ButtonDownload'),
|
|
|
|
|
// id: 'download',
|
|
|
|
|
// ironIcon: 'file-download'
|
|
|
|
|
//});
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-19 19:06:05 -07:00
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('HeaderGroupVersions'),
|
|
|
|
|
id: 'groupvideos',
|
|
|
|
|
ironIcon: 'call-merge'
|
|
|
|
|
});
|
|
|
|
|
|
2016-04-16 09:51:52 -07:00
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('MarkPlayed'),
|
|
|
|
|
id: 'markplayed'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('MarkUnplayed'),
|
|
|
|
|
id: 'markunplayed'
|
|
|
|
|
});
|
|
|
|
|
|
2015-09-27 17:59:30 -07:00
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('ButtonRefresh'),
|
|
|
|
|
id: 'refresh',
|
|
|
|
|
ironIcon: 'refresh'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
items.push({
|
|
|
|
|
name: Globalize.translate('ButtonSync'),
|
|
|
|
|
id: 'sync',
|
2015-10-16 15:21:03 -07:00
|
|
|
|
ironIcon: 'sync'
|
2015-09-27 17:59:30 -07:00
|
|
|
|
});
|
|
|
|
|
|
2016-01-30 21:04:00 -07:00
|
|
|
|
require(['actionsheet'], function (actionsheet) {
|
2015-09-27 16:32:09 -07:00
|
|
|
|
|
2016-01-30 21:04:00 -07:00
|
|
|
|
actionsheet.show({
|
2015-09-27 16:32:09 -07:00
|
|
|
|
items: items,
|
|
|
|
|
positionTo: e.target,
|
|
|
|
|
callback: function (id) {
|
|
|
|
|
|
2015-10-13 22:46:11 -07:00
|
|
|
|
var items = selectedItems.slice(0);
|
2016-06-06 10:33:27 -07:00
|
|
|
|
var serverId = ApiClient.serverInfo().Id;
|
2015-10-13 22:46:11 -07:00
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
switch (id) {
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
case 'addtocollection':
|
2016-05-21 19:28:47 -07:00
|
|
|
|
require(['collectionEditor'], function (collectionEditor) {
|
2015-10-13 22:46:11 -07:00
|
|
|
|
|
2016-05-21 19:28:47 -07:00
|
|
|
|
new collectionEditor().show({
|
2016-06-06 10:33:27 -07:00
|
|
|
|
items: items,
|
|
|
|
|
serverId: serverId
|
2016-05-21 19:28:47 -07:00
|
|
|
|
});
|
2015-10-13 22:46:11 -07:00
|
|
|
|
});
|
2015-09-27 18:50:11 -07:00
|
|
|
|
hideSelections();
|
2015-09-27 16:32:09 -07:00
|
|
|
|
break;
|
|
|
|
|
case 'playlist':
|
2016-05-21 23:08:44 -07:00
|
|
|
|
require(['playlistEditor'], function (playlistEditor) {
|
|
|
|
|
new playlistEditor().show({
|
|
|
|
|
items: items,
|
|
|
|
|
serverId: serverId
|
|
|
|
|
});
|
2016-02-17 19:55:15 -07:00
|
|
|
|
});
|
2016-05-21 23:08:44 -07:00
|
|
|
|
hideSelections();
|
2015-09-27 16:32:09 -07:00
|
|
|
|
break;
|
2016-01-19 12:03:46 -07:00
|
|
|
|
case 'delete':
|
|
|
|
|
LibraryBrowser.deleteItems(items).then(function () {
|
2016-03-15 22:33:31 -07:00
|
|
|
|
Dashboard.navigate('home.html');
|
2016-01-19 12:03:46 -07:00
|
|
|
|
});
|
|
|
|
|
hideSelections();
|
|
|
|
|
break;
|
2015-10-19 19:06:05 -07:00
|
|
|
|
case 'groupvideos':
|
2016-05-17 10:44:17 -07:00
|
|
|
|
combineVersions(parentWithClass(e.target, 'page'), items);
|
2015-10-19 19:06:05 -07:00
|
|
|
|
break;
|
2016-04-16 09:51:52 -07:00
|
|
|
|
case 'markplayed':
|
2016-04-17 22:58:08 -07:00
|
|
|
|
items.forEach(function (itemId) {
|
2016-04-16 09:51:52 -07:00
|
|
|
|
ApiClient.markPlayed(Dashboard.getCurrentUserId(), itemId);
|
|
|
|
|
});
|
|
|
|
|
hideSelections();
|
|
|
|
|
break;
|
|
|
|
|
case 'markunplayed':
|
|
|
|
|
items.forEach(function (itemId) {
|
|
|
|
|
ApiClient.markUnplayed(Dashboard.getCurrentUserId(), itemId);
|
|
|
|
|
});
|
|
|
|
|
hideSelections();
|
|
|
|
|
break;
|
2015-09-27 17:59:30 -07:00
|
|
|
|
case 'refresh':
|
2016-06-15 09:45:45 -07:00
|
|
|
|
require(['refreshDialog'], function (refreshDialog) {
|
|
|
|
|
new refreshDialog({
|
|
|
|
|
itemIds: items,
|
|
|
|
|
serverId: serverId
|
|
|
|
|
}).show();
|
2016-04-30 12:31:58 -07:00
|
|
|
|
});
|
2015-09-27 18:50:11 -07:00
|
|
|
|
hideSelections();
|
2015-09-27 17:59:30 -07:00
|
|
|
|
break;
|
|
|
|
|
case 'sync':
|
2016-02-17 21:57:19 -07:00
|
|
|
|
require(['syncDialog'], function (syncDialog) {
|
|
|
|
|
syncDialog.showMenu({
|
|
|
|
|
items: items.map(function (i) {
|
|
|
|
|
return {
|
|
|
|
|
Id: i
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
});
|
2015-09-27 17:59:30 -07:00
|
|
|
|
});
|
2015-09-27 18:50:11 -07:00
|
|
|
|
hideSelections();
|
2015-09-27 17:59:30 -07:00
|
|
|
|
break;
|
2015-09-27 16:32:09 -07:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-03-17 18:45:41 -07:00
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-03-17 18:45:41 -07:00
|
|
|
|
|
2015-10-19 19:06:05 -07:00
|
|
|
|
function combineVersions(page, selection) {
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2014-03-17 18:45:41 -07:00
|
|
|
|
if (selection.length < 2) {
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2014-03-17 18:45:41 -07:00
|
|
|
|
Dashboard.alert({
|
2014-06-03 20:34:36 -07:00
|
|
|
|
message: Globalize.translate('MessagePleaseSelectTwoItems'),
|
2014-05-30 12:23:56 -07:00
|
|
|
|
title: Globalize.translate('HeaderError')
|
2014-03-17 18:45:41 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-19 19:06:05 -07:00
|
|
|
|
var msg = Globalize.translate('MessageTheSelectedItemsWillBeGrouped');
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2016-02-22 12:31:28 -07:00
|
|
|
|
require(['confirm'], function (confirm) {
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
2016-02-22 12:31:28 -07:00
|
|
|
|
confirm(msg, Globalize.translate('HeaderGroupVersions')).then(function () {
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2014-07-01 22:16:59 -07:00
|
|
|
|
ApiClient.ajax({
|
2014-06-30 11:55:38 -07:00
|
|
|
|
|
2014-03-18 18:35:40 -07:00
|
|
|
|
type: "POST",
|
|
|
|
|
url: ApiClient.getUrl("Videos/MergeVersions", { Ids: selection.join(',') })
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}).then(function () {
|
2014-03-18 18:35:40 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2015-10-19 19:06:05 -07:00
|
|
|
|
hideSelections();
|
2016-06-01 23:08:47 -07:00
|
|
|
|
page.querySelector('.itemsContainer').dispatchEvent(new CustomEvent('needsrefresh', {}));
|
2014-03-18 18:35:40 -07:00
|
|
|
|
});
|
2016-02-22 12:31:28 -07:00
|
|
|
|
});
|
2014-03-18 18:35:40 -07:00
|
|
|
|
});
|
2014-03-17 18:45:41 -07:00
|
|
|
|
}
|
2014-06-30 11:55:38 -07:00
|
|
|
|
|
2016-02-17 21:57:19 -07:00
|
|
|
|
function showSyncButtonsPerUser(page) {
|
|
|
|
|
|
|
|
|
|
var apiClient = window.ApiClient;
|
|
|
|
|
|
|
|
|
|
if (!apiClient || !apiClient.getCurrentUserId()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Dashboard.getCurrentUser().then(function (user) {
|
|
|
|
|
|
|
|
|
|
var item = {
|
|
|
|
|
SupportsSync: true
|
|
|
|
|
};
|
|
|
|
|
|
2016-06-01 23:08:47 -07:00
|
|
|
|
var categorySyncButtons = page.querySelectorAll('.categorySyncButton');
|
|
|
|
|
for (var i = 0, length = categorySyncButtons.length; i < length; i++) {
|
2016-07-16 18:58:51 -07:00
|
|
|
|
if (itemHelper.canSync(user, item)) {
|
2016-06-01 23:08:47 -07:00
|
|
|
|
categorySyncButtons[i].classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
categorySyncButtons[i].classList.add('hide');
|
|
|
|
|
}
|
2016-02-17 21:57:19 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-01 23:08:47 -07:00
|
|
|
|
function onCategorySyncButtonClick(e) {
|
2016-02-17 21:57:19 -07:00
|
|
|
|
|
2016-06-01 23:08:47 -07:00
|
|
|
|
var button = this;
|
2016-02-17 21:57:19 -07:00
|
|
|
|
var category = button.getAttribute('data-category');
|
|
|
|
|
var parentId = LibraryMenu.getTopParentId();
|
|
|
|
|
|
|
|
|
|
require(['syncDialog'], function (syncDialog) {
|
|
|
|
|
syncDialog.showMenu({
|
|
|
|
|
ParentId: parentId,
|
|
|
|
|
Category: category
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-07 21:22:38 -07:00
|
|
|
|
pageClassOn('pageinit', "libraryPage", function () {
|
2014-03-17 18:45:41 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2016-06-01 23:08:47 -07:00
|
|
|
|
var categorySyncButtons = page.querySelectorAll('.categorySyncButton');
|
2016-07-17 11:55:07 -07:00
|
|
|
|
for (var i = 0, length = categorySyncButtons.length; i < length; i++) {
|
2016-06-01 23:08:47 -07:00
|
|
|
|
categorySyncButtons[i].addEventListener('click', onCategorySyncButtonClick);
|
|
|
|
|
}
|
2016-02-17 21:57:19 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
pageClassOn('pageshow', "libraryPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
if (!Dashboard.isServerlessPage()) {
|
|
|
|
|
showSyncButtonsPerUser(page);
|
|
|
|
|
}
|
2015-09-07 21:22:38 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-09-27 18:50:11 -07:00
|
|
|
|
pageClassOn('pagebeforehide', "libraryPage", function () {
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2015-09-27 16:32:09 -07:00
|
|
|
|
hideSelections();
|
2014-03-17 18:45:41 -07:00
|
|
|
|
});
|
|
|
|
|
|
2016-02-29 23:02:03 -07:00
|
|
|
|
});
|