1(function () { 2 'use strict'; 3 4 document.addEventListener('DOMContentLoaded', function () { 5 initSticky(); 6 initGreeting(); 7 initPopup(); 8 initGaEvents(); 9 }); 10 11 /* =============== ÐÐ¸Ð¿ÐºÐ°Ñ ÐºÐ½Ð¾Ð¿ÐºÐ° =============== */ 12 function initSticky() { 13 var sticky = document.getElementById('rbm-sticky'); 14 if (!sticky) return; 15 16 var toggle = document.getElementById('rbm-sticky-toggle'); 17 var clickAction = sticky.getAttribute('data-click-action'); 18 19 if (!toggle) return; 20 21 if (clickAction === 'expand') { 22 var userToggled = false; 23 var autoExpandTimer = null; 24 25 toggle.addEventListener('click', function () { 26 userToggled = true; 27 if (autoExpandTimer) { 28 clearTimeout(autoExpandTimer); 29 autoExpandTimer = null; 30 } 31 var isOpen = sticky.classList.toggle('rbm-open'); 32 toggle.setAttribute('aria-expanded', isOpen ? 'true' : 'false'); 33 }); 34 35 document.addEventListener('click', function (e) { 36 if (!sticky.contains(e.target)) { 37 sticky.classList.remove('rbm-open'); 38 toggle.setAttribute('aria-expanded', 'false'); 39 } 40 }); 41 42 document.addEventListener('keydown', function (e) { 43 if (e.key === 'Escape') { 44 sticky.classList.remove('rbm-open'); 45 toggle.setAttribute('aria-expanded', 'false'); 46 } 47 }); 48 49 initAutoExpand(sticky, toggle, function () { return userToggled; }, function (timer) { autoExpandTimer = timer; }); 50 } 51 // еÑли click_action === 'popup', кнопка Ñже помеÑена клаÑÑом rbm-popup-trigger 52 // и обÑабаÑÑваеÑÑÑ Ð² initPopup() 53 } 54 55 /* =============== ÐвÑоÑаÑкÑÑÑие ÑпиÑка иконок по ÑаймеÑÑ =============== */ 56 function initAutoExpand(sticky, toggle, isUserToggled, setTimerRef) { 57 var enabled = sticky.getAttribute('data-auto-expand') === '1'; 58 if (!enabled) return; 59 60 var delay = parseInt(sticky.getAttribute('data-auto-expand-delay'), 10) || 5; 61 var once = sticky.getAttribute('data-auto-expand-once') === '1'; 62 var storageKey = 'rbm_auto_expand_shown'; 63 64 if (once && sessionStorage.getItem(storageKey) === '1') { 65 return; 66 } 67 68 var timer = setTimeout(function () { 69 // не ÑаÑкÑÑваем авÑомаÑиÑеÑки, еÑли полÑзоваÑÐµÐ»Ñ Ñже Ñам оÑкÑÑл/закÑÑл ÐºÐ½Ð¾Ð¿ÐºÑ 70 if (isUserToggled()) return; 71 72 sticky.classList.add('rbm-open'); 73 toggle.setAttribute('aria-expanded', 'true'); 74 75 if (once) { 76 try { sessionStorage.setItem(storageKey, '1'); } catch (e) {} 77 } 78 }, delay * 1000); 79 80 setTimerRef(timer); 81 } 82 83 /* =============== ÐÑивеÑÑÑвеннÑй бабл =============== */ 84 function initGreeting() { 85 var greeting = document.querySelector('.rbm-greeting'); 86 if (!greeting) return; 87 88 var delay = parseInt(greeting.getAttribute('data-delay'), 10) || 0; 89 var autohide = parseInt(greeting.getAttribute('data-autohide'), 10) || 0; 90 var once = greeting.getAttribute('data-once') === '1'; 91 var storageKey = 'rbm_greeting_shown'; 92 93 if (once && sessionStorage.getItem(storageKey) === '1') { 94 greeting.style.display = 'none'; 95 return; 96 } 97 98 var closeBtn = greeting.querySelector('.rbm-greeting-close'); 99 var showTimer = setTimeout(function () { 100 greeting.classList.add('rbm-visible'); 101 if (once) { 102 try { sessionStorage.setItem(storageKey, '1'); } catch (e) {} 103 }
104 if (autohide > 0) { 105 setTimeout(function () { 106 greeting.classList.remove('rbm-visible'); 107 }, autohide * 1000); 108 } 109 }, delay * 1000); 110 111 if (closeBtn) { 112 closeBtn.addEventListener('click', function (e) { 113 e.preventDefault(); 114 e.stopPropagation(); 115 clearTimeout(showTimer); 116 greeting.classList.remove('rbm-visible'); 117 greeting.style.display = 'none'; 118 }); 119 } 120 } 121 122 /* =============== Ðопап =============== */ 123 function initPopup() { 124 var popup = document.getElementById('rbm-popup'); 125 if (!popup) return; 126 127 var closeOnOverlay = popup.getAttribute('data-close-on-overlay') === '1'; 128 var overlay = popup.querySelector('.rbm-popup-overlay'); 129 var closeBtn = popup.querySelector('.rbm-popup-close'); 130 var triggerSelector = popup.getAttribute('data-trigger-selector') || '.rbm-popup-trigger'; 131 132 function openPopup(e) { 133 if (e) e.preventDefault(); 134 popup.classList.add('rbm-open'); 135 popup.setAttribute('aria-hidden', 'false'); 136 document.body.style.overflow = 'hidden'; 137 } 138 function closePopup() { 139 popup.classList.remove('rbm-open'); 140 popup.setAttribute('aria-hidden', 'true'); 141 document.body.style.overflow = ''; 142 } 143 144 document.addEventListener('click', function (e) { 145 var trigger = e.target.closest(triggerSelector); 146 if (trigger) { 147 openPopup(e); 148 } 149 }); 150 151 if (closeBtn) closeBtn.addEventListener('click', closePopup); 152 if (overlay && closeOnOverlay) overlay.addEventListener('click', closePopup); 153 154 document.addEventListener('keydown', function (e) { 155 if (e.key === 'Escape') closePopup(); 156 }); 157 } 158 159 /* =============== GA / меÑÑика ÑобÑÑÐ¸Ñ =============== */ 160 function initGaEvents() { 161 if (typeof window.RBM_DATA === 'undefined' || !window.RBM_DATA.gaEvent) return; 162 163 document.addEventListener('click', function (e) { 164 var el = e.target.closest('[data-rbm-type]'); 165 if (!el) return; 166 var type = el.getAttribute('data-rbm-type'); 167 168 if (typeof window.gtag === 'function') { 169 window.gtag('event', 'rbm_click', { messenger: type }); 170 } 171 if (typeof window.ym === 'function' && window.RBM_YM_ID) { 172 window.ym(window.RBM_YM_ID, 'reachGoal', 'rbm_click_' + type); 173 } 174 window.dataLayer = window.dataLayer || []; 175 window.dataLayer.push({ event: 'rbm_click', rbm_messenger: type }); 176 }); 177 } 178})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.