mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update components
This commit is contained in:
parent
857b8348bb
commit
165a3a99a2
11 changed files with 99 additions and 48 deletions
|
@ -125,9 +125,8 @@ milliseconds.
|
|||
computed: '_makeRegExp(urlSpaceRegex)'
|
||||
},
|
||||
|
||||
_lastChangedAtAt: {
|
||||
type: Number,
|
||||
value: -Infinity
|
||||
_lastChangedAt: {
|
||||
type: Number
|
||||
},
|
||||
|
||||
_initialized: {
|
||||
|
@ -146,6 +145,9 @@ milliseconds.
|
|||
this.listen(window, 'location-changed', '_urlChanged');
|
||||
this.listen(window, 'popstate', '_urlChanged');
|
||||
this.listen(/** @type {!HTMLBodyElement} */(document.body), 'click', '_globalOnClick');
|
||||
// Give a 200ms grace period to make initial redirects without any
|
||||
// additions to the user's history.
|
||||
this._lastChangedAt = window.performance.now() - (this.dwellTime - 200);
|
||||
|
||||
this._initialized = true;
|
||||
this._urlChanged();
|
||||
|
@ -157,17 +159,6 @@ milliseconds.
|
|||
this.unlisten(/** @type {!HTMLBodyElement} */(document.body), 'click', '_globalOnClick');
|
||||
this._initialized = false;
|
||||
},
|
||||
/**
|
||||
* @return {number} the number of milliseconds since some point in the
|
||||
* past. Only useful for comparing against other results from this
|
||||
* function.
|
||||
*/
|
||||
_now: function() {
|
||||
if (window.performance && window.performance.now) {
|
||||
return window.performance.now();
|
||||
}
|
||||
return new Date().getTime();
|
||||
},
|
||||
_hashChanged: function() {
|
||||
this.hash = window.location.hash.substring(1);
|
||||
},
|
||||
|
@ -212,7 +203,7 @@ milliseconds.
|
|||
// Need to use a full URL in case the containing page has a base URI.
|
||||
var fullNewUrl = new URL(
|
||||
newUrl, window.location.protocol + '//' + window.location.host).href;
|
||||
var now = this._now();
|
||||
var now = window.performance.now();
|
||||
var shouldReplace =
|
||||
this._lastChangedAt + this.dwellTime > now;
|
||||
this._lastChangedAt = now;
|
||||
|
@ -230,6 +221,12 @@ milliseconds.
|
|||
* @param {MouseEvent} event .
|
||||
*/
|
||||
_globalOnClick: function(event) {
|
||||
// If another event handler has stopped this event then there's nothing
|
||||
// for us to do. This can happen e.g. when there are multiple
|
||||
// iron-location elements in a page.
|
||||
if (event.defaultPrevented) {
|
||||
return;
|
||||
}
|
||||
var href = this._getSameOriginLinkHref(event);
|
||||
if (!href) {
|
||||
return;
|
||||
|
@ -268,18 +265,18 @@ milliseconds.
|
|||
|
||||
// If there's no link there's nothing to do.
|
||||
if (!anchor) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Target blank is a new tab, don't intercept.
|
||||
if (anchor.target === '_blank') {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
// If the link is for an existing parent frame, don't intercept.
|
||||
if ((anchor.target === '_top' ||
|
||||
anchor.target === '_parent') &&
|
||||
window.top !== window) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
var href = anchor.href;
|
||||
|
@ -319,6 +316,11 @@ milliseconds.
|
|||
// Need to use a full URL in case the containing page has a base URI.
|
||||
var fullNormalizedHref = new URL(
|
||||
normalizedHref, window.location.href).href;
|
||||
// If the navigation is to the current page we shouldn't add a history
|
||||
// entry.
|
||||
if (fullNormalizedHref === window.location.href) {
|
||||
return null;
|
||||
}
|
||||
return fullNormalizedHref;
|
||||
},
|
||||
_makeRegExp: function(urlSpaceRegex) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue