mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Format alert module
This commit is contained in:
parent
49ccabf5af
commit
24fad10f36
1 changed files with 16 additions and 14 deletions
|
@ -1,23 +1,25 @@
|
||||||
import { appRouter } from './router/appRouter';
|
import { appRouter } from "./router/appRouter";
|
||||||
import browser from '../scripts/browser';
|
import browser from "../scripts/browser";
|
||||||
import dialog from './dialog/dialog';
|
import dialog from "./dialog/dialog";
|
||||||
import globalize from '../scripts/globalize';
|
import globalize from "../scripts/globalize";
|
||||||
|
|
||||||
function useNativeAlert() {
|
function useNativeAlert() {
|
||||||
// webOS seems to block modals
|
// webOS seems to block modals
|
||||||
// Tizen 2.x seems to block modals
|
// Tizen 2.x seems to block modals
|
||||||
return !browser.web0s
|
return (
|
||||||
&& !(browser.tizenVersion && browser.tizenVersion < 3)
|
!browser.web0s &&
|
||||||
&& browser.tv
|
!(browser.tizenVersion && browser.tizenVersion < 3) &&
|
||||||
&& window.alert;
|
browser.tv &&
|
||||||
|
window.alert
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function (text, title) {
|
export default async function (text, title) {
|
||||||
let options;
|
let options;
|
||||||
if (typeof text === 'string') {
|
if (typeof text === "string") {
|
||||||
options = {
|
options = {
|
||||||
title: title,
|
title: title,
|
||||||
text: text
|
text: text,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
options = text;
|
options = text;
|
||||||
|
@ -26,15 +28,15 @@ export default async function (text, title) {
|
||||||
await appRouter.ready();
|
await appRouter.ready();
|
||||||
|
|
||||||
if (useNativeAlert()) {
|
if (useNativeAlert()) {
|
||||||
alert((options.text || '').replaceAll('<br/>', '\n'));
|
alert((options.text || "").replaceAll("<br/>", "\n"));
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
} else {
|
} else {
|
||||||
const items = [];
|
const items = [];
|
||||||
|
|
||||||
items.push({
|
items.push({
|
||||||
name: globalize.translate('ButtonGotIt'),
|
name: globalize.translate("ButtonGotIt"),
|
||||||
id: 'ok',
|
id: "ok",
|
||||||
type: 'submit'
|
type: "submit",
|
||||||
});
|
});
|
||||||
|
|
||||||
options.buttons = items;
|
options.buttons = items;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue