1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

fix action sheet

This commit is contained in:
Luke Pulverenti 2016-01-28 23:18:31 -05:00
parent 4dc7a40afd
commit e881e6380a
3 changed files with 48 additions and 65 deletions

View file

@ -2,7 +2,7 @@
function show(options) {
require(['paper-menu', 'paper-dialog', 'paper-dialog-scrollable', 'scale-up-animation', 'fade-out-animation'], function () {
require(['paper-menu', 'paper-dialog', 'scale-up-animation', 'fade-out-animation'], function () {
showInternal(options);
});
}
@ -134,7 +134,10 @@
}
};
dlg.open();
var delay = browserInfo.chrome ? 0 : 100;
setTimeout(function () {
dlg.open();
}, delay);
// Has to be assigned a z-index after the call to .open()
dlg.addEventListener('iron-overlay-closed', function () {
@ -144,23 +147,39 @@
// Seeing an issue in some non-chrome browsers where this is requiring a double click
var eventName = browserInfo.chrome || browserInfo.safari ? 'click' : 'mousedown';
dlg.querySelector('.actionSheetMenuItem').addEventListener(eventName, function (e) {
dlg.addEventListener(eventName, function (e) {
var selectedId = e.target.getAttribute('data-id');
var target = parentWithClass(e.target, 'actionSheetMenuItem');
if (target) {
var selectedId = target.getAttribute('data-id');
// Add a delay here to allow the click animation to finish, for nice effect
setTimeout(function () {
// Add a delay here to allow the click animation to finish, for nice effect
setTimeout(function () {
dlg.close();
dlg.close();
if (options.callback) {
options.callback(selectedId);
}
if (options.callback) {
options.callback(selectedId);
}
}, 100);
}, 100);
}
});
}
function parentWithClass(elem, className) {
while (!elem.classList || !elem.classList.contains(className)) {
elem = elem.parentNode;
if (!elem) {
return null;
}
}
return elem;
}
window.ActionSheetElement = {
show: show
};