1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/confirm/confirm.js

40 lines
1 KiB
JavaScript
Raw Normal View History

2016-07-20 02:23:18 -04:00
define(['dialog', 'globalize'], function (dialog, globalize) {
2016-10-04 01:15:39 -04:00
'use strict';
2016-02-22 13:25:45 -05:00
2016-02-22 14:31:28 -05:00
return function (text, title) {
2016-02-22 13:25:45 -05:00
2016-02-22 14:31:28 -05:00
var options;
if (typeof text === 'string') {
2016-02-22 13:25:45 -05:00
options = {
2016-02-22 14:31:28 -05:00
title: title,
text: text
2016-02-22 13:25:45 -05:00
};
2016-02-22 14:31:28 -05:00
} else {
options = text;
2016-02-22 13:25:45 -05:00
}
2016-07-20 02:23:18 -04:00
var items = [];
items.push({
2016-09-18 01:52:10 -04:00
name: options.cancelText || globalize.translate('sharedcomponents#ButtonCancel'),
id: 'cancel',
2016-10-04 01:15:39 -04:00
type: options.primary === 'cancel' ? 'submit' : 'cancel'
2016-07-20 02:23:18 -04:00
});
2016-02-22 13:25:45 -05:00
2016-07-20 02:23:18 -04:00
items.push({
2016-09-18 01:52:10 -04:00
name: options.confirmText || globalize.translate('sharedcomponents#ButtonOk'),
id: 'ok',
2016-10-04 01:15:39 -04:00
type: options.primary === 'cancel' ? 'cancel' : 'submit'
2016-07-20 02:23:18 -04:00
});
options.buttons = items;
return dialog(options).then(function (result) {
2016-10-04 01:15:39 -04:00
if (result === 'ok') {
2016-07-20 02:23:18 -04:00
return Promise.resolve();
}
return Promise.reject();
});
2016-02-22 13:25:45 -05:00
};
});