diff --git a/public/js/myResources.js b/public/js/myResources.js index ceafed56..f5f41b6a 100644 --- a/public/js/myResources.js +++ b/public/js/myResources.js @@ -590,26 +590,30 @@ function deleteImage(image, tile, button) { // Asked, because it removes the picture from every deck that used it. The // deck keeps working; the figure is simply no longer there. - if (!window.confirm('Delete this image? Any resource that used it will render without it.')) return; - button.disabled = true; - fetch('/api/generated-images/' + encodeURIComponent(image.id), { - method: 'DELETE', headers: getAuthHeaders() - }) - .then(function (r) { return r.json(); }) - .then(function (data) { - if (!data.success) throw new Error(data.error || 'Could not delete that image'); - tile.remove(); - var grid = document.getElementById('mr-images-grid'); - var empty = document.getElementById('mr-images-empty'); - if (grid && !grid.children.length && empty) { - empty.hidden = false; - empty.textContent = 'No images yet.'; - } + var message = 'Delete this image? Any resource that used it will render without it.'; + if (!window.showConfirm) { if (window.confirm(message)) doDelete(); return; } + window.showConfirm(message, doDelete, { danger: true, confirmText: 'Delete' }); + function doDelete() { + button.disabled = true; + fetch('/api/generated-images/' + encodeURIComponent(image.id), { + method: 'DELETE', headers: getAuthHeaders() }) - .catch(function (err) { - button.disabled = false; - if (typeof showToast === 'function') showToast(err.message, 'error'); - }); + .then(function (r) { return r.json(); }) + .then(function (data) { + if (!data.success) throw new Error(data.error || 'Could not delete that image'); + tile.remove(); + var grid = document.getElementById('mr-images-grid'); + var empty = document.getElementById('mr-images-empty'); + if (grid && !grid.children.length && empty) { + empty.hidden = false; + empty.textContent = 'No images yet.'; + } + }) + .catch(function (err) { + button.disabled = false; + if (typeof showToast === 'function') showToast(err.message, 'error'); + }); + } } // The library as last fetched. Held so searching and the Modify picker both