MediaWiki:Common.js: различия между версиями
Материал из GorbyWiki
Admin KVK (обсуждение | вклад) Нет описания правки |
Admin KVK (обсуждение | вклад) Нет описания правки |
||
| Строка 25: | Строка 25: | ||
(function () { | (function () { | ||
var btn = document.createElement('button'); | var btn = document.createElement('button'); | ||
btn.innerHTML = ''; | btn.innerHTML = '<svg viewBox="0 0 20 20" fill="none" stroke="#faf8f3" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10 14V6M6 10l4-4 4 4"/></svg>'; | ||
btn.title = 'Наверх'; | btn.title = 'Наверх'; | ||
btn.style.cssText = [ | btn.style.cssText = [ | ||
| Строка 34: | Строка 34: | ||
'height:48px', | 'height:48px', | ||
'border-radius:50%', | 'border-radius:50%', | ||
'background:# | 'background:#5c4033', | ||
'border: | 'border:none', | ||
'display:flex', | 'display:flex', | ||
'align-items:center', | 'align-items:center', | ||
| Строка 41: | Строка 41: | ||
'cursor:pointer', | 'cursor:pointer', | ||
'opacity:0', | 'opacity:0', | ||
'transition:opacity 0.25s, background | 'transition:opacity 0.25s, background 0.15s', | ||
'z-index:9999 | 'z-index:9999' | ||
].join(';'); | ].join(';'); | ||
btn.onmouseenter = function () { | btn.onmouseenter = function () { btn.style.background = '#8b4513'; }; | ||
btn.onmouseleave = function () { btn.style.background = '#5c4033'; }; | |||
btn.onclick = function () { window.scrollTo({ top: 0, behavior: 'smooth' }); }; | |||
btn.onmouseleave = function () { | |||
btn.onclick = function () { | |||
document.body.appendChild(btn); | document.body.appendChild(btn); | ||
window.addEventListener('scroll', function () { | window.addEventListener('scroll', function () { | ||
btn.style.opacity = | var visible = window.scrollY > 300; | ||
btn.style.pointerEvents = | btn.style.opacity = visible ? '1' : '0'; | ||
btn.style.pointerEvents = visible ? 'auto' : 'none'; | |||
}); | }); | ||
})(); | })(); | ||
Версия от 19:21, 21 апреля 2026
/* Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице */
// Кнопки размера текста для статей
$(document).ready(function() {
$('#btn-minus').click(function() {
var el = document.getElementById('article-text');
if (el) {
var current = parseFloat(window.getComputedStyle(el).fontSize);
el.style.fontSize = (current - 2) + 'px';
}
});
$('#btn-reset').click(function() {
var el = document.getElementById('article-text');
if (el) { el.style.fontSize = '1em'; }
});
$('#btn-plus').click(function() {
var el = document.getElementById('article-text');
if (el) {
var current = parseFloat(window.getComputedStyle(el).fontSize);
el.style.fontSize = (current + 2) + 'px';
}
});
});
/* Кнопка «Наверх» — GorbyWiki */
(function () {
var btn = document.createElement('button');
btn.innerHTML = '<svg viewBox="0 0 20 20" fill="none" stroke="#faf8f3" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10 14V6M6 10l4-4 4 4"/></svg>';
btn.title = 'Наверх';
btn.style.cssText = [
'position:fixed',
'bottom:32px',
'right:28px',
'width:48px',
'height:48px',
'border-radius:50%',
'background:#5c4033',
'border:none',
'display:flex',
'align-items:center',
'justify-content:center',
'cursor:pointer',
'opacity:0',
'transition:opacity 0.25s, background 0.15s',
'z-index:9999'
].join(';');
btn.onmouseenter = function () { btn.style.background = '#8b4513'; };
btn.onmouseleave = function () { btn.style.background = '#5c4033'; };
btn.onclick = function () { window.scrollTo({ top: 0, behavior: 'smooth' }); };
document.body.appendChild(btn);
window.addEventListener('scroll', function () {
var visible = window.scrollY > 300;
btn.style.opacity = visible ? '1' : '0';
btn.style.pointerEvents = visible ? 'auto' : 'none';
});
})();
