|
//TAKEN FROM 1693 site |
|
|
|
<script> |
|
//Function for creating cookies |
|
function setCookie(cname, cvalue) { |
|
const maxAge = 86400 |
|
document.cookie = cname + "=" + cvalue + ";Max-Age=" + maxAge + ";path=/"; |
|
} |
|
|
|
//Function for reading cookies |
|
function getCookie(cname) { |
|
let name = cname + "="; |
|
let ca = document.cookie.split(';'); |
|
for(let i = 0; i < ca.length; i++) { |
|
let c = ca[i]; |
|
while (c.charAt(0) == ' ') { |
|
c = c.substring(1); |
|
} |
|
if (c.indexOf(name) == 0) { |
|
return c.substring(name.length, c.length); |
|
} |
|
} |
|
return ""; |
|
} |
|
|
|
//Set the expiry cookie when modal is closed |
|
jQuery('#popupModalWrapper #popupModalClose').on('click', function() { |
|
setCookie('sameSessionPSC', true); |
|
}); |
|
|
|
//Behavior for showing the modal |
|
if ( getCookie('sameSessionPSC') != 'true' ) { |
|
jQuery('#launchModal').click(); |
|
} |
|
</script> |
|
|
|
//PHP/HTML |
|
<button id = "launchModal" class = "d-none" type="button" data-bs-toggle="modal" data-bs-target="#popupModalWrapper"> |
|
Launch Modal |
|
</button> |
|
<div id="popupModalWrapper" class="modal fade" tabindex="-1" aria-hidden="true"> |
|
<div class="modal-dialog modal-dialog-centered modal-lg"> |
|
<div class="modal-content pt-5 pb-3 pb-lg-5 px-3 px-lg-5"> |
|
<button type="button" id = "popupModalClose" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
|
<h3><?php the_field('popup_header', 'options'); ?></h3> |
|
<div class="modal-body p-0"> |
|
<div class = "wysiwyg"> |
|
<?php the_field('popup_content', 'options'); ?> |
|
</div> |
|
</div> |
|
<?php |
|
$link = get_field('popup_button', 'options'); |
|
if( $link ): |
|
$link_url = $link['url']; |
|
$link_title = $link['title']; |
|
$link_target = $link['target'] ? ['target'] : '_self'; |
|
?> |
|
|
|
<a class = "button text-center" href = "<?php echo esc_url( $link_url ); ?>" target="<?php echo esc_attr( $link_target ); ?>"><button role = "button" class = "btn yellow"><?php echo esc_html( $link_title ); ?></button></a> |
|
<?php endif; ?> |
|
</div> |
|
</div> |
|
</div> |
|
|