feat: Добавлен плавающий виджет опроса (триггер + модальное окно, встроить Яндекс Формы)
This commit is contained in:
@@ -0,0 +1,72 @@
|
|||||||
|
{{ $coffeeOn := site.Params.buymeacoffee.globalWidget | default false }}
|
||||||
|
{{ $coffeePos := lower (site.Params.buymeacoffee.globalWidgetPosition | default "right") }}
|
||||||
|
{{ $coffeeOnRight := and $coffeeOn (eq $coffeePos "right") }}
|
||||||
|
{{ $scrollTopOn := site.Params.footer.showScrollToTop | default true }}
|
||||||
|
|
||||||
|
{{ $side := "right" }}
|
||||||
|
{{ $bottomPx := 24 }}
|
||||||
|
{{ if $coffeeOnRight }}
|
||||||
|
{{ $side = "left" }}
|
||||||
|
{{ else if $scrollTopOn }}
|
||||||
|
{{ $bottomPx = 90 }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
<button id="survey-trigger" type="button" aria-label="Пройти опрос"
|
||||||
|
style="{{ $side }}: 20px; bottom: {{ $bottomPx }}px;">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M152.1 38.2c9.9 8.9 10.7 24 1.8 33.9l-72 80c-4.4 4.9-10.6 7.8-17.2 7.9s-12.9-2.4-17.6-7L7 113C-2.3 103.6-2.3 88.4 7 79s24.6-9.4 33.9 0l22.1 22.1 55.1-61.2c8.9-9.9 24-10.7 33.9-1.8zm0 160c9.9 8.9 10.7 24 1.8 33.9l-72 80c-4.4 4.9-10.6 7.8-17.2 7.9s-12.9-2.4-17.6-7L7 273c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l22.1 22.1 55.1-61.2c8.9-9.9 24-10.7 33.9-1.8zM224 96c0-17.7 14.3-32 32-32H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H256c-17.7 0-32-14.3-32-32zm0 160c0-17.7 14.3-32 32-32H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H256c-17.7 0-32-14.3-32-32zM160 416c0-17.7 14.3-32 32-32H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H192c-17.7 0-32-14.3-32-32zM48 368a48 48 0 1 1 0 96 48 48 0 1 1 0-96z"/></svg>
|
||||||
|
<span>Опрос</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<script src="https://forms.yandex.ru/_static/embed.js"></script>
|
||||||
|
|
||||||
|
<div id="survey-modal" class="survey-modal" hidden>
|
||||||
|
<div class="survey-modal__overlay" data-survey-close></div>
|
||||||
|
<div class="survey-modal__box">
|
||||||
|
<button class="survey-modal__close" data-survey-close aria-label="Закрыть">×</button>
|
||||||
|
<iframe
|
||||||
|
data-src="https://forms.yandex.ru/cloud/6a6a10ac5913304db80c1a53?iframe=1"
|
||||||
|
name="ya-form-6a6a10ac5913304db80c1a53"
|
||||||
|
frameborder="0"
|
||||||
|
width="100%"
|
||||||
|
class="survey-modal__iframe"></iframe>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
var article = document.querySelector('.article-content');
|
||||||
|
if (!article) return;
|
||||||
|
|
||||||
|
var DISMISS_KEY = 'survey-dismissed-until';
|
||||||
|
var DISMISS_DAYS = 14;
|
||||||
|
var SCROLL_THRESHOLD = 0.55;
|
||||||
|
|
||||||
|
var trigger = document.getElementById('survey-trigger');
|
||||||
|
var modal = document.getElementById('survey-modal');
|
||||||
|
var iframe = modal ? modal.querySelector('iframe') : null;
|
||||||
|
if (!trigger || !modal) return;
|
||||||
|
|
||||||
|
if (Date.now() < Number(localStorage.getItem(DISMISS_KEY) || 0)) return;
|
||||||
|
|
||||||
|
function onScroll() {
|
||||||
|
var rect = article.getBoundingClientRect();
|
||||||
|
if (rect.height > 0 && (window.innerHeight - rect.top) / rect.height >= SCROLL_THRESHOLD) {
|
||||||
|
trigger.classList.add('is-visible');
|
||||||
|
window.removeEventListener('scroll', onScroll);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.addEventListener('scroll', onScroll, { passive: true });
|
||||||
|
onScroll();
|
||||||
|
|
||||||
|
trigger.addEventListener('click', function () {
|
||||||
|
if (iframe && !iframe.src) { iframe.src = iframe.dataset.src; }
|
||||||
|
modal.hidden = false;
|
||||||
|
});
|
||||||
|
modal.querySelectorAll('[data-survey-close]').forEach(function (el) {
|
||||||
|
el.addEventListener('click', function () {
|
||||||
|
modal.hidden = true;
|
||||||
|
localStorage.setItem(DISMISS_KEY, Date.now() + DISMISS_DAYS * 86400000);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
@@ -6,12 +6,82 @@
|
|||||||
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
|
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
|
||||||
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)
|
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)
|
||||||
})(window, document,'script','https://mc.yandex.ru/metrika/tag.js?id=106995329', 'ym');
|
})(window, document,'script','https://mc.yandex.ru/metrika/tag.js?id=106995329', 'ym');
|
||||||
|
|
||||||
ym(106995329, 'init', {ssr:true, webvisor:true, clickmap:true, ecommerce:"dataLayer", referrer: document.referrer, url: location.href, accurateTrackBounce:true, trackLinks:true});
|
ym(106995329, 'init', {ssr:true, webvisor:true, clickmap:true, ecommerce:"dataLayer", referrer: document.referrer, url: location.href, accurateTrackBounce:true, trackLinks:true});
|
||||||
</script>
|
</script>
|
||||||
<noscript><div><img src="https://mc.yandex.ru/watch/106995329" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
|
<noscript><div><img src="https://mc.yandex.ru/watch/106995329" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
|
||||||
<!-- /Yandex.Metrika counter -->
|
<!-- /Yandex.Metrika counter -->
|
||||||
|
|
||||||
<!-- Dzen.Metrika counter -->
|
<!-- Dzen.Metrika counter -->
|
||||||
<meta name="zen-verification" content="GDc1yxlsRy03jcI1t8NJ8OTleUE3f4I4PEmfOBjz4KBCezoDX1WWctO3l8Z2HGEx" />
|
<meta name="zen-verification" content="GDc1yxlsRy03jcI1t8NJ8OTleUE3f4I4PEmfOBjz4KBCezoDX1WWctO3l8Z2HGEx" />
|
||||||
<!-- /Dzen.Metrika counter -->
|
<!-- /Dzen.Metrika counter -->
|
||||||
|
<!-- Survey widget: floating trigger + modal styles -->
|
||||||
|
<style>
|
||||||
|
#survey-trigger {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 40;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 14px 22px;
|
||||||
|
border-radius: 999px;
|
||||||
|
border: none;
|
||||||
|
background: #FF5A36;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(10px) scale(0.9);
|
||||||
|
pointer-events: none;
|
||||||
|
transition: opacity .25s ease, transform .25s ease, background .2s ease;
|
||||||
|
box-shadow: 0 4px 14px rgba(255,90,54,.45);
|
||||||
|
}
|
||||||
|
#survey-trigger:hover { background: #E8481F; }
|
||||||
|
#survey-trigger.is-visible { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
|
||||||
|
#survey-trigger svg { width: 20px; height: 20px; flex-shrink: 0; }
|
||||||
|
.survey-modal {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 10000;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
.survey-modal[hidden] { display: none; }
|
||||||
|
.survey-modal__overlay { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
|
||||||
|
.survey-modal__box {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 680px;
|
||||||
|
max-height: calc(100vh - 32px);
|
||||||
|
max-height: calc(100dvh - 32px);
|
||||||
|
overflow-y: auto;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 44px 8px 8px;
|
||||||
|
}
|
||||||
|
.survey-modal__iframe {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 420px;
|
||||||
|
border: 0;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.survey-modal__close {
|
||||||
|
position: absolute;
|
||||||
|
top: 8px;
|
||||||
|
right: 8px;
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border: none;
|
||||||
|
background: #f2f2f2;
|
||||||
|
border-radius: 50%;
|
||||||
|
font-size: 20px;
|
||||||
|
line-height: 1;
|
||||||
|
cursor: pointer;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
.survey-modal__close:hover { background: #e5e5e5; }
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user