MediaWiki:Common.js: відмінності між версіями

нема опису редагування
Немає опису редагування
Немає опису редагування
 
(Не показані 4 проміжні версії цього користувача)
Рядок 1: Рядок 1:
// ==================================================
// RANDOM ARTICLES
// ==================================================
$(document).ready(function() {
$(document).ready(function() {
     var apiUrl = mw.config.get('wgScriptPath') + '/api.php';
     var apiUrl = mw.config.get('wgScriptPath') + '/api.php';
Рядок 6: Рядок 9:
         list: 'random',
         list: 'random',
         rnnamespace: '0',
         rnnamespace: '0',
         rnlimit: '5', // fetch five random articles
         rnlimit: '5',
         prop: 'extracts',
         prop: 'extracts',
         exchars: '250', // limit the preview to 250 characters
         exchars: '250',
         exlimit: 'max',
         exlimit: 'max',
         explaintext: true
         explaintext: true
Рядок 23: Рядок 26:
});
});


// ==================================================
// L-BOX NAVIGATION
// ==================================================
$(function() {
$(function() {
     var items = $('.l-box-item');
     var items = $('.l-box-item');
Рядок 48: Рядок 54:
             var el = document.getElementById(target);
             var el = document.getElementById(target);
             if (el) {
             if (el) {
                 scrollTo = $(el).offset().top - 40;
                 scrollTo = $(el).offset().top - 100;
             }
             }
         }
         }
Рядок 56: Рядок 62:
      
      
     $(window).on('scroll', function() {
     $(window).on('scroll', function() {
         var scrollPos = $(window).scrollTop() + 100;
         var scrollPos = $(window).scrollTop() + 120;
         var current = null;
         var current = null;
          
          
Рядок 75: Рядок 81:
});
});


// Profile icons - grayscale if no URL, clickable if has URL
// ==================================================
// PROFILE ICONS
// ==================================================
$(document).ready(function() {
$(document).ready(function() {
     $('.profile-icon').each(function() {
     $('.profile-icon').each(function() {
Рядок 94: Рядок 102:
         }
         }
     });
     });
});
// ==================================================
// ВИПРАВЛЕННЯ ПОШУКУ - БЕЗ OVERLAY
// ==================================================
$(document).ready(function() {
    var $searchInput = $('#searchInput');
    var $body = $('body');
   
    // Невелика затримка щоб DOM повністю завантажився
    setTimeout(function() {
        // Змінюємо placeholder
        $searchInput.attr('placeholder', 'Пошук...');
       
        // Прибираємо readonly
        $searchInput.prop('readonly', false);
        $searchInput.removeAttr('readonly');
       
        // Прибираємо класи тригера
        $searchInput.removeClass('skin-minerva-search-trigger');
       
        // Прибираємо всі обробники подій з input
        $searchInput.off();
       
        // Блокуємо overlay при кліку/фокусі
        $searchInput.on('click focus', function(e) {
            e.stopPropagation();
            e.stopImmediatePropagation();
           
            // Прибираємо overlay класи
            $body.removeClass('overlay-enabled search-enabled');
           
            // Ховаємо overlay
            $('.overlay, .search-overlay').remove();
           
            // Прибираємо hash
            if (window.location.hash === '#/search') {
                history.replaceState(null, null, window.location.pathname);
            }
           
            // Фокус на input
            $(this).focus();
        });
       
        // При введенні тексту
        $searchInput.on('input', function(e) {
            $body.removeClass('overlay-enabled search-enabled');
            $('.overlay, .search-overlay').remove();
        });
       
        // При Enter - перехід на сторінку пошуку
        $searchInput.on('keydown', function(e) {
            if (e.which === 13 || e.keyCode === 13) {
                e.preventDefault();
                e.stopPropagation();
                var query = $(this).val().trim();
                if (query) {
                    window.location.href = '/index.php?title=Спеціальна:Пошук&search=' + encodeURIComponent(query);
                }
                return false;
            }
        });
       
    }, 50);
   
    // MutationObserver - блокуємо overlay класи на body
    var observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            if (mutation.attributeName === 'class') {
                if ($body.hasClass('overlay-enabled')) {
                    $body.removeClass('overlay-enabled search-enabled');
                    $('.overlay, .search-overlay').remove();
                   
                    // Прибираємо hash
                    if (window.location.hash === '#/search') {
                        history.replaceState(null, null, window.location.pathname);
                    }
                }
            }
        });
    });
   
    observer.observe(document.body, { attributes: true });
   
    // Блокуємо hashchange на #/search
    $(window).on('hashchange', function(e) {
        if (window.location.hash === '#/search') {
            e.preventDefault();
            history.replaceState(null, null, window.location.pathname);
            $body.removeClass('overlay-enabled search-enabled');
            $('.overlay, .search-overlay').remove();
        }
    });
   
    // Перевіряємо hash при завантаженні
    if (window.location.hash === '#/search') {
        history.replaceState(null, null, window.location.pathname);
    }
});
});