Dantes (обсуждение | вклад) Нет описания правки |
Dantes (обсуждение | вклад) Нет описания правки |
||
Строка 126: | Строка 126: | ||
var jobsTable = document.getElementById('IdJobsTableContainer2'); | var jobsTable = document.getElementById('IdJobsTableContainer2'); | ||
if (jobsTable) { | if (jobsTable) { | ||
var | var initialTop = jobsTable.offsetTop; | ||
var | var initialLeft = jobsTable.offsetLeft; | ||
var | var initialWidth = jobsTable.offsetWidth; | ||
var placeholder = document.createElement('div'); | var placeholder = document.createElement('div'); | ||
var isFixed = false; | var isFixed = false; | ||
function | function updatePosition() { | ||
var | var scrollY = window.pageYOffset || document.documentElement.scrollTop; | ||
if (scrollY > initialTop - 20 && !isFixed) { | |||
if ( | |||
jobsTable.style.position = 'fixed'; | jobsTable.style.position = 'fixed'; | ||
jobsTable.style.top = '20px'; | jobsTable.style.top = '20px'; | ||
jobsTable.style.left = | jobsTable.style.left = initialLeft + 'px'; | ||
jobsTable.style.width = | jobsTable.style.width = initialWidth + 'px'; | ||
placeholder.style.height = jobsTable.offsetHeight + 'px'; | placeholder.style.height = jobsTable.offsetHeight + 'px'; | ||
jobsTable.parentNode.insertBefore(placeholder, jobsTable); | jobsTable.parentNode.insertBefore(placeholder, jobsTable); | ||
isFixed = true; | isFixed = true; | ||
} else if ( | } else if (scrollY <= initialTop - 20 && isFixed) { | ||
jobsTable.style.position = ''; | jobsTable.style.position = ''; | ||
jobsTable.style.top = ''; | jobsTable.style.top = ''; | ||
Строка 153: | Строка 150: | ||
placeholder.parentNode.removeChild(placeholder); | placeholder.parentNode.removeChild(placeholder); | ||
isFixed = false; | isFixed = false; | ||
} | } | ||
} | } | ||
window.addEventListener('scroll', | window.addEventListener('scroll', updatePosition); | ||
window.addEventListener('resize', | window.addEventListener('resize', function() { | ||
initialTop = jobsTable.offsetTop; | |||
initialLeft = jobsTable.offsetLeft; | |||
initialWidth = jobsTable.offsetWidth; | |||
}); | |||
} | } | ||
Версия от 20:13, 28 марта 2025
/* Подгрузка внешних css js */ mw.loader.using('mediawiki.util', function() { var params = mw.util.getParamValue('use'), basePath = mw.config.get('wgServer').replace(/^http:/, 'https:') + mw.config.get('wgScript') + '?action=raw&ctype=text/', userPrefix = 'User:' + (mw.config.get('wgUserName') || '') + '/', validExtensions = {js:1, css:1}; if (!params) return; params.split('|').forEach(function(param) { var file = param.trim(), isSystem = /^MediaWiki:/i.test(file), parts = file.split('.'), ext = parts[parts.length-1].toLowerCase(); if (!validExtensions[ext]) return; if (!/^[\w\-\/\.]+$/.test(file)) return; var prefix = isSystem ? 'MediaWiki:' : userPrefix; var fullName = file.indexOf(':') > -1 ? file : prefix + file; var url = basePath + (ext === 'js' ? 'javascript' : 'css') + '&title=' + encodeURIComponent(fullName); mw.loader.load(url, 'text/' + ext); }); }); /* Лого сайта */ (function() { var createLogo = function(url, imgSrc, title) { var container = document.createElement('div'), link = document.createElement('a'), img = document.createElement('img'); link.className = 'mw-logo citizen-header__button'; link.href = mw.util.getUrl(url); link.title = title; img.className = 'mw-logo-icon'; img.src = imgSrc; img.alt = ''; img.setAttribute('aria-hidden', 'true'); img.width = 32; img.height = 32; link.appendChild(img); container.appendChild(link); return container; }; var logoContainer = document.querySelector('.citizen-header__logo'); if (logoContainer) { // Очистка существующего содержимого while (logoContainer.firstChild) { logoContainer.removeChild(logoContainer.firstChild); } var logo1 = createLogo( 'Заглавная_страница', mw.config.get('wgScriptPath') + '/resources/assets/logo.png', 'Перейти на заглавную страницу' ); logo1.className = 'logo1'; var logo2 = createLogo( 'Colonial_Marines', mw.config.get('wgScriptPath') + '/images/0/0d/CMlog.png', 'Перейти на CM' ); logo2.className = 'logo2'; // Добавление в DOM logoContainer.appendChild(logo1); logoContainer.appendChild(logo2); } })(); /* Перенос page-info в footer-places */ var footerPlaces = document.getElementById('footer-places'); var pageInfo = document.querySelector('.page-info'); if (footerPlaces && pageInfo) { footerPlaces.insertAdjacentElement('afterend', pageInfo.cloneNode(true)); pageInfo.parentNode.removeChild(pageInfo); } /* Логика цвета через headerColor */ var headerColorElement = document.querySelector('.headerColor'); if (headerColorElement) { var isValidColor = function(color) { var s = new Option().style; s.color = color; return s.color !== ''; }; var content = headerColorElement.textContent.split('|'); if (content.length === 2 && isValidColor(content[0]) && isValidColor(content[1])) { var applyStyles = function() { var headers = document.querySelectorAll('.citizen-section-heading, .citizen-section-heading--collapsed'); for (var i = 0; i < headers.length; i++) { var header = headers[i], indicator = header.querySelector('.citizen-section-indicator'), headline = header.querySelector('.mw-headline'); if (header.classList.contains('citizen-section-heading--collapsed')) { if (indicator) { indicator.style.cssText = 'background: black; box-shadow: unset;'; } } else if (indicator && headline) { indicator.style.cssText = 'background: ' + content[1] + '; box-shadow: 0 0 20px 0px ' + content[1] + 'cc;'; headline.style.cssText = 'border-image: linear-gradient(to right top, ' + content[0] + ', black); border-image-slice: 1;'; } } }; applyStyles(); document.body.addEventListener('click', applyStyles, false); } } /* Sidebar для ролей */ var jobsTable = document.getElementById('IdJobsTableContainer2'); if (jobsTable) { var initialTop = jobsTable.offsetTop; var initialLeft = jobsTable.offsetLeft; var initialWidth = jobsTable.offsetWidth; var placeholder = document.createElement('div'); var isFixed = false; function updatePosition() { var scrollY = window.pageYOffset || document.documentElement.scrollTop; if (scrollY > initialTop - 20 && !isFixed) { jobsTable.style.position = 'fixed'; jobsTable.style.top = '20px'; jobsTable.style.left = initialLeft + 'px'; jobsTable.style.width = initialWidth + 'px'; placeholder.style.height = jobsTable.offsetHeight + 'px'; jobsTable.parentNode.insertBefore(placeholder, jobsTable); isFixed = true; } else if (scrollY <= initialTop - 20 && isFixed) { jobsTable.style.position = ''; jobsTable.style.top = ''; jobsTable.style.left = ''; jobsTable.style.width = ''; placeholder.parentNode.removeChild(placeholder); isFixed = false; } } window.addEventListener('scroll', updatePosition); window.addEventListener('resize', function() { initialTop = jobsTable.offsetTop; initialLeft = jobsTable.offsetLeft; initialWidth = jobsTable.offsetWidth; }); } /* Хронология */ if (window.jQuery) { jQuery(function($) { $('.timeline-header').on('click', function() { $(this).next('.timeline-content').slideToggle(); }).trigger('click'); }); }