1/* FamilySpace mobile-tap: пÑевÑаÑÐ°ÐµÑ CSS-hover-Ð¼ÐµÐ½Ñ Ð² tap-toggle на touch-ÑÑÑÑойÑÑÐ²Ð°Ñ . 2 ÐеÑÐµÑ Ð²Ð°ÑÑÐ²Ð°ÐµÑ Ð¿ÐµÑвÑй tap на пÑÐ½ÐºÑ Ñ hover-dropdown â добавлÑÐµÑ ÐºÐ»Ð°ÑÑ .tap-open, 3 CSS-пÑавила ÑаÑкÑÑваÑÑ Ð¿Ð¾Ð´Ð¼ÐµÐ½Ñ. ÐовÑоÑнÑй tap на пÑнкÑе/tap вне/Esc â закÑÑваÑÑ. 4 Ðа деÑкÑопе (без touch) â ниÑего не делаеÑ, hover ÑабоÑÐ°ÐµÑ ÐºÐ°Ðº ÑанÑÑе. */ 5(function () { 6 'use strict'; 7 var isTouch = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0); 8 if (!isTouch) return; 9 10 // ÐлеменÑÑ Ñ hover-dropdown-поведением, коÑоÑÑе надо обÑабаÑÑваÑÑ Ð¿Ð¾ tap: 11 // - .list-popup > li (ÑаÑкÑÑÐ²Ð°ÐµÑ .list-popup-items) 12 // - .menu-item-more (ÑаÑкÑÑÐ²Ð°ÐµÑ .more-balloon) 13 var TRIGGER_SELECTOR = '.list-popup > li, .menu-item-more'; 14 15 function closeAll(exceptEl) { 16 var open = document.querySelectorAll('.tap-open'); 17 for (var i = 0; i < open.length; i++) { 18 if (exceptEl && open[i].contains(exceptEl)) continue; 19 open[i].classList.remove('tap-open'); 20 } 21 // ÐÑобÑй ÑлÑÑай: .more-balloon оÑкÑÑваеÑÑÑ Ð¾ÑделÑно (ÑÑо sibling, не ÑебÑнок) 22 if (!exceptEl || !exceptEl.closest('.menu-item-more, .more-balloon')) { 23 var balloon = document.querySelector('.more-balloon'); 24 if (balloon) balloon.classList.remove('tap-open'); 25 } 26 } 27 28 function handleTap(e) { 29 var trigger = e.target.closest(TRIGGER_SELECTOR); 30 if (!trigger) { 31 // Тап вне ÑÑиггеÑов â закÑÑваем вÑÑ 32 closeAll(null); 33 return; 34 } 35 // Ðлик по ÑÑÑлке ÐÐУТРРÑже оÑкÑÑÑого Ð¼ÐµÐ½Ñ â пÑопÑÑкаем (navigate) 36 var inside = e.target.closest('.list-popup-items, .more-balloon'); 37 if (inside) return; 38 39 // ÐеÑвÑй Ñап: оÑкÑÑваем. ÐÑоÑой Ñап: закÑÑваем. 40 var wasOpen = trigger.classList.contains('tap-open'); 41 closeAll(trigger); 42 if (!wasOpen) { 43 e.preventDefault(); 44 trigger.classList.add('tap-open'); 45 // ÐÐ»Ñ .menu-item-more дополниÑелÑно добавлÑем клаÑÑ Ð½Ð° .more-balloon 46 if (trigger.classList.contains('menu-item-more')) { 47 var balloon = document.querySelector('.more-balloon'); 48 if (balloon) balloon.classList.add('tap-open'); 49 } 50 } 51 } 52 53 function onKey(e) { 54 if (e.key === 'Escape' || e.keyCode === 27) closeAll(null); 55 } 56 57 document.addEventListener('click', handleTap, true); 58 document.addEventListener('keydown', onKey, false); 59})();
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.