MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
Line 1,414: Line 1,414:
});
});
/*-----------------------------------------01-07-2026-------------------------------------------*/
/*-----------------------------------------01-07-2026-------------------------------------------*/
/* Make WikiEditor toolbar sticky below Ekatra toolbar */
/* Make WikiEditor toolbar sticky below the Ekatra toolbar */
$(function () {
$(function () {


     function updateWikiToolbar() {
     function makeWikiToolbarSticky() {
         var $toolbar = $('.wikiEditor-ui-top');
         var $toolbar = $('.wikiEditor-ui-top');
         var $ekatra = $('#editpage-specialchars');
         var $ekatraToolbar = $('#editpage-specialchars');


         if (!$toolbar.length || !$ekatra.length) {
        // Stop if either toolbar doesn't exist
         if (!$toolbar.length || !$ekatraToolbar.length) {
             return;
             return;
         }
         }


        // Place the WikiEditor toolbar below the Ekatra toolbar
         $toolbar.css({
         $toolbar.css({
             position: 'sticky',
             position: 'sticky',
             top: $ekatra.outerHeight() + 'px',
             top: $ekatraToolbar.outerHeight() + 'px',
             zIndex: 999,
             zIndex: 999,
             background: '#fff'
             background: '#fff'
Line 1,433: Line 1,435:
     }
     }


     // Wait until WikiEditor has been created
     // Wait for WikiEditor to finish loading
     var interval = setInterval(function () {
     setTimeout(makeWikiToolbarSticky, 300);
        if ($('.wikiEditor-ui-top').length) {
            clearInterval(interval);


            updateWikiToolbar();
    // Update position if window size changes
 
    $(window).on('resize', makeWikiToolbarSticky);
            // Update if window size changes
            $(window).on('resize', updateWikiToolbar);
        }
    }, 100);


});
});