Migration confirm to ES6 modules
This commit is contained in:
parent
999f276140
commit
1b581077f2
18 changed files with 36 additions and 30 deletions
|
@ -96,6 +96,7 @@
|
||||||
"src/components/cardbuilder/cardBuilder.js",
|
"src/components/cardbuilder/cardBuilder.js",
|
||||||
"src/components/cardbuilder/chaptercardbuilder.js",
|
"src/components/cardbuilder/chaptercardbuilder.js",
|
||||||
"src/components/cardbuilder/peoplecardbuilder.js",
|
"src/components/cardbuilder/peoplecardbuilder.js",
|
||||||
|
"src/components/confirm/confirm.js",
|
||||||
"src/components/images/imageLoader.js",
|
"src/components/images/imageLoader.js",
|
||||||
"src/components/indicators/indicators.js",
|
"src/components/indicators/indicators.js",
|
||||||
"src/components/lazyLoader/lazyLoaderIntersectionObserver.js",
|
"src/components/lazyLoader/lazyLoaderIntersectionObserver.js",
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
define(['browser', 'dialog', 'globalize'], function(browser, dialog, globalize) {
|
import browser from 'browser';
|
||||||
'use strict';
|
import dialog from 'dialog';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
|
||||||
|
/* eslint-disable indent */
|
||||||
|
export default (() => {
|
||||||
|
|
||||||
function replaceAll(str, find, replace) {
|
function replaceAll(str, find, replace) {
|
||||||
return str.split(find).join(replace);
|
return str.split(find).join(replace);
|
||||||
|
@ -7,7 +11,7 @@ define(['browser', 'dialog', 'globalize'], function(browser, dialog, globalize)
|
||||||
|
|
||||||
if (browser.tv && window.confirm) {
|
if (browser.tv && window.confirm) {
|
||||||
// Use the native confirm dialog
|
// Use the native confirm dialog
|
||||||
return function (options) {
|
return options => {
|
||||||
if (typeof options === 'string') {
|
if (typeof options === 'string') {
|
||||||
options = {
|
options = {
|
||||||
title: '',
|
title: '',
|
||||||
|
@ -15,8 +19,8 @@ define(['browser', 'dialog', 'globalize'], function(browser, dialog, globalize)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var text = replaceAll(options.text || '', '<br/>', '\n');
|
const text = replaceAll(options.text || '', '<br/>', '\n');
|
||||||
var result = confirm(text);
|
const result = confirm(text);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
@ -26,8 +30,8 @@ define(['browser', 'dialog', 'globalize'], function(browser, dialog, globalize)
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// Use our own dialog
|
// Use our own dialog
|
||||||
return function (text, title) {
|
return (text, title) => {
|
||||||
var options;
|
let options;
|
||||||
if (typeof text === 'string') {
|
if (typeof text === 'string') {
|
||||||
options = {
|
options = {
|
||||||
title: title,
|
title: title,
|
||||||
|
@ -37,7 +41,7 @@ define(['browser', 'dialog', 'globalize'], function(browser, dialog, globalize)
|
||||||
options = text;
|
options = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
var items = [];
|
const items = [];
|
||||||
|
|
||||||
items.push({
|
items.push({
|
||||||
name: options.cancelText || globalize.translate('ButtonCancel'),
|
name: options.cancelText || globalize.translate('ButtonCancel'),
|
||||||
|
@ -53,7 +57,7 @@ define(['browser', 'dialog', 'globalize'], function(browser, dialog, globalize)
|
||||||
|
|
||||||
options.buttons = items;
|
options.buttons = items;
|
||||||
|
|
||||||
return dialog(options).then(function (result) {
|
return dialog.show(options).then(result => {
|
||||||
if (result === 'ok') {
|
if (result === 'ok') {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
@ -62,4 +66,5 @@ define(['browser', 'dialog', 'globalize'], function(browser, dialog, globalize)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
})();
|
||||||
|
/* eslint-enable indent */
|
||||||
|
|
|
@ -200,7 +200,7 @@ define(['dialogHelper', 'connectionManager', 'loading', 'dom', 'layoutManager',
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
|
|
||||||
confirm({
|
confirm.default({
|
||||||
|
|
||||||
text: globalize.translate('ConfirmDeleteImage'),
|
text: globalize.translate('ConfirmDeleteImage'),
|
||||||
confirmText: globalize.translate('Delete'),
|
confirmText: globalize.translate('Delete'),
|
||||||
|
|
|
@ -34,7 +34,7 @@ define(['globalize', 'loading', 'connectionManager'], function (globalize, loadi
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
|
|
||||||
confirm({
|
confirm.default({
|
||||||
|
|
||||||
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
||||||
primary: 'delete',
|
primary: 'delete',
|
||||||
|
@ -59,7 +59,7 @@ define(['globalize', 'loading', 'connectionManager'], function (globalize, loadi
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
|
|
||||||
confirm({
|
confirm.default({
|
||||||
|
|
||||||
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
||||||
primary: 'delete',
|
primary: 'delete',
|
||||||
|
|
|
@ -69,7 +69,7 @@ define(['dialogHelper', 'require', 'layoutManager', 'globalize', 'userSettings',
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
|
|
||||||
confirm({
|
confirm.default({
|
||||||
|
|
||||||
title: globalize.translate('ConfirmDeletion'),
|
title: globalize.translate('ConfirmDeletion'),
|
||||||
text: msg,
|
text: msg,
|
||||||
|
|
|
@ -3,7 +3,7 @@ define(['datetime', 'loading', 'libraryMenu', 'dom', 'globalize', 'emby-button']
|
||||||
|
|
||||||
function revoke(page, key) {
|
function revoke(page, key) {
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm(globalize.translate('MessageConfirmRevokeApiKey'), globalize.translate('HeaderConfirmRevokeApiKey')).then(function () {
|
confirm.default(globalize.translate('MessageConfirmRevokeApiKey'), globalize.translate('HeaderConfirmRevokeApiKey')).then(function () {
|
||||||
loading.show();
|
loading.show();
|
||||||
ApiClient.ajax({
|
ApiClient.ajax({
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
|
|
|
@ -708,7 +708,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
||||||
},
|
},
|
||||||
restart: function (btn) {
|
restart: function (btn) {
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm({
|
confirm.default({
|
||||||
title: globalize.translate('HeaderRestart'),
|
title: globalize.translate('HeaderRestart'),
|
||||||
text: globalize.translate('MessageConfirmRestart'),
|
text: globalize.translate('MessageConfirmRestart'),
|
||||||
confirmText: globalize.translate('ButtonRestart'),
|
confirmText: globalize.translate('ButtonRestart'),
|
||||||
|
@ -723,7 +723,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
||||||
},
|
},
|
||||||
shutdown: function (btn) {
|
shutdown: function (btn) {
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm({
|
confirm.default({
|
||||||
title: globalize.translate('HeaderShutdown'),
|
title: globalize.translate('HeaderShutdown'),
|
||||||
text: globalize.translate('MessageConfirmShutdown'),
|
text: globalize.translate('MessageConfirmShutdown'),
|
||||||
confirmText: globalize.translate('ButtonShutdown'),
|
confirmText: globalize.translate('ButtonShutdown'),
|
||||||
|
|
|
@ -9,7 +9,7 @@ define(['loading', 'dom', 'libraryMenu', 'globalize', 'scripts/imagehelper', 'da
|
||||||
var msg = globalize.translate('DeleteDeviceConfirmation');
|
var msg = globalize.translate('DeleteDeviceConfirmation');
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm({
|
confirm.default({
|
||||||
text: msg,
|
text: msg,
|
||||||
title: globalize.translate('HeaderDeleteDevice'),
|
title: globalize.translate('HeaderDeleteDevice'),
|
||||||
confirmText: globalize.translate('ButtonDelete'),
|
confirmText: globalize.translate('ButtonDelete'),
|
||||||
|
|
|
@ -59,7 +59,7 @@ define(['jQuery', 'globalize', 'loading', 'libraryMenu', 'listViewStyle', 'emby-
|
||||||
|
|
||||||
function deleteProfile(page, id) {
|
function deleteProfile(page, id) {
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm(globalize.translate('MessageConfirmProfileDeletion'), globalize.translate('HeaderConfirmProfileDeletion')).then(function () {
|
confirm.default(globalize.translate('MessageConfirmProfileDeletion'), globalize.translate('HeaderConfirmProfileDeletion')).then(function () {
|
||||||
loading.show();
|
loading.show();
|
||||||
ApiClient.ajax({
|
ApiClient.ajax({
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
|
|
|
@ -38,7 +38,7 @@ define(['jQuery', 'apphost', 'scripts/taskbutton', 'loading', 'libraryMenu', 'gl
|
||||||
}
|
}
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm({
|
confirm.default({
|
||||||
|
|
||||||
text: msg,
|
text: msg,
|
||||||
title: globalize.translate('HeaderRemoveMediaFolder'),
|
title: globalize.translate('HeaderRemoveMediaFolder'),
|
||||||
|
|
|
@ -91,7 +91,7 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize', 'connectionManager', 'e
|
||||||
msg += globalize.translate('PleaseConfirmPluginInstallation');
|
msg += globalize.translate('PleaseConfirmPluginInstallation');
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm(msg, globalize.translate('HeaderConfirmPluginInstallation')).then(function () {
|
confirm.default(msg, globalize.translate('HeaderConfirmPluginInstallation')).then(function () {
|
||||||
alertCallback();
|
alertCallback();
|
||||||
}, function () {
|
}, function () {
|
||||||
console.debug('plugin not installed');
|
console.debug('plugin not installed');
|
||||||
|
|
|
@ -5,7 +5,7 @@ define(['loading', 'libraryMenu', 'dom', 'globalize', 'cardStyle', 'emby-button'
|
||||||
var msg = globalize.translate('UninstallPluginConfirmation', name);
|
var msg = globalize.translate('UninstallPluginConfirmation', name);
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm({
|
confirm.default({
|
||||||
title: globalize.translate('UninstallPluginHeader'),
|
title: globalize.translate('UninstallPluginHeader'),
|
||||||
text: msg,
|
text: msg,
|
||||||
primary: 'delete',
|
primary: 'delete',
|
||||||
|
|
|
@ -130,7 +130,7 @@ define(['jQuery', 'loading', 'datetime', 'dom', 'globalize', 'emby-input', 'emby
|
||||||
},
|
},
|
||||||
confirmDeleteTrigger: function (view, index) {
|
confirmDeleteTrigger: function (view, index) {
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm(globalize.translate('MessageDeleteTaskTrigger'), globalize.translate('HeaderDeleteTaskTrigger')).then(function () {
|
confirm.default(globalize.translate('MessageDeleteTaskTrigger'), globalize.translate('HeaderDeleteTaskTrigger')).then(function () {
|
||||||
ScheduledTaskPage.deleteTrigger(view, index);
|
ScheduledTaskPage.deleteTrigger(view, index);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -142,7 +142,7 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading
|
||||||
var msg = globalize.translate('PasswordResetConfirmation');
|
var msg = globalize.translate('PasswordResetConfirmation');
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm(msg, globalize.translate('PasswordResetHeader')).then(function () {
|
confirm.default(msg, globalize.translate('PasswordResetHeader')).then(function () {
|
||||||
var userId = params.userId;
|
var userId = params.userId;
|
||||||
loading.show();
|
loading.show();
|
||||||
ApiClient.resetUserPassword(userId).then(function () {
|
ApiClient.resetUserPassword(userId).then(function () {
|
||||||
|
@ -161,7 +161,7 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading
|
||||||
var msg = globalize.translate('PinCodeResetConfirmation');
|
var msg = globalize.translate('PinCodeResetConfirmation');
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm(msg, globalize.translate('HeaderPinCodeReset')).then(function () {
|
confirm.default(msg, globalize.translate('HeaderPinCodeReset')).then(function () {
|
||||||
var userId = params.userId;
|
var userId = params.userId;
|
||||||
loading.show();
|
loading.show();
|
||||||
ApiClient.resetEasyPassword(userId).then(function () {
|
ApiClient.resetEasyPassword(userId).then(function () {
|
||||||
|
|
|
@ -5,7 +5,7 @@ define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-but
|
||||||
var msg = globalize.translate('DeleteUserConfirmation');
|
var msg = globalize.translate('DeleteUserConfirmation');
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm({
|
confirm.default({
|
||||||
title: globalize.translate('DeleteUser'),
|
title: globalize.translate('DeleteUser'),
|
||||||
text: msg,
|
text: msg,
|
||||||
confirmText: globalize.translate('ButtonDelete'),
|
confirmText: globalize.translate('ButtonDelete'),
|
||||||
|
|
|
@ -1936,7 +1936,7 @@ define(['loading', 'appRouter', 'layoutManager', 'connectionManager', 'userSetti
|
||||||
|
|
||||||
function splitVersions(instance, page, apiClient, params) {
|
function splitVersions(instance, page, apiClient, params) {
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm('Are you sure you wish to split the media sources into separate items?', 'Split Media Apart').then(function () {
|
confirm.default('Are you sure you wish to split the media sources into separate items?', 'Split Media Apart').then(function () {
|
||||||
loading.show();
|
loading.show();
|
||||||
apiClient.ajax({
|
apiClient.ajax({
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
|
|
|
@ -49,7 +49,7 @@ define(['jQuery', 'globalize', 'scripts/taskbutton', 'dom', 'libraryMenu', 'layo
|
||||||
var message = globalize.translate('MessageConfirmDeleteTunerDevice');
|
var message = globalize.translate('MessageConfirmDeleteTunerDevice');
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm(message, globalize.translate('HeaderDeleteDevice')).then(function () {
|
confirm.default(message, globalize.translate('HeaderDeleteDevice')).then(function () {
|
||||||
loading.show();
|
loading.show();
|
||||||
ApiClient.ajax({
|
ApiClient.ajax({
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
|
@ -167,7 +167,7 @@ define(['jQuery', 'globalize', 'scripts/taskbutton', 'dom', 'libraryMenu', 'layo
|
||||||
var message = globalize.translate('MessageConfirmDeleteGuideProvider');
|
var message = globalize.translate('MessageConfirmDeleteGuideProvider');
|
||||||
|
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm(message, globalize.translate('HeaderDeleteProvider')).then(function () {
|
confirm.default(message, globalize.translate('HeaderDeleteProvider')).then(function () {
|
||||||
loading.show();
|
loading.show();
|
||||||
ApiClient.ajax({
|
ApiClient.ajax({
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
|
|
|
@ -86,7 +86,7 @@ define(['controllers/dashboard/users/userpasswordpage', 'loading', 'libraryMenu'
|
||||||
new UserPasswordPage(view, params);
|
new UserPasswordPage(view, params);
|
||||||
view.querySelector('#btnDeleteImage').addEventListener('click', function () {
|
view.querySelector('#btnDeleteImage').addEventListener('click', function () {
|
||||||
require(['confirm'], function (confirm) {
|
require(['confirm'], function (confirm) {
|
||||||
confirm(globalize.translate('DeleteImageConfirmation'), globalize.translate('DeleteImage')).then(function () {
|
confirm.default(globalize.translate('DeleteImageConfirmation'), globalize.translate('DeleteImage')).then(function () {
|
||||||
loading.show();
|
loading.show();
|
||||||
var userId = getParameterByName('userId');
|
var userId = getParameterByName('userId');
|
||||||
ApiClient.deleteUserImage(userId, 'primary').then(function () {
|
ApiClient.deleteUserImage(userId, 'primary').then(function () {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue