MediaWiki:Common.js: відмінності між версіями
Wiki (обговорення | внесок) Немає опису редагування |
Wiki (обговорення | внесок) мНемає опису редагування |
||
| (Не показано 37 проміжних версій цього користувача) | |||
| Рядок 1: | Рядок 1: | ||
// ========================= | |||
// ОСНОВНИЙ КОД ДЛЯ ТЕМ, ДОСТУПНОСТІ ТА ЛУПИ | |||
// ========================= | |||
$(function () { | $(function () { | ||
// Теми | // Теми | ||
| Рядок 10: | Рядок 13: | ||
theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; | theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; | ||
} | } | ||
if (themes[theme]) mw.loader.load(themes[theme], 'text/css'); | |||
// Завантажуємо тему | |||
if (themes[theme]) { | |||
mw.loader.load(themes[theme], 'text/css'); | |||
} | |||
// Розмір шрифту | |||
var fontSize = parseInt(localStorage.getItem('fontSize')) || parseInt($('body').css('font-size')) || 16; | |||
function applyFontSize() { | |||
var content = document.querySelector('.mw-parser-output'); | |||
if (content) { | |||
content.style.fontSize = fontSize + 'px'; | |||
} | |||
} | |||
// Масив для збереження позицій кнопок | |||
var buttonCount = 0; | |||
// Функція створення кнопки праворуч з автоматичним вертикальним розташуванням | |||
function createButtonRight(text, onClick, title) { | |||
var btn = document.createElement('button'); | |||
btn.innerText = text; | |||
btn.title = title; | |||
btn.style.position = 'fixed'; | |||
btn.style.right = '10px'; | |||
btn.style.bottom = (10 + buttonCount * 60) + 'px'; // вертикальний відступ між кнопками | |||
btn.style.padding = '10px 16px'; | |||
btn.style.border = 'none'; | |||
btn.style.borderRadius = '25px'; | |||
btn.style.background = '#1a73e8'; | |||
btn.style.color = '#fff'; | |||
btn.style.fontWeight = 'bold'; | |||
btn.style.fontSize = '14px'; | |||
btn.style.cursor = 'pointer'; | |||
btn.style.zIndex = 9999; | |||
btn.style.textAlign = 'center'; | |||
btn.style.boxShadow = '0 2px 6px rgba(0,0,0,0.3)'; | |||
btn.style.whiteSpace = 'nowrap'; | |||
btn.onclick = onClick; | |||
document.body.appendChild(btn); | |||
buttonCount++; // збільшуємо лічильник кнопок для наступного bottom | |||
return btn; | |||
return | |||
} | } | ||
// Кнопка Темна/Світла тема | // Кнопка Темна/Світла тема | ||
createButtonRight( | |||
theme === 'dark' ? 'Світла тема ☀️' : 'Темна тема 🌙', | theme === 'dark' ? 'Світла тема ☀️' : 'Темна тема 🌙', | ||
function () { | function () { | ||
var newTheme = theme === 'dark' ? 'light' : 'dark'; | var newTheme = theme === 'dark' ? 'light' : 'dark'; | ||
| Рядок 45: | Рядок 70: | ||
'Змінити тему' | 'Змінити тему' | ||
); | ); | ||
// Кнопка доступності | // Кнопка доступності | ||
createButtonRight( | |||
'Доступність' | localStorage.getItem('accessibilityMode') === 'on' ? 'Доступність' : 'Доступність', | ||
function () { | function () { | ||
if (!$('body').hasClass('accessibility-mode')) { | if (!$('body').hasClass('accessibility-mode')) { | ||
$('body').addClass('accessibility-mode'); | $('body').addClass('accessibility-mode'); | ||
localStorage.setItem('accessibilityMode', 'on'); | localStorage.setItem('accessibilityMode', 'on'); | ||
} else { | } else { | ||
$('body').removeClass('accessibility-mode'); | $('body').removeClass('accessibility-mode'); | ||
localStorage.setItem('accessibilityMode', 'off'); | localStorage.setItem('accessibilityMode', 'off'); | ||
} | } | ||
}, | }, | ||
| Рядок 74: | Рядок 86: | ||
); | ); | ||
// | // Кнопки лупи | ||
createButtonRight('🔍 +', function () { | |||
fontSize += 2; | fontSize += 2; | ||
if (fontSize > 30) fontSize = 30; | if (fontSize > 30) fontSize = 30; | ||
| Рядок 89: | Рядок 94: | ||
}, 'Збільшити шрифт'); | }, 'Збільшити шрифт'); | ||
createButtonRight('🔍 -', function () { | |||
fontSize -= 2; | fontSize -= 2; | ||
if (fontSize < 12) fontSize = 12; | if (fontSize < 12) fontSize = 12; | ||
| Рядок 96: | Рядок 101: | ||
}, 'Зменшити шрифт'); | }, 'Зменшити шрифт'); | ||
// Відновлення | // Застосовуємо шрифт при завантаженні | ||
if (localStorage.getItem(' | applyFontSize(); | ||
// Відновлення стану доступності при завантаженні | |||
if (localStorage.getItem('accessibilityMode') === 'on') { | |||
$('body').addClass('accessibility-mode'); | |||
} | } | ||
}); | }); | ||
//OVERLAY | // ========================= | ||
// ВАШ СТАРИЙ OVERLAY КОД (без змін) | |||
// ========================= | |||
(function() { | (function() { | ||
'use strict'; | 'use strict'; | ||
| Рядок 116: | Рядок 125: | ||
// Стиль зображення | // Стиль зображення | ||
imageMaxWidth: '90vw', | imageMaxWidth: '90vw', | ||
imageMaxHeight: '80vh', | imageMaxHeight: '80vh', | ||
// Панель інформації | // Панель інформації | ||
| Рядок 137: | Рядок 146: | ||
borderRadius: '5px', | borderRadius: '5px', | ||
margin: '5px' | margin: '5px' | ||
}, | |||
// Кнопка закриття | |||
closeBtn: { | |||
background: 'rgba(0,0,0,0.7)', | |||
color: '#fff', | |||
size: '40px', | |||
fontSize: '20px', | |||
top: '20px', | |||
right: '20px' | |||
}, | }, | ||
| Рядок 158: | Рядок 177: | ||
const maxScale = 3; | const maxScale = 3; | ||
const scaleStep = 0.25; | const scaleStep = 0.25; | ||
// Повністю відключаємо стандартний MediaViewer | |||
function disableMediaViewerCompletely() { | |||
const mediaViewerLinks = document.querySelectorAll('a[href*="/wiki/File:"], a[href*="/w/images/"]'); | |||
mediaViewerLinks.forEach(link => { | |||
link.removeAttribute('data-mw'); | |||
link.removeAttribute('data-mediatype'); | |||
link.removeAttribute('data-file'); | |||
link.addEventListener('click', function(e) { | |||
const img = this.querySelector('img'); | |||
if (img && shouldOpenInOverlay(img)) { | |||
e.preventDefault(); | |||
e.stopImmediatePropagation(); | |||
showMediaViewerOverlay(img); | |||
return false; | |||
} | |||
}, true); | |||
}); | |||
} | |||
// Створення оверлею в стилі MediaViewer | // Створення оверлею в стилі MediaViewer | ||
| Рядок 176: | Рядок 215: | ||
opacity: 0; | opacity: 0; | ||
transition: opacity ${config.animationDuration} ease; | transition: opacity ${config.animationDuration} ease; | ||
cursor: default; | |||
`; | `; | ||
// | // Головний контейнер | ||
const | const mainContainer = document.createElement('div'); | ||
mainContainer.style.cssText = ` | |||
position: relative; | position: relative; | ||
display: flex; | display: flex; | ||
flex-direction: column; | flex-direction: column; | ||
align-items: center; | align-items: center; | ||
max-width: 95vw; | |||
max-height: 95vh; | |||
`; | `; | ||
// | // Кнопка закриття × | ||
const closeBtn = document.createElement('button'); | const closeBtn = document.createElement('button'); | ||
closeBtn.innerHTML = '×'; | closeBtn.innerHTML = '×'; | ||
closeBtn.title = 'Закрити (Esc)'; | closeBtn.title = 'Закрити (Esc)'; | ||
closeBtn.style.cssText = ` | closeBtn.style.cssText = ` | ||
width: ${config. | width: ${config.closeBtn.size}; | ||
height: ${config. | height: ${config.closeBtn.size}; | ||
background: ${config. | background: ${config.closeBtn.background}; | ||
color: ${config. | color: ${config.closeBtn.color}; | ||
border: none; | border: none; | ||
border-radius: 50%; | border-radius: 50%; | ||
font-size: | font-size: ${config.closeBtn.fontSize}; | ||
cursor: pointer; | cursor: pointer; | ||
display: flex; | display: flex; | ||
| Рядок 214: | Рядок 246: | ||
justify-content: center; | justify-content: center; | ||
transition: all 0.2s ease; | transition: all 0.2s ease; | ||
position: absolute; | |||
top: ${config.closeBtn.top}; | |||
right: ${config.closeBtn.right}; | |||
z-index: 10001; | |||
`; | |||
// Основний контейнер для зображення та кнопок | |||
const imageAndControlsContainer = document.createElement('div'); | |||
imageAndControlsContainer.style.cssText = ` | |||
position: relative; | |||
display: inline-block; | |||
max-width: ${config.imageMaxWidth}; | |||
max-height: ${config.imageMaxHeight}; | |||
margin-bottom: 10px; | |||
`; | `; | ||
| Рядок 220: | Рядок 266: | ||
imageContainer.style.cssText = ` | imageContainer.style.cssText = ` | ||
position: relative; | position: relative; | ||
display: | display: block; | ||
max-width: 100%; | |||
max-height: 100%; | |||
max-width: | |||
max-height: | |||
`; | `; | ||
| Рядок 235: | Рядок 278: | ||
border-radius: 8px; | border-radius: 8px; | ||
box-shadow: 0 10px 30px rgba(0,0,0,0.5); | box-shadow: 0 10px 30px rgba(0,0,0,0.5); | ||
cursor: default; | cursor: default !important; | ||
transition: transform 0.3s ease; | transition: transform 0.3s ease; | ||
display: block; | |||
`; | `; | ||
| Рядок 242: | Рядок 286: | ||
const prevBtn = createNavButton('‹', 'Попереднє зображення (←)'); | const prevBtn = createNavButton('‹', 'Попереднє зображення (←)'); | ||
const nextBtn = createNavButton('›', 'Наступне зображення (→)'); | const nextBtn = createNavButton('›', 'Наступне зображення (→)'); | ||
prevBtn.style. | prevBtn.style.cssText += 'left: 10px;'; | ||
nextBtn.style. | nextBtn.style.cssText += 'right: 10px;'; | ||
// | // Контейнер для кнопок масштабування - ПРИКРІПЛЕНИЙ ДО НИЗУ ЗОБРАЖЕННЯ | ||
const buttonPanel = document.createElement('div'); | const buttonPanel = document.createElement('div'); | ||
buttonPanel.className = 'zoom-controls-panel'; | |||
buttonPanel.style.cssText = ` | buttonPanel.style.cssText = ` | ||
position: absolute; | |||
bottom: 10px; | |||
left: 50%; | |||
transform: translateX(-50%); | |||
display: flex; | display: flex; | ||
justify-content: center; | justify-content: center; | ||
align-items: center; | align-items: center; | ||
gap: | gap: 8px; | ||
background: rgba(0,0,0,0.8); | |||
padding: 8px 12px; | |||
border-radius: 8px; | |||
z-index: 10001; | |||
min-width: 200px; | |||
backdrop-filter: blur(5px); | |||
`; | `; | ||
| Рядок 259: | Рядок 313: | ||
const resetZoomBtn = createToolButton('1:1', 'Скинути масштаб (Ctrl + 0)'); | const resetZoomBtn = createToolButton('1:1', 'Скинути масштаб (Ctrl + 0)'); | ||
const zoomInBtn = createToolButton('+', 'Збільшити (Ctrl + +)'); | const zoomInBtn = createToolButton('+', 'Збільшити (Ctrl + +)'); | ||
const infoBtn = createToolButton('i', 'Інформація (I)'); | const infoBtn = createToolButton('i', 'Інформація (I)'); | ||
| Рядок 271: | Рядок 323: | ||
padding: ${config.infoPanel.padding}; | padding: ${config.infoPanel.padding}; | ||
border-radius: ${config.infoPanel.borderRadius}; | border-radius: ${config.infoPanel.borderRadius}; | ||
margin-top: | margin-top: 10px; | ||
max-width: ${config.infoPanel.maxWidth}; | max-width: ${config.infoPanel.maxWidth}; | ||
width: 100%; | width: 100%; | ||
| Рядок 278: | Рядок 330: | ||
display: none; | display: none; | ||
`; | `; | ||
// Функція для оновлення позиції кнопок при зміні розміру зображення | |||
function updateButtonPanelPosition() { | |||
if (!img.parentElement) return; | |||
const imgRect = img.getBoundingClientRect(); | |||
const containerRect = imageAndControlsContainer.getBoundingClientRect(); | |||
// Позиціонуємо кнопки відносно видимого зображення | |||
if (imgRect.height > 0) { | |||
buttonPanel.style.bottom = '10px'; | |||
} | |||
} | |||
// Спостерігач за змінами розміру зображення | |||
const resizeObserver = new ResizeObserver(() => { | |||
updateButtonPanelPosition(); | |||
}); | |||
// Збірка інтерфейсу | // Збірка інтерфейсу | ||
imageContainer.appendChild(img); | imageContainer.appendChild(img); | ||
imageContainer.appendChild(prevBtn); | imageContainer.appendChild(prevBtn); | ||
imageContainer.appendChild(nextBtn); | imageContainer.appendChild(nextBtn); | ||
imageContainer.appendChild(buttonPanel); | |||
imageAndControlsContainer.appendChild(imageContainer); | |||
buttonPanel.appendChild(zoomOutBtn); | buttonPanel.appendChild(zoomOutBtn); | ||
| Рядок 291: | Рядок 362: | ||
buttonPanel.appendChild(infoBtn); | buttonPanel.appendChild(infoBtn); | ||
mainContainer.appendChild(closeBtn); | |||
mainContainer.appendChild(imageAndControlsContainer); | |||
mainContainer.appendChild(infoPanel); | |||
overlay.appendChild( | overlay.appendChild(mainContainer); | ||
document.body.appendChild(overlay); | document.body.appendChild(overlay); | ||
// Спостерігаємо за змінами розміру зображення | |||
resizeObserver.observe(img); | |||
// Функції масштабування | |||
function zoomImage(scale) { | |||
currentScale = Math.max(minScale, Math.min(maxScale, scale)); | |||
img.style.transform = `scale(${currentScale})`; | |||
updateZoomButtons(); | |||
// Оновлюємо позицію кнопок після масштабування | |||
setTimeout(updateButtonPanelPosition, 50); | |||
} | |||
function updateZoomButtons() { | |||
zoomInBtn.disabled = currentScale >= maxScale; | |||
zoomOutBtn.disabled = currentScale <= minScale; | |||
zoomInBtn.style.opacity = zoomInBtn.disabled ? '0.5' : '1'; | |||
zoomOutBtn.style.opacity = zoomOutBtn.disabled ? '0.5' : '1'; | |||
} | |||
// Обробники подій | // Обробники подій | ||
| Рядок 303: | Рядок 393: | ||
// Закриття | // Закриття | ||
const closeOverlay = () => { | const closeOverlay = () => { | ||
resizeObserver.disconnect(); | |||
overlay.style.opacity = '0'; | overlay.style.opacity = '0'; | ||
setTimeout(() => { | setTimeout(() => { | ||
| Рядок 345: | Рядок 436: | ||
img.style.transform = 'scale(1)'; | img.style.transform = 'scale(1)'; | ||
updateZoomButtons(); | updateZoomButtons(); | ||
setTimeout(updateButtonPanelPosition, 50); | |||
}); | }); | ||
| Рядок 354: | Рядок 446: | ||
// Клавіатура | // Клавіатура | ||
const keyHandler = (e) => { | |||
if (!currentOverlay) return; | if (!currentOverlay) return; | ||
| Рядок 368: | Рядок 460: | ||
break; | break; | ||
case 'i': | case 'i': | ||
case 'І': | case 'І': | ||
e.preventDefault(); | e.preventDefault(); | ||
toggleInfoPanel(); | toggleInfoPanel(); | ||
| Рядок 391: | Рядок 483: | ||
img.style.transform = 'scale(1)'; | img.style.transform = 'scale(1)'; | ||
updateZoomButtons(); | updateZoomButtons(); | ||
setTimeout(updateButtonPanelPosition, 50); | |||
} | } | ||
break; | break; | ||
} | |||
}; | |||
document.addEventListener('keydown', keyHandler); | |||
// Видаляємо обробник при закритті | |||
overlay.addEventListener('click', function handler() { | |||
if (overlay.style.display === 'none') { | |||
document.removeEventListener('keydown', keyHandler); | |||
overlay.removeEventListener('click', handler); | |||
} | } | ||
}); | }); | ||
| Рядок 409: | Рядок 512: | ||
}); | }); | ||
}); | }); | ||
// Оновлюємо позицію при завантаженні зображення | |||
img.addEventListener('load', () => { | |||
setTimeout(updateButtonPanelPosition, 100); | |||
}); | |||
} | } | ||
setupEventListeners(); | setupEventListeners(); | ||
updateZoomButtons(); | |||
return { | return { | ||
| Рядок 437: | Рядок 531: | ||
zoomOutBtn, | zoomOutBtn, | ||
resetZoomBtn, | resetZoomBtn, | ||
infoBtn | infoBtn, | ||
buttonPanel, | |||
updateZoomButtons, | |||
updateButtonPanelPosition | |||
}; | }; | ||
} | } | ||
| Рядок 473: | Рядок 570: | ||
btn.title = title; | btn.title = title; | ||
btn.style.cssText = ` | btn.style.cssText = ` | ||
width: ${config.buttons.size}; | min-width: ${config.buttons.size}; | ||
height: ${config.buttons.size}; | height: ${config.buttons.size}; | ||
background: ${config.buttons.background}; | background: ${config.buttons.background}; | ||
| Рядок 485: | Рядок 582: | ||
justify-content: center; | justify-content: center; | ||
transition: all 0.2s ease; | transition: all 0.2s ease; | ||
padding: 0 10px; | |||
`; | `; | ||
return btn; | return btn; | ||
| Рядок 523: | Рядок 621: | ||
})); | })); | ||
currentImageIndex = images.findIndex(img => img.src === clickedImage.src); | currentImageIndex = images.findIndex(img => img.src === clickedImage.src); | ||
return images; | return images; | ||
| Рядок 539: | Рядок 636: | ||
} | } | ||
if (element.closest('.gallery, .thumb, .mw-gallery')) { | if (element.closest('.gallery, .thumb, .mw-gallery')) { | ||
return false; | return false; | ||
| Рядок 549: | Рядок 645: | ||
// Показ оверлею | // Показ оверлею | ||
function showMediaViewerOverlay(imageElement) { | function showMediaViewerOverlay(imageElement) { | ||
if (imageElement.closest('a')) { | |||
const link = imageElement.closest('a'); | |||
if (link.href && link.href.includes('/wiki/File:')) { | |||
link.addEventListener('click', function(e) { | |||
e.preventDefault(); | |||
e.stopImmediatePropagation(); | |||
}, true); | |||
} | |||
} | |||
if (!currentOverlay) { | if (!currentOverlay) { | ||
currentOverlay = createMediaViewerStyleOverlay(); | currentOverlay = createMediaViewerStyleOverlay(); | ||
} | } | ||
imagesInGallery = collectAllImages(imageElement); | imagesInGallery = collectAllImages(imageElement); | ||
| Рядок 560: | Рядок 665: | ||
showImage(imagesInGallery[currentImageIndex]); | showImage(imagesInGallery[currentImageIndex]); | ||
currentOverlay.overlay.style.display = 'flex'; | currentOverlay.overlay.style.display = 'flex'; | ||
setTimeout(() => { | setTimeout(() => { | ||
| Рядок 566: | Рядок 670: | ||
}, 10); | }, 10); | ||
document.body.style.overflow = 'hidden'; | document.body.style.overflow = 'hidden'; | ||
currentOverlay.prevBtn.style.display = imagesInGallery.length > 1 ? 'flex' : 'none'; | currentOverlay.prevBtn.style.display = imagesInGallery.length > 1 ? 'flex' : 'none'; | ||
currentOverlay.nextBtn.style.display = imagesInGallery.length > 1 ? 'flex' : 'none'; | currentOverlay.nextBtn.style.display = imagesInGallery.length > 1 ? 'flex' : 'none'; | ||
currentScale = 1; | currentScale = 1; | ||
currentOverlay.img.style.transform = 'scale(1)'; | currentOverlay.img.style.transform = 'scale(1)'; | ||
| Рядок 579: | Рядок 680: | ||
currentOverlay.updateZoomButtons(); | currentOverlay.updateZoomButtons(); | ||
} | } | ||
// Оновлюємо позицію кнопок після показу | |||
setTimeout(() => { | |||
if (currentOverlay && currentOverlay.updateButtonPanelPosition) { | |||
currentOverlay.updateButtonPanelPosition(); | |||
} | |||
}, 200); | |||
} | } | ||
| Рядок 588: | Рядок 696: | ||
currentOverlay.img.alt = imageData.alt; | currentOverlay.img.alt = imageData.alt; | ||
currentOverlay.infoPanel.innerHTML = ` | currentOverlay.infoPanel.innerHTML = ` | ||
<div><strong>${imageData.alt}</strong></div> | <div><strong>${imageData.alt}</strong></div> | ||
| Рядок 597: | Рядок 704: | ||
`; | `; | ||
currentScale = 1; | currentScale = 1; | ||
currentOverlay.img.style.transform = 'scale(1)'; | currentOverlay.img.style.transform = 'scale(1)'; | ||
| Рядок 603: | Рядок 709: | ||
currentOverlay.updateZoomButtons(); | currentOverlay.updateZoomButtons(); | ||
} | } | ||
// Оновлюємо позицію кнопок після завантаження нового зображення | |||
currentOverlay.img.onload = () => { | |||
setTimeout(() => { | |||
if (currentOverlay && currentOverlay.updateButtonPanelPosition) { | |||
currentOverlay.updateButtonPanelPosition(); | |||
} | |||
}, 100); | |||
}; | |||
} | } | ||
| Рядок 609: | Рядок 724: | ||
const target = e.target; | const target = e.target; | ||
if (target.closest('.custom-media-viewer')) { | if (target.closest('.custom-media-viewer')) { | ||
return; | return; | ||
} | } | ||
if (target.tagName === 'IMG' && shouldOpenInOverlay(target)) { | if (target.tagName === 'IMG' && shouldOpenInOverlay(target)) { | ||
e.preventDefault(); | e.preventDefault(); | ||
e. | e.stopImmediatePropagation(); | ||
showMediaViewerOverlay(target); | showMediaViewerOverlay(target); | ||
return false; | |||
} | } | ||
if (target.tagName === 'A' && target.href && | |||
if (target.tagName === 'A' && target.href && target.href.match(/\.(jpg|jpeg|png|gif|webp)(\?|$)/i)) { | (target.href.match(/\/wiki\/File:|\.(jpg|jpeg|png|gif|webp)(\?|$)/i))) { | ||
const img = target.querySelector('img'); | const img = target.querySelector('img'); | ||
if (img && shouldOpenInOverlay(img)) { | if (img && shouldOpenInOverlay(img)) { | ||
e.preventDefault(); | e.preventDefault(); | ||
e. | e.stopImmediatePropagation(); | ||
showMediaViewerOverlay(img); | showMediaViewerOverlay(img); | ||
return false; | |||
} | } | ||
} | } | ||
} | }, true); | ||
// Повністю відключаємо MediaViewer при завантаженні | |||
document.addEventListener('DOMContentLoaded', disableMediaViewerCompletely); | |||
setTimeout(disableMediaViewerCompletely, 100); | |||
// Стилі | |||
// Стилі | |||
const style = document.createElement('style'); | const style = document.createElement('style'); | ||
style.textContent = ` | style.textContent = ` | ||
| Рядок 682: | Рядок 770: | ||
.custom-media-viewer img { | .custom-media-viewer img { | ||
transition: transform 0.3s ease !important; | transition: transform 0.3s ease !important; | ||
cursor: default !important; | |||
} | |||
/* Панель кнопок масштабування - завжди внизу зображення */ | |||
.zoom-controls-panel { | |||
position: absolute !important; | |||
bottom: 10px !important; | |||
left: 50% !important; | |||
transform: translateX(-50%) !important; | |||
background: rgba(0,0,0,0.8) !important; | |||
padding: 8px 12px !important; | |||
border-radius: 8px !important; | |||
z-index: 10001 !important; | |||
min-width: 200px !important; | |||
backdrop-filter: blur(5px) !important; | |||
} | |||
/* Контейнер зображення */ | |||
.custom-media-viewer .image-container { | |||
position: relative !important; | |||
display: inline-block !important; | |||
} | |||
/* Повністю ховаємо стандартний MediaViewer */ | |||
.mw-mmv-overlay, | |||
.mediaViewerOverlay { | |||
display: none !important; | |||
} | } | ||
@media (max-width: 768px) { | @media (max-width: 768px) { | ||
.custom-media-viewer button { | .custom-media-viewer button { | ||
width: 35px !important; | min-width: 35px !important; | ||
height: 35px !important; | height: 35px !important; | ||
font-size: 16px !important; | font-size: 16px !important; | ||
padding: 0 8px !important; | |||
} | } | ||
| Рядок 694: | Рядок 810: | ||
font-size: 12px !important; | font-size: 12px !important; | ||
padding: 10px !important; | padding: 10px !important; | ||
margin-top: 10px !important; | |||
} | |||
.zoom-controls-panel { | |||
min-width: 180px !important; | |||
padding: 6px 10px !important; | |||
bottom: 8px !important; | |||
} | |||
} | |||
@media (max-width: 480px) { | |||
.custom-media-viewer button { | |||
min-width: 30px !important; | |||
height: 30px !important; | |||
font-size: 14px !important; | |||
padding: 0 6px !important; | |||
} | |||
.zoom-controls-panel { | |||
min-width: 160px !important; | |||
padding: 5px 8px !important; | |||
bottom: 5px !important; | |||
gap: 5px !important; | |||
} | } | ||
} | } | ||
| Рядок 699: | Рядок 838: | ||
document.head.appendChild(style); | document.head.appendChild(style); | ||
})(); | |||
// ========================= | |||
// КНОПКА ВИПАДКОВА СТОРІНКА (вище) | |||
// ========================= | |||
function createRandomButton() { | |||
if (document.getElementById('float-random-btn')) return; | |||
if (!document.body.classList.contains('skin-minerva')) return; | |||
const btn = document.createElement('button'); | |||
btn.id = 'float-random-btn'; | |||
btn.innerHTML = '🎲 Випадкова cторінка'; | |||
btn.title = 'Випадкова сторінка'; | |||
btn.style.cssText = ` | |||
position: fixed; | |||
bottom: 240px; | |||
left: 15px; | |||
z-index: 9998; | |||
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%); | |||
color: white; | |||
border: none; | |||
padding: 12px 18px; | |||
border-radius: 25px; | |||
font-size: 16px; | |||
font-weight: bold; | |||
cursor: pointer; | |||
box-shadow: 0 4px 15px rgba(0,0,0,0.3); | |||
display: flex; | |||
align-items: center; | |||
gap: 8px; | |||
transition: all 0.3s ease; | |||
white-space: nowrap; | |||
`; | |||
btn.addEventListener('click', function(e) { | |||
e.preventDefault(); | |||
e.stopPropagation(); | |||
btn.innerHTML = '⏳ Завантаження...'; | |||
btn.style.opacity = '0.7'; | |||
btn.disabled = true; | |||
setTimeout(() => { | |||
window.location.href = '/w/index.php/Спеціальна:Випадкова_сторінка'; | |||
}, 100); | |||
}); | |||
btn.addEventListener('mouseenter', function() { | |||
if (!this.disabled) { | |||
this.style.transform = 'scale(1.05)'; | |||
this.style.boxShadow = '0 6px 20px rgba(0,0,0,0.4)'; | |||
} | |||
}); | |||
btn.addEventListener('mouseleave', function() { | |||
this.style.transform = 'scale(1)'; | |||
this.style.boxShadow = '0 4px 15px rgba(0,0,0,0.3)'; | |||
}); | |||
document.body.appendChild(btn); | |||
} | |||
// ========================= | |||
// КНОПКА "ЯК ЦЕ ПРАЦЮЄ?" (виправлена версія) | |||
// ========================= | |||
function createHowItWorksButton() { | |||
if (document.getElementById('how-it-works-btn')) return; | |||
const btn = document.createElement('button'); | |||
btn.id = 'how-it-works-btn'; | |||
btn.innerHTML = '?'; | |||
btn.title = 'Як це працює?'; | |||
btn.style.cssText = ` | |||
position: fixed; | |||
bottom: 140px; | |||
left: 15px; | |||
z-index: 9998; | |||
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%); | |||
color: white; | |||
border: none; | |||
width: 60px; | |||
height: 60px; | |||
border-radius: 50%; | |||
font-size: 24px; | |||
font-weight: bold; | |||
cursor: pointer; | |||
box-shadow: 0 4px 15px rgba(0,0,0,0.3); | |||
display: flex; | |||
align-items: center; | |||
justify-content: center; | |||
transition: all 0.3s ease; | |||
line-height: 1; | |||
`; | |||
btn.addEventListener('click', function(e) { | |||
e.preventDefault(); | |||
e.stopPropagation(); | |||
window.location.href = '/w/index.php/FAQ'; | |||
}); | |||
btn.addEventListener('mouseenter', function() { | |||
this.style.transform = 'scale(1.05)'; | |||
this.style.boxShadow = '0 6px 20px rgba(0,0,0,0.4)'; | |||
}); | |||
btn.addEventListener('mouseleave', function() { | |||
this.style.transform = 'scale(1)'; | |||
this.style.boxShadow = '0 4px 15px rgba(0,0,0,0.3)'; | |||
}); | |||
document.body.appendChild(btn); | |||
} | |||
// ========================= | |||
// ВИПРАВЛЕНА ІНІЦІАЛІЗАЦІЯ (замінити тільки цю частину) | |||
// ========================= | |||
// Видаляємо всі старі ініціалізатори і замінюємо на цей простий код: | |||
})(); | let buttonsInitialized = false; | ||
function initializeLeftButtons() { | |||
if (buttonsInitialized) return; | |||
buttonsInitialized = true; | |||
// Кнопка "Як це працює?" для всіх тем | |||
createHowItWorksButton(); | |||
// Кнопка "Випадкова сторінка" тільки для Minerva | |||
if (document.body.classList.contains('skin-minerva')) { | |||
createRandomButton(); | |||
} | |||
} | |||
// Тільки один спосіб ініціалізації | |||
if (document.readyState === 'loading') { | |||
document.addEventListener('DOMContentLoaded', initializeLeftButtons); | |||
} else { | |||
setTimeout(initializeLeftButtons, 100); | |||
} | |||
// Тільки один резервний таймер | |||
setTimeout(initializeLeftButtons, 1000); | |||