MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 1,186: Line 1,186:


});
});
/*-----------------------------------------28-05-2026--------------------------------/
/*-----------------------------------------28-05-2026--------------------------------*/


/*--------------------------------------swati---------------------------------------*/
/*--------------------------------------swati---------------------------------------*/
/* hide sub suggestion in global searchbox */
/* hide sub suggestion in global searchbox */
$(function () {
/*$(function () {


     function removeSubpageResults() {
     function removeSubpageResults() {
Line 1,232: Line 1,232:


});
});
 
*/
/* hide sub suggestion in search page */
/* hide sub suggestion in search page */
$(document).ready(function () {
/*$(document).ready(function () {


     // Inject CSS instantly
     // Inject CSS instantly
Line 1,277: Line 1,277:


});
});
 
*/
$(document).ready(function () {
/*$(document).ready(function () {


     // Override broken REST API search
     // Override broken REST API search
Line 1,310: Line 1,310:


});
});
 
*/
/*
$(function () {
$(function () {


Line 1,339: Line 1,340:


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


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


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


        // Place the WikiEditor toolbar below the Ekatra toolbar
         $toolbar.css({
         $toolbar.css({
             position: 'sticky',
             position: 'sticky',
             top: $ekatraToolbar.outerHeight() + 'px',
             top: $('#editpage-specialchars').outerHeight() + 'px',
             zIndex: 999,
             zIndex: 999,
             background: '#fff'
             background: '#fff'
         });
         });
        clearInterval(timer);
     }
     }


     // Wait for WikiEditor to finish loading
     var timer = setInterval(stickyToolbar, 100);
    setTimeout(makeWikiToolbarSticky, 300);


     // Update position if window size changes
     $(window).on('resize', stickyToolbar);
     $(window).on('resize', makeWikiToolbarSticky);
 
});
 
/*----------------------------------08-07-2026----------------------------------*/
/* Remove blank <p><br></p> after Author template without removing TemplateStyles */
$(function () {
 
     $('.ekatra-author').next('p').each(function () {
 
        var $p = $(this);
 
        // Move TemplateStyles outside the paragraph
        $p.children('style[data-mw-deduplicate]').each(function () {
            $(this).insertBefore($p);
        });
 
        // Remove only <br>
        $p.children('br').remove();
 
        // Remove the paragraph only if it is now empty
        if (
            $.trim($p.text()) === '' &&
            $p.children().length === 0
        ) {
            $p.remove();
        }
 
    });


});
});