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
2015-09-17 17:26:06 -04:00

54 lines
No EOL
1.1 KiB
JavaScript

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