|
|
| (не показано 28 промежуточных версий 2 участников) |
| Строка 1: |
Строка 1: |
| const pageName = mw.config.get("wgPageName"); | | const pageName = mw.config.get("wgPageName"); |
|
| |
|
| // Темная тема на главной странице
| | mw.loader.using([], function () { |
| | | importScript("MediaWiki:PageDefaultAttributes.js"); |
| if (pageName == "Заглавная_страница" || pageName == "Test2") {
| | }); |
| document.documentElement.classList.replace('skin-theme-clientpref-day', 'skin-theme-clientpref-night'); | |
| } | |
|
| |
|
| // Отображение онлайна | | // Отображение онлайна |
| Строка 166: |
Строка 164: |
| } | | } |
| } | | } |
|
| |
|
| |
|
| |
| const btnUp = {
| |
| el: document.querySelector('.btn-up'),
| |
| scrolling: false,
| |
| show() {
| |
| if (this.el.classList.contains('btn-up_hide') && !this.el.classList.contains('btn-up_hiding')) {
| |
| this.el.classList.remove('btn-up_hide');
| |
| this.el.classList.add('btn-up_hiding');
| |
| window.setTimeout(() => {
| |
| this.el.classList.remove('btn-up_hiding');
| |
| }, 300);
| |
| }
| |
| },
| |
| hide() {
| |
| if (!this.el.classList.contains('btn-up_hide') && !this.el.classList.contains('btn-up_hiding')) {
| |
| this.el.classList.add('btn-up_hiding');
| |
| window.setTimeout(() => {
| |
| this.el.classList.add('btn-up_hide');
| |
| this.el.classList.remove('btn-up_hiding');
| |
| }, 300);
| |
| }
| |
| },
| |
| addEventListener() {
| |
| // при прокрутке окна (window)
| |
| window.addEventListener('scroll', () => {
| |
| const scrollY = window.scrollY || document.documentElement.scrollTop;
| |
| if (this.scrolling && scrollY > 0) {
| |
| return;
| |
| }
| |
| this.scrolling = false;
| |
| // если пользователь прокрутил страницу более чем на 200px
| |
| if (scrollY > 400) {
| |
| // сделаем кнопку .btn-up видимой
| |
| this.show();
| |
| } else {
| |
| // иначе скроем кнопку .btn-up
| |
| this.hide();
| |
| }
| |
| });
| |
| // при нажатии на кнопку .btn-up
| |
| document.querySelector('.btn-up').onclick = () => {
| |
| this.scrolling = true;
| |
| this.hide();
| |
| // переместиться в верхнюю часть страницы
| |
| window.scrollTo({
| |
| top: 0,
| |
| left: 0,
| |
| behavior: 'smooth'
| |
| });
| |
| }
| |
| }
| |
| }
| |
|
| |
| btnUp.addEventListener();
| |