mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 11:28:23 -07:00
80 lines
1.8 KiB
JavaScript
80 lines
1.8 KiB
JavaScript
(function (globalScope) {
|
|
|
|
function paperDialogHashHandler(dlg, hash, lockDocumentScroll) {
|
|
|
|
function onHashChange(e, data) {
|
|
|
|
data = data.state;
|
|
var isActive = data.hash == '#' + hash;
|
|
|
|
if (data.direction == 'back') {
|
|
if (dlg) {
|
|
if (!isActive) {
|
|
dlg.close();
|
|
dlg = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function onDialogClosed() {
|
|
|
|
if (lockDocumentScroll !== false) {
|
|
Dashboard.onPopupClose();
|
|
}
|
|
|
|
dlg = null;
|
|
if (enableHashChange()) {
|
|
$(window).off('navigate', onHashChange);
|
|
|
|
if (window.location.hash == '#' + hash) {
|
|
history.back();
|
|
}
|
|
}
|
|
}
|
|
|
|
var self = this;
|
|
|
|
$(dlg).on('iron-overlay-closed', onDialogClosed);
|
|
dlg.open();
|
|
|
|
if (lockDocumentScroll !== false) {
|
|
Dashboard.onPopupOpen();
|
|
}
|
|
|
|
if (enableHashChange()) {
|
|
|
|
window.location.hash = hash;
|
|
|
|
$(window).on('navigate', onHashChange);
|
|
}
|
|
}
|
|
|
|
function enableHashChange() {
|
|
// It's not firing popstate in response to hashbang changes
|
|
if ($.browser.msie) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function openWithHash(dlg, hash, lockDocumentScroll) {
|
|
|
|
new paperDialogHashHandler(dlg, hash, lockDocumentScroll);
|
|
}
|
|
|
|
function close(dlg) {
|
|
|
|
if (enableHashChange()) {
|
|
history.back();
|
|
} else {
|
|
dlg.close();
|
|
}
|
|
}
|
|
|
|
globalScope.PaperDialogHelper = {
|
|
openWithHash: openWithHash,
|
|
close: close
|
|
};
|
|
|
|
})(this); |