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 browser from '../scripts/browser';
|
||||
import dialog from './dialog/dialog';
|
||||
import globalize from '../scripts/globalize';
|
||||
import { appRouter } from "./router/appRouter";
|
||||
import browser from "../scripts/browser";
|
||||
import dialog from "./dialog/dialog";
|
||||
import globalize from "../scripts/globalize";
|
||||
|
||||
function useNativeAlert() {
|
||||
// webOS seems to block modals
|
||||
// Tizen 2.x seems to block modals
|
||||
return !browser.web0s
|
||||
&& !(browser.tizenVersion && browser.tizenVersion < 3)
|
||||
&& browser.tv
|
||||
&& window.alert;
|
||||
return (
|
||||
!browser.web0s &&
|
||||
!(browser.tizenVersion && browser.tizenVersion < 3) &&
|
||||
browser.tv &&
|
||||
window.alert
|
||||
);
|
||||
}
|
||||
|
||||
export default async function (text, title) {
|
||||
let options;
|
||||
if (typeof text === 'string') {
|
||||
if (typeof text === "string") {
|
||||
options = {
|
||||
title: title,
|
||||
text: text
|
||||
text: text,
|
||||
};
|
||||
} else {
|
||||
options = text;
|
||||
|
@ -26,15 +28,15 @@ export default async function (text, title) {
|
|||
await appRouter.ready();
|
||||
|
||||
if (useNativeAlert()) {
|
||||
alert((options.text || '').replaceAll('<br/>', '\n'));
|
||||
alert((options.text || "").replaceAll("<br/>", "\n"));
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
const items = [];
|
||||
|
||||
items.push({
|
||||
name: globalize.translate('ButtonGotIt'),
|
||||
id: 'ok',
|
||||
type: 'submit'
|
||||
name: globalize.translate("ButtonGotIt"),
|
||||
id: "ok",
|
||||
type: "submit",
|
||||
});
|
||||
|
||||
options.buttons = items;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue