mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 03:18:19 -07:00
update action sheet
This commit is contained in:
parent
81d936ff1c
commit
62e03ef0be
@ -2577,9 +2577,19 @@
|
|||||||
|
|
||||||
options.imageType = "thumb";
|
options.imageType = "thumb";
|
||||||
|
|
||||||
var itemId = item.ImageTags && item.ImageTags.Thumb ? item.Id : item.ParentThumbItemId;
|
if (item.ImageTags && item.ImageTags.Thumb) {
|
||||||
|
|
||||||
return itemId ? self.getImageUrl(itemId, options) : null;
|
options.tag = item.ImageTags.Thumb;
|
||||||
|
return self.getImageUrl(item.Id, options);
|
||||||
|
}
|
||||||
|
else if (item.ParentThumbItemId) {
|
||||||
|
|
||||||
|
options.tag = item.ImageTags.ParentThumbImageTag;
|
||||||
|
return self.getImageUrl(item.ParentThumbItemId, options);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,132 +2,130 @@
|
|||||||
|
|
||||||
function show(options) {
|
function show(options) {
|
||||||
|
|
||||||
require(['paperbuttonstyle'], function () {
|
// items
|
||||||
// items
|
// positionTo
|
||||||
// positionTo
|
// showCancel
|
||||||
// showCancel
|
// title
|
||||||
// title
|
var id = 'dlg' + new Date().getTime();
|
||||||
var id = 'dlg' + new Date().getTime();
|
var html = '';
|
||||||
var html = '';
|
|
||||||
|
|
||||||
var style = "";
|
var style = "";
|
||||||
|
|
||||||
var windowHeight = $(window).height();
|
var windowHeight = $(window).height();
|
||||||
|
|
||||||
// If the window height is under a certain amount, don't bother trying to position
|
// If the window height is under a certain amount, don't bother trying to position
|
||||||
// based on an element.
|
// based on an element.
|
||||||
if (options.positionTo && windowHeight >= 540) {
|
if (options.positionTo && windowHeight >= 540) {
|
||||||
|
|
||||||
var pos = $(options.positionTo).offset();
|
var pos = $(options.positionTo).offset();
|
||||||
|
|
||||||
pos.top += $(options.positionTo).innerHeight() / 2;
|
pos.top += $(options.positionTo).innerHeight() / 2;
|
||||||
pos.left += $(options.positionTo).innerWidth() / 2;
|
pos.left += $(options.positionTo).innerWidth() / 2;
|
||||||
|
|
||||||
// Account for margins
|
// Account for margins
|
||||||
pos.top -= 24;
|
pos.top -= 24;
|
||||||
pos.left -= 24;
|
pos.left -= 24;
|
||||||
|
|
||||||
// Account for popup size - we can't predict this yet so just estimate
|
// Account for popup size - we can't predict this yet so just estimate
|
||||||
pos.top -= (55 * options.items.length) / 2;
|
pos.top -= (55 * options.items.length) / 2;
|
||||||
pos.left -= 80;
|
pos.left -= 80;
|
||||||
|
|
||||||
// Account for scroll position
|
// Account for scroll position
|
||||||
pos.top -= $(window).scrollTop();
|
pos.top -= $(window).scrollTop();
|
||||||
pos.left -= $(window).scrollLeft();
|
pos.left -= $(window).scrollLeft();
|
||||||
|
|
||||||
// Avoid showing too close to the bottom
|
// Avoid showing too close to the bottom
|
||||||
pos.top = Math.min(pos.top, $(window).height() - 300);
|
pos.top = Math.min(pos.top, $(window).height() - 300);
|
||||||
pos.left = Math.min(pos.left, $(window).width() - 300);
|
pos.left = Math.min(pos.left, $(window).width() - 300);
|
||||||
|
|
||||||
// Do some boundary checking
|
// Do some boundary checking
|
||||||
pos.top = Math.max(pos.top, 0);
|
pos.top = Math.max(pos.top, 0);
|
||||||
pos.left = Math.max(pos.left, 0);
|
pos.left = Math.max(pos.left, 0);
|
||||||
|
|
||||||
style += 'position:fixed;top:' + pos.top + 'px;left:' + pos.left + 'px';
|
style += 'position:fixed;top:' + pos.top + 'px;left:' + pos.left + 'px';
|
||||||
|
}
|
||||||
|
|
||||||
|
html += '<paper-dialog id="' + id + '" with-backdrop style="' + style + '">';
|
||||||
|
|
||||||
|
if (options.title) {
|
||||||
|
html += '<h2>';
|
||||||
|
html += options.title;
|
||||||
|
html += '</h2>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// There seems to be a bug with this in safari causing it to immediately roll up to 0 height
|
||||||
|
var isScrollable = !$.browser.safari;
|
||||||
|
|
||||||
|
if (isScrollable) {
|
||||||
|
html += '<paper-dialog-scrollable>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// If any items have an icon, give them all an icon just to make sure they're all lined up evenly
|
||||||
|
var renderIcon = options.items.filter(function (o) {
|
||||||
|
return o.ironIcon;
|
||||||
|
}).length;
|
||||||
|
|
||||||
|
html += '<paper-menu>';
|
||||||
|
for (var i = 0, length = options.items.length; i < length; i++) {
|
||||||
|
|
||||||
|
var option = options.items[i];
|
||||||
|
|
||||||
|
html += '<paper-menu-item class="actionSheetMenuItem" data-id="' + option.id + '" style="display:block;">';
|
||||||
|
|
||||||
|
if (option.ironIcon) {
|
||||||
|
html += '<iron-icon icon="' + option.ironIcon + '"></iron-icon>';
|
||||||
}
|
}
|
||||||
|
else if (renderIcon) {
|
||||||
html += '<paper-dialog id="' + id + '" with-backdrop style="' + style + '">';
|
html += '<iron-icon></iron-icon>';
|
||||||
|
|
||||||
if (options.title) {
|
|
||||||
html += '<h2>';
|
|
||||||
html += options.title;
|
|
||||||
html += '</h2>';
|
|
||||||
}
|
}
|
||||||
|
html += '<span>' + option.name + '</span>';
|
||||||
|
html += '</paper-menu-item>';
|
||||||
|
}
|
||||||
|
html += '</paper-menu>';
|
||||||
|
|
||||||
// There seems to be a bug with this in safari causing it to immediately roll up to 0 height
|
if (isScrollable) {
|
||||||
var isScrollable = !$.browser.safari;
|
html += '</paper-dialog-scrollable>';
|
||||||
|
}
|
||||||
|
|
||||||
if (isScrollable) {
|
if (options.showCancel) {
|
||||||
html += '<paper-dialog-scrollable>';
|
html += '<div class="buttons">';
|
||||||
}
|
html += '<paper-button dialog-dismiss>' + Globalize.translate('ButtonCancel') + '</paper-button>';
|
||||||
|
html += '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
// If any items have an icon, give them all an icon just to make sure they're all lined up evenly
|
html += '</paper-dialog>';
|
||||||
var renderIcon = options.items.filter(function (o) {
|
|
||||||
return o.ironIcon;
|
|
||||||
}).length;
|
|
||||||
|
|
||||||
html += '<paper-menu>';
|
$(document.body).append(html);
|
||||||
for (var i = 0, length = options.items.length; i < length; i++) {
|
|
||||||
|
|
||||||
var option = options.items[i];
|
setTimeout(function () {
|
||||||
|
var dlg = document.getElementById(id);
|
||||||
|
|
||||||
html += '<paper-menu-item class="actionSheetMenuItem" data-id="' + option.id + '" style="display:block;">';
|
dlg.open();
|
||||||
|
|
||||||
if (option.ironIcon) {
|
// Has to be assigned a z-index after the call to .open()
|
||||||
html += '<iron-icon icon="' + option.ironIcon + '"></iron-icon>';
|
$(dlg).on('iron-overlay-closed', function () {
|
||||||
}
|
$(this).remove();
|
||||||
else if (renderIcon) {
|
});
|
||||||
html += '<iron-icon></iron-icon>';
|
|
||||||
}
|
|
||||||
html += '<span>' + option.name + '</span>';
|
|
||||||
html += '</paper-menu-item>';
|
|
||||||
}
|
|
||||||
html += '</paper-menu>';
|
|
||||||
|
|
||||||
if (isScrollable) {
|
// Seeing an issue in some non-chrome browsers where this is requiring a double click
|
||||||
html += '</paper-dialog-scrollable>';
|
var eventName = $.browser.chrome ? 'click' : 'mousedown';
|
||||||
}
|
|
||||||
|
|
||||||
if (options.showCancel) {
|
$('.actionSheetMenuItem', dlg).on(eventName, function () {
|
||||||
html += '<div class="buttons">';
|
|
||||||
html += '<paper-button dialog-dismiss>' + Globalize.translate('ButtonCancel') + '</paper-button>';
|
|
||||||
html += '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
html += '</paper-dialog>';
|
var selectedId = this.getAttribute('data-id');
|
||||||
|
|
||||||
$(document.body).append(html);
|
// Add a delay here to allow the click animation to finish, for nice effect
|
||||||
|
setTimeout(function () {
|
||||||
|
|
||||||
setTimeout(function () {
|
dlg.close();
|
||||||
var dlg = document.getElementById(id);
|
|
||||||
|
|
||||||
dlg.open();
|
if (options.callback) {
|
||||||
|
options.callback(selectedId);
|
||||||
|
}
|
||||||
|
|
||||||
// Has to be assigned a z-index after the call to .open()
|
}, 100);
|
||||||
$(dlg).on('iron-overlay-closed', function () {
|
});
|
||||||
$(this).remove();
|
}, 100);
|
||||||
});
|
|
||||||
|
|
||||||
// Seeing an issue in some non-chrome browsers where this is requiring a double click
|
|
||||||
var eventName = $.browser.chrome ? 'click' : 'mousedown';
|
|
||||||
|
|
||||||
$('.actionSheetMenuItem', dlg).on(eventName, function () {
|
|
||||||
|
|
||||||
var selectedId = this.getAttribute('data-id');
|
|
||||||
|
|
||||||
// Add a delay here to allow the click animation to finish, for nice effect
|
|
||||||
setTimeout(function () {
|
|
||||||
|
|
||||||
dlg.close();
|
|
||||||
|
|
||||||
if (options.callback) {
|
|
||||||
options.callback(selectedId);
|
|
||||||
}
|
|
||||||
|
|
||||||
}, 100);
|
|
||||||
});
|
|
||||||
}, 100);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.ActionSheetElement = {
|
window.ActionSheetElement = {
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
currentItem = item;
|
currentItem = item;
|
||||||
|
|
||||||
if (item.Type == "UserRootFolder") {
|
if (!LibraryBrowser.supportsEditing(item.Type)) {
|
||||||
$('.editPageInnerContent', page)[0].style.visibility = 'hidden';
|
$('.editPageInnerContent', page)[0].style.visibility = 'hidden';
|
||||||
Dashboard.hideLoadingMsg();
|
Dashboard.hideLoadingMsg();
|
||||||
return;
|
return;
|
||||||
|
@ -680,6 +680,15 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
supportsEditing: function (itemType) {
|
||||||
|
|
||||||
|
if (itemType == "UserRootFolder" || /*itemType == "CollectionFolder" ||*/ itemType == "UserView") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
getMoreCommands: function (item, user) {
|
getMoreCommands: function (item, user) {
|
||||||
|
|
||||||
var commands = [];
|
var commands = [];
|
||||||
@ -701,7 +710,9 @@
|
|||||||
|
|
||||||
if (user.Policy.IsAdministrator) {
|
if (user.Policy.IsAdministrator) {
|
||||||
|
|
||||||
commands.push('edit');
|
if (LibraryBrowser.supportsEditing(item.Type)) {
|
||||||
|
commands.push('edit');
|
||||||
|
}
|
||||||
|
|
||||||
if (item.MediaType == 'Video' && item.Type != 'TvChannel' && item.Type != 'Program' && item.LocationType != 'Virtual') {
|
if (item.MediaType == 'Video' && item.Type != 'TvChannel' && item.Type != 'Program' && item.LocationType != 'Virtual') {
|
||||||
commands.push('editsubtitles');
|
commands.push('editsubtitles');
|
||||||
@ -1469,7 +1480,9 @@
|
|||||||
// itemCommands.push('playmenu');
|
// itemCommands.push('playmenu');
|
||||||
//}
|
//}
|
||||||
|
|
||||||
itemCommands.push('edit');
|
if (LibraryBrowser.supportsEditing(item.Type)) {
|
||||||
|
itemCommands.push('edit');
|
||||||
|
}
|
||||||
|
|
||||||
if (item.LocalTrailerCount) {
|
if (item.LocalTrailerCount) {
|
||||||
itemCommands.push('trailer');
|
itemCommands.push('trailer');
|
||||||
|
Loading…
Reference in New Issue
Block a user