MediaWiki:Common.js: различия между версиями
Материал из GorbyWiki
Admin KVK (обсуждение | вклад) Новая страница: «→Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице: // Кнопки размера текста для статей $(document).ready(function() { $('#btn-minus').click(function() { var el = document.getElementById('article-text'); if (el) { var current = parseFloat(window.getComputedStyle(el).fontSize)...» |
Admin KVK (обсуждение | вклад) Нет описания правки |
||
| Строка 21: | Строка 21: | ||
}); | }); | ||
}); | }); | ||
/* Кнопка «Наверх» — GorbyWiki */ | |||
(function () { | |||
var btn = document.createElement('button'); | |||
btn.innerHTML = ''; | |||
btn.title = 'Наверх'; | |||
btn.style.cssText = [ | |||
'position:fixed', | |||
'bottom:32px', | |||
'right:28px', | |||
'width:48px', | |||
'height:48px', | |||
'border-radius:50%', | |||
'background:#faf8f3', | |||
'border:1.5px solid #d4c4a8', | |||
'display:flex', | |||
'align-items:center', | |||
'justify-content:center', | |||
'cursor:pointer', | |||
'opacity:0', | |||
'transition:opacity 0.25s, background 0.15s, border-color 0.15s', | |||
'z-index:9999', | |||
'box-shadow:none' | |||
].join(';'); | |||
btn.onmouseenter = function () { | |||
btn.style.background = '#fffaf0'; | |||
btn.style.borderColor = '#8b4513'; | |||
}; | |||
btn.onmouseleave = function () { | |||
btn.style.background = '#faf8f3'; | |||
btn.style.borderColor = '#d4c4a8'; | |||
}; | |||
btn.onclick = function () { | |||
window.scrollTo({ top: 0, behavior: 'smooth' }); | |||
}; | |||
document.body.appendChild(btn); | |||
window.addEventListener('scroll', function () { | |||
btn.style.opacity = window.scrollY > 300 ? '1' : '0'; | |||
btn.style.pointerEvents = window.scrollY > 300 ? 'auto' : 'none'; | |||
}); | |||
})(); | |||
Версия от 19:18, 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 = '';
btn.title = 'Наверх';
btn.style.cssText = [
'position:fixed',
'bottom:32px',
'right:28px',
'width:48px',
'height:48px',
'border-radius:50%',
'background:#faf8f3',
'border:1.5px solid #d4c4a8',
'display:flex',
'align-items:center',
'justify-content:center',
'cursor:pointer',
'opacity:0',
'transition:opacity 0.25s, background 0.15s, border-color 0.15s',
'z-index:9999',
'box-shadow:none'
].join(';');
btn.onmouseenter = function () {
btn.style.background = '#fffaf0';
btn.style.borderColor = '#8b4513';
};
btn.onmouseleave = function () {
btn.style.background = '#faf8f3';
btn.style.borderColor = '#d4c4a8';
};
btn.onclick = function () {
window.scrollTo({ top: 0, behavior: 'smooth' });
};
document.body.appendChild(btn);
window.addEventListener('scroll', function () {
btn.style.opacity = window.scrollY > 300 ? '1' : '0';
btn.style.pointerEvents = window.scrollY > 300 ? 'auto' : 'none';
});
})();
