mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
switch paperDialogHashHandler from hashchange to pushstate
This commit is contained in:
parent
35a8a1611a
commit
00b18fdc5f
3 changed files with 80 additions and 42 deletions
|
@ -85,23 +85,41 @@
|
|||
|
||||
})(jQuery, this);
|
||||
|
||||
window.addEventListener('popstate', function (event) {
|
||||
var previousState = {};
|
||||
|
||||
// This is just a temporary api until jquery mobile is eventually deprecated and we have an actual routing library
|
||||
jQuery.onStatePushed = function(state) {
|
||||
previousState = state;
|
||||
};
|
||||
|
||||
function ignorePopState(event) {
|
||||
|
||||
var state = event.state || {};
|
||||
|
||||
setTimeout(function () {
|
||||
if (previousState.navigate === false) {
|
||||
// Ignore
|
||||
previousState = state;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.historyState) {
|
||||
$.extend(state, event.historyState);
|
||||
previousState = state;
|
||||
return false;
|
||||
}
|
||||
|
||||
function fireNavigateFromPopstateEvent(event) {
|
||||
|
||||
var state = event.state || {};
|
||||
if (event.historyState) {
|
||||
$.extend(state, event.historyState);
|
||||
}
|
||||
|
||||
window.dispatchEvent(new CustomEvent("navigate", {
|
||||
detail: {
|
||||
state: state,
|
||||
originalEvent: event
|
||||
}
|
||||
|
||||
window.dispatchEvent(new CustomEvent("navigate", {
|
||||
detail: {
|
||||
state: state,
|
||||
originalEvent: event
|
||||
}
|
||||
}));
|
||||
}, 0);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
jQuery.mobile.widgets = {};
|
||||
|
||||
|
@ -785,8 +803,16 @@
|
|||
// TODO grab the original event here and use it for the synthetic event in the
|
||||
// second half of the navigate execution that will follow this binding
|
||||
popstate: function (event) {
|
||||
var hash, state;
|
||||
|
||||
if (ignorePopState(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
fireNavigateFromPopstateEvent(event);
|
||||
}, 0);
|
||||
|
||||
var hash, state;
|
||||
// If this is the popstate triggered by the actual alteration of the hash
|
||||
// prevent it completely. History is tracked manually
|
||||
if (this.preventHashAssignPopState) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue