* Dialog box * @param {string} titleText Title text * @param {string} html HTML string * @param {string} [hideButtonText] Text for hide button * @param {string} [cancelButtonText] Text for cancel button * @returns {PromiseLike}
(titleText, html, hideButtonText, cancelButtonText)
| 12 | * @returns {PromiseLike} |
| 13 | */ |
| 14 | function dialog(titleText, html, hideButtonText, cancelButtonText) { |
| 15 | let waitFor = 0, |
| 16 | strOK = hideButtonText || strings.ok, |
| 17 | _onclick = () => {}, |
| 18 | _onhide = () => {}, |
| 19 | _then = () => {}, |
| 20 | _onOk = _hide, |
| 21 | _onCancel = () => {}; |
| 22 | |
| 23 | const promiseLike = { |
| 24 | hide, |
| 25 | wait, |
| 26 | onclick, |
| 27 | onhide, |
| 28 | then, |
| 29 | ok, |
| 30 | cancel, |
| 31 | }; |
| 32 | |
| 33 | let cancelBtn; |
| 34 | let hideButton = typeof hideButtonText === "boolean" ? hideButtonText : false; |
| 35 | |
| 36 | if (cancelButtonText) { |
| 37 | cancelBtn = tag("button", { |
| 38 | className: "disabled", |
| 39 | textContent: cancelButtonText, |
| 40 | onclick: () => { |
| 41 | _onCancel(); |
| 42 | }, |
| 43 | }); |
| 44 | } |
| 45 | |
| 46 | const okBtn = tag("button", { |
| 47 | className: "disabled", |
| 48 | textContent: strOK, |
| 49 | onclick: () => { |
| 50 | _onOk(); |
| 51 | }, |
| 52 | }); |
| 53 | const body = tag("div", { |
| 54 | className: "message", |
| 55 | innerHTML: html, |
| 56 | onclick: __onclick, |
| 57 | }); |
| 58 | const box = tag("div", { |
| 59 | className: "prompt box", |
| 60 | children: [ |
| 61 | tag("strong", { |
| 62 | className: "title", |
| 63 | textContent: titleText, |
| 64 | }), |
| 65 | body, |
| 66 | ], |
| 67 | }); |
| 68 | const mask = tag("span", { |
| 69 | className: "mask", |
| 70 | onclick: _hide, |
| 71 | }); |
no test coverage detected