| 1 |
<?php |
| 2 |
$hideForScroll = ''; |
| 3 |
if (!$edition && isset($form->settings['display']['scroll']) && $form->settings['display']['scroll'] != 0) { |
| 4 |
$hideForScroll = 'style="display: none;"'; |
| 5 |
} |
| 6 |
?> |
| 7 |
<div id="acym_fulldiv_<?php echo $form->form_tag_name; ?>" |
| 8 |
class="acym__subscription__form__popup__overlay acym__subscription__form-erase" |
| 9 |
<?php echo $hideForScroll; ?>> |
| 10 |
<div class="acym__subscription__form__popup"> |
| 11 |
<div class="acym__subscription__form__popup__close acymicon-close"></div> |
| 12 |
<?php |
| 13 |
if ($edition) { |
| 14 |
echo '<form action="#" onsubmit="return false;" id="'.$form->form_tag_name.'">'; |
| 15 |
} else { |
| 16 |
$isButton = $form->settings['display']['display_action'] === 'yes'; |
| 17 |
if ($isButton) { |
| 18 |
$cookieExpirationAttr = 'acym-data-cookie="0"'; |
| 19 |
} else { |
| 20 |
$cookieExpirationAttr = empty($form->settings['cookie']['cookie_expiration']) ? 'acym-data-cookie="1"' |
| 21 |
: 'acym-data-cookie="'.$form->settings['cookie']['cookie_expiration'].'"'; |
| 22 |
} |
| 23 |
echo '<form acym-data-id="'.$form->id.'" '.$cookieExpirationAttr.' action="'.$form->form_tag_action.'" id="'.$form->form_tag_name.'" name="'.$form->form_tag_name.'" enctype="multipart/form-data" onsubmit="return submitAcymForm(\'subscribe\',\''.$form->form_tag_name.'\', \'acymSubmitSubForm\')">'; |
| 24 |
} |
| 25 |
if (in_array($form->settings['style']['position'], ['image-top', 'image-left'])) { |
| 26 |
if (!empty($form->settings['message']['text']) && $form->settings['message']['position'] === 'before-image') { |
| 27 |
echo '<p id="acym__subscription__form__popup-text">'.nl2br(acym_translation($form->settings['message']['text'])).'</p>'; |
| 28 |
} |
| 29 |
include acym_getPartial('forms', 'image'); |
| 30 |
} |
| 31 |
echo '<div class="acym__subscription__form__popup__fields-button">'; |
| 32 |
include acym_getPartial('forms', 'fields'); |
| 33 |
if (!empty($form->settings['message']['text']) && $form->settings['message']['position'] == 'before-button') { |
| 34 |
echo '<p id="acym__subscription__form__popup-text">'.nl2br(acym_translation($form->settings['message']['text'])).'</p>'; |
| 35 |
} |
| 36 |
include acym_getPartial('forms', 'button'); |
| 37 |
echo '</div>'; |
| 38 |
if (in_array($form->settings['style']['position'], ['image-bottom', 'image-right'])) { |
| 39 |
if (!empty($form->settings['message']['text']) && $form->settings['message']['position'] == 'before-image') { |
| 40 |
echo '<p id="acym__subscription__form__popup-text">'.nl2br(acym_translation($form->settings['message']['text'])).'</p>'; |
| 41 |
} |
| 42 |
include acym_getPartial('forms', 'image'); |
| 43 |
} |
| 44 |
include acym_getPartial('forms', 'hidden_params'); |
| 45 |
?> |
| 46 |
</form> |
| 47 |
</div> |
| 48 |
</div> |
| 49 |
<style> |
| 50 |
<?php echo '#acym_fulldiv_'.$form->form_tag_name; ?>.acym__subscription__form__popup__overlay{ |
| 51 |
display: <?php echo $edition ? 'inline' : 'none';?>; |
| 52 |
position: fixed; |
| 53 |
top: 0; |
| 54 |
bottom: 0; |
| 55 |
right: 0; |
| 56 |
left: 0; |
| 57 |
background-color: rgba(200, 200, 200, .5); |
| 58 |
z-index: 999999; |
| 59 |
} |
| 60 |
|
| 61 |
<?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup__close{ |
| 62 |
position: absolute; |
| 63 |
top: 10px; |
| 64 |
right: 10px; |
| 65 |
font-weight: bold; |
| 66 |
font-size: 1rem; |
| 67 |
cursor: pointer; |
| 68 |
} |
| 69 |
|
| 70 |
<?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup{ |
| 71 |
position: fixed; |
| 72 |
left: 50%; |
| 73 |
transform: translate(-50%, -50%); |
| 74 |
top: 50%; |
| 75 |
padding: <?php echo $form->settings['style']['padding']['height'];?>px <?php echo $form->settings['style']['padding']['width'];?>px; |
| 76 |
background-color: <?php echo $form->settings['style']['background_color'];?>; |
| 77 |
color: <?php echo $form->settings['style']['text_color'];?> !important; |
| 78 |
background-image: url("<?php echo $form->settings['style']['background_image']; ?>"); |
| 79 |
background-size: <?php echo $form->settings['style']['background_size']; ?>; |
| 80 |
background-position: <?php echo str_replace('_', ' ', $form->settings['style']['background_position']); ?>; |
| 81 |
background-repeat: <?php echo $form->settings['style']['background_repeat']; ?>; |
| 82 |
z-index: 999999; |
| 83 |
text-align: center; |
| 84 |
display: flex; |
| 85 |
justify-content: center; |
| 86 |
align-items: center; |
| 87 |
} |
| 88 |
|
| 89 |
<?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .responseContainer{ |
| 90 |
margin-bottom: 0 !important; |
| 91 |
padding: .4rem !important; |
| 92 |
} |
| 93 |
|
| 94 |
<?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup <?php echo '#'.$form->form_tag_name;?>{ |
| 95 |
margin: 0; |
| 96 |
} |
| 97 |
|
| 98 |
<?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields, <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__button{ |
| 99 |
display: block; |
| 100 |
width: 100%; |
| 101 |
margin: 1rem 0 !important; |
| 102 |
} |
| 103 |
|
| 104 |
<?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields input:not([type="radio"]):not([type="checkbox"]), <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields label{ |
| 105 |
display: block; |
| 106 |
} |
| 107 |
|
| 108 |
<?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields input[type="radio"], <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields input[type="checkbox"]{ |
| 109 |
margin-left: 5px; |
| 110 |
} |
| 111 |
|
| 112 |
<?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields .acym__subscription__form__lists{ |
| 113 |
display: block; |
| 114 |
width: 100%; |
| 115 |
margin: 1rem 10px !important; |
| 116 |
} |
| 117 |
|
| 118 |
<?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup .acym__subscription__form__fields .acym__user__edit__email{ |
| 119 |
margin: auto; |
| 120 |
} |
| 121 |
|
| 122 |
<?php if(!empty($form->settings['message']['color'])) { ?> |
| 123 |
<?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>#acym__subscription__form__popup-text{ |
| 124 |
color: <?php echo $form->settings['message']['color']; ?>; |
| 125 |
} |
| 126 |
|
| 127 |
<?php } ?> |
| 128 |
|
| 129 |
<?php if (in_array($form->settings['style']['position'], ['image-right', 'image-left'])){?> |
| 130 |
<?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup <?php echo '#'.$form->form_tag_name;?>{ |
| 131 |
display: flex; |
| 132 |
justify-content: center; |
| 133 |
align-items: center |
| 134 |
} |
| 135 |
|
| 136 |
<?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__popup__fields-button, <?php echo '#acym_fulldiv_'.$form->form_tag_name.' '; ?>.acym__subscription__form__image{ |
| 137 |
display: inline-block; |
| 138 |
} |
| 139 |
|
| 140 |
<?php }?> |
| 141 |
|
| 142 |
</style> |
| 143 |
<?php if (!$edition) { ?> |
| 144 |
<script type="text/javascript"> |
| 145 |
const acymBackupFormTimeout<?php echo $form->form_tag_name; ?> = setTimeout(() => { |
| 146 |
acym_initPopupDisplay<?php echo $form->form_tag_name; ?>(true); |
| 147 |
}, 1000); |
| 148 |
|
| 149 |
window.addEventListener('DOMContentLoaded', function () { |
| 150 |
clearTimeout(acymBackupFormTimeout<?php echo $form->form_tag_name; ?>); |
| 151 |
acym_initPopupDisplay<?php echo $form->form_tag_name; ?>(); |
| 152 |
}); |
| 153 |
|
| 154 |
function acym_initPopupDisplay<?php echo $form->form_tag_name; ?>(addedDelayForBackup = false) { |
| 155 |
const acym_popupForm = document.querySelector('#acym_fulldiv_<?php echo $form->form_tag_name; ?>.acym__subscription__form__popup__overlay'); |
| 156 |
|
| 157 |
if (!acym_popupForm) { |
| 158 |
return; |
| 159 |
} |
| 160 |
|
| 161 |
const isDisplayButton = <?php echo $isButton ? 'true' : 'false'; ?>; |
| 162 |
|
| 163 |
function acym_closePopupform<?php echo $form->form_tag_name;?>(element) { |
| 164 |
element.style.display = 'none'; |
| 165 |
|
| 166 |
if (isDisplayButton) { |
| 167 |
return; |
| 168 |
} |
| 169 |
|
| 170 |
let expirationDate = new Date(); |
| 171 |
expirationDate.setDate(expirationDate.getDate() + <?php echo empty($form->settings['cookie']['cookie_expiration']) ? 1 |
| 172 |
: $form->settings['cookie']['cookie_expiration'];?>); |
| 173 |
document.cookie = 'acym_form_<?php echo $form->id; ?>=' + Date.now() + ';expires=' + expirationDate.toUTCString() + ';path=/'; |
| 174 |
} |
| 175 |
|
| 176 |
acym_popupForm.addEventListener('click', function (event) { |
| 177 |
if (event.target.closest('.acym__subscription__form__popup') === null) { |
| 178 |
acym_closePopupform<?php echo $form->form_tag_name; ?>(this); |
| 179 |
} |
| 180 |
}); |
| 181 |
document.querySelector('#acym_fulldiv_<?php echo $form->form_tag_name; ?> .acym__subscription__form__popup__close').addEventListener('click', function (event) { |
| 182 |
acym_closePopupform<?php echo $form->form_tag_name; ?>(event.target.closest('.acym__subscription__form__popup__overlay')); |
| 183 |
}); |
| 184 |
|
| 185 |
if (isDisplayButton) { |
| 186 |
displayByButton(); |
| 187 |
} else { |
| 188 |
displayByDelayAndScroll(); |
| 189 |
} |
| 190 |
|
| 191 |
function displayByButton() { |
| 192 |
const button = document.querySelector('#<?php echo $form->settings['display']['button'];?>'); |
| 193 |
|
| 194 |
if (!button) { |
| 195 |
console.error('Could not find the button with the ID <?php echo $form->settings['display']['button'];?>'); |
| 196 |
return; |
| 197 |
} |
| 198 |
|
| 199 |
button.addEventListener('click', function () { |
| 200 |
acym_popupForm.style.display = 'inline'; |
| 201 |
}); |
| 202 |
} |
| 203 |
|
| 204 |
function displayByDelayAndScroll() { |
| 205 |
const delayDisplay = parseInt(<?php echo $form->settings['display']['delay']; ?>); |
| 206 |
const scrollPercentLimit = parseInt(<?php echo $form->settings['display']['scroll']; ?>); |
| 207 |
let windowSize; |
| 208 |
let browserHeight; |
| 209 |
let delayRemaining = false; |
| 210 |
if (delayDisplay > 0) { |
| 211 |
delayRemaining = true; |
| 212 |
} |
| 213 |
let scrollRemaining = false; |
| 214 |
if (scrollPercentLimit > 0) { |
| 215 |
scrollRemaining = true; |
| 216 |
} |
| 217 |
|
| 218 |
windowSize = document.getElementsByTagName('body')[0].clientHeight; |
| 219 |
browserHeight = document.documentElement.clientHeight; |
| 220 |
if (windowSize <= browserHeight && !delayRemaining) { |
| 221 |
scrollRemaining = false; |
| 222 |
acym_popupForm.style.display = 'inline'; |
| 223 |
} |
| 224 |
|
| 225 |
function displayAcymPopupForm() { |
| 226 |
let scrollPercent = Math.round((window.scrollY) / (windowSize - browserHeight) * 100); |
| 227 |
if (scrollPercent >= scrollPercentLimit) { |
| 228 |
scrollRemaining = false; |
| 229 |
window.removeEventListener('scroll', displayAcymPopupForm); |
| 230 |
if (!delayRemaining) { |
| 231 |
if (acym_popupForm) { |
| 232 |
acym_popupForm.style.display = 'inline'; |
| 233 |
} |
| 234 |
} |
| 235 |
} |
| 236 |
} |
| 237 |
|
| 238 |
window.addEventListener('scroll', displayAcymPopupForm); |
| 239 |
|
| 240 |
let delayInMs = delayDisplay * 1000; |
| 241 |
if (addedDelayForBackup && delayDisplay > 1000) { |
| 242 |
delayInMs -= 1000; |
| 243 |
} |
| 244 |
|
| 245 |
setTimeout(function () { |
| 246 |
if (acym_popupForm !== null) { |
| 247 |
delayRemaining = false; |
| 248 |
if (!scrollRemaining) { |
| 249 |
acym_popupForm.style.display = 'inline'; |
| 250 |
} |
| 251 |
} |
| 252 |
}, delayInMs); |
| 253 |
} |
| 254 |
} |
| 255 |
</script> |
| 256 |
<?php |
| 257 |
include acym_getPartial('forms', 'cookie'); |
| 258 |
} |
| 259 |
?> |
| 260 |
|