|
|
| (не показаны 4 промежуточные версии этого же участника) |
| Строка 2: |
Строка 2: |
|
| |
|
| // console.log("Привет"); | | // console.log("Привет"); |
| /*_____________________*/
| |
| // Проверяем загрузку jQuery
| |
| mw.loader.using('jquery').then(function() {
| |
| $(function() {
| |
| // Создаем контейнер, если его нет
| |
| var $customContainer = $('.citizen-header__custom-bottom');
| |
| if ($customContainer.length === 0) {
| |
| $customContainer = $('<div>')
| |
| .addClass('citizen-header__custom-bottom')
| |
| .appendTo('.citizen-header');
| |
| }
| |
|
| |
| // Пример данных (замените на свои!)
| |
| var items = [
| |
| {
| |
| type: 'image',
| |
| src: 'https://wiki.ss220.club/resources/assets/logo.png',
| |
| link: 'https://wiki.ss220.club',
| |
| width: '20px'
| |
| },
| |
| {
| |
| type: 'image',
| |
| src: 'https://bs.ss220.club/resources/assets/logo.png',
| |
| link: 'https://bs.ss220.club',
| |
| width: '20px'
| |
| }
| |
| ];
| |
|
| |
| // Очищаем контейнер перед добавлением
| |
| $customContainer.empty();
| |
|
| |
| // Добавляем элементы
| |
| items.forEach(function(item) {
| |
| var $element;
| |
| if (item.type === 'image') {
| |
| $element = $('<img>')
| |
| .attr('src', item.src)
| |
| .css('width', item.width);
| |
| } else {
| |
| $element = $('<span>').text(item.text);
| |
| }
| |
|
| |
| var $link = $('<a>')
| |
| .attr('href', item.link)
| |
| .append($element)
| |
| .css({
| |
| display: 'grid',
| |
| margin: '0 10px'
| |
| });
| |
|
| |
| $customContainer.append($link);
| |
| });
| |
|
| |
| // Принудительно показываем контейнер
| |
| $customContainer.css('display', 'flex');
| |
| });
| |
| });
| |
|
| |
| // Закрытие выпадающих элементов при клике вне их области
| |
| document.addEventListener('click', function(event) {
| |
| // Проверяем все открытые элементы (меню, поиск и т.д.)
| |
| const openElements = document.querySelectorAll('.citizen-menu-open, .citizen-search-active');
| |
|
| |
| openElements.forEach(function(element) {
| |
| if (!element.contains(event.target)) {
| |
| // Закрываем элемент
| |
| element.classList.remove('citizen-menu-open', 'citizen-search-active');
| |
| }
| |
| });
| |
| });
| |
|
| |
| // Для кастомных элементов (например, вашего меню)
| |
| $(document).on('click', function(e) {
| |
| if ($('.citizen-header-custom-bottom').is(':visible') &&
| |
| !$(e.target).closest('.citizen-header-custom-bottom').length) {
| |
| $('.citizen-header-custom-bottom').hide();
| |
| }
| |
| });
| |
|
| |
| // Отключаем стандартное поведение скрытия шапки
| |
| window.addEventListener('scroll', function() {
| |
| document.querySelector('.citizen-header').classList.remove('citizen-scroll--down');
| |
| });
| |
|
| |
| // Принудительно показываем шапку при касании
| |
| document.addEventListener('touchstart', function() {
| |
| document.querySelector('.citizen-header').style.transform = 'translateY(0)';
| |
| });
| |
/* Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице */
// console.log("Привет");