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

нема опису редагування
Немає опису редагування
Немає опису редагування
Рядок 20: Рядок 20:
         });
         });
         $('#random-articles-container').html(html);
         $('#random-articles-container').html(html);
    });
});
$(function() {
    var items = $('.l-box-item');
    var sections = [];
   
    items.each(function() {
        var href = $(this).find('a').attr('href');
        if (href && href.startsWith('#')) {
            var target = $(href.replace(/\./g, '\\.'));
            if (target.length) {
                sections.push({item: $(this), target: target});
            }
        }
    });
   
    $(window).on('scroll', function() {
        var scrollPos = $(window).scrollTop() + 100;
        var current = null;
       
        sections.forEach(function(s) {
            if (s.target.offset().top <= scrollPos) {
                current = s.item;
            }
        });
       
        items.removeClass('active');
        if (current) {
            current.addClass('active');
        }
     });
     });
});
});