2023-06-19 13:16:50 +05:30
|
|
|
import $ from 'jquery';
|
|
|
|
import {svg} from '../../svg.js';
|
|
|
|
import {htmlEscape} from 'escape-goat';
|
|
|
|
|
|
|
|
const {i18n} = window.config;
|
|
|
|
|
2023-09-19 03:35:31 +05:30
|
|
|
export async function confirmModal(opts = {content: '', buttonColor: 'primary'}) {
|
2023-06-19 13:16:50 +05:30
|
|
|
return new Promise((resolve) => {
|
|
|
|
const $modal = $(`
|
|
|
|
<div class="ui g-modal-confirm modal">
|
|
|
|
<div class="content">${htmlEscape(opts.content)}</div>
|
|
|
|
<div class="actions">
|
2023-09-19 03:35:31 +05:30
|
|
|
<button class="ui cancel button">${svg('octicon-x')} ${i18n.modal_cancel}</button>
|
|
|
|
<button class="ui ${opts.buttonColor || 'primary'} ok button">${svg('octicon-check')} ${i18n.modal_confirm}</button>
|
2023-06-19 13:16:50 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`);
|
|
|
|
|
|
|
|
$modal.appendTo(document.body);
|
|
|
|
$modal.modal({
|
|
|
|
onApprove() {
|
|
|
|
resolve(true);
|
|
|
|
},
|
|
|
|
onHidden() {
|
|
|
|
$modal.remove();
|
|
|
|
resolve(false);
|
|
|
|
},
|
|
|
|
}).modal('show');
|
|
|
|
});
|
|
|
|
}
|