One of my ongoing project needed several confirmations on several different pages. As these actions might be delayed, I needed something to work asynchronously. This script adds a custom confirm dialog with Promise support to your website application.
The modal returns a Promise with the selected option:
true if the user accepted,
false if the user clicked cancel and
null if the user closed the modal window.
The modal constructor takes four parameters: the title, the content and the button labels (“Accept” or “Cancel”).
See the example on the Thin UI page or a live Codepen below: