merged alert and nativeAlert for webpack

This commit is contained in:
vitorsemeano 2019-02-23 19:14:56 +00:00
parent 8e1c56adf5
commit 2665923bb0
4 changed files with 42 additions and 65 deletions

40
src/components/alert.js Normal file
View File

@ -0,0 +1,40 @@
define(['browser', 'dialog', 'globalize'], function (browser, dialog, globalize) {
'use strict';
return function (text, title) {
var options;
if (typeof text === 'string') {
options = {
title: title,
text: text
};
} else {
options = text;
}
if (browser.tv && window.alert) {
alert(replaceAll(options.text || '', '<br/>', '\n'));
} else {
var items = [];
items.push({
name: globalize.translate('ButtonGotIt'),
id: 'ok',
type: 'submit'
});
options.buttons = items;
return dialog(options).then(function (result) {
if (result === 'ok') {
return Promise.resolve();
}
return Promise.reject();
});
}
return Promise.resolve();
};
});

View File

@ -1,34 +0,0 @@
define(['dialog', 'globalize'], function (dialog, globalize) {
'use strict';
return function (text, title) {
var options;
if (typeof text === 'string') {
options = {
title: title,
text: text
};
} else {
options = text;
}
var items = [];
items.push({
name: globalize.translate('ButtonGotIt'),
id: 'ok',
type: 'submit'
});
options.buttons = items;
return dialog(options).then(function (result) {
if (result === 'ok') {
return Promise.resolve();
}
return Promise.reject();
});
};
});

View File

@ -1,23 +0,0 @@
define([], function () {
'use strict';
function replaceAll(str, find, replace) {
return str.split(find).join(replace);
}
return function (options) {
if (typeof options === 'string') {
options = {
text: options
};
}
var text = replaceAll(options.text || '', '<br/>', '\n');
alert(text);
return Promise.resolve();
};
});

View File

@ -465,8 +465,6 @@ var AppInfo = {};
define("apiclient", ["bower_components/emby-apiclient/apiclient"], returnFirstDependency); define("apiclient", ["bower_components/emby-apiclient/apiclient"], returnFirstDependency);
} }
define("actionsheet", ["webActionSheet"], returnFirstDependency);
if ("registerElement" in document) { if ("registerElement" in document) {
define("registerElement", []); define("registerElement", []);
} else { } else {
@ -491,11 +489,7 @@ var AppInfo = {};
var preferNativeAlerts = browser.tv; var preferNativeAlerts = browser.tv;
if (preferNativeAlerts && window.alert) { define("alert", [embyWebComponentsBowerPath + "/alert"], returnFirstDependency);
define("alert", [embyWebComponentsBowerPath + "/alert/nativealert"], returnFirstDependency);
} else {
define("alert", [embyWebComponentsBowerPath + "/alert/alert"], returnFirstDependency);
}
defineResizeObserver(); defineResizeObserver();
define("dialog", [embyWebComponentsBowerPath + "/dialog/dialog"], returnFirstDependency); define("dialog", [embyWebComponentsBowerPath + "/dialog/dialog"], returnFirstDependency);
@ -1400,7 +1394,7 @@ var AppInfo = {};
paths.shaka = embyWebComponentsBowerPath + "/shaka/shaka-player.compiled"; paths.shaka = embyWebComponentsBowerPath + "/shaka/shaka-player.compiled";
define("chromecastHelper", [embyWebComponentsBowerPath + "/chromecast/chromecasthelpers"], returnFirstDependency); define("chromecastHelper", [embyWebComponentsBowerPath + "/chromecast/chromecasthelpers"], returnFirstDependency);
define("mediaSession", [embyWebComponentsBowerPath + "/playback/mediasession"], returnFirstDependency); define("mediaSession", [embyWebComponentsBowerPath + "/playback/mediasession"], returnFirstDependency);
define("webActionSheet", [embyWebComponentsBowerPath + "/actionsheet/actionsheet"], returnFirstDependency); define("actionsheet", [embyWebComponentsBowerPath + "/actionsheet/actionsheet"], returnFirstDependency);
define("libjass", [bowerPath + "/libjass/libjass.min", "css!" + bowerPath + "/libjass/libjass"], returnFirstDependency); define("libjass", [bowerPath + "/libjass/libjass.min", "css!" + bowerPath + "/libjass/libjass"], returnFirstDependency);
define("tunerPicker", ["components/tunerpicker"], returnFirstDependency); define("tunerPicker", ["components/tunerpicker"], returnFirstDependency);
define("mainTabsManager", [embyWebComponentsBowerPath + "/maintabsmanager"], returnFirstDependency); define("mainTabsManager", [embyWebComponentsBowerPath + "/maintabsmanager"], returnFirstDependency);