MediaWiki:Common.js: відмінності між версіями
Wiki (обговорення | внесок) Немає опису редагування |
Wiki (обговорення | внесок) Немає опису редагування |
||
| Рядок 171: | Рядок 171: | ||
// Повністю відключаємо стандартний MediaViewer | // Повністю відключаємо стандартний MediaViewer | ||
function disableMediaViewerCompletely() { | function disableMediaViewerCompletely() { | ||
const mediaViewerLinks = document.querySelectorAll('a[href*="/wiki/File:"], a[href*="/w/images/"]'); | const mediaViewerLinks = document.querySelectorAll('a[href*="/wiki/File:"], a[href*="/w/images/"]'); | ||
mediaViewerLinks.forEach(link => { | mediaViewerLinks.forEach(link => { | ||
| Рядок 178: | Рядок 177: | ||
link.removeAttribute('data-file'); | link.removeAttribute('data-file'); | ||
link.addEventListener('click', function(e) { | link.addEventListener('click', function(e) { | ||
const img = this.querySelector('img'); | const img = this.querySelector('img'); | ||
| Рядок 189: | Рядок 187: | ||
}, true); | }, true); | ||
}); | }); | ||
} | } | ||
| Рядок 224: | Рядок 209: | ||
`; | `; | ||
// | // Основний контейнер, який центрує все | ||
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; | ||
justify-content: center; | |||
max-width: 95vw; | |||
max-height: 95vh; | |||
`; | `; | ||
| Рядок 258: | Рядок 244: | ||
`; | `; | ||
// Контейнер для зображення | // Контейнер для зображення та кнопок навігації | ||
const imageContainer = document.createElement('div'); | const imageContainer = document.createElement('div'); | ||
imageContainer.style.cssText = ` | imageContainer.style.cssText = ` | ||
position: relative; | position: relative; | ||
display: | display: inline-block; | ||
max-width: ${config.imageMaxWidth}; | max-width: ${config.imageMaxWidth}; | ||
max-height: ${config.imageMaxHeight}; | max-height: ${config.imageMaxHeight}; | ||
`; | `; | ||
| Рядок 279: | Рядок 262: | ||
cursor: default !important; | cursor: default !important; | ||
transition: transform 0.3s ease; | transition: transform 0.3s ease; | ||
display: block; | |||
`; | `; | ||
// | // Кнопки навігації (зліва/справа від зображення) | ||
const prevBtn = createNavButton('‹', 'Попереднє зображення (←)'); | const prevBtn = createNavButton('‹', 'Попереднє зображення (←)'); | ||
const nextBtn = createNavButton('›', 'Наступне зображення (→)'); | const nextBtn = createNavButton('›', 'Наступне зображення (→)'); | ||
prevBtn.style. | prevBtn.style.cssText += 'left: 15px;'; | ||
nextBtn.style. | nextBtn.style.cssText += 'right: 15px;'; | ||
// | // Контейнер для кнопок масштабування - ФІКСОВАНИЙ під зображенням | ||
const buttonPanel = document.createElement('div'); | const buttonPanel = document.createElement('div'); | ||
buttonPanel.style.cssText = ` | buttonPanel.style.cssText = ` | ||
position: absolute; | |||
bottom: -60px; | |||
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.7); | |||
background: rgba(0,0,0,0. | padding: 8px 12px; | ||
padding: | |||
border-radius: 8px; | border-radius: 8px; | ||
z-index: 10001; | |||
min-width: 200px; | |||
`; | `; | ||
| Рядок 319: | Рядок 303: | ||
padding: ${config.infoPanel.padding}; | padding: ${config.infoPanel.padding}; | ||
border-radius: ${config.infoPanel.borderRadius}; | border-radius: ${config.infoPanel.borderRadius}; | ||
margin-top: | margin-top: 80px; | ||
max-width: ${config.infoPanel.maxWidth}; | max-width: ${config.infoPanel.maxWidth}; | ||
width: 100%; | width: 100%; | ||
| Рядок 331: | Рядок 315: | ||
imageContainer.appendChild(prevBtn); | imageContainer.appendChild(prevBtn); | ||
imageContainer.appendChild(nextBtn); | imageContainer.appendChild(nextBtn); | ||
imageContainer.appendChild(buttonPanel); | |||
buttonPanel.appendChild(zoomOutBtn); | buttonPanel.appendChild(zoomOutBtn); | ||
| Рядок 337: | Рядок 322: | ||
buttonPanel.appendChild(infoBtn); | buttonPanel.appendChild(infoBtn); | ||
mainContainer.appendChild(closeBtn); | |||
mainContainer.appendChild(imageContainer); | |||
mainContainer.appendChild(infoPanel); | |||
overlay.appendChild( | overlay.appendChild(mainContainer); | ||
document.body.appendChild(overlay); | document.body.appendChild(overlay); | ||
| Рядок 495: | Рядок 479: | ||
resetZoomBtn, | resetZoomBtn, | ||
infoBtn, | infoBtn, | ||
buttonPanel, | |||
updateZoomButtons | updateZoomButtons | ||
}; | }; | ||
| Рядок 606: | Рядок 591: | ||
// Показ оверлею | // Показ оверлею | ||
function showMediaViewerOverlay(imageElement) { | function showMediaViewerOverlay(imageElement) { | ||
if (imageElement.closest('a')) { | if (imageElement.closest('a')) { | ||
const link = imageElement.closest('a'); | const link = imageElement.closest('a'); | ||
if (link.href && link.href.includes('/wiki/File:')) { | if (link.href && link.href.includes('/wiki/File:')) { | ||
link.addEventListener('click', function(e) { | link.addEventListener('click', function(e) { | ||
e.preventDefault(); | e.preventDefault(); | ||
| Рядок 667: | Рядок 650: | ||
} | } | ||
// Обробник кліків | // Обробник кліків | ||
document.addEventListener('click', function(e) { | document.addEventListener('click', function(e) { | ||
const target = e.target; | const target = e.target; | ||
| Рядок 675: | Рядок 658: | ||
} | } | ||
if (target.tagName === 'IMG' && shouldOpenInOverlay(target)) { | if (target.tagName === 'IMG' && shouldOpenInOverlay(target)) { | ||
e.preventDefault(); | e.preventDefault(); | ||
| Рядок 683: | Рядок 665: | ||
} | } | ||
if (target.tagName === 'A' && target.href && | if (target.tagName === 'A' && target.href && | ||
(target.href.match(/\/wiki\/File:|\.(jpg|jpeg|png|gif|webp)(\?|$)/i))) { | (target.href.match(/\/wiki\/File:|\.(jpg|jpeg|png|gif|webp)(\?|$)/i))) { | ||
| Рядок 694: | Рядок 675: | ||
} | } | ||
} | } | ||
}, true); | }, true); | ||
// Повністю відключаємо MediaViewer при завантаженні | // Повністю відключаємо MediaViewer при завантаженні | ||
| Рядок 720: | Рядок 701: | ||
transition: transform 0.3s ease !important; | transition: transform 0.3s ease !important; | ||
cursor: default !important; | cursor: default !important; | ||
} | |||
/* Панель кнопок масштабування */ | |||
.custom-media-viewer .zoom-controls { | |||
position: absolute; | |||
bottom: -60px; | |||
left: 50%; | |||
transform: translateX(-50%); | |||
background: rgba(0,0,0,0.8); | |||
padding: 10px; | |||
border-radius: 8px; | |||
z-index: 10001; | |||
} | } | ||
| Рядок 739: | Рядок 732: | ||
font-size: 12px !important; | font-size: 12px !important; | ||
padding: 10px !important; | padding: 10px !important; | ||
margin-top: 60px !important; | |||
} | |||
.custom-media-viewer .zoom-controls { | |||
bottom: -50px !important; | |||
padding: 6px !important; | |||
} | |||
} | |||
@media (max-width: 480px) { | |||
.custom-media-viewer button { | |||
min-width: 30px !important; | |||
height: 30px !important; | |||
font-size: 14px !important; | |||
padding: 0 6px !important; | |||
} | } | ||
} | } | ||