mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Use custom modals on webOS and Tizen 2.x
This commit is contained in:
parent
0831207057
commit
527215e0f0
2 changed files with 20 additions and 2 deletions
|
@ -10,6 +10,15 @@ import globalize from '../scripts/globalize';
|
||||||
return originalString.replace(reg, strWith);
|
return originalString.replace(reg, strWith);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
export default async function (text, title) {
|
export default async function (text, title) {
|
||||||
let options;
|
let options;
|
||||||
if (typeof text === 'string') {
|
if (typeof text === 'string') {
|
||||||
|
@ -21,7 +30,7 @@ import globalize from '../scripts/globalize';
|
||||||
options = text;
|
options = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (browser.tv && window.alert) {
|
if (useNativeAlert()) {
|
||||||
await appRouter.ready();
|
await appRouter.ready();
|
||||||
alert(replaceAll(options.text || '', '<br/>', '\n'));
|
alert(replaceAll(options.text || '', '<br/>', '\n'));
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
|
|
@ -7,6 +7,15 @@ function replaceAll(str, find, replace) {
|
||||||
return str.split(find).join(replace);
|
return str.split(find).join(replace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function useNativeConfirm() {
|
||||||
|
// webOS seems to block modals
|
||||||
|
// Tizen 2.x seems to block modals
|
||||||
|
return !browser.web0s
|
||||||
|
&& !(browser.tizenVersion && browser.tizenVersion < 3)
|
||||||
|
&& browser.tv
|
||||||
|
&& window.confirm;
|
||||||
|
}
|
||||||
|
|
||||||
async function nativeConfirm(options) {
|
async function nativeConfirm(options) {
|
||||||
if (typeof options === 'string') {
|
if (typeof options === 'string') {
|
||||||
options = {
|
options = {
|
||||||
|
@ -62,6 +71,6 @@ function customConfirm(text, title) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirm = browser.tv && window.confirm ? nativeConfirm : customConfirm;
|
const confirm = useNativeConfirm() ? nativeConfirm : customConfirm;
|
||||||
|
|
||||||
export default confirm;
|
export default confirm;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue