| 1 |
/** |
| 2 |
* Setup Wizard |
| 3 |
* |
| 4 |
* @author ConvertKit |
| 5 |
*/ |
| 6 |
|
| 7 |
/** |
| 8 |
* Conditionally shows and hides elements when a button or link is clicked, based on that |
| 9 |
* button/link's configuration. |
| 10 |
* |
| 11 |
* @since 1.9.8.4 |
| 12 |
*/ |
| 13 |
document.addEventListener('DOMContentLoaded', function () { |
| 14 |
// Redirect parent screen to a given URL after clicking a link that opens |
| 15 |
// the href URL in a new tab. |
| 16 |
document |
| 17 |
.querySelectorAll('a.convertkit-redirect') |
| 18 |
.forEach(function (element) { |
| 19 |
element.addEventListener('click', function () { |
| 20 |
// Delay the redirect, otherwise browsers will block opening the href attribute |
| 21 |
// thinking it's a popup. |
| 22 |
setTimeout(function () { |
| 23 |
// Redirect the parent screen to the link's data-convertkit-redirect-url property. |
| 24 |
window.location.href = |
| 25 |
element.dataset.convertkitRedirectUrl; |
| 26 |
}, 1000); |
| 27 |
}); |
| 28 |
}); |
| 29 |
|
| 30 |
// Show a confirmation dialog for specific links. |
| 31 |
document |
| 32 |
.querySelectorAll('a.convertkit-confirm') |
| 33 |
.forEach(function (element) { |
| 34 |
element.addEventListener('click', function (e) { |
| 35 |
if (!confirm(element.dataset.message)) { |
| 36 |
e.preventDefault(); |
| 37 |
} |
| 38 |
}); |
| 39 |
}); |
| 40 |
}); |
| 41 |
|