code.gitea.io/gitea@v1.21.7/web_src/js/features/comp/ConfirmModal.js (about) 1 import $ from 'jquery'; 2 import {svg} from '../../svg.js'; 3 import {htmlEscape} from 'escape-goat'; 4 5 const {i18n} = window.config; 6 7 export async function confirmModal(opts = {content: '', buttonColor: 'primary'}) { 8 return new Promise((resolve) => { 9 const $modal = $(` 10 <div class="ui g-modal-confirm modal"> 11 <div class="content">${htmlEscape(opts.content)}</div> 12 <div class="actions"> 13 <button class="ui cancel button">${svg('octicon-x')} ${i18n.modal_cancel}</button> 14 <button class="ui ${opts.buttonColor || 'primary'} ok button">${svg('octicon-check')} ${i18n.modal_confirm}</button> 15 </div> 16 </div> 17 `); 18 19 $modal.appendTo(document.body); 20 $modal.modal({ 21 onApprove() { 22 resolve(true); 23 }, 24 onHidden() { 25 $modal.remove(); 26 resolve(false); 27 }, 28 }).modal('show'); 29 }); 30 }