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

54 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-09-17 12:04:04 -04:00
(function (globalScope) {
function paperDialogHashHandler(dlg, hash) {
2015-09-17 13:24:23 -04:00
var isActive = true;
2015-09-17 12:04:04 -04:00
function onHashChange(e, data) {
data = data.state;
2015-09-17 13:24:23 -04:00
isActive = data.hash == '#' + hash;
2015-09-17 12:04:04 -04:00
if (data.direction == 'back') {
if (dlg) {
2015-09-17 13:24:23 -04:00
if (!isActive) {
2015-09-17 12:04:04 -04:00
dlg.close();
dlg = null;
}
}
}
}
function onDialogClosed() {
2015-09-17 17:26:06 -04:00
Dashboard.onPopupClose();
2015-09-17 12:04:04 -04:00
dlg = null;
$(window).off('navigate', onHashChange);
if (window.location.hash == '#' + hash) {
history.back();
}
}
var self = this;
$(dlg).on('iron-overlay-closed', onDialogClosed);
dlg.open();
2015-09-17 17:26:06 -04:00
Dashboard.onPopupOpen();
2015-09-17 12:04:04 -04:00
window.location.hash = hash;
$(window).on('navigate', onHashChange);
}
function openWithHash(dlg, hash) {
new paperDialogHashHandler(dlg, hash);
}
globalScope.PaperDialogHelper = {
openWithHash: openWithHash
};
})(this);