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