Каталог файловtilda-skiplink-1.0.js
1function t_skiplink__addButton() {2 var allRecords = document.getElementById('allrecords');3 if (!allRecords) return;4 5 /* Прекращаем выполнение, если на странице не подключен header */6 if (!allRecords.querySelector('#t-header')) {7 return;8 }9 10 var skipLinkHTML =11 '<noindex><a href="#t-main-content" class="t-skiplink" rel="nofollow" aria-label="' +12 t_skiplink__dict('skiplinkAriaLabel') +
История файла и сравнение версий
'" style="opacity:0;">' +
14 t_skiplink__dict('skiplink') + 17 document.head.insertAdjacentHTML( 19 '<style>.t-skiplink{position:absolute;top:0;left:20px;z-index:99999;padding:8px 10px;font-family:"Arial",sans-serif;font-size:18px;text-align:center;text-decoration:none;background-color:#c7d2e9;border:1px solid #c7d2e9;border-radius:8px;transform:translateY(-200px);transition:transform .3s ease;}.t-skiplink:focus{transform:translateY(20px);opacity:1 !important;}#allrecords a.t-skiplink{color:#000000;}</style>' 21 allRecords.insertAdjacentHTML('afterbegin', skipLinkHTML); 23 t_skiplink__addAnchor(); 26function t_skiplink__addAnchor() { 27 var menuBlocks = document.querySelectorAll('[data-menu="yes"]'); 28 var header = document.getElementById('t-header'); 29 var anchorDiv = '<div id="t-main-content"></div>'; 32 header.insertAdjacentHTML('afterend', anchorDiv); 35 if (menuBlocks && menuBlocks.length > 0 && !header) { 36 var menuFirstParentRec = menuBlocks[0].parentNode; 37 if (menuBlocks.length === 1) { 38 menuFirstParentRec.insertAdjacentHTML('afterend', anchorDiv); 40 for (var i = 0; i < menuBlocks.length; i++) { 41 var menuBlockParentRec = menuBlocks[i].closest('.t-rec'); 42 if (menuBlockParentRec.nextSibling && menuBlockParentRec.nextSibling.querySelector('[data-menu="yes"]') === null) { 43 menuBlockParentRec.insertAdjacentHTML('afterend', anchorDiv); 51function t_skiplink__dict(msg) { 55 EN: 'To main content', 56 RU: 'К основному контенту', 59 dict['skiplinkAriaLabel'] = { 60 EN: 'Skip to main content', 61 RU: 'К основному контенту', 65 var projectLang = document.querySelector('html').getAttribute('lang'); 68 lang = projectLang.toUpperCase(); 70 lang = window.browserLang; 74 if (dict[msg][lang]) { 75 return dict[msg][lang]; 81 return 'Text not found #' + msg; 84t_skiplink__addButton(); 88if (!Element.prototype.closest) { 89 Element.prototype.closest = function (s) { 91 while (el && el.nodeType === 1) { 92 if (Element.prototype.matches.call(el, s)) { 95 el = el.parentElement || el.parentNode;