初版:小白超人(从线上实例导出)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
|
||||
window.uiNavigate = function (url) {
|
||||
if (reduceMotion) {
|
||||
window.location.href = url;
|
||||
return;
|
||||
}
|
||||
document.body.classList.add('ui-page-leaving');
|
||||
window.setTimeout(function () { window.location.href = url; }, 170);
|
||||
};
|
||||
|
||||
window.uiCloseWindow = function () {
|
||||
if (reduceMotion) {
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
document.body.classList.add('ui-page-leaving');
|
||||
window.setTimeout(function () { window.close(); }, 170);
|
||||
};
|
||||
|
||||
document.addEventListener('click', function (event) {
|
||||
const link = event.target.closest('a[href]');
|
||||
if (!link || event.defaultPrevented || event.button !== 0 || event.metaKey ||
|
||||
event.ctrlKey || event.shiftKey || event.altKey || link.target === '_blank' ||
|
||||
link.hasAttribute('download')) return;
|
||||
|
||||
const destination = new URL(link.href, window.location.href);
|
||||
if (destination.origin !== window.location.origin ||
|
||||
(destination.pathname === window.location.pathname && destination.hash)) return;
|
||||
|
||||
event.preventDefault();
|
||||
window.uiNavigate(destination.href);
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user