jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/confirm/confirm.js

40 lines
1.0 KiB
JavaScript
Raw Normal View History

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