MediaWiki:Common.js: Difference between revisions

From Ghost Theory Wiki
No edit summary
No edit summary
Line 1: Line 1:
mw.loader.using(['jquery'], function () {
mw.loader.using(['jquery'], function () {
     $(function () {
 
     function waitForHeader(callback) {
        var check = setInterval(function () {
            var banner = document.getElementById('p-banner');
            if (banner) {
                clearInterval(check);
                callback(banner);
            }
        }, 200);
    }
 
    waitForHeader(function (banner) {
         // Insert the sidebar toggle button next to the site title
         // Insert the sidebar toggle button next to the site title
        var banner = $('#p-banner');
         if (!document.getElementById('mw-sidebar-button')) {
 
             $(banner).after(
         if (banner.length && !document.getElementById('mw-sidebar-button')) {
             banner.after(
                 '<button id="mw-sidebar-button" class="mw-ui-icon mw-ui-icon-element mw-ui-icon-menu" style="margin-left:10px;"><span>Menu</span></button>'
                 '<button id="mw-sidebar-button" class="mw-ui-icon mw-ui-icon-element mw-ui-icon-menu" style="margin-left:10px;"><span>Menu</span></button>'
             );
             );
Line 15: Line 24:
         });
         });
     });
     });
});
});