2019-01-10 15:39:37 +03:00
|
|
|
define(['dialog', 'globalize'], function (dialog, globalize) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
return function (text, title) {
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var options;
|
2019-01-10 15:39:37 +03:00
|
|
|
if (typeof text === 'string') {
|
|
|
|
options = {
|
|
|
|
title: title,
|
|
|
|
text: text
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
options = text;
|
|
|
|
}
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var items = [];
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
items.push({
|
2019-02-03 02:41:16 +09:00
|
|
|
name: options.cancelText || globalize.translate('ButtonCancel'),
|
2019-01-10 15:39:37 +03:00
|
|
|
id: 'cancel',
|
|
|
|
type: options.primary === 'cancel' ? 'submit' : 'cancel'
|
|
|
|
});
|
|
|
|
|
|
|
|
items.push({
|
2019-02-03 02:41:16 +09:00
|
|
|
name: options.confirmText || globalize.translate('ButtonOk'),
|
2019-01-10 15:39:37 +03:00
|
|
|
id: 'ok',
|
|
|
|
type: options.primary === 'cancel' ? 'cancel' : 'submit'
|
|
|
|
});
|
|
|
|
|
|
|
|
options.buttons = items;
|
|
|
|
|
|
|
|
return dialog(options).then(function (result) {
|
|
|
|
if (result === 'ok') {
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
|
|
|
|
return Promise.reject();
|
|
|
|
});
|
|
|
|
};
|
2018-10-23 01:05:09 +03:00
|
|
|
});
|