816 lines
33 KiB
JavaScript
816 lines
33 KiB
JavaScript
define([
|
|
"exports",
|
|
"./../emby-apiclient/connectionmanager.js",
|
|
"./../dom.js",
|
|
"./../common/globalize.js",
|
|
"./../layoutmanager.js",
|
|
"./../common/itemmanager/itemmanager.js",
|
|
"./../imageloader/imageloader.js",
|
|
"./../dialoghelper/dialoghelper.js",
|
|
"./../emby-elements/emby-button/emby-button.js",
|
|
"./../emby-elements/emby-scroller/emby-scroller.js",
|
|
"./../emby-elements/emby-itemscontainer/emby-itemscontainer.js",
|
|
"./../approuter.js",
|
|
"./../focusmanager.js",
|
|
"./../listview/listview.js",
|
|
"./../shortcuts.js",
|
|
"./../browser.js",
|
|
"./../common/textencoding.js",
|
|
], function (
|
|
_exports,
|
|
_connectionmanager,
|
|
_dom,
|
|
_globalize,
|
|
_layoutmanager,
|
|
_itemmanager,
|
|
_imageloader,
|
|
_dialoghelper,
|
|
_embyButton,
|
|
_embyScroller,
|
|
_embyItemscontainer,
|
|
_approuter,
|
|
_focusmanager,
|
|
_listview,
|
|
_shortcuts,
|
|
_browser,
|
|
_textencoding,
|
|
) {
|
|
function onCancelClick(e) {
|
|
_dialoghelper.default.close(this.closest(".actionSheet"));
|
|
}
|
|
function getTextLinkButton(item) {
|
|
var href = _approuter.default.getRouteUrl(item);
|
|
return (
|
|
'<a is="emby-linkbutton" class="button-link noautofocus actionsheetPreviewTextItem mediaInfoItem" data-href="' +
|
|
href +
|
|
'" href="' +
|
|
href +
|
|
'">' +
|
|
_textencoding.default.htmlEncode(item.Name) +
|
|
"</a>"
|
|
);
|
|
}
|
|
function onItemsContainerUpgraded() {
|
|
return this.querySelector(".itemsContainer").resume({ refresh: !0 });
|
|
}
|
|
function refreshItemsContainer() {
|
|
var itemsContainer = this.querySelector(".itemsContainer");
|
|
return itemsContainer.resume
|
|
? onItemsContainerUpgraded.call(this)
|
|
: (function (instance, itemsContainer) {
|
|
return new Promise(function (resolve, reject) {
|
|
_dom.default.addEventListener(
|
|
itemsContainer,
|
|
"upgraded",
|
|
function () {
|
|
onItemsContainerUpgraded.call(instance).then(resolve, reject);
|
|
},
|
|
{ once: !0 },
|
|
);
|
|
});
|
|
})(this, itemsContainer);
|
|
}
|
|
function getListViewItemFromInputItem(option, options) {
|
|
var isSelected,
|
|
item = {
|
|
Name:
|
|
option.Name || option.name || option.textContent || option.innerText,
|
|
ServerId: option.ServerId || null,
|
|
MediaType: option.MediaType || null,
|
|
IsFolder: option.IsFolder,
|
|
Type: option.Type,
|
|
Overview: option.Overview,
|
|
PrimaryImageAspectRatio: option.PrimaryImageAspectRatio,
|
|
RunTimeTicks: option.RunTimeTicks,
|
|
IndexNumber: option.IndexNumber,
|
|
IndexNumberEnd: option.IndexNumberEnd,
|
|
SupportsResume: option.SupportsResume,
|
|
ParentIndexNumber: option.ParentIndexNumber,
|
|
ProductionYear: option.ProductionYear,
|
|
PremiereDate: option.PremiereDate,
|
|
SeriesName: option.SeriesName,
|
|
NameSubtitle: option.nameSubtitle,
|
|
Artists: option.Artists,
|
|
ArtistItems: option.ArtistItems,
|
|
AlbumArtists: option.AlbumArtists,
|
|
Composers: option.Composers,
|
|
AlbumArtist: option.AlbumArtist,
|
|
Album: option.Album,
|
|
AlbumId: option.AlbumId,
|
|
SeriesId: option.SeriesId,
|
|
SeasonId: option.SeasonId,
|
|
SeasonName: option.SeasonName,
|
|
ImageTags: option.ImageTags,
|
|
BackdropImageTags: option.BackdropImageTags,
|
|
PrimaryImageTag: option.PrimaryImageTag,
|
|
AlbumPrimaryImageTag: option.AlbumPrimaryImageTag,
|
|
SeriesPrimaryImageTag: option.SeriesPrimaryImageTag,
|
|
ParentThumbItemId: option.ParentThumbItemId,
|
|
ParentThumbImageTag: option.ParentThumbImageTag,
|
|
ParentLogoItemId: option.ParentLogoItemId,
|
|
ParentLogoImageTag: option.ParentLogoImageTag,
|
|
ParentBackdropItemId: option.ParentBackdropItemId,
|
|
ParentBackdropImageTags: option.ParentBackdropImageTags,
|
|
hasDivider: option.dividerAfter,
|
|
};
|
|
return (
|
|
options.idProperty && null != option[options.idProperty]
|
|
? (item.Id = option[options.idProperty])
|
|
: null != option.Id
|
|
? (item.Id = option.Id)
|
|
: null != option.id && "" !== option.id
|
|
? (item.Id = option.id)
|
|
: null != option.value
|
|
? (item.Id = option.value)
|
|
: (item.Id = option.Name || option.name),
|
|
options.multiple
|
|
? ((isSelected =
|
|
(options.emptyValueSetEqualsAll &&
|
|
!options.selectedValuesClone.length) ||
|
|
options.selectedValuesClone.includes(item.Id)),
|
|
(item.Selected = isSelected))
|
|
: (item.Selected =
|
|
option.selected ||
|
|
option.Selected ||
|
|
options.selectedValuesClone.includes(item.Id)),
|
|
(item.Icon =
|
|
option.icon ||
|
|
option.Icon ||
|
|
(item.Selected && options.hasItemSelectionState ? "" : null)),
|
|
(item.iconClass = option.iconClass),
|
|
(item.asideText = option.asideText),
|
|
(item.asideIcon = option.asideIcon),
|
|
(item.ShortOverview = option.secondaryText || option.title),
|
|
(item.hideWithFinePointer = option.hideWithFinePointer),
|
|
item
|
|
);
|
|
}
|
|
function getItemsFn(options) {
|
|
return function (query) {
|
|
if (((query = query || {}), options.getItems))
|
|
return (function (options, query) {
|
|
return options.getItems(query).then(function (result) {
|
|
for (
|
|
var items = result.Items, i = 0, length = items.length;
|
|
i < length;
|
|
i++
|
|
)
|
|
items[i] = getListViewItemFromInputItem(items[i], options);
|
|
return result;
|
|
});
|
|
})(options, query);
|
|
for (
|
|
var inputItems = options.items || [],
|
|
items = [],
|
|
i = 0,
|
|
length = inputItems.length;
|
|
i < length;
|
|
i++
|
|
) {
|
|
var item = getListViewItemFromInputItem(inputItems[i], options);
|
|
items.push(item);
|
|
}
|
|
var totalRecordCount = items.length,
|
|
items = items.slice(query.StartIndex || 0);
|
|
return (
|
|
null != query.length &&
|
|
items.length > query.length &&
|
|
(items.length = Math.min(items.length, query.length)),
|
|
Promise.resolve({ Items: items, TotalRecordCount: totalRecordCount })
|
|
);
|
|
};
|
|
}
|
|
function getListOptions() {
|
|
return {
|
|
renderer: _listview.default,
|
|
options: (function (options) {
|
|
var listItemBodyClass,
|
|
iconClass,
|
|
asideTextClass,
|
|
menuItemClass = "actionSheetMenuItem",
|
|
fields =
|
|
(options.menuItemClass &&
|
|
(menuItemClass += " " + options.menuItemClass),
|
|
options.iconRight &&
|
|
(menuItemClass += " actionSheetMenuItem-iconright"),
|
|
options.multiple
|
|
? (listItemBodyClass = "actionsheetListItemBody-multiple")
|
|
: (_layoutmanager.default.tv &&
|
|
(menuItemClass += " actionSheetMenuItem-tv"),
|
|
options.hasItemIcon ||
|
|
options.hasItemSelectionState ||
|
|
(menuItemClass += " actionSheetMenuItem-noicon"),
|
|
(listItemBodyClass = "actionsheetListItemBody"),
|
|
options.iconRight &&
|
|
(listItemBodyClass += " actionsheetListItemBody-iconright"),
|
|
(iconClass =
|
|
"actionsheetMenuItemIcon listItemIcon listItemIcon-transparent md-icon"),
|
|
(asideTextClass = "actionSheetItemAsideText")),
|
|
options.fields),
|
|
overviewLines = 2,
|
|
fields =
|
|
(fields ||
|
|
((fields = ["Name"]),
|
|
options.showNameSubtitle && fields.push("NameSubtitle"),
|
|
options.multiple || fields.push("ShortOverview"),
|
|
options.showOverview &&
|
|
(fields.push("Overview"), (overviewLines = 3))),
|
|
options.multiple && fields.unshift("ItemCheckbox"),
|
|
{
|
|
action: options.multiple ? "togglecheckbox" : "custom",
|
|
fields: fields,
|
|
draggable: !1,
|
|
multiSelect: !1,
|
|
contextMenu: !1,
|
|
hoverPlayButton: !1,
|
|
itemClass: menuItemClass,
|
|
listItemBodyClassName: listItemBodyClass,
|
|
iconClass: iconClass,
|
|
listItemBodyTextClass: "actionSheetItemText",
|
|
fillEmptyTextlines: !1,
|
|
enableDefaultIcon: !0 === options.enableDefaultIcon,
|
|
highlight: options.highlight,
|
|
border: options.border,
|
|
artist: options.artist,
|
|
asideTextClass: asideTextClass,
|
|
asideIconClass: (
|
|
(asideTextClass || "") + " actionSheetItemAsideIcon"
|
|
).trim(),
|
|
image:
|
|
!options.multiple &&
|
|
(!0 === options.hasItemIcon ||
|
|
!0 === options.hasItemImage ||
|
|
!0 === options.hasItemSelectionState),
|
|
checkboxAction: "toggleitemselected",
|
|
enableUserDataButtons: !1,
|
|
moreButton: !1,
|
|
mediaInfo: !1,
|
|
textLinks: !1,
|
|
enableSideMediaInfo: !1,
|
|
overviewLines: overviewLines,
|
|
iconSpacing: !0,
|
|
}),
|
|
menuItemClass = "actionSheetItemImageContainer";
|
|
return (
|
|
options.useListViewSizing ||
|
|
((menuItemClass += " actionSheetItemImageContainer-customsize"),
|
|
!1 !== options.useCustomImageContainerWidth &&
|
|
(menuItemClass += " actionSheetItemImageContainer-customwidth")),
|
|
(options.hasItemSelectionState || options.hasItemIcon) &&
|
|
(menuItemClass += " actionSheetItemImageContainer-transparent"),
|
|
(fields.imageContainerClass = menuItemClass),
|
|
fields
|
|
);
|
|
})(this),
|
|
virtualScrollLayout: "vertical-list",
|
|
};
|
|
}
|
|
function callUpdateElement(itemsContainer, options) {
|
|
for (
|
|
var items = itemsContainer.querySelectorAll(
|
|
itemsContainer.getItemSelector(),
|
|
),
|
|
i = 0,
|
|
length = items.length;
|
|
i < length;
|
|
i++
|
|
) {
|
|
var elem = items[i];
|
|
!(function (element, item, options) {
|
|
var classList;
|
|
element &&
|
|
(classList = element.classList) &&
|
|
(item && item.Selected
|
|
? classList.add("autofocus")
|
|
: classList.remove("autofocus"),
|
|
item && item.hideWithFinePointer
|
|
? classList.add("actionSheetMenuItem-hiddenfinepointer")
|
|
: classList.remove("actionSheetMenuItem-hiddenfinepointer"),
|
|
!1 === options.highlight) &&
|
|
((classList = element.querySelector(".listItem-content").classList),
|
|
item && item.hasDivider
|
|
? classList.add("listItem-border")
|
|
: classList.remove("listItem-border"));
|
|
})(elem, itemsContainer.getItemFromElement(elem), options);
|
|
}
|
|
}
|
|
function ActionSheet() {}
|
|
Object.defineProperty(_exports, "__esModule", { value: !0 }),
|
|
(_exports.default = void 0),
|
|
require(["css!modules/actionsheet/actionsheet.css", "material-icons"]),
|
|
(ActionSheet.prototype.show = function (options) {
|
|
_layoutmanager.default.tv ||
|
|
_browser.default.iOS ||
|
|
_browser.default.osx ||
|
|
(options.highlight = !1);
|
|
var dialogOptions = {
|
|
removeOnClose: !0,
|
|
enableHistory: options.enableHistory,
|
|
autoFocus: !1,
|
|
refocus: options.refocus,
|
|
autoCenter: !1,
|
|
transparentBackground: !0,
|
|
positionTo: options.positionTo,
|
|
positionX: options.positionX,
|
|
positionY: options.positionY,
|
|
transformOrigin: options.transformOrigin,
|
|
preventOverflow: options.preventOverflow,
|
|
minWidthToElement: options.minWidthToElement,
|
|
positionClientX: options.positionClientX,
|
|
positionClientY: options.positionClientY,
|
|
offsetLeft: options.offsetLeft,
|
|
offsetTop: options.offsetTop,
|
|
blurBackground: options.blurBackground,
|
|
setCurrentFocusScope: options.setCurrentFocusScope,
|
|
setDialogSize: !1,
|
|
},
|
|
useVirtualScroller =
|
|
null != options.getItems && options.enableVirtualScroller,
|
|
isFullscreen =
|
|
(useVirtualScroller && (dialogOptions.fixedSize = !0),
|
|
_layoutmanager.default.tv && !1 !== options.autoTvLayout
|
|
? (dialogOptions.size = "fullscreen")
|
|
: (dialogOptions.modal = !1),
|
|
"fullscreen" === dialogOptions.size),
|
|
dlg =
|
|
(options.hasItemImage &&
|
|
((options.paddedScroller = !0), (options.useListViewSizing = !0)),
|
|
isFullscreen || (options.paddedScroller = !0),
|
|
_dialoghelper.default.createDialog(dialogOptions)),
|
|
instance = this,
|
|
dialogOptions =
|
|
((instance.dlg = dlg).classList.add("actionSheet"),
|
|
_layoutmanager.default.tv &&
|
|
dlg.classList.add("actionSheet-focusscale"),
|
|
(_layoutmanager.default.tv ||
|
|
isFullscreen ||
|
|
options.hasItemSelectionState) &&
|
|
(dlg.classList.add("dlg-autofocus"),
|
|
_layoutmanager.default.tv || options.hasItemSelectionState) &&
|
|
dlg.classList.add("dlg-autofocus-force"),
|
|
isFullscreen ||
|
|
(useVirtualScroller &&
|
|
dlg.classList.add(
|
|
"actionSheet-virtualscroll",
|
|
"dialog-fullscreen-lowres",
|
|
),
|
|
_layoutmanager.default.tv ||
|
|
(dlg.classList.add(
|
|
"actionSheet-automobile",
|
|
"actionSheet-largefont",
|
|
),
|
|
options.multiple && dlg.classList.add("actionSheet-smallfont")),
|
|
!1 !== options.blur &&
|
|
_dom.default.allowBackdropFilter() &&
|
|
dlg.classList.add("dialog-blur")),
|
|
options.dialogClass && dlg.classList.add(options.dialogClass),
|
|
"");
|
|
!options.hasItemIcon ||
|
|
options.hasItemAsideIcon ||
|
|
options.hasItemAsideText ||
|
|
!1 === options.iconRight ||
|
|
(options.iconRight = !0),
|
|
options.iconRight &&
|
|
!isFullscreen &&
|
|
(options.useCustomImageContainerWidth = !1),
|
|
isFullscreen
|
|
? (dialogOptions +=
|
|
'<button is="paper-icon-button-light" class="btnCloseActionSheet btnCloseActionSheet-tv hide-mouse-idle-tv" tabindex="-1"><i class="md-icon autortl"></i></button>')
|
|
: useVirtualScroller &&
|
|
(dialogOptions +=
|
|
'<button is="paper-icon-button-light" class="btnCloseActionSheet btnCloseActionSheet-hideNonFullscreen btnCloseActionSheet-tv hide-mouse-idle-tv" tabindex="-1"><i class="md-icon autortl"></i></button>');
|
|
((!options.title ||
|
|
options.hasItemIcon ||
|
|
options.hasItemImage ||
|
|
options.hasItemSelectionState) &&
|
|
!isFullscreen) ||
|
|
dlg.classList.add("actionsheet-centered");
|
|
for (
|
|
var selectNoneText,
|
|
previewHtml = "",
|
|
headerClass =
|
|
(options.item &&
|
|
(previewHtml = (function (options, item) {
|
|
var html = "",
|
|
apiClient =
|
|
((html +=
|
|
'<div class="actionsheetItemPreview flex flex-direction-row">'),
|
|
_connectionmanager.default.getApiClient(item)),
|
|
imageUrl = (imageUrlInfo = _imageloader.default.getImageUrl(
|
|
item,
|
|
apiClient,
|
|
{ height: 60, width: 200 },
|
|
)).imgUrl,
|
|
imgClass = "",
|
|
round = "MusicArtist" === item.Type,
|
|
html = imageUrl
|
|
? ((imageUrlInfo = imageUrlInfo.aspect || 1),
|
|
(imgClass =
|
|
(imgClass += " actionsheetItemPreviewImage-bg") +
|
|
" actionsheetItemPreviewImage-bg-" +
|
|
(shape =
|
|
_imageloader.default.getShapeFromAspect(
|
|
imageUrlInfo,
|
|
))),
|
|
round &&
|
|
"square" === shape &&
|
|
(imgClass += " actionsheetItemPreviewImage-round"),
|
|
html +
|
|
('<div class="' + imgClass.trim()) +
|
|
'" style="aspect-ratio:' +
|
|
imageUrlInfo +
|
|
";background-image:url(" +
|
|
imageUrl +
|
|
');"></div>')
|
|
: ((imgClass +=
|
|
" actionsheetItemPreviewImage-iconcontainer"),
|
|
round &&
|
|
(imgClass += " actionsheetItemPreviewImage-round"),
|
|
(html =
|
|
html +
|
|
('<div class="' + imgClass.trim()) +
|
|
'"><i class="actionsheetItemPreviewImage-icon md-icon autortl">') +
|
|
_itemmanager.default.getDefaultIcon(item) +
|
|
"</i></div>"),
|
|
lines =
|
|
((html += '<div class="actionsheetItemPreviewContent">'),
|
|
[]),
|
|
shape =
|
|
(item.SeriesName
|
|
? item.SeriesId
|
|
? lines.push(
|
|
getTextLinkButton({
|
|
Type: "Series",
|
|
Id: item.SeriesId,
|
|
Name: item.SeriesName,
|
|
IsFolder: !0,
|
|
ServerId: item.ServerId,
|
|
}),
|
|
)
|
|
: lines.push(
|
|
_textencoding.default.htmlEncode(
|
|
item.SeriesName || "",
|
|
),
|
|
)
|
|
: "Program" === item.Type &&
|
|
lines.push(
|
|
_textencoding.default.htmlEncode(item.Name || ""),
|
|
),
|
|
_textencoding.default.htmlEncode(
|
|
_itemmanager.default.getDisplayName(item, {}) || "",
|
|
)),
|
|
imageUrlInfo =
|
|
'<div class="actionsheetPreviewTextItem mediaInfoItem">' +
|
|
shape +
|
|
"</div>",
|
|
round =
|
|
("Audio" !== item.MediaType ||
|
|
_layoutmanager.default.tv ||
|
|
!1 === options.linkToItem ||
|
|
(imageUrlInfo +=
|
|
'<a is="emby-linkbutton" title="' +
|
|
shape +
|
|
'" style="font-weight:inherit;" href="' +
|
|
_approuter.default.getRouteUrl(item) +
|
|
'" class="flex-shrink-zero actionsheetPreviewTextItem mediaInfoItem button-link button-link-color-inherit"><i class="md-icon" style="font-size:160%;"></i></a>'),
|
|
lines.push(imageUrlInfo),
|
|
"Server" === item.Type &&
|
|
(apiClient &&
|
|
apiClient.serverVersion() &&
|
|
lines.push(apiClient.serverVersion()),
|
|
apiClient) &&
|
|
apiClient.serverAddress() &&
|
|
lines.push(apiClient.serverAddress()),
|
|
"User" === item.Type &&
|
|
options.showServerName &&
|
|
(imageUrl = apiClient.serverName()) &&
|
|
lines.push(_textencoding.default.htmlEncode(imageUrl)),
|
|
item.IsFolder &&
|
|
item.AlbumArtists &&
|
|
item.AlbumArtists.length
|
|
? lines.push(
|
|
getTextLinkButton({
|
|
Type: "MusicArtist",
|
|
Id: item.AlbumArtists[0].Id,
|
|
Name: item.AlbumArtists[0].Name,
|
|
ServerId: item.ServerId,
|
|
}),
|
|
)
|
|
: item.ArtistItems && item.ArtistItems.length
|
|
? lines.push(
|
|
getTextLinkButton({
|
|
Type: "MusicArtist",
|
|
Id: item.ArtistItems[0].Id,
|
|
Name: item.ArtistItems[0].Name,
|
|
ServerId: item.ServerId,
|
|
}),
|
|
)
|
|
: item.AlbumArtists &&
|
|
item.AlbumArtists.length &&
|
|
lines.push(
|
|
getTextLinkButton({
|
|
Type: "MusicArtist",
|
|
Id: item.AlbumArtists[0].Id,
|
|
Name: item.AlbumArtists[0].Name,
|
|
ServerId: item.ServerId,
|
|
}),
|
|
),
|
|
[]);
|
|
item.Album && item.AlbumId
|
|
? round.push(
|
|
getTextLinkButton({
|
|
Type:
|
|
"Photo" === item.MediaType
|
|
? "PhotoAlbum"
|
|
: "MusicAlbum",
|
|
Id: item.AlbumId,
|
|
Name: item.Album,
|
|
ServerId: item.ServerId,
|
|
}),
|
|
)
|
|
: item.Album &&
|
|
round.push(
|
|
'<div class="actionsheetPreviewTextItem mediaInfoItem">' +
|
|
_textencoding.default.htmlEncode(item.Album) +
|
|
"</div>",
|
|
),
|
|
item.ProductionYear &&
|
|
"Episode" !== item.Type &&
|
|
round.push(
|
|
'<div class="actionsheetPreviewTextItem mediaInfoItem">' +
|
|
item.ProductionYear +
|
|
"</div>",
|
|
),
|
|
round.length && lines.push(round.join(""));
|
|
for (
|
|
var i = 0, length = Math.min(lines.length, 3);
|
|
i < length;
|
|
i++
|
|
)
|
|
html =
|
|
1 <= i
|
|
? (html +=
|
|
'<div class="actionsheetItemPreviewText mediaInfoItems secondaryText">') +
|
|
lines[i] +
|
|
"</div>"
|
|
: (html +=
|
|
'<div class="actionsheetItemPreviewText mediaInfoItems actionsheetItemPreviewText-main">') +
|
|
lines[i] +
|
|
"</div>";
|
|
return (html = html + "</div>" + "</div>");
|
|
})(options, options.item)),
|
|
_layoutmanager.default.tv || (dialogOptions += previewHtml),
|
|
options.title &&
|
|
((headerClass = "actionSheetTitle"),
|
|
options.hideTitleWhenNotFullscreen &&
|
|
!isFullscreen &&
|
|
(headerClass += " actionSheetTitle-hideNonFullscreen"),
|
|
(dialogOptions =
|
|
(dialogOptions += '<h3 class="' + headerClass + '">') +
|
|
options.title +
|
|
"</h3>")),
|
|
options.text &&
|
|
(dialogOptions =
|
|
(dialogOptions += '<p class="actionSheetText">') +
|
|
options.text +
|
|
"</p>"),
|
|
"actionSheetScroller focuscontainer-x"),
|
|
scrollSliderClass =
|
|
(isFullscreen
|
|
? ((headerClass += " actionSheetScroller-fullscreen"),
|
|
useVirtualScroller &&
|
|
(headerClass += " actionSheetScroller-fullscreen-virtual"))
|
|
: (useVirtualScroller && (headerClass += " flex-grow"),
|
|
options.paddedScroller &&
|
|
(headerClass += " actionSheetScroller-padded")),
|
|
_layoutmanager.default.tv &&
|
|
(headerClass += " actionSheetScroller-focusscale"),
|
|
(options.title || options.text) &&
|
|
(headerClass += " actionSheetScroller-withheader"),
|
|
" actionsheetScrollSlider scrollSlider flex flex-direction-column itemsContainer"),
|
|
isFullscreen =
|
|
(isFullscreen ||
|
|
(options.multiple && !useVirtualScroller) ||
|
|
!1 !== options.highlight ||
|
|
options.paddedScroller ||
|
|
(useVirtualScroller
|
|
? (headerClass += " actionsheetScrollSlider-bottompadded")
|
|
: (scrollSliderClass +=
|
|
" actionsheetScrollSlider-bottompadded")),
|
|
options.multiple &&
|
|
((scrollSliderClass += " actionsheet-scrollSlider-multiple"),
|
|
_layoutmanager.default.tv) &&
|
|
(scrollSliderClass += " actionsheet-scrollSlider-multiple-tv"),
|
|
""),
|
|
btnCloseActionSheets =
|
|
(useVirtualScroller &&
|
|
(isFullscreen += ' data-virtualscrolllayout="vertical-grid"'),
|
|
(dialogOptions =
|
|
(dialogOptions =
|
|
dialogOptions +
|
|
('<div is="emby-scroller" data-horizontal="false" data-focusscroll="true" class="' +
|
|
headerClass +
|
|
'">') +
|
|
('<div is="emby-itemscontainer" class="' +
|
|
scrollSliderClass +
|
|
' vertical-list"' +
|
|
isFullscreen +
|
|
">")) +
|
|
"</div>" +
|
|
"</div>"),
|
|
options.bottomText &&
|
|
(dialogOptions =
|
|
(dialogOptions +=
|
|
'<div class="actionSheetBottomText fieldDescription">') +
|
|
options.bottomText +
|
|
"</div>"),
|
|
options.multiple &&
|
|
useVirtualScroller &&
|
|
((dialogOptions +=
|
|
'<div class="flex align-items-center justify-content-flex-start text-align-start" style="width:100%;"><div style="padding:1em .75em 1em .75em;" class="flex flex-grow align-items-center justify-content-center">'),
|
|
(headerClass = "btnActionSheetSelectNone"),
|
|
options.selectAllOnSelectNone
|
|
? ((selectNoneText = _globalize.default.translate("SelectAll")),
|
|
(headerClass += " dlg-close"))
|
|
: (selectNoneText = _globalize.default.translate("SelectNone")),
|
|
(dialogOptions =
|
|
dialogOptions +
|
|
'<button type="button" is="emby-button" class="button-link ' +
|
|
headerClass +
|
|
'">' +
|
|
selectNoneText +
|
|
"</button></div></div>")),
|
|
(dlg.innerHTML = dialogOptions),
|
|
dlg.querySelectorAll(".btnCloseActionSheet")),
|
|
i = 0,
|
|
length = btnCloseActionSheets.length;
|
|
i < length;
|
|
i++
|
|
)
|
|
btnCloseActionSheets[i].addEventListener("click", onCancelClick);
|
|
scrollSliderClass = dlg.querySelector(".btnActionSheetSelectNone");
|
|
return (
|
|
scrollSliderClass &&
|
|
scrollSliderClass.addEventListener("click", function () {
|
|
(options.selectedValuesClone = []),
|
|
this.classList.contains("dlg-close")
|
|
? _dialoghelper.default.close(dlg)
|
|
: dlg.querySelector(".itemsContainer").refreshItems();
|
|
}),
|
|
new Promise(function (resolve, reject) {
|
|
var selectedItem, isResolved;
|
|
options.selectedValuesClone = (options.selectedValues || []).slice(0);
|
|
var itemsContainer = dlg.querySelector(".itemsContainer"),
|
|
openPromise =
|
|
(itemsContainer.addEventListener("action-null", function (e) {
|
|
var _selectedItem2;
|
|
options.multiple ||
|
|
((e = e.detail.item),
|
|
(selectedItem = e),
|
|
(e = options.resolveWithSelectedItem
|
|
? selectedItem
|
|
: null == (e = selectedItem)
|
|
? void 0
|
|
: e.Id),
|
|
!options.resolveOnClick ||
|
|
(options.resolveOnClick.indexOf &&
|
|
-1 ===
|
|
options.resolveOnClick.indexOf(
|
|
null == (_selectedItem2 = selectedItem)
|
|
? void 0
|
|
: _selectedItem2.Id,
|
|
)) ||
|
|
(resolve(e), (isResolved = !0)),
|
|
_dialoghelper.default.close(dlg));
|
|
}),
|
|
(itemsContainer.fetchData = getItemsFn(options)),
|
|
(itemsContainer.getListOptions = getListOptions.bind(options)),
|
|
itemsContainer.addEventListener("change", function (e) {
|
|
var arr,
|
|
value,
|
|
e = e.target.closest("input"),
|
|
itemValue = _shortcuts.default.getItemFromChildNode(
|
|
e,
|
|
null,
|
|
this,
|
|
).Id;
|
|
(arr = options.selectedValuesClone),
|
|
(value = itemValue),
|
|
-1 < (value = arr.indexOf(value)) && arr.splice(value, 1),
|
|
e.checked && options.selectedValuesClone.push(itemValue);
|
|
}),
|
|
(itemsContainer.afterRefresh = function () {
|
|
itemsContainer.virtualScroller ||
|
|
callUpdateElement(itemsContainer, options),
|
|
_layoutmanager.default.tv &&
|
|
itemsContainer.insertAdjacentHTML(
|
|
"afterbegin",
|
|
previewHtml,
|
|
);
|
|
}),
|
|
new Promise(function (resolve, reject) {
|
|
dlg.addEventListener("opened", resolve);
|
|
})),
|
|
closePromise = _dialoghelper.default.open(dlg);
|
|
(useVirtualScroller
|
|
? Promise.resolve()
|
|
: refreshItemsContainer.call(dlg)
|
|
)
|
|
.then(function () {
|
|
var timeout, refreshPromise;
|
|
return (
|
|
(dlg.dialogOptions.setDialogSize = !0),
|
|
_dialoghelper.default.positionDialog(dlg),
|
|
options.timeout &&
|
|
(timeout = setTimeout(function () {
|
|
_dialoghelper.default.close(dlg);
|
|
}, options.timeout)),
|
|
useVirtualScroller &&
|
|
(refreshPromise = refreshItemsContainer.call(dlg)),
|
|
openPromise.then(function () {
|
|
return (
|
|
(refreshPromise || Promise.resolve()).then(
|
|
function () {
|
|
var skipIfNotEnabled;
|
|
this.classList.contains("dlg-autofocus") &&
|
|
((skipIfNotEnabled = !this.classList.contains(
|
|
"dlg-autofocus-force",
|
|
)),
|
|
_focusmanager.default.autoFocus(
|
|
this.querySelector(".itemsContainer"),
|
|
{ skipIfNotEnabled: skipIfNotEnabled },
|
|
) ||
|
|
(skipIfNotEnabled &&
|
|
!_focusmanager.default.isAutoFocusEnabled()) ||
|
|
_focusmanager.default.autoFocus(this, {
|
|
skipIfNotEnabled: skipIfNotEnabled,
|
|
}));
|
|
}.bind(dlg),
|
|
),
|
|
itemsContainer.virtualScroller &&
|
|
itemsContainer.virtualScroller.onResized(),
|
|
closePromise.then(function () {
|
|
var _selectedItem3;
|
|
if (
|
|
((instance.dlg = null),
|
|
timeout && (clearTimeout(timeout), (timeout = null)),
|
|
!isResolved)
|
|
)
|
|
return null !=
|
|
(_selectedItem3 = options.multiple
|
|
? options.selectedValuesClone
|
|
: options.resolveWithSelectedItem
|
|
? selectedItem
|
|
: null == (_selectedItem3 = selectedItem)
|
|
? void 0
|
|
: _selectedItem3.Id)
|
|
? (options.callback &&
|
|
options.callback(_selectedItem3),
|
|
_selectedItem3)
|
|
: Promise.reject();
|
|
})
|
|
);
|
|
})
|
|
);
|
|
})
|
|
.then(resolve, reject);
|
|
})
|
|
);
|
|
}),
|
|
(ActionSheet.prototype.refreshItems = function () {
|
|
var _this$dlg =
|
|
null == (_this$dlg = this.dlg)
|
|
? void 0
|
|
: _this$dlg.querySelector(".itemsContainer");
|
|
_this$dlg && _this$dlg.refreshItems();
|
|
}),
|
|
(ActionSheet.prototype.isShowing = function () {
|
|
return null != this.dlg;
|
|
}),
|
|
(ActionSheet.prototype.autoFocus = function (options) {
|
|
console.log("focusing actionsheet"),
|
|
_focusmanager.default.autoFocus(this.dlg, options);
|
|
}),
|
|
(ActionSheet.prototype.close = function () {
|
|
var dlg = this.dlg;
|
|
dlg && _dialoghelper.default.close(dlg);
|
|
}),
|
|
(ActionSheet.prototype.destroy = function () {
|
|
this.dlg = null;
|
|
}),
|
|
(_exports.default = {
|
|
show: function (options) {
|
|
var actionSheet = new ActionSheet();
|
|
return actionSheet.show(options).then(
|
|
function (result) {
|
|
return actionSheet.destroy(), Promise.resolve(result);
|
|
},
|
|
function (result) {
|
|
return actionSheet.destroy(), Promise.reject(result);
|
|
},
|
|
);
|
|
},
|
|
constructor: ActionSheet,
|
|
});
|
|
});
|