* Shows confirmation and calls callback if it's approved. * @param {string} message * @param {function()} callback
(message, callback)
| 348 | * @param {function()} callback |
| 349 | */ |
| 350 | function showConfirmation_(message, callback) { |
| 351 | const container = devAssert(document.getElementById('popup-container')); |
| 352 | const messageElement = devAssert(document.getElementById('popup-message')); |
| 353 | const confirmButton = devAssert(document.getElementById('popup-button-ok')); |
| 354 | const cancelButton = devAssert( |
| 355 | document.getElementById('popup-button-cancel') |
| 356 | ); |
| 357 | const unlistenSet = []; |
| 358 | const closePopup = (affirmative) => { |
| 359 | container.classList.remove('show'); |
| 360 | unlistenSet.forEach((unlisten) => unlisten()); |
| 361 | if (affirmative) { |
| 362 | callback(); |
| 363 | } |
| 364 | }; |
| 365 | |
| 366 | messageElement.textContent = message; |
| 367 | unlistenSet.push(listenOnce(confirmButton, 'click', () => closePopup(true))); |
| 368 | unlistenSet.push(listenOnce(cancelButton, 'click', () => closePopup(false))); |
| 369 | container.classList.add('show'); |
| 370 | } |
| 371 | |
| 372 | /** |
| 373 | * Loads the AMP_CONFIG objects from whatever the v0.js is that the user has |
no test coverage detected